From 98b06cdf6e485857703d141e683b6fea5df4fec8 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Sun, 28 Sep 2025 20:58:08 +0000 Subject: [PATCH] Refactor settings page --- src/components/settings/LocationTab.tsx | 4 ++-- src/integrations/supabase/types.ts | 10 ++++++++++ src/types/database.ts | 1 + ...0928205734_8d125b06-d1c3-4864-a535-2e56df1ebf79.sql | 3 +++ 4 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 supabase/migrations/20250928205734_8d125b06-d1c3-4864-a535-2e56df1ebf79.sql diff --git a/src/components/settings/LocationTab.tsx b/src/components/settings/LocationTab.tsx index 8de79914..9388ca65 100644 --- a/src/components/settings/LocationTab.tsx +++ b/src/components/settings/LocationTab.tsx @@ -49,7 +49,7 @@ export function LocationTab() { timezone: profile?.timezone || 'UTC', preferred_language: profile?.preferred_language || 'en', personal_location: (profile as any)?.personal_location || '', - home_park_id: profile?.location_id || '' + home_park_id: (profile as any)?.home_park_id || '' } }); useEffect(() => { @@ -98,7 +98,7 @@ export function LocationTab() { timezone: data.timezone, preferred_language: data.preferred_language, personal_location: data.personal_location || null, - location_id: data.home_park_id || null, + home_park_id: data.home_park_id || null, updated_at: new Date().toISOString() }).eq('user_id', user.id); diff --git a/src/integrations/supabase/types.ts b/src/integrations/supabase/types.ts index 8b3ff5af..217acaa8 100644 --- a/src/integrations/supabase/types.ts +++ b/src/integrations/supabase/types.ts @@ -354,6 +354,7 @@ export type Database = { created_at: string date_of_birth: string | null display_name: string | null + home_park_id: string | null id: string location_id: string | null park_count: number | null @@ -380,6 +381,7 @@ export type Database = { created_at?: string date_of_birth?: string | null display_name?: string | null + home_park_id?: string | null id?: string location_id?: string | null park_count?: number | null @@ -406,6 +408,7 @@ export type Database = { created_at?: string date_of_birth?: string | null display_name?: string | null + home_park_id?: string | null id?: string location_id?: string | null park_count?: number | null @@ -424,6 +427,13 @@ export type Database = { username?: string } Relationships: [ + { + foreignKeyName: "profiles_home_park_id_fkey" + columns: ["home_park_id"] + isOneToOne: false + referencedRelation: "parks" + referencedColumns: ["id"] + }, { foreignKeyName: "profiles_location_id_fkey" columns: ["location_id"] diff --git a/src/types/database.ts b/src/types/database.ts index 95900805..4c28c0c6 100644 --- a/src/types/database.ts +++ b/src/types/database.ts @@ -105,6 +105,7 @@ export interface Profile { location?: Location; location_id?: string; personal_location?: string; + home_park_id?: string; date_of_birth?: string; privacy_level: 'public' | 'friends' | 'private'; theme_preference: 'light' | 'dark' | 'system'; diff --git a/supabase/migrations/20250928205734_8d125b06-d1c3-4864-a535-2e56df1ebf79.sql b/supabase/migrations/20250928205734_8d125b06-d1c3-4864-a535-2e56df1ebf79.sql new file mode 100644 index 00000000..d798eb9b --- /dev/null +++ b/supabase/migrations/20250928205734_8d125b06-d1c3-4864-a535-2e56df1ebf79.sql @@ -0,0 +1,3 @@ +-- Add home_park_id field to profiles table to store user's selected home park +ALTER TABLE public.profiles +ADD COLUMN home_park_id UUID REFERENCES public.parks(id); \ No newline at end of file