Files
fotospiel-app/resources/js/admin/mobile/ProfilePage.tsx
Codex Agent 4ce409e918 Completed the full mobile app polish pass: navigation feel, safe‑area consistency, input styling, list rows, FAB
patterns, skeleton loading, photo selection/bulk actions with shared‑element transitions, notification detail sheet,
  offline banner, maskable manifest icons, and route prefetching.

  Key changes

  - Navigation/shell: press feedback on all header actions, glassy sticky header and tab bar, safer bottom spacing
    (resources/js/admin/mobile/components/MobileShell.tsx, resources/js/admin/mobile/components/BottomNav.tsx).
  - Forms + lists: shared mobile form controls, list‑style rows in settings/profile, consistent inputs across core
    flows (resources/js/admin/mobile/components/FormControls.tsx, resources/js/admin/mobile/SettingsPage.tsx,
    resources/js/admin/mobile/ProfilePage.tsx, resources/js/admin/mobile/EventFormPage.tsx, resources/js/admin/mobile/
    EventMembersPage.tsx, resources/js/admin/mobile/EventTasksPage.tsx, resources/js/admin/mobile/
    EventGuestNotificationsPage.tsx, resources/js/admin/mobile/NotificationsPage.tsx, resources/js/admin/mobile/
    EventPhotosPage.tsx, resources/js/admin/mobile/EventsPage.tsx).
  - Media workflows: shared‑element photo transitions, selection mode + bulk actions bar (resources/js/admin/mobile/
    EventPhotosPage.tsx).
  - Loading UX: shimmering skeletons (resources/css/app.css, resources/js/admin/mobile/components/Primitives.tsx).
  - PWA polish + perf: maskable icons, offline banner hook, and route prefetch (public/manifest.json, resources/js/
    admin/mobile/hooks/useOnlineStatus.tsx, resources/js/admin/mobile/prefetch.ts, resources/js/admin/main.tsx).
2025-12-27 23:55:48 +01:00

201 lines
7.2 KiB
TypeScript

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 { Pressable } from '@tamagui/react-native-web-lite';
import { useTheme } from '@tamagui/core';
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 } from '../constants';
import i18n from '../i18n';
import { useAppearance } from '@/hooks/use-appearance';
export default function MobileProfilePage() {
const { user, logout } = useAuth();
const navigate = useNavigate();
const { t } = useTranslation('management');
const { appearance, updateAppearance } = useAppearance();
const theme = useTheme();
const textColor = String(theme.color?.val ?? '#111827');
const mutedText = String(theme.gray?.val ?? '#4b5563');
const borderColor = String(theme.borderColor?.val ?? '#e5e7eb');
const avatarBg = String(theme.surface?.val ?? '#e0f2fe');
const primary = String(theme.primary?.val ?? '#2563eb');
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<string>(user?.role ?? '');
const [language, setLanguage] = React.useState<string>(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 (
<MobileShell
activeTab="profile"
title={t('mobileProfile.title', 'Profile')}
onBack={() => navigate(-1)}
>
<MobileCard space="$3" alignItems="center">
<XStack
width={64}
height={64}
borderRadius={20}
alignItems="center"
justifyContent="center"
backgroundColor={avatarBg}
>
<User size={28} color={primary} />
</XStack>
<Text fontSize="$md" fontWeight="800" color={textColor}>
{name}
</Text>
<Text fontSize="$sm" color={mutedText}>
{email}
</Text>
{role ? (
<Text fontSize="$xs" color={mutedText}>
{role}
</Text>
) : null}
</MobileCard>
<MobileCard space="$3">
<Text fontSize="$md" fontWeight="800" color={textColor}>
{t('mobileProfile.settings', 'Settings')}
</Text>
<YGroup borderRadius="$4" borderWidth={1} borderColor={borderColor} overflow="hidden">
<YGroup.Item bordered>
<Pressable onPress={() => navigate(adminPath('/mobile/settings'))}>
<ListItem
hoverTheme
pressTheme
paddingVertical="$2"
paddingHorizontal="$3"
title={
<Text fontSize="$sm" color={textColor}>
{t('mobileProfile.account', 'Account & security')}
</Text>
}
iconAfter={<Settings size={18} color="#9ca3af" />}
/>
</Pressable>
</YGroup.Item>
<YGroup.Item bordered>
<Pressable onPress={() => navigate(adminPath('/mobile/billing#packages'))}>
<ListItem
hoverTheme
pressTheme
paddingVertical="$2"
paddingHorizontal="$3"
title={
<Text fontSize="$sm" color={textColor}>
{t('billing.sections.packages.title', 'Packages & Billing')}
</Text>
}
iconAfter={<Settings size={18} color="#9ca3af" />}
/>
</Pressable>
</YGroup.Item>
<YGroup.Item bordered>
<Pressable onPress={() => navigate(adminPath('/mobile/billing#invoices'))}>
<ListItem
hoverTheme
pressTheme
paddingVertical="$2"
paddingHorizontal="$3"
title={
<Text fontSize="$sm" color={textColor}>
{t('billing.sections.invoices.title', 'Invoices & Payments')}
</Text>
}
iconAfter={<Settings size={18} color="#9ca3af" />}
/>
</Pressable>
</YGroup.Item>
<YGroup.Item bordered>
<ListItem
paddingVertical="$2"
paddingHorizontal="$3"
title={
<XStack space="$2" alignItems="center">
<Globe size={16} color="#6b7280" />
<Text fontSize="$sm" color={textColor}>
{t('mobileProfile.language', 'Language')}
</Text>
</XStack>
}
iconAfter={
<MobileSelect
value={language}
onChange={(e) => {
const lng = e.target.value;
setLanguage(lng);
void i18n.changeLanguage(lng);
}}
compact
style={{ minWidth: 130 }}
>
<option value="de">{t('mobileProfile.languageDe', 'Deutsch')}</option>
<option value="en">{t('mobileProfile.languageEn', 'English')}</option>
</MobileSelect>
}
/>
</YGroup.Item>
<YGroup.Item>
<ListItem
paddingVertical="$2"
paddingHorizontal="$3"
title={
<XStack space="$2" alignItems="center">
<Moon size={16} color="#6b7280" />
<Text fontSize="$sm" color={textColor}>
{t('mobileProfile.theme', 'Theme')}
</Text>
</XStack>
}
iconAfter={
<MobileSelect
value={appearance}
onChange={(e) => updateAppearance(e.target.value as 'light' | 'dark' | 'system')}
compact
style={{ minWidth: 130 }}
>
<option value="light">{t('mobileProfile.themeLight', 'Light')}</option>
<option value="dark">{t('mobileProfile.themeDark', 'Dark')}</option>
<option value="system">{t('mobileProfile.themeSystem', 'System')}</option>
</MobileSelect>
}
/>
</YGroup.Item>
</YGroup>
</MobileCard>
<CTAButton
label={t('mobileProfile.logout', 'Log out')}
onPress={() => {
logout();
navigate(adminPath('/logout'));
}}
/>
</MobileShell>
);
}