mirror of
https://github.com/nicotsx/zerobyte.git
synced 2026-04-18 22:09:30 -04:00
* refactor: move to tanstack start * refactor: auth flow & volumes * refactor: repo & snapshot details * refactor: backups, create repo, volumes * refactor: create volume & restore snapshot * refactor: notifications * refactor: settings * refactor: breadcrumbs * fix: ts issues * refactor: prod deployment * fix: import css production * refactor: nitro build * refactor: winston -> consola * fix: memory leak is sse events cleanup * fix: cli usage * chore: remove rr routes file * refactor: pr feedbacks * refactor: patch api client to have a global client per call * refactor: pr feedbacks * fix(dockerfile): add explicit port * fix(e2e): healthcheck under /api
62 lines
1.6 KiB
TypeScript
62 lines
1.6 KiB
TypeScript
import { useMatches, Link } from "@tanstack/react-router";
|
|
import {
|
|
Breadcrumb,
|
|
BreadcrumbItem,
|
|
BreadcrumbLink,
|
|
BreadcrumbList,
|
|
BreadcrumbPage,
|
|
BreadcrumbSeparator,
|
|
} from "~/client/components/ui/breadcrumb";
|
|
|
|
export interface BreadcrumbItemData {
|
|
label: string;
|
|
href?: string;
|
|
}
|
|
|
|
type BreadcrumbFunction = (match: ReturnType<typeof useMatches>[number]) => BreadcrumbItemData[] | null;
|
|
|
|
export function AppBreadcrumb() {
|
|
const matches = useMatches();
|
|
|
|
const lastMatchWithBreadcrumb = [...matches].reverse().find((match) => {
|
|
const breadcrumbFn = match.staticData?.breadcrumb as BreadcrumbFunction | undefined;
|
|
return breadcrumbFn;
|
|
});
|
|
|
|
if (!lastMatchWithBreadcrumb) {
|
|
return null;
|
|
}
|
|
|
|
const breadcrumbFn = lastMatchWithBreadcrumb.staticData?.breadcrumb as BreadcrumbFunction;
|
|
const breadcrumbs = breadcrumbFn?.(lastMatchWithBreadcrumb);
|
|
|
|
if (!breadcrumbs || breadcrumbs.length === 0) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<Breadcrumb className="min-w-0">
|
|
<BreadcrumbList>
|
|
{breadcrumbs.map((breadcrumb, index) => {
|
|
const isLast = index === breadcrumbs.length - 1;
|
|
|
|
return (
|
|
<div key={`${breadcrumb.label}-${index}`} className="contents">
|
|
<BreadcrumbItem>
|
|
{isLast || !breadcrumb.href ? (
|
|
<BreadcrumbPage>{breadcrumb.label}</BreadcrumbPage>
|
|
) : (
|
|
<BreadcrumbLink asChild>
|
|
<Link to={breadcrumb.href}>{breadcrumb.label}</Link>
|
|
</BreadcrumbLink>
|
|
)}
|
|
</BreadcrumbItem>
|
|
{!isLast && <BreadcrumbSeparator />}
|
|
</div>
|
|
);
|
|
})}
|
|
</BreadcrumbList>
|
|
</Breadcrumb>
|
|
);
|
|
}
|