import { ActionIcon, Group, Stack, Text, Title } from "@mantine/core"; import { ArrowLeft } from "lucide-react"; import type { ReactNode } from "react"; import { useNavigate } from "react-router-dom"; import Breadcrumbs, { type BreadcrumbItem } from "@/components/ui/Breadcrumbs"; export interface PageHeaderProps { title: string; subtitle?: ReactNode; /** Breadcrumb trail — pass only on nested pages (details, sub-resources). */ breadcrumbs?: BreadcrumbItem[]; /** Route to return to; renders a back arrow before the title. */ backTo?: string; /** Inline content beside the title (e.g. status badges). */ meta?: ReactNode; /** Right-aligned actions — the primary CTA lives here. */ action?: ReactNode; } /** * Unified page header: optional breadcrumbs, a title (with optional back arrow * and inline meta), a subtitle, and a right-aligned action slot. Keeps title / * action placement and spacing identical across every dashboard page. */ export function PageHeader({ title, subtitle, breadcrumbs, backTo, meta, action, }: PageHeaderProps) { const navigate = useNavigate(); return ( {breadcrumbs?.length ? : null} {backTo ? ( navigate(backTo)} aria-label="Go back" > ) : null}
{title} {meta} {subtitle ? ( typeof subtitle === "string" ? ( {subtitle} ) : ( // A component subtitle handles its own layout — truncating it // to one line would defeat e.g. an expandable description.
{subtitle}
) ) : null}
{action ? ( {action} ) : null}
); } export default PageHeader;