stateful tabs and reliable back behavior, and a full onboarding flow is wired in with conditional package selection
(skips when an active package exists).
What changed
- Added per‑tab history + back navigation fallback to make tab switching/Back feel native (resources/js/admin/mobile/
lib/tabHistory.ts, resources/js/admin/mobile/hooks/useBackNavigation.ts, resources/js/admin/mobile/hooks/
useMobileNav.ts, resources/js/admin/mobile/components/MobileShell.tsx + updates across mobile pages).
- Implemented onboarding flow pages + shared shell, and wired new routes/prefetch (resources/js/admin/mobile/welcome/
WelcomeLandingPage.tsx, resources/js/admin/mobile/welcome/WelcomePackagesPage.tsx, resources/js/admin/mobile/
welcome/WelcomeSummaryPage.tsx, resources/js/admin/mobile/welcome/WelcomeEventPage.tsx, resources/js/admin/mobile/
components/OnboardingShell.tsx, resources/js/admin/router.tsx, resources/js/admin/mobile/prefetch.ts).
- Conditional package step: packages page redirects to event setup if activePackage exists; selection stored locally
for summary (resources/js/admin/mobile/lib/onboardingSelection.ts, resources/js/admin/mobile/welcome/
WelcomePackagesPage.tsx).
- Added a “Start welcome journey” CTA in the empty dashboard state (resources/js/admin/mobile/DashboardPage.tsx).
- Added translations for onboarding shell + selected package + dashboard CTA (resources/js/admin/i18n/locales/en/
onboarding.json, resources/js/admin/i18n/locales/de/onboarding.json, resources/js/admin/i18n/locales/en/
management.json, resources/js/admin/i18n/locales/de/management.json).
- Tests for new helpers/hooks (resources/js/admin/mobile/lib/tabHistory.test.ts, resources/js/admin/mobile/lib/
onboardingSelection.test.ts, resources/js/admin/mobile/hooks/useBackNavigation.test.tsx).
203 lines
7.3 KiB
TypeScript
203 lines
7.3 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';
|
|
import { useBackNavigation } from './hooks/useBackNavigation';
|
|
|
|
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 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<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={back}
|
|
>
|
|
<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>
|
|
);
|
|
}
|