"use client"; import { usePathname } from "next/navigation"; import { useEffect, useState } from "react"; import { FormLayoutIcon } from "../icons"; import { BreadcrumbItem, BreadcrumbList } from "../ui/breadcrumb"; export const Breadcrumb = () => { const [, setCurrentPage] = useState(""); const pathname = usePathname(); const pathnameSplit = pathname.split("/"); pathnameSplit.shift(); const pathnameTransformed = pathnameSplit.map((item) => { const words = item.split("-"); const capitalizedWords = words.map( (word) => word.charAt(0).toUpperCase() + word?.slice(1) ); return capitalizedWords.join(" "); }); console.log("pathname : ", pathnameTransformed); useEffect(() => { setCurrentPage(pathnameSplit[pathnameSplit.length - 1]); }, [pathnameSplit]); return ( <>

{pathnameTransformed[pathnameTransformed.length - 1]}

{pathnameTransformed?.map((item, index) => ( {item} ))}
); };