import React, { useState, useEffect } from 'react'; import { toast } from 'sonner'; import { api } from '@/api'; import { Card, CardHeader, CardTitle, CardContent } from '@/components/ui/card'; import { FieldRow, Toggle } from './adminShared'; export default function PrivacyAdminCard() { const [geoEnabled, setGeoEnabled] = useState(false); const [loading, setLoading] = useState(true); const [saving, setSaving] = useState(false); useEffect(() => { api.privacySettings() .then(d => { setGeoEnabled(!!d.geolocation_enabled); }) .catch(() => toast.error('Failed to load privacy settings')) .finally(() => setLoading(false)); }, []); async function toggleGeo(next) { setSaving(true); try { const d = await api.setPrivacySettings({ geolocation_enabled: next }); setGeoEnabled(!!d.geolocation_enabled); toast.success(next ? 'Geolocation enabled' : 'Geolocation disabled'); } catch { toast.error('Failed to update privacy settings'); } finally { setSaving(false); } } return ( Privacy
{geoEnabled ? 'On' : 'Off (default)'}

When enabled, new-device logins resolve the login IP to a city/region via{' '} ip-api.com over plain HTTP. Disable to keep all login data on-device. Location data is encrypted at rest.

); }