Files
GSB-Construction/resources/js/Layouts/AuthenticatedLayout.tsx

53 lines
2.1 KiB
TypeScript

import { SidebarInset, SidebarProvider, SidebarTrigger } from '@/Components/ui/sidebar';
import { Separator } from '@/Components/ui/separator';
import AppSidebar from '@/Components/AppSidebar';
import { usePage } from '@inertiajs/react';
import { PropsWithChildren, ReactNode } from 'react';
import { PageProps } from '@/types';
import { Building2 } from 'lucide-react';
export default function Authenticated({
header,
children,
}: PropsWithChildren<{ header?: ReactNode }>) {
const { auth } = usePage<PageProps>().props;
const isContractorUser = auth.user.contractor_id !== null;
const contractorName = auth.user.contractor?.company_name;
return (
<SidebarProvider>
<AppSidebar />
<SidebarInset>
{/* Contractor Context Banner (Option D) */}
{isContractorUser && contractorName && (
<div className="flex items-center gap-2 border-b border-blue-100 bg-blue-50 px-4 py-1.5">
<Building2 className="h-3.5 w-3.5 shrink-0 text-blue-500" />
<p className="text-xs text-blue-700">
You are managing <span className="font-semibold">{contractorName}</span>.
All users you create will be added to this company.
</p>
</div>
)}
{/* Top header bar */}
<header className="flex h-14 shrink-0 items-center gap-2 border-b bg-background px-4">
<SidebarTrigger className="-ml-1" />
{header && (
<>
<Separator orientation="vertical" className="mr-2 h-4" />
<div className="flex flex-1 items-center justify-between">
{header}
</div>
</>
)}
</header>
{/* Page content */}
<main className="flex-1">
{children}
</main>
</SidebarInset>
</SidebarProvider>
);
}