import { createContext, useContext } from "react";

export type BreadcrumbItem = { label: string; to?: string };

type BreadcrumbContextValue = {
  trail: BreadcrumbItem[];
  setTrail: (trail: BreadcrumbItem[]) => void;
};

export const BreadcrumbContext = createContext<BreadcrumbContextValue>({
  trail: [],
  setTrail: () => {},
});

export function useBreadcrumbTrail(): BreadcrumbItem[] {
  return useContext(BreadcrumbContext).trail;
}
