Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 

66 righe
1.7 KiB

  1. "use client";
  2. import Breadcrumbs from "@mui/material/Breadcrumbs";
  3. import Typography from "@mui/material/Typography";
  4. import Link from "next/link";
  5. import MUILink from "@mui/material/Link";
  6. import { usePathname } from "next/navigation";
  7. import { useTranslation } from "react-i18next";
  8. const pathToLabelMap: { [path: string]: string } = {
  9. "": "Overview",
  10. "/home": "User Workspace",
  11. "/projects": "Projects",
  12. "/projects/create": "Create Project",
  13. "/tasks": "Task Template",
  14. "/tasks/create": "Create Task Template",
  15. "/customer": "Customer",
  16. "/customer/create": "Create Customer",
  17. "/settings": "Settings",
  18. "/company": "Company",
  19. "/settings/department": "Department",
  20. "/settings/department/new": "Create Department",
  21. "/settings/position": "Position",
  22. "/settings/position/new": "Create Position",
  23. "/settings/salarys": "Salary",
  24. };
  25. const Breadcrumb = () => {
  26. const pathname = usePathname();
  27. const segments = pathname.split("/");
  28. // const { t } = useTranslation("customer");
  29. return (
  30. <Breadcrumbs>
  31. {segments.map((segment, index) => {
  32. const href = segments.slice(0, index + 1).join("/");
  33. const label = pathToLabelMap[href] || segment;
  34. if (index === segments.length - 1) {
  35. return (
  36. <Typography key={index} color="text.primary">
  37. {label}
  38. {/* {t(label)} */}
  39. </Typography>
  40. );
  41. } else {
  42. return (
  43. <MUILink
  44. underline="hover"
  45. color="inherit"
  46. key={index}
  47. component={Link}
  48. href={href || "/"}
  49. >
  50. {label}
  51. </MUILink>
  52. );
  53. }
  54. })}
  55. </Breadcrumbs>
  56. );
  57. };
  58. export default Breadcrumb;