Refactor code structure for improved readability and maintainability
This commit is contained in:
@@ -10,7 +10,6 @@ import {
|
||||
ChevronDownIcon,
|
||||
ClipboardDocumentCheckIcon,
|
||||
ClipboardDocumentListIcon,
|
||||
SparklesIcon,
|
||||
Cog6ToothIcon,
|
||||
CreditCardIcon,
|
||||
CubeIcon,
|
||||
@@ -23,6 +22,7 @@ import {
|
||||
LockClosedIcon,
|
||||
PlusIcon,
|
||||
ShieldCheckIcon,
|
||||
SparklesIcon,
|
||||
StarIcon,
|
||||
TagIcon,
|
||||
UserCircleIcon,
|
||||
@@ -32,9 +32,9 @@ import {
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { useState } from "react";
|
||||
import { NavLink, useLocation, useNavigate } from "react-router-dom";
|
||||
import { useSubscription } from "../../hooks/useSubscription";
|
||||
import { usePermissions } from "../../hooks/usePermissions";
|
||||
import { useSecretaryEarnings } from "../../hooks/useSecretaryEarnings";
|
||||
import { useSubscription } from "../../hooks/useSubscription";
|
||||
import { useAuthStore } from "../../stores/authStore";
|
||||
import { useUiStore } from "../../stores/uiStore";
|
||||
|
||||
@@ -62,7 +62,11 @@ const APPOINTMENTS_CHILDREN: SubItem[] = [
|
||||
*/
|
||||
const APPOINTMENTS_CHILDREN_WITH_RESERVE: SubItem[] = [
|
||||
...APPOINTMENTS_CHILDREN,
|
||||
{ to: "/admin/appointments/reserve", label: "رزرو نوبت", icon: ArchiveBoxIcon },
|
||||
{
|
||||
to: "/admin/appointments/reserve",
|
||||
label: "رزرو نوبت",
|
||||
icon: ArchiveBoxIcon,
|
||||
},
|
||||
];
|
||||
|
||||
function buildSections(
|
||||
@@ -94,25 +98,55 @@ function buildSections(
|
||||
});
|
||||
}
|
||||
if (can("payments", "view")) {
|
||||
items.push({ to: "/admin/my-payments", icon: CreditCardIcon, label: "پرداختها" });
|
||||
items.push({
|
||||
to: "/admin/my-payments",
|
||||
icon: CreditCardIcon,
|
||||
label: "پرداختها",
|
||||
});
|
||||
}
|
||||
if (can("insurances", "view")) {
|
||||
items.push(
|
||||
{ to: "/admin/insurance-pricing", icon: ShieldCheckIcon, label: "قیمتگذاری بیمه", feature: "insurance" },
|
||||
{ to: "/admin/claims", icon: DocumentTextIcon, label: "مطالبات بیمه", feature: "insurance" },
|
||||
{
|
||||
to: "/admin/insurance-pricing",
|
||||
icon: ShieldCheckIcon,
|
||||
label: "قیمتگذاری بیمه",
|
||||
feature: "insurance",
|
||||
},
|
||||
{
|
||||
to: "/admin/claims",
|
||||
icon: DocumentTextIcon,
|
||||
label: "مطالبات بیمه",
|
||||
feature: "insurance",
|
||||
},
|
||||
);
|
||||
}
|
||||
if (can("services", "view")) {
|
||||
items.push({ to: "/admin/clinic-services", icon: WrenchScrewdriverIcon, label: "سرویس ها" });
|
||||
items.push({
|
||||
to: "/admin/clinic-services",
|
||||
icon: WrenchScrewdriverIcon,
|
||||
label: "سرویس ها",
|
||||
});
|
||||
}
|
||||
if (can("appointments", "view")) {
|
||||
items.push({ to: "/admin/treatment-cases", icon: ClipboardDocumentListIcon, label: "درمانهای چندجلسهای" });
|
||||
items.push({
|
||||
to: "/admin/treatment-cases",
|
||||
icon: ClipboardDocumentListIcon,
|
||||
label: "دورههای درمان",
|
||||
});
|
||||
}
|
||||
if (can("appointment_settings", "view")) {
|
||||
items.push({ to: "/admin/resources", icon: CubeIcon, label: "منابع" });
|
||||
items.push({
|
||||
to: "/admin/resources",
|
||||
icon: CubeIcon,
|
||||
label: "منابع",
|
||||
});
|
||||
}
|
||||
if (can("inventory", "view")) {
|
||||
items.push({ to: "/admin/inventory", icon: ArchiveBoxIcon, label: "انبارداری" });
|
||||
items.push({
|
||||
to: "/admin/inventory",
|
||||
icon: ArchiveBoxIcon,
|
||||
label: "انبارداری",
|
||||
});
|
||||
}
|
||||
|
||||
// زیرمنوهای «تنظیمات» (services/tags/staff/discounts/sms/appointment_settings)
|
||||
@@ -121,12 +155,24 @@ function buildSections(
|
||||
return [
|
||||
{
|
||||
label: "عمومی",
|
||||
items: [{ to: "/admin/dashboard", icon: ChartBarIcon, label: "داشبورد" }],
|
||||
items: [
|
||||
{
|
||||
to: "/admin/dashboard",
|
||||
icon: ChartBarIcon,
|
||||
label: "داشبورد",
|
||||
},
|
||||
],
|
||||
},
|
||||
{ label: "مدیریت", items },
|
||||
{
|
||||
label: "تنظیمات",
|
||||
items: [{ to: "/admin/account-settings", icon: Cog6ToothIcon, label: "تنظیمات" }],
|
||||
items: [
|
||||
{
|
||||
to: "/admin/account-settings",
|
||||
icon: Cog6ToothIcon,
|
||||
label: "تنظیمات",
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
}
|
||||
@@ -323,7 +369,7 @@ function buildSections(
|
||||
{
|
||||
to: "/admin/treatment-cases",
|
||||
icon: ClipboardDocumentListIcon,
|
||||
label: "درمانهای چندجلسهای",
|
||||
label: "دورههای درمان",
|
||||
},
|
||||
{
|
||||
to: "/admin/resources",
|
||||
@@ -408,7 +454,7 @@ function buildSections(
|
||||
{
|
||||
to: "/admin/treatment-cases",
|
||||
icon: ClipboardDocumentListIcon,
|
||||
label: "درمانهای چندجلسهای",
|
||||
label: "دورههای درمان",
|
||||
},
|
||||
{
|
||||
to: "/admin/resources",
|
||||
@@ -486,7 +532,7 @@ function buildSections(
|
||||
items.push({
|
||||
to: "/admin/treatment-cases",
|
||||
icon: ClipboardDocumentListIcon,
|
||||
label: "درمانهای چندجلسهای",
|
||||
label: "دورههای درمان",
|
||||
});
|
||||
}
|
||||
if (can("appointment_settings", "view")) {
|
||||
@@ -525,7 +571,13 @@ function buildSections(
|
||||
return [
|
||||
{
|
||||
label: "عمومی",
|
||||
items: [{ to: "/admin/dashboard", icon: ChartBarIcon, label: "داشبورد" }],
|
||||
items: [
|
||||
{
|
||||
to: "/admin/dashboard",
|
||||
icon: ChartBarIcon,
|
||||
label: "داشبورد",
|
||||
},
|
||||
],
|
||||
},
|
||||
{ label: "مدیریت", items },
|
||||
{
|
||||
@@ -549,7 +601,13 @@ function buildSections(
|
||||
return [
|
||||
{
|
||||
label: "عمومی",
|
||||
items: [{ to: "/admin/dashboard", icon: ChartBarIcon, label: "داشبورد" }],
|
||||
items: [
|
||||
{
|
||||
to: "/admin/dashboard",
|
||||
icon: ChartBarIcon,
|
||||
label: "داشبورد",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: "مدیریت",
|
||||
@@ -799,7 +857,9 @@ export default function Sidebar({ mobileOpen: _m, onMobileClose: _c }: Props) {
|
||||
const navigate = useNavigate();
|
||||
|
||||
const { can } = usePermissions();
|
||||
const { summary: secretaryEarnings } = useSecretaryEarnings(primaryRole === "secretary");
|
||||
const { summary: secretaryEarnings } = useSecretaryEarnings(
|
||||
primaryRole === "secretary",
|
||||
);
|
||||
const sections = buildSections(
|
||||
primaryRole,
|
||||
dbUuid,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user