Fix migration conflict

This commit is contained in:
gpt-engineer-app[bot]
2025-09-28 20:50:13 +00:00
parent 57f8450beb
commit ce99aeceed
3 changed files with 52 additions and 21 deletions

View File

@@ -17,7 +17,8 @@ const locationSchema = z.object({
preferred_pronouns: z.string().max(20).optional(),
timezone: z.string(),
preferred_language: z.string(),
location_id: z.string().optional()
personal_location: z.string().max(100).optional(),
home_park_id: z.string().optional()
});
type LocationFormData = z.infer<typeof locationSchema>;
interface AccessibilityOptions {
@@ -35,7 +36,7 @@ export function LocationTab() {
toast
} = useToast();
const [loading, setLoading] = useState(false);
const [locations, setLocations] = useState<any[]>([]);
const [parks, setParks] = useState<any[]>([]);
const [accessibility, setAccessibility] = useState<AccessibilityOptions>({
font_size: 'medium',
high_contrast: false,
@@ -47,23 +48,26 @@ export function LocationTab() {
preferred_pronouns: profile?.preferred_pronouns || '',
timezone: profile?.timezone || 'UTC',
preferred_language: profile?.preferred_language || 'en',
location_id: profile?.location_id || ''
personal_location: (profile as any)?.personal_location || '',
home_park_id: profile?.location_id || ''
}
});
useEffect(() => {
fetchLocations();
fetchParks();
fetchAccessibilityPreferences();
}, [user]);
const fetchLocations = async () => {
const fetchParks = async () => {
try {
const {
data,
error
} = await supabase.from('locations').select('id, name, city, state_province, country').order('name');
const { data, error } = await supabase
.from('parks')
.select('id, name, location_id, locations(city, state_province, country)')
.order('name');
if (error) throw error;
setLocations(data || []);
setParks(data || []);
} catch (error) {
console.error('Error fetching locations:', error);
console.error('Error fetching parks:', error);
}
};
const fetchAccessibilityPreferences = async () => {
@@ -93,7 +97,8 @@ export function LocationTab() {
preferred_pronouns: data.preferred_pronouns || null,
timezone: data.timezone,
preferred_language: data.preferred_language,
location_id: data.location_id || null,
personal_location: data.personal_location || null,
location_id: data.home_park_id || null,
updated_at: new Date().toISOString()
}).eq('user_id', user.id);
@@ -147,21 +152,41 @@ export function LocationTab() {
</CardHeader>
<CardContent className="space-y-6">
<div className="space-y-2">
<Label htmlFor="location_id">Home Park</Label>
<Select value={form.watch('location_id')} onValueChange={value => form.setValue('location_id', value)}>
<Label htmlFor="personal_location">Your Location</Label>
<Input
id="personal_location"
{...form.register('personal_location')}
placeholder="e.g., San Francisco, CA or Berlin, Germany"
/>
<p className="text-sm text-muted-foreground">
Your personal location (optional, displayed as text)
</p>
</div>
<div className="space-y-2">
<Label htmlFor="home_park_id">Home Park</Label>
<Select value={form.watch('home_park_id')} onValueChange={value => form.setValue('home_park_id', value)}>
<SelectTrigger>
<SelectValue placeholder="Select your home park" />
</SelectTrigger>
<SelectContent>
{locations.map(location => <SelectItem key={location.id} value={location.id}>
{location.name}
{location.city && `, ${location.city}`}
{location.state_province && `, ${location.state_province}`}
{location.country && `, ${location.country}`}
</SelectItem>)}
{parks.map(park => (
<SelectItem key={park.id} value={park.id}>
{park.name}
{park.locations && (
<>
{park.locations.city && `, ${park.locations.city}`}
{park.locations.state_province && `, ${park.locations.state_province}`}
{park.locations.country && `, ${park.locations.country}`}
</>
)}
</SelectItem>
))}
</SelectContent>
</Select>
<p className="text-sm text-muted-foreground">
The theme park you visit most often or consider your "home" park
</p>
</div>
<div className="space-y-2">

View File

@@ -357,6 +357,7 @@ export type Database = {
id: string
location_id: string | null
park_count: number | null
personal_location: string | null
preferred_language: string | null
preferred_pronouns: string | null
privacy_level: string
@@ -382,6 +383,7 @@ export type Database = {
id?: string
location_id?: string | null
park_count?: number | null
personal_location?: string | null
preferred_language?: string | null
preferred_pronouns?: string | null
privacy_level?: string
@@ -407,6 +409,7 @@ export type Database = {
id?: string
location_id?: string | null
park_count?: number | null
personal_location?: string | null
preferred_language?: string | null
preferred_pronouns?: string | null
privacy_level?: string

View File

@@ -0,0 +1,3 @@
-- Add personal_location field to profiles table for user's personal location text
ALTER TABLE public.profiles
ADD COLUMN personal_location TEXT;