feat: move "منابع" to main sidebar and update related components
This commit is contained in:
@@ -36,15 +36,22 @@ describe('SettingsLayout', () => {
|
||||
|
||||
/**
|
||||
* سایدبار و فهرست موبایل یک منبع دارند؛ آیتمی که به منو اضافه میشود باید در هر دو
|
||||
* دیده شود. قبلاً دو کپی بود و «منابع»/«دستهبندیها» فقط در موبایل ظاهر شدند.
|
||||
* دیده شود. قبلاً دو کپی بود و «دستهبندیها» فقط در موبایل ظاهر شد.
|
||||
*/
|
||||
it('shows the resource-first entries in the desktop sidebar too', () => {
|
||||
useAuthStore.setState({ primaryRole: 'clinic' });
|
||||
renderWithProviders(<SettingsLayout active="resources"><div /></SettingsLayout>);
|
||||
renderWithProviders(<SettingsLayout active="service-categories"><div /></SettingsLayout>);
|
||||
|
||||
expect(screen.getByText('منابع').closest('a')).toHaveAttribute('href', '/admin/resources');
|
||||
expect(screen.getByText('دستهبندیها').closest('a')).toHaveAttribute('href', '/admin/service-categories');
|
||||
expect(screen.getByText('منابع').closest('a')).toHaveAttribute('aria-current', 'page');
|
||||
expect(screen.getByText('دستهبندیها').closest('a')).toHaveAttribute('aria-current', 'page');
|
||||
});
|
||||
|
||||
/** «منابع» کارِ روزمره است و به سایدبار اصلی رفت؛ نباید در منوی تنظیمات تکرار شود. */
|
||||
it('does not list منابع in the settings menu any more', () => {
|
||||
useAuthStore.setState({ primaryRole: 'clinic' });
|
||||
renderWithProviders(<SettingsLayout active="service-categories"><div /></SettingsLayout>);
|
||||
|
||||
expect(screen.queryByText('منابع')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('role-gates the desktop sidebar: a doctor does not see the clinic-doctors tab', () => {
|
||||
|
||||
@@ -141,6 +141,22 @@ describe("Sidebar — گِیت منوی منشی بر اساس مجوز", () =>
|
||||
expect(screen.queryByText("تنظیمات نوبتدهی")).not.toBeInTheDocument();
|
||||
expect(screen.queryByText("پزشکان کلینیک")).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
/**
|
||||
* «منابع» از منوی تنظیمات به سایدبار اصلی منتقل شد. گِیتش عوض نشده — همان
|
||||
* `appointment_settings.view` که در منوی تنظیمات داشت.
|
||||
*/
|
||||
it("«منابع» در سایدبار اصلی میآید و به مجوز appointment_settings گِیت است", () => {
|
||||
setSecretary({ appointment_settings: { view: true } });
|
||||
renderWithProviders(<Sidebar />, { route: "/admin/dashboard" });
|
||||
expect(screen.getByText("منابع").closest("a")).toHaveAttribute("href", "/admin/resources");
|
||||
});
|
||||
|
||||
it("منشیِ بدون مجوز، «منابع» را نمیبیند", () => {
|
||||
setSecretary({ appointments: { view: true } });
|
||||
renderWithProviders(<Sidebar />, { route: "/admin/dashboard" });
|
||||
expect(screen.queryByText("منابع")).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
describe("Sidebar — گِیت منوی پزشکِ عضوِ کلینیک بر اساس مجوز", () => {
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
ClipboardDocumentCheckIcon,
|
||||
Cog6ToothIcon,
|
||||
CreditCardIcon,
|
||||
CubeIcon,
|
||||
CurrencyDollarIcon,
|
||||
DevicePhoneMobileIcon,
|
||||
DocumentTextIcon,
|
||||
@@ -102,6 +103,9 @@ function buildSections(
|
||||
if (can("services", "view")) {
|
||||
items.push({ to: "/admin/clinic-services", icon: WrenchScrewdriverIcon, label: "سرویس ها" });
|
||||
}
|
||||
if (can("appointment_settings", "view")) {
|
||||
items.push({ to: "/admin/resources", icon: CubeIcon, label: "منابع" });
|
||||
}
|
||||
if (can("inventory", "view")) {
|
||||
items.push({ to: "/admin/inventory", icon: ArchiveBoxIcon, label: "انبارداری" });
|
||||
}
|
||||
@@ -306,6 +310,11 @@ function buildSections(
|
||||
icon: WrenchScrewdriverIcon,
|
||||
label: "سرویس ها",
|
||||
},
|
||||
{
|
||||
to: "/admin/resources",
|
||||
icon: CubeIcon,
|
||||
label: "منابع",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -381,6 +390,11 @@ function buildSections(
|
||||
icon: WrenchScrewdriverIcon,
|
||||
label: "سرویس ها",
|
||||
},
|
||||
{
|
||||
to: "/admin/resources",
|
||||
icon: CubeIcon,
|
||||
label: "منابع",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -448,6 +462,13 @@ function buildSections(
|
||||
label: "سرویس ها",
|
||||
});
|
||||
}
|
||||
if (can("appointment_settings", "view")) {
|
||||
items.push({
|
||||
to: "/admin/resources",
|
||||
icon: CubeIcon,
|
||||
label: "منابع",
|
||||
});
|
||||
}
|
||||
if (can("inventory", "view")) {
|
||||
items.push({
|
||||
to: "/admin/inventory",
|
||||
|
||||
@@ -3,7 +3,7 @@ import {
|
||||
CreditCardIcon, UserIcon, CalendarDaysIcon, BuildingOffice2Icon,
|
||||
BanknotesIcon, UsersIcon, ShieldCheckIcon,
|
||||
TagIcon, ChatBubbleLeftRightIcon, UserCircleIcon, UserPlusIcon, ReceiptPercentIcon,
|
||||
CubeIcon, RectangleStackIcon,
|
||||
RectangleStackIcon,
|
||||
} from '@heroicons/react/24/outline';
|
||||
|
||||
/**
|
||||
@@ -34,7 +34,8 @@ export const SETTINGS_MENU: SettingsMenuItem[] = [
|
||||
{ key: 'appointment', label: 'مدیریت نوبت دهی', icon: CalendarDaysIcon, to: '/admin/appointment-settings', roles: ['doctor'], perm: ['appointment_settings', 'view'] },
|
||||
{ key: 'appointment', label: 'مدیریت نوبت دهی', icon: CalendarDaysIcon, to: '/admin/settings/appointment-settings', roles: ['clinic'], perm: ['appointment_settings', 'view'] },
|
||||
{ key: 'clinic-doctors', label: 'پزشکان کلینیک', icon: BuildingOffice2Icon, to: '/admin/settings/clinic-doctors', roles: ['clinic'], perm: ['clinic_doctors', 'view'] },
|
||||
{ key: 'resources', label: 'منابع', icon: CubeIcon, to: '/admin/resources', roles: ['doctor', 'clinic'], perm: ['appointment_settings', 'view'] },
|
||||
// «منابع» به سایدبار اصلی («مدیریت») منتقل شد — کارِ روزمره است، نه تنظیمات.
|
||||
// گِیتش آنجا همین است: `appointment_settings.view` در هر چهار نقشی که اینجا میدیدندش.
|
||||
{ key: 'service-categories', label: 'دستهبندیها', icon: RectangleStackIcon, to: '/admin/service-categories', roles: ['doctor', 'clinic'], perm: ['appointment_settings', 'view'] },
|
||||
{ key: 'holidays', label: 'تعطیلات رسمی', icon: CalendarDaysIcon, to: '/admin/holidays', roles: ['doctor', 'clinic'], perm: ['appointment_settings', 'view'] },
|
||||
{ key: 'payment', label: 'مدیریت پرداخت', icon: BanknotesIcon, to: '/admin/my-financial', perm: ['payments', 'view'] },
|
||||
|
||||
Reference in New Issue
Block a user