mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 09:51:13 -05:00
Fix migration conflict
This commit is contained in:
@@ -17,7 +17,8 @@ const locationSchema = z.object({
|
|||||||
preferred_pronouns: z.string().max(20).optional(),
|
preferred_pronouns: z.string().max(20).optional(),
|
||||||
timezone: z.string(),
|
timezone: z.string(),
|
||||||
preferred_language: 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>;
|
type LocationFormData = z.infer<typeof locationSchema>;
|
||||||
interface AccessibilityOptions {
|
interface AccessibilityOptions {
|
||||||
@@ -35,7 +36,7 @@ export function LocationTab() {
|
|||||||
toast
|
toast
|
||||||
} = useToast();
|
} = useToast();
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [locations, setLocations] = useState<any[]>([]);
|
const [parks, setParks] = useState<any[]>([]);
|
||||||
const [accessibility, setAccessibility] = useState<AccessibilityOptions>({
|
const [accessibility, setAccessibility] = useState<AccessibilityOptions>({
|
||||||
font_size: 'medium',
|
font_size: 'medium',
|
||||||
high_contrast: false,
|
high_contrast: false,
|
||||||
@@ -47,23 +48,26 @@ export function LocationTab() {
|
|||||||
preferred_pronouns: profile?.preferred_pronouns || '',
|
preferred_pronouns: profile?.preferred_pronouns || '',
|
||||||
timezone: profile?.timezone || 'UTC',
|
timezone: profile?.timezone || 'UTC',
|
||||||
preferred_language: profile?.preferred_language || 'en',
|
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(() => {
|
useEffect(() => {
|
||||||
fetchLocations();
|
fetchParks();
|
||||||
fetchAccessibilityPreferences();
|
fetchAccessibilityPreferences();
|
||||||
}, [user]);
|
}, [user]);
|
||||||
const fetchLocations = async () => {
|
|
||||||
|
const fetchParks = async () => {
|
||||||
try {
|
try {
|
||||||
const {
|
const { data, error } = await supabase
|
||||||
data,
|
.from('parks')
|
||||||
error
|
.select('id, name, location_id, locations(city, state_province, country)')
|
||||||
} = await supabase.from('locations').select('id, name, city, state_province, country').order('name');
|
.order('name');
|
||||||
|
|
||||||
if (error) throw error;
|
if (error) throw error;
|
||||||
setLocations(data || []);
|
setParks(data || []);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching locations:', error);
|
console.error('Error fetching parks:', error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const fetchAccessibilityPreferences = async () => {
|
const fetchAccessibilityPreferences = async () => {
|
||||||
@@ -93,7 +97,8 @@ export function LocationTab() {
|
|||||||
preferred_pronouns: data.preferred_pronouns || null,
|
preferred_pronouns: data.preferred_pronouns || null,
|
||||||
timezone: data.timezone,
|
timezone: data.timezone,
|
||||||
preferred_language: data.preferred_language,
|
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()
|
updated_at: new Date().toISOString()
|
||||||
}).eq('user_id', user.id);
|
}).eq('user_id', user.id);
|
||||||
|
|
||||||
@@ -147,21 +152,41 @@ export function LocationTab() {
|
|||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent className="space-y-6">
|
<CardContent className="space-y-6">
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<Label htmlFor="location_id">Home Park</Label>
|
<Label htmlFor="personal_location">Your Location</Label>
|
||||||
<Select value={form.watch('location_id')} onValueChange={value => form.setValue('location_id', value)}>
|
<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>
|
<SelectTrigger>
|
||||||
<SelectValue placeholder="Select your home park" />
|
<SelectValue placeholder="Select your home park" />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
{locations.map(location => <SelectItem key={location.id} value={location.id}>
|
{parks.map(park => (
|
||||||
{location.name}
|
<SelectItem key={park.id} value={park.id}>
|
||||||
{location.city && `, ${location.city}`}
|
{park.name}
|
||||||
{location.state_province && `, ${location.state_province}`}
|
{park.locations && (
|
||||||
{location.country && `, ${location.country}`}
|
<>
|
||||||
</SelectItem>)}
|
{park.locations.city && `, ${park.locations.city}`}
|
||||||
|
{park.locations.state_province && `, ${park.locations.state_province}`}
|
||||||
|
{park.locations.country && `, ${park.locations.country}`}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</SelectItem>
|
||||||
|
))}
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
|
<p className="text-sm text-muted-foreground">
|
||||||
|
The theme park you visit most often or consider your "home" park
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
|
|||||||
@@ -357,6 +357,7 @@ export type Database = {
|
|||||||
id: string
|
id: string
|
||||||
location_id: string | null
|
location_id: string | null
|
||||||
park_count: number | null
|
park_count: number | null
|
||||||
|
personal_location: string | null
|
||||||
preferred_language: string | null
|
preferred_language: string | null
|
||||||
preferred_pronouns: string | null
|
preferred_pronouns: string | null
|
||||||
privacy_level: string
|
privacy_level: string
|
||||||
@@ -382,6 +383,7 @@ export type Database = {
|
|||||||
id?: string
|
id?: string
|
||||||
location_id?: string | null
|
location_id?: string | null
|
||||||
park_count?: number | null
|
park_count?: number | null
|
||||||
|
personal_location?: string | null
|
||||||
preferred_language?: string | null
|
preferred_language?: string | null
|
||||||
preferred_pronouns?: string | null
|
preferred_pronouns?: string | null
|
||||||
privacy_level?: string
|
privacy_level?: string
|
||||||
@@ -407,6 +409,7 @@ export type Database = {
|
|||||||
id?: string
|
id?: string
|
||||||
location_id?: string | null
|
location_id?: string | null
|
||||||
park_count?: number | null
|
park_count?: number | null
|
||||||
|
personal_location?: string | null
|
||||||
preferred_language?: string | null
|
preferred_language?: string | null
|
||||||
preferred_pronouns?: string | null
|
preferred_pronouns?: string | null
|
||||||
privacy_level?: string
|
privacy_level?: string
|
||||||
|
|||||||
@@ -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;
|
||||||
Reference in New Issue
Block a user