import { useLocal } from "@/utils/use-local"; import { FC, ReactNode, useEffect } from "react"; import { Skeleton } from "../ui/skeleton"; type BreadcrumbProps = { on_load: () => Promise; props: any; }; export const Breadcrumb: FC = (_arg) => { const { on_load } = _arg; const local = useLocal({ list: [] as { label: string; url: string }[], status: "init" as "init" | "loading" | "ready", params: {}, }); useEffect(() => { (async () => { if (local.status === "init") { local.status = "loading"; local.render(); local.list = await on_load(); local.status = "ready"; local.render(); } })(); }, [on_load]); return (
{local.status !== "ready" ? ( ) : ( <> {local.list === null ? ( <>

Dummy

) : ( (local.list || []).map((item, index): ReactNode => { const lastIndex = local.list.length - 1; return ( <> {index === lastIndex ? (

{item?.label}

) : (

{ navigate(item?.url); }} > {item?.label}

)} {index !== lastIndex && (
)} ); }) )} )}
); };