From 6a46b1c14a6e1abf8a6d5463ec43136b62028f26 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:54:16 +0000 Subject: [PATCH] Add location field to profile --- .../profile/PersonalLocationDisplay.tsx | 52 +++++++++++++++++++ src/pages/Profile.tsx | 4 ++ src/types/database.ts | 1 + 3 files changed, 57 insertions(+) create mode 100644 src/components/profile/PersonalLocationDisplay.tsx diff --git a/src/components/profile/PersonalLocationDisplay.tsx b/src/components/profile/PersonalLocationDisplay.tsx new file mode 100644 index 00000000..2a1467ea --- /dev/null +++ b/src/components/profile/PersonalLocationDisplay.tsx @@ -0,0 +1,52 @@ +import { useState, useEffect } from 'react'; +import { MapPin } from 'lucide-react'; +import { supabase } from '@/integrations/supabase/client'; + +interface PersonalLocationDisplayProps { + personalLocation: string; + userId: string; + isOwnProfile: boolean; +} + +export function PersonalLocationDisplay({ personalLocation, userId, isOwnProfile }: PersonalLocationDisplayProps) { + const [showLocation, setShowLocation] = useState(false); + + useEffect(() => { + fetchLocationPrivacy(); + }, [userId, isOwnProfile]); + + const fetchLocationPrivacy = async () => { + // Always show location for own profile + if (isOwnProfile) { + setShowLocation(true); + return; + } + + try { + const { data } = await supabase + .from('user_preferences') + .select('privacy_settings') + .eq('user_id', userId) + .maybeSingle(); + + if (data?.privacy_settings) { + const settings = data.privacy_settings as any; + setShowLocation(settings.show_location || false); + } + } catch (error) { + console.error('Error fetching location privacy:', error); + setShowLocation(false); + } + }; + + if (!showLocation || !personalLocation) { + return null; + } + + return ( +