FPSMS-frontend
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

Breadcrumb.tsx 2.0 KiB

il y a 10 mois
il y a 6 mois
il y a 10 mois
il y a 7 mois
il y a 6 mois
il y a 6 mois
il y a 6 mois
il y a 3 semaines
il y a 10 mois
il y a 10 mois
il y a 6 mois
il y a 10 mois
il y a 6 mois
il y a 10 mois
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. "/projects": "Projects",
  11. "/projects/create": "Create Project",
  12. "/tasks": "Task Template",
  13. "/tasks/create": "Create Task Template",
  14. "/settings/qcItem": "Qc Item",
  15. "/settings/qrCodeHandle": "QR Code Handle",
  16. "/settings/rss": "Demand Forecast Setting",
  17. "/scheduling/rough": "Demand Forecast",
  18. "/scheduling/rough/edit": "FG & Material Demand Forecast Detail",
  19. "/scheduling/detailed": "Detail Scheduling",
  20. "/scheduling/detailed/edit": "FG Production Schedule",
  21. "/inventory": "Inventory",
  22. "/settings/importTesting": "Import Testing",
  23. "/do": "Delivery Order",
  24. "/pickOrder": "Pick Order",
  25. "/po": "Purchase Order",
  26. "/dashboard": "dashboard",
  27. "/jo": "Job Order",
  28. "/jo/edit": "Edit Job Order",
  29. "/putAway": "Put Away",
  30. "/stockIssue": "Stock Issue",
  31. };
  32. const Breadcrumb = () => {
  33. const pathname = usePathname();
  34. const segments = pathname.split("/");
  35. const { t } = useTranslation("common");
  36. return (
  37. <Breadcrumbs>
  38. {segments.map((segment, index) => {
  39. const href = segments.slice(0, index + 1).join("/");
  40. const label = pathToLabelMap[href] || segment;
  41. if (index === segments.length - 1) {
  42. return (
  43. <Typography key={index} color="text.primary">
  44. {t(label)}
  45. </Typography>
  46. );
  47. } else {
  48. return (
  49. <MUILink
  50. underline="hover"
  51. color="inherit"
  52. key={index}
  53. component={Link}
  54. href={href || "/"}
  55. >
  56. {t(label)}
  57. </MUILink>
  58. );
  59. }
  60. })}
  61. </Breadcrumbs>
  62. );
  63. };
  64. export default Breadcrumb;