Files
fotospiel-app/resources/js/admin/mobile/hooks/useMobileNav.ts
Codex Agent 73e550ee87 Implemented a shared mobile shell and navigation aligned to the new architecture, plus refactored the dashboard and
tab flows.

  - Added a dynamic MobileShell with sticky header (notification bell with badge, quick QR when an event is
    active, event switcher for multi-event users) and stabilized bottom tabs (home, tasks, uploads, profile)
    driven by useMobileNav (resources/js/admin/mobile/components/MobileShell.tsx, components/BottomNav.tsx, hooks/
    useMobileNav.ts).
  - Centralized event handling now supports 0/1/many-event states without auto-selecting in multi-tenant mode and
    exposes helper flags/activeSlug for consumers (resources/js/admin/context/EventContext.tsx).
  - Rebuilt the mobile dashboard into explicit states: onboarding/no-event, single-event focus, and multi-event picker
    with featured/secondary actions, KPI strip, and alerts (resources/js/admin/mobile/DashboardPage.tsx).
  - Introduced tab entry points that respect event context and prompt selection when needed (resources/js/admin/
    mobile/TasksTabPage.tsx, UploadsTabPage.tsx). Refreshed tasks/uploads detail screens to use the new shell and sync
    event selection (resources/js/admin/mobile/EventTasksPage.tsx, EventPhotosPage.tsx).
  - Updated mobile routes and existing screens to the new tab keys and header/footer behavior (resources/js/admin/
    router.tsx, mobile/* pages, i18n nav/header strings).
2025-12-10 16:13:44 +01:00

43 lines
1.1 KiB
TypeScript

import React from 'react';
import { useNavigate } from 'react-router-dom';
import { adminPath } from '../../constants';
import { useEventContext } from '../../context/EventContext';
import { NavKey } from '../components/BottomNav';
export function useMobileNav(currentSlug?: string | null) {
const navigate = useNavigate();
const { activeEvent } = useEventContext();
const slug = currentSlug ?? activeEvent?.slug ?? null;
const go = React.useCallback(
(key: NavKey) => {
if (key === 'tasks') {
if (slug) {
navigate(adminPath(`/mobile/events/${slug}/tasks`));
} else {
navigate(adminPath('/mobile/tasks'));
}
return;
}
if (key === 'uploads') {
if (slug) {
navigate(adminPath(`/mobile/events/${slug}/photos`));
} else {
navigate(adminPath('/mobile/uploads'));
}
return;
}
if (key === 'home') {
navigate(adminPath('/mobile/dashboard'));
return;
}
if (key === 'profile') {
navigate(adminPath('/mobile/profile'));
}
},
[navigate, slug]
);
return { go, slug };
}