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