File tree Expand file tree Collapse file tree 2 files changed +55
-2
lines changed
Expand file tree Collapse file tree 2 files changed +55
-2
lines changed Original file line number Diff line number Diff line change 1+ import AppLogo from '@/components/app-logo' ;
12import { NavAdmin } from '@/components/navigation/nav-admin' ;
23import NavAttendant from '@/components/navigation/nav-attendant' ;
34import { NavDoctor } from '@/components/navigation/nav-doctor' ;
45import { NavFooter } from '@/components/navigation/nav-footer' ;
56import { NavMain } from '@/components/navigation/nav-main' ;
7+ import NavManager from '@/components/navigation/nav-manager' ;
8+ import { NavPatient } from '@/components/navigation/nav-patient' ;
69import { NavUser } from '@/components/navigation/nav-user' ;
710import {
811 Sidebar ,
@@ -17,8 +20,6 @@ import { dashboard } from '@/routes';
1720import { type NavItem } from '@/types' ;
1821import { Link } from '@inertiajs/react' ;
1922import { BriefcaseBusinessIcon , FolderIcon , LayoutGrid } from 'lucide-react' ;
20- import AppLogo from './app-logo' ;
21- import { NavPatient } from './navigation/nav-patient' ;
2223
2324const mainNavItems : NavItem [ ] = [
2425 {
@@ -61,6 +62,7 @@ export function AppSidebar() {
6162 < NavPatient />
6263 < NavAttendant />
6364 < NavDoctor />
65+ < NavManager />
6466 < NavAdmin />
6567 </ SidebarContent >
6668
Original file line number Diff line number Diff line change 1+ import {
2+ SidebarGroup ,
3+ SidebarGroupLabel ,
4+ SidebarMenu ,
5+ SidebarMenuButton ,
6+ SidebarMenuItem ,
7+ } from '@/components/ui/sidebar' ;
8+ import invoices from '@/routes/invoices' ;
9+ import { type NavItem , SharedData } from '@/types' ;
10+ import { Link , usePage } from '@inertiajs/react' ;
11+ import { ScrollTextIcon } from 'lucide-react' ;
12+
13+ export default function NavManager ( ) {
14+ const { props, url } = usePage < SharedData > ( ) ;
15+ const auth = props . auth ;
16+
17+ const isManager = auth . roles . includes ( 'Manager' ) ;
18+ if ( ! isManager || ! auth . user . employee_info_id ) return null ;
19+
20+ const managerItems : NavItem [ ] = [
21+ {
22+ title : 'Invoices' ,
23+ href : invoices . index ( ) . url ,
24+ icon : ScrollTextIcon ,
25+ } ,
26+ ] ;
27+
28+ return (
29+ < SidebarGroup className = "px-2 py-0" >
30+ < SidebarGroupLabel > Manager</ SidebarGroupLabel >
31+ < SidebarMenu >
32+ { managerItems . map ( ( item ) => {
33+ const urlWithoutQuery = url . split ( '?' ) [ 0 ] ;
34+ const endingPath = typeof item . href === 'string' ? item . href : item . href . url ;
35+ const isActive = urlWithoutQuery . endsWith ( endingPath ) ;
36+
37+ return (
38+ < SidebarMenuItem key = { item . title } >
39+ < SidebarMenuButton asChild isActive = { isActive } tooltip = { { children : item . title } } >
40+ < Link href = { item . href } prefetch >
41+ { item . icon && < item . icon /> }
42+ < span > { item . title } </ span >
43+ </ Link >
44+ </ SidebarMenuButton >
45+ </ SidebarMenuItem >
46+ ) ;
47+ } ) }
48+ </ SidebarMenu >
49+ </ SidebarGroup >
50+ ) ;
51+ }
You can’t perform that action at this time.
0 commit comments