import React from 'react'; import { useNavigate } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; import { LogOut, User, Settings, Shield, Globe, Moon } from 'lucide-react'; import { YStack, XStack } from '@tamagui/stacks'; import { SizableText as Text } from '@tamagui/text'; import { MobileScaffold } from './components/Scaffold'; import { MobileCard, CTAButton } from './components/Primitives'; import { BottomNav } from './components/BottomNav'; import { useAuth } from '../auth/context'; import { fetchTenantProfile } from '../api'; import { useMobileNav } from './hooks/useMobileNav'; import { adminPath } from '../constants'; import i18n from '../i18n'; export default function MobileProfilePage() { const { user, logout } = useAuth(); const navigate = useNavigate(); const { t } = useTranslation('management'); const { go } = useMobileNav(); const [name, setName] = React.useState(user?.name ?? 'Guest'); const [email, setEmail] = React.useState(user?.email ?? ''); const [role, setRole] = React.useState(user?.role ?? ''); const [theme, setTheme] = React.useState<'light' | 'dark'>('light'); const [language, setLanguage] = React.useState(i18n.language || 'de'); React.useEffect(() => { (async () => { try { const profile = await fetchTenantProfile(); setName(profile.name ?? name); setEmail(profile.email ?? email); setRole((profile as any)?.role ?? role); } catch { // non-fatal for mobile profile view } })(); }, [email, name, role]); return ( navigate(-1)} footer={ } > {name} {email} {role ? ( {role} ) : null} {t('profile.settings', 'Settings')} navigate(adminPath('/settings'))}> {t('profile.account', 'Account & Security')} {t('profile.language', 'Language')} {t('profile.theme', 'Theme')} { logout(); navigate(adminPath('/logout')); }} /> ); }