78 lines
3.1 KiB
TypeScript
78 lines
3.1 KiB
TypeScript
// * Packages
|
|
import { Head, Link, usePage } from "@inertiajs/react";
|
|
import { ArrowLeft, Plus } from "lucide-react";
|
|
// * Components shadcn
|
|
import { Breadcrumb, BreadcrumbItem, BreadcrumbList, BreadcrumbSeparator } from "@/components/ui/breadcrumb";
|
|
import { Button } from "@/components/ui/button";
|
|
// * Other
|
|
import CustomSidebarTrigger from "@/back/Components/CustomSidebarTrigger";
|
|
|
|
export function AppHeader({
|
|
title,
|
|
linkBefore,
|
|
linkAfter,
|
|
}: {
|
|
title: string;
|
|
linkBefore?: string;
|
|
linkAfter?: string;
|
|
}) {
|
|
const breadcrumbs = usePage().props.breacrumbs as Array<{
|
|
title: string;
|
|
url: string;
|
|
}>;
|
|
return (
|
|
<header className="relative">
|
|
<div className="breadcrumbs fixed top-0 left-[calc(var(--sidebar-width)+2rem)] transition-\[width\] duration-200 ease-linear w-[calc(100%-var(--sidebar-width)-4rem)] bg-white flex justify-start items-center border-b py-3 z-10">
|
|
<CustomSidebarTrigger />
|
|
<Breadcrumb className="border-s ms-1 px-4">
|
|
<BreadcrumbList>
|
|
{breadcrumbs.map((breadcrumb, index) => (
|
|
<>
|
|
{index >= 1 && <BreadcrumbSeparator />}
|
|
<BreadcrumbItem>
|
|
{index !== breadcrumbs.length - 1 ? (
|
|
<Link
|
|
href={breadcrumb.url}
|
|
className="rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"
|
|
>
|
|
{breadcrumb.title}
|
|
</Link>
|
|
) : (
|
|
breadcrumb.title
|
|
)}
|
|
</BreadcrumbItem>
|
|
</>
|
|
))}
|
|
</BreadcrumbList>
|
|
</Breadcrumb>
|
|
</div>
|
|
<Head title={title} />
|
|
<div className="flex justify-between items-center mt-[48px] py-4">
|
|
<div className="flex justify-start items-center">
|
|
{linkBefore && (
|
|
<Link href={linkBefore}>
|
|
<Button size="icon">
|
|
<ArrowLeft />
|
|
</Button>
|
|
</Link>
|
|
)}
|
|
<h1
|
|
className={
|
|
"scroll-m-20 text-4xl font-extrabold tracking-tight lg:text-5xl" +
|
|
(linkBefore ? " ms-2" : "")
|
|
}
|
|
>
|
|
{title}
|
|
</h1>
|
|
</div>
|
|
{linkAfter && (
|
|
<Button size="icon" asChild>
|
|
<Link href={linkAfter}>
|
|
<Plus />
|
|
</Link>
|
|
</Button>
|
|
)}
|
|
</div>
|
|
</header>
|
|
);
|
|
}
|