"use client"; import { useEffect, useState } from "react"; import { Button } from "@nextui-org/button"; import { BreadcrumbItem, Breadcrumbs } from "@nextui-org/react"; import { usePathname, useRouter } from "next/navigation"; import { Image } from "@nextui-org/react"; import { FormLayoutIcon } from "../icons"; export const Breadcrumb = () => { const [currentPage, setCurrentPage] = useState(""); const router = useRouter(); const pathname = usePathname(); const pathnameSplit = pathname.split("/"); pathnameSplit.shift(); let pathnameTransformed = pathnameSplit.map((item) => { let words = item.split("-"); let 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]); const handleAction = (key: any) => { const keyIndex = pathnameSplit.indexOf(key); const combinedPath = pathnameSplit.slice(0, keyIndex + 1).join("/"); router.push("/" + combinedPath); }; return (

{pathnameTransformed[pathnameTransformed.length - 1]}

handleAction(key)} > {pathnameTransformed?.map( (item, index) => item !== "Admin" && ( {item} ) )}
); };