manual improvement 1

This commit is contained in:
hamid
2026-07-27 22:27:04 +03:30
parent bd06ef0016
commit baa3cc63cd
166 changed files with 3111 additions and 1770 deletions
+36 -76
View File
@@ -1,102 +1,62 @@
'use client';
import { FunctionComponent, PropsWithChildren, useMemo } from 'react';
import { useTranslations } from 'next-intl';
import { Stack } from '@mui/material';
import { NotificationBell } from '@/components/notifications';
import { ProfileSummary } from '@/components';
import { ROUTES } from '@/constants';
import { LinkToPage } from '@/utils';
import { useMe } from '@/services/auth';
import { useNurseProfile } from '@/services/profiles';
import { useSupportUnreadTotal } from '@/services/tickets';
import { useVerificationStatus } from '@/services/verification';
import { ownBadgeState } from '@/services/verification/types';
import TopBarAndSideBarLayout from './TopBarAndSideBarLayout';
import { BottomBar } from './components';
import ActorSwitcher from './components/ActorSwitcher';
/** A "more" bottom-nav tab isn't a real route — this sentinel never matches a pathname. */
const MORE_TAB_PATH = '#more';
import MobileShell from './MobileShell';
/**
* Nurse app shell — the "نمای پرستار" workspace. Sectioned sidebar (امروز/حرفهٔ من/مالی/پشتیبانی)
* with a real `ProfileSummary` identity card (name, masked phone, own `TrustBadge`), plus a 5-tab
* mobile bottom nav whose «بیشتر» tab opens the same sidebar drawer for the remaining items.
* Nurse app shell — the "نمای پرستار" workspace. Four bottom-nav destinations, one per group the
* sidebar used to hide behind a hamburger: امروز (the operational home), حرفهٔ من, مالی, and a
* بیشتر hub carrying support, notifications and settings. The identity card that lived in the
* drawer header now opens from that hub, where it can be read rather than glanced at.
* @layout NurseLayout
*/
const NurseLayout: FunctionComponent<PropsWithChildren> = ({ children }) => {
const t = useTranslations('nav');
const { data: me } = useMe();
const { data: nurseProfile } = useNurseProfile();
const { data: verification } = useVerificationStatus();
const supportUnreadTotal = useSupportUnreadTotal();
const identityLoading = !me;
const displayName = me ? [me.firstName, me.lastName].filter(Boolean).join(' ').trim() || me.phone : '';
const sidebarItems: Array<LinkToPage> = useMemo(() => {
const groupToday = t('group_today');
const groupProfession = t('group_profession');
const groupFinance = t('group_finance');
const groupSupport = t('group_support');
return [
{ title: t('dashboard'), path: ROUTES.NURSE, icon: 'dashboard', group: groupToday },
{ title: t('requests'), path: ROUTES.NURSE_REQUESTS, icon: 'requests', group: groupToday },
{ title: t('visits'), path: ROUTES.NURSE_VISITS, icon: 'visits', group: groupToday },
{ title: t('profile'), path: ROUTES.NURSE_PROFILE, icon: 'profile', group: groupProfession },
{ title: t('services'), path: ROUTES.NURSE_SERVICES, icon: 'services', group: groupProfession },
{ title: t('coverage'), path: ROUTES.NURSE_COVERAGE, icon: 'coverage', group: groupProfession },
{ title: t('verification'), path: ROUTES.NURSE_VERIFICATION, icon: 'verification', group: groupProfession },
{ title: t('earnings'), path: ROUTES.NURSE_EARNINGS, icon: 'earnings', group: groupFinance },
{ title: t('bank'), path: ROUTES.NURSE_BANK, icon: 'bank', group: groupFinance },
const tabs: Array<LinkToPage> = useMemo(
() => [
{
title: t('support'),
path: ROUTES.NURSE_SUPPORT_TICKETS,
icon: 'support',
group: groupSupport,
title: t('group_today'),
path: ROUTES.NURSE,
icon: 'today',
},
{
title: t('group_profession'),
path: ROUTES.NURSE_PRACTICE,
icon: 'practice',
matchPaths: [
ROUTES.NURSE_PROFILE,
ROUTES.NURSE_SERVICES,
ROUTES.NURSE_COVERAGE,
ROUTES.NURSE_VERIFICATION,
],
},
{
title: t('group_finance'),
path: ROUTES.NURSE_FINANCE,
icon: 'earnings',
matchPaths: [ROUTES.NURSE_EARNINGS, ROUTES.NURSE_BANK],
},
{
title: t('more'),
path: ROUTES.NURSE_MORE,
icon: 'more',
matchPaths: [ROUTES.NURSE_SUPPORT_TICKETS, ROUTES.NURSE_NOTIFICATIONS],
badgeCount: supportUnreadTotal ?? undefined,
},
];
}, [t, supportUnreadTotal]);
const mobileTabs = useMemo(
(): Array<LinkToPage> => [
{ title: t('dashboard'), path: ROUTES.NURSE, icon: 'dashboard' },
{ title: t('requests'), path: ROUTES.NURSE_REQUESTS, icon: 'requests' },
{ title: t('visits'), path: ROUTES.NURSE_VISITS, icon: 'visits' },
{ title: t('earnings'), path: ROUTES.NURSE_EARNINGS, icon: 'earnings' },
{ title: t('more'), path: MORE_TAB_PATH, icon: 'menu' },
],
[t]
[t, supportUnreadTotal]
);
return (
<TopBarAndSideBarLayout
sidebarItems={sidebarItems}
headerActions={<NotificationBell role="nurse" />}
sidebarIdentity={
<Stack sx={{ gap: 1.5 }}>
<ProfileSummary
displayName={displayName}
phone={me?.phone}
avatarUrl={nurseProfile?.avatarUrl}
trustState={ownBadgeState(verification)}
loading={identityLoading}
/>
<ActorSwitcher target="customer" />
</Stack>
}
mobileBottomBar={(openMobileSidebar) => (
<BottomBar
items={mobileTabs.map((item) =>
item.path === MORE_TAB_PATH ? { ...item, onSelect: openMobileSidebar } : item
)}
/>
)}
>
<MobileShell name="Nurse" tabs={tabs} headerActions={<NotificationBell role="nurse" />}>
{children}
</TopBarAndSideBarLayout>
</MobileShell>
);
};