import React from 'react'; import { useNavigate } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; import { User, Settings, Globe, Moon, Download, LogOut, HelpCircle } from 'lucide-react'; import { Avatar } from '@tamagui/avatar'; import { Card } from '@tamagui/card'; import { YStack, XStack } from '@tamagui/stacks'; import { SizableText as Text } from '@tamagui/text'; import { YGroup } from '@tamagui/group'; import { ListItem } from '@tamagui/list-item'; import { MobileShell } from './components/MobileShell'; import { CTAButton } from './components/Primitives'; import { MobileSelect } from './components/FormControls'; import { useAuth } from '../auth/context'; import { fetchTenantProfile } from '../api'; import { adminPath, ADMIN_DATA_EXPORTS_PATH, ADMIN_PROFILE_ACCOUNT_PATH, ADMIN_FAQ_PATH } from '../constants'; import i18n from '../i18n'; import { useAppearance } from '@/hooks/use-appearance'; import { useBackNavigation } from './hooks/useBackNavigation'; import { withAlpha } from './components/colors'; import { useAdminTheme } from './theme'; export default function MobileProfilePage() { const { user, logout } = useAuth(); const isMember = user?.role === 'member'; const navigate = useNavigate(); const { t } = useTranslation('management'); const { appearance, updateAppearance } = useAppearance(); const { textStrong, muted, border, accentSoft, primary, subtle, surface, surfaceMuted, shadow, danger } = 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')} {t('mobileProfile.account', 'Account bearbeiten')} } iconAfter={} onPress={() => navigate(ADMIN_PROFILE_ACCOUNT_PATH)} /> {!isMember ? ( <> {t('billing.sections.packages.title', 'Packages & Billing')} } iconAfter={} onPress={() => navigate(adminPath('/mobile/billing#packages'))} /> {t('billing.sections.invoices.title', 'Invoices & Payments')} } iconAfter={} onPress={() => navigate(adminPath('/mobile/billing#invoices'))} /> {t('dataExports.title', 'Data exports')} } iconAfter={} onPress={() => navigate(ADMIN_DATA_EXPORTS_PATH)} /> ) : null} {t('common.help', 'Help')} } iconAfter={} onPress={() => navigate(ADMIN_FAQ_PATH)} /> {t('mobileProfile.settings', 'Preferences')} {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 }} > } /> {t('mobileProfile.logoutTitle', 'Sign out')} {t('mobileProfile.logoutHint', 'Sign out from this device.')} { logout(); navigate(adminPath('/logout')); }} /> ); }