2026-04-23 15:33:11 +03:30
|
|
|
'use client';
|
|
|
|
|
|
2026-04-29 14:02:42 +03:30
|
|
|
import Link from 'next/link';
|
2026-04-30 00:52:05 +03:30
|
|
|
import { memo, useMemo } from 'react';
|
2026-04-29 14:02:42 +03:30
|
|
|
import { usePathname } from 'next/navigation';
|
2026-04-23 15:33:11 +03:30
|
|
|
import {
|
|
|
|
|
LayoutDashboard,
|
|
|
|
|
Users,
|
|
|
|
|
Calendar,
|
|
|
|
|
UserCog,
|
|
|
|
|
FlaskConical,
|
|
|
|
|
FileText,
|
2026-04-29 20:19:40 +03:30
|
|
|
CreditCard,
|
2026-04-23 15:33:11 +03:30
|
|
|
} from 'lucide-react';
|
2026-04-30 00:52:05 +03:30
|
|
|
import { useAuth } from '@/lib/hooks/useAuth';
|
2026-04-30 14:05:44 +03:30
|
|
|
import { canViewTab } from '@/shared/permissions';
|
2026-04-23 15:33:11 +03:30
|
|
|
|
|
|
|
|
const menu = [
|
2026-04-30 00:52:05 +03:30
|
|
|
{ name: 'Today', path: '/today', icon: LayoutDashboard, read: 'TAB_TODAY_READ' as const },
|
|
|
|
|
{ name: 'Patients', path: '/patients', icon: Users, read: 'TAB_PATIENTS_READ' as const },
|
|
|
|
|
{ name: 'Appointments', path: '/appointments', icon: Calendar, read: 'TAB_APPOINTMENTS_READ' as const },
|
|
|
|
|
{ name: 'Staff Management', path: '/staff', icon: UserCog, read: 'TAB_STAFF_READ' as const },
|
|
|
|
|
{ name: 'Lab Management', path: '/lab', icon: FlaskConical, read: 'TAB_LAB_READ' as const },
|
|
|
|
|
{ name: 'Billing', path: '/billing', icon: CreditCard, read: 'TAB_BILLING_READ' as const },
|
|
|
|
|
{ name: 'Reports', path: '/reports', icon: FileText, read: 'TAB_REPORTS_READ' as const },
|
2026-04-23 15:33:11 +03:30
|
|
|
];
|
|
|
|
|
|
2026-04-29 14:02:42 +03:30
|
|
|
function Sidebar() {
|
2026-04-23 15:33:11 +03:30
|
|
|
const pathname = usePathname();
|
2026-04-30 00:52:05 +03:30
|
|
|
const { currentOrganization } = useAuth();
|
|
|
|
|
|
|
|
|
|
const visibleMenu = useMemo(
|
|
|
|
|
() => menu.filter((item) => canViewTab(currentOrganization, item.read)),
|
|
|
|
|
[currentOrganization],
|
|
|
|
|
);
|
2026-04-23 15:33:11 +03:30
|
|
|
|
|
|
|
|
return (
|
2026-04-29 21:55:46 +03:30
|
|
|
<aside className="w-64 bg-background-secondary/90 border-r border-border text-text-primary flex flex-col">
|
|
|
|
|
<div className="h-[71px] px-4 flex items-center">
|
|
|
|
|
<h1 className="text-lg font-medium tracking-tight">DyoLink</h1>
|
2026-04-23 15:33:11 +03:30
|
|
|
</div>
|
2026-04-29 21:55:46 +03:30
|
|
|
<div className="mx-4 border-b border-border/70" />
|
2026-04-23 15:33:11 +03:30
|
|
|
|
2026-04-29 21:55:46 +03:30
|
|
|
<nav className="flex flex-col gap-2 p-4">
|
2026-04-30 00:52:05 +03:30
|
|
|
{visibleMenu.map((item) => {
|
2026-04-23 15:33:11 +03:30
|
|
|
const Icon = item.icon;
|
|
|
|
|
const isActive = pathname === item.path;
|
|
|
|
|
|
|
|
|
|
return (
|
2026-04-29 14:02:42 +03:30
|
|
|
<Link
|
2026-04-23 15:33:11 +03:30
|
|
|
key={item.name}
|
2026-04-29 14:02:42 +03:30
|
|
|
href={item.path}
|
|
|
|
|
prefetch
|
2026-04-29 01:22:53 +03:30
|
|
|
className={`flex items-center gap-3 px-3 py-2.5 rounded-[var(--radius-sm)] border transition-colors ${
|
2026-04-23 15:33:11 +03:30
|
|
|
isActive
|
2026-04-29 01:22:53 +03:30
|
|
|
? 'bg-primary-soft border-primary/60 text-text-primary'
|
|
|
|
|
: 'border-border/50 text-text-secondary hover:bg-background-card/70 hover:text-text-primary hover:border-border'
|
2026-04-23 15:33:11 +03:30
|
|
|
}`}
|
|
|
|
|
>
|
2026-04-29 01:22:53 +03:30
|
|
|
<Icon className="w-[18px] h-[18px] icon-flat" />
|
|
|
|
|
<span className="text-sm">{item.name}</span>
|
2026-04-29 14:02:42 +03:30
|
|
|
</Link>
|
2026-04-23 15:33:11 +03:30
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</nav>
|
|
|
|
|
</aside>
|
|
|
|
|
);
|
2026-04-29 14:02:42 +03:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default memo(Sidebar);
|