Refactor settings page

This commit is contained in:
gpt-engineer-app[bot]
2025-09-28 20:58:08 +00:00
parent e841fd2b7c
commit 98b06cdf6e
4 changed files with 16 additions and 2 deletions

View File

@@ -49,7 +49,7 @@ export function LocationTab() {
timezone: profile?.timezone || 'UTC', timezone: profile?.timezone || 'UTC',
preferred_language: profile?.preferred_language || 'en', preferred_language: profile?.preferred_language || 'en',
personal_location: (profile as any)?.personal_location || '', personal_location: (profile as any)?.personal_location || '',
home_park_id: profile?.location_id || '' home_park_id: (profile as any)?.home_park_id || ''
} }
}); });
useEffect(() => { useEffect(() => {
@@ -98,7 +98,7 @@ export function LocationTab() {
timezone: data.timezone, timezone: data.timezone,
preferred_language: data.preferred_language, preferred_language: data.preferred_language,
personal_location: data.personal_location || null, 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() updated_at: new Date().toISOString()
}).eq('user_id', user.id); }).eq('user_id', user.id);

View File

@@ -354,6 +354,7 @@ export type Database = {
created_at: string created_at: string
date_of_birth: string | null date_of_birth: string | null
display_name: string | null display_name: string | null
home_park_id: string | null
id: string id: string
location_id: string | null location_id: string | null
park_count: number | null park_count: number | null
@@ -380,6 +381,7 @@ export type Database = {
created_at?: string created_at?: string
date_of_birth?: string | null date_of_birth?: string | null
display_name?: string | null display_name?: string | null
home_park_id?: string | null
id?: string id?: string
location_id?: string | null location_id?: string | null
park_count?: number | null park_count?: number | null
@@ -406,6 +408,7 @@ export type Database = {
created_at?: string created_at?: string
date_of_birth?: string | null date_of_birth?: string | null
display_name?: string | null display_name?: string | null
home_park_id?: string | null
id?: string id?: string
location_id?: string | null location_id?: string | null
park_count?: number | null park_count?: number | null
@@ -424,6 +427,13 @@ export type Database = {
username?: string username?: string
} }
Relationships: [ Relationships: [
{
foreignKeyName: "profiles_home_park_id_fkey"
columns: ["home_park_id"]
isOneToOne: false
referencedRelation: "parks"
referencedColumns: ["id"]
},
{ {
foreignKeyName: "profiles_location_id_fkey" foreignKeyName: "profiles_location_id_fkey"
columns: ["location_id"] columns: ["location_id"]

View File

@@ -105,6 +105,7 @@ export interface Profile {
location?: Location; location?: Location;
location_id?: string; location_id?: string;
personal_location?: string; personal_location?: string;
home_park_id?: string;
date_of_birth?: string; date_of_birth?: string;
privacy_level: 'public' | 'friends' | 'private'; privacy_level: 'public' | 'friends' | 'private';
theme_preference: 'light' | 'dark' | 'system'; theme_preference: 'light' | 'dark' | 'system';

View File

@@ -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);