'use client'; import { FunctionComponent, PropsWithChildren, useMemo } from 'react'; import { Badge, Box, Stack, Tab, Tabs } from '@mui/material'; import { useTranslations } from 'next-intl'; import { AppIcon, AppIconButton, ErrorBoundary, RouteFadeIn } from '@/components'; import { NotificationBell } from '@/components/notifications'; import { CONTENT_MAX_WIDTH } from '@/components/config'; import { ROUTES } from '@/constants'; import { useSupportUnreadTotal } from '@/services/tickets'; import { LinkToPage } from '@/utils'; import { usePathname, useRouter } from '@/i18n/navigation'; import { TopBar, BottomBar } from './components'; import { DarkModeToggleButton } from './components/DarkModeButton'; import BrandLockup from './components/BrandLockup'; import { matchActivePath } from './matchActivePath'; import { PageTitleProvider, isCustomerRootTab, useRouteTitle } from './routeTitle'; import { TOP_BAR_DESKTOP_HEIGHT, TOP_BAR_MOBILE_HEIGHT, TOP_NAV_DESKTOP_HEIGHT } from './config'; /** The ≥md replacement for the mobile BottomBar — the same 5 tabs, inline in the header. */ const CustomerDesktopNav: FunctionComponent<{ items: Array }> = ({ items }) => { const pathname = usePathname(); const router = useRouter(); const activePath = matchActivePath(pathname, items.map((item) => item.path)) ?? false; return ( router.push(value)} sx={{ minHeight: TOP_NAV_DESKTOP_HEIGHT, px: 2 }} > {items.map((item) => ( : undefined} iconPosition="start" sx={{ minHeight: TOP_NAV_DESKTOP_HEIGHT }} /> ))} ); }; const CustomerHeader: FunctionComponent<{ bottomNavItems: Array }> = ({ bottomNavItems }) => { const t = useTranslations('nav'); const tc = useTranslations('common'); const pathname = usePathname(); const router = useRouter(); const title = useRouteTitle(); const onRootTab = isCustomerRootTab(pathname); const supportUnreadTotal = useSupportUnreadTotal(); return ( router.push(ROUTES.SUPPORT_TICKETS)} /> ) : ( router.back()} /> ) } titleNode={onRootTab ? : undefined} title={onRootTab ? undefined : (title ?? undefined)} endNode={ } secondaryRow={} /> ); }; /** * Customer (family) app shell — the primary, mobile-first experience. A contextual TopBar (brand * lockup on the 5 root tabs, page title + back chevron on pushed routes), a reading-width content * column on a `background.default` canvas, and the 5-tab `BottomBar` on mobile — replaced by an * inline desktop top-nav (`CustomerDesktopNav`) at `≥md`, where the mobile tab bar hides entirely. * @layout CustomerLayout */ const CustomerLayout: FunctionComponent = ({ children }) => { const t = useTranslations('nav'); const tChrome = useTranslations('routeChrome'); const bottomNavItems: Array = useMemo( () => [ { title: t('home'), path: ROUTES.HOME, icon: 'home' }, { title: t('bookings'), path: ROUTES.BOOKINGS, icon: 'bookings' }, { title: t('patients'), path: ROUTES.PATIENTS, icon: 'patients' }, { title: t('wallet'), path: ROUTES.WALLET, icon: 'wallet' }, { title: t('profile'), path: ROUTES.PROFILE, icon: 'profile' }, ], [t] ); return ( {children} ); }; export default CustomerLayout;