import React from 'react'; import { useNavigate } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; import { LogOut, User, Settings, Shield, Globe, Moon, Download } from 'lucide-react'; import { YStack, XStack } from '@tamagui/stacks'; import { SizableText as Text } from '@tamagui/text'; import { Pressable } from '@tamagui/react-native-web-lite'; import { YGroup } from '@tamagui/group'; import { ListItem } from '@tamagui/list-item'; import { MobileShell } from './components/MobileShell'; import { MobileCard, CTAButton } from './components/Primitives'; import { MobileSelect } from './components/FormControls'; import { useAuth } from '../auth/context'; import { fetchTenantProfile } from '../api'; import { adminPath, ADMIN_DATA_EXPORTS_PATH } from '../constants'; import i18n from '../i18n'; import { useAppearance } from '@/hooks/use-appearance'; import { useBackNavigation } from './hooks/useBackNavigation'; import { useAdminTheme } from './theme'; export default function MobileProfilePage() { const { user, logout } = useAuth(); const navigate = useNavigate(); const { t } = useTranslation('management'); const { appearance, updateAppearance } = useAppearance(); const { textStrong, muted, border, accentSoft, primary, subtle } = useAdminTheme(); const textColor = textStrong; const mutedText = muted; const borderColor = border; const avatarBg = accentSoft; const back = useBackNavigation(adminPath('/mobile/dashboard')); const [name, setName] = React.useState(user?.name ?? t('events.members.roles.guest', 'Guest')); const [email, setEmail] = React.useState(user?.email ?? ''); const [role, setRole] = React.useState(user?.role ?? ''); 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 ( {name} {email} {role ? ( {role} ) : null} {t('mobileProfile.settings', 'Settings')} navigate(adminPath('/mobile/profile/security'))}> {t('mobileProfile.account', 'Account & security')} } iconAfter={} /> navigate(adminPath('/mobile/billing#packages'))}> {t('billing.sections.packages.title', 'Packages & Billing')} } iconAfter={} /> navigate(adminPath('/mobile/billing#invoices'))}> {t('billing.sections.invoices.title', 'Invoices & Payments')} } iconAfter={} /> navigate(ADMIN_DATA_EXPORTS_PATH)}> {t('dataExports.title', 'Data exports')} } iconAfter={} /> {t('mobileProfile.language', 'Language')} } iconAfter={ { const lng = e.target.value; setLanguage(lng); void i18n.changeLanguage(lng); }} compact style={{ minWidth: 130 }} > } /> {t('mobileProfile.theme', 'Theme')} } iconAfter={ updateAppearance(e.target.value as 'light' | 'dark' | 'system')} compact style={{ minWidth: 130 }} > } /> { logout(); navigate(adminPath('/logout')); }} /> ); }