FPSMS-frontend
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 

78 rader
2.3 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. "/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. "/settings/equipment": "Equipment",
  18. "/settings/equipment/MaintenanceEdit": "MaintenanceEdit",
  19. "/settings/shop": "ShopAndTruck",
  20. "/settings/shop/detail": "Shop Detail",
  21. "/settings/shop/truckdetail": "Truck Lane Detail",
  22. "/settings/printer": "Printer",
  23. "/scheduling/rough": "Demand Forecast",
  24. "/scheduling/rough/edit": "FG & Material Demand Forecast Detail",
  25. "/scheduling/detailed": "Detail Scheduling",
  26. "/scheduling/detailed/edit": "FG Production Schedule",
  27. "/inventory": "Inventory",
  28. "/settings/importTesting": "Import Testing",
  29. "/do": "Delivery Order",
  30. "/pickOrder": "Pick Order",
  31. "/po": "Purchase Order",
  32. "/dashboard": "dashboard",
  33. "/jo": "Job Order",
  34. "/jo/edit": "Edit Job Order",
  35. "/putAway": "Put Away",
  36. "/stockIssue": "Stock Issue",
  37. "/report": "Report",
  38. };
  39. const Breadcrumb = () => {
  40. const pathname = usePathname();
  41. const segments = pathname.split("/");
  42. const { t } = useTranslation("common");
  43. return (
  44. <Breadcrumbs>
  45. {segments.map((segment, index) => {
  46. const href = segments.slice(0, index + 1).join("/");
  47. const label = pathToLabelMap[href] || segment;
  48. if (index === segments.length - 1) {
  49. return (
  50. <Typography key={index} color="text.primary">
  51. {t(label)}
  52. </Typography>
  53. );
  54. } else {
  55. return (
  56. <MUILink
  57. underline="hover"
  58. color="inherit"
  59. key={index}
  60. component={Link}
  61. href={href || "/"}
  62. >
  63. {t(label)}
  64. </MUILink>
  65. );
  66. }
  67. })}
  68. </Breadcrumbs>
  69. );
  70. };
  71. export default Breadcrumb;