Add location field to profile

This commit is contained in:
gpt-engineer-app[bot]
2025-09-28 20:54:16 +00:00
parent 6efbf78680
commit 6a46b1c14a
3 changed files with 57 additions and 0 deletions

View File

@@ -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 (
<div className="flex items-center gap-1">
<MapPin className="w-4 h-4" />
{personalLocation}
</div>
);
}