90 lines
2.9 KiB
TypeScript
90 lines
2.9 KiB
TypeScript
import { profileLinks } from '@/components/profile-navigation';
|
|
import type { ProfileAccess } from '@/types/profile-access';
|
|
import { Link, usePage } from '@inertiajs/react';
|
|
import { LayoutGrid } from 'lucide-react';
|
|
import { portalNavigation } from '@/lib/portal-navigation';
|
|
import AppLogo from '@/components/app-logo';
|
|
import { NavMain } from '@/components/nav-main';
|
|
import { NavUser } from '@/components/nav-user';
|
|
import {
|
|
Sidebar,
|
|
SidebarContent,
|
|
SidebarFooter,
|
|
SidebarHeader,
|
|
SidebarMenu,
|
|
SidebarMenuButton,
|
|
SidebarMenuItem,
|
|
} from '@/components/ui/sidebar';
|
|
import { dashboard } from '@/routes';
|
|
import type { Auth } from '@/types';
|
|
import type { OpportunityManagementAccess } from '@/types/opportunity-management';
|
|
|
|
export function AppSidebar() {
|
|
const {
|
|
auth,
|
|
existingBusinessEnabled,
|
|
educationEnabled,
|
|
aiEnabled,
|
|
opportunityManagement,
|
|
profileAccess,
|
|
} = usePage<{
|
|
auth: Auth;
|
|
existingBusinessEnabled?: boolean;
|
|
educationEnabled?: boolean;
|
|
aiEnabled?: boolean;
|
|
profileAccess?: ProfileAccess | null;
|
|
opportunityManagement?: OpportunityManagementAccess | null;
|
|
}>().props;
|
|
const groups = portalNavigation({
|
|
authenticated: !!auth.user,
|
|
manager: auth.canManagePortal,
|
|
businesses: existingBusinessEnabled,
|
|
education: educationEnabled,
|
|
ai: aiEnabled,
|
|
opportunityManagement,
|
|
});
|
|
const items = groups.map((group) => ({
|
|
title: group.label,
|
|
href: group.children?.find((item) => item.href)?.href ?? '/',
|
|
icon: LayoutGrid,
|
|
}));
|
|
if (auth.canManagePortal && opportunityManagement) {
|
|
items.push({
|
|
title: opportunityManagement.manage.label,
|
|
href: opportunityManagement.manage.href,
|
|
icon: LayoutGrid,
|
|
});
|
|
if (opportunityManagement.installed) {
|
|
items.push({
|
|
title: opportunityManagement.create.label,
|
|
href: opportunityManagement.create.href,
|
|
icon: LayoutGrid,
|
|
});
|
|
}
|
|
}
|
|
items.push(...profileLinks(profileAccess).map(link => ({...link, icon: LayoutGrid})));
|
|
return (
|
|
<Sidebar collapsible="icon" variant="inset">
|
|
<SidebarHeader>
|
|
<SidebarMenu>
|
|
<SidebarMenuItem>
|
|
<SidebarMenuButton size="lg" asChild>
|
|
<Link href={dashboard()} prefetch>
|
|
<AppLogo />
|
|
</Link>
|
|
</SidebarMenuButton>
|
|
</SidebarMenuItem>
|
|
</SidebarMenu>
|
|
</SidebarHeader>
|
|
|
|
<SidebarContent>
|
|
<NavMain items={items} />
|
|
</SidebarContent>
|
|
|
|
<SidebarFooter>
|
|
<NavUser />
|
|
</SidebarFooter>
|
|
</Sidebar>
|
|
);
|
|
}
|