Files
Investidor-V2/resources/js/components/app-sidebar.tsx
T

82 lines
2.8 KiB
TypeScript

import {PortalSidebarNavigation} from '@/components/portal-sidebar-navigation';
import type { ProfileAccess } from '@/types/profile-access';
import { Link, usePage } from '@inertiajs/react';
import { portalNavigation,canShowLegacyManagement } from '@/lib/portal-navigation';
import AppLogo from '@/components/app-logo';
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 currentPage=usePage();
const {
auth,
existingBusinessEnabled,
educationEnabled,
aiEnabled,
opportunityManagement,
contentManagementHref,
contentManagementAccess,
profileAccess,
scopedAdministration,
} = usePage<{
auth: Auth;
existingBusinessEnabled?: boolean;
educationEnabled?: boolean;
aiEnabled?: boolean;
profileAccess?: ProfileAccess | null;
opportunityManagement?: OpportunityManagementAccess | null;
contentManagementHref?: string | null;
scopedAdministration?: {label:string;href:string}[];
contentManagementAccess?: {opportunities?:{index:string;create?:string|null}};
}>().props;
const groups = portalNavigation({
authenticated: !!auth.user,
manager: canShowLegacyManagement(auth),
businesses: existingBusinessEnabled,
education: educationEnabled,
ai: aiEnabled,
opportunityManagement,
profileAccess,
contentManagementHref,
contentManagementAccess,
scopedAdministration,
legacyContent: currentPage.props.legacyContentEnabled as boolean|undefined,
procurement: currentPage.props.procurementEnabled as boolean|undefined,
businessReviewUrl: currentPage.props.businessReviewUrl as string|null|undefined,
});
return (
<Sidebar collapsible="offcanvas" variant="inset">
<SidebarHeader>
<SidebarMenu>
<SidebarMenuItem>
<SidebarMenuButton size="lg" asChild>
<Link href={dashboard()} prefetch>
<AppLogo />
</Link>
</SidebarMenuButton>
</SidebarMenuItem>
</SidebarMenu>
</SidebarHeader>
<SidebarContent>
<PortalSidebarNavigation groups={groups} url={currentPage.url}/>
</SidebarContent>
<SidebarFooter>
<NavUser />
</SidebarFooter>
</Sidebar>
);
}