FPSMS-frontend
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

86 regels
2.5 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. "": "總覽",
  10. "/chart": "圖表報告",
  11. "/chart/warehouse": "庫存與倉儲",
  12. "/chart/purchase": "採購",
  13. "/chart/delivery": "發貨與配送",
  14. "/chart/joborder": "工單",
  15. "/chart/forecast": "預測與計劃",
  16. "/projects": "Projects",
  17. "/projects/create": "Create Project",
  18. "/tasks": "Task Template",
  19. "/tasks/create": "Create Task Template",
  20. "/settings/qcItem": "Qc Item",
  21. "/settings/qcItemAll": "QC Item All",
  22. "/settings/qrCodeHandle": "QR Code Handle",
  23. "/settings/rss": "Demand Forecast Setting",
  24. "/settings/equipment": "Equipment",
  25. "/settings/equipment/MaintenanceEdit": "MaintenanceEdit",
  26. "/settings/shop": "ShopAndTruck",
  27. "/settings/shop/detail": "Shop Detail",
  28. "/settings/shop/truckdetail": "Truck Lane Detail",
  29. "/settings/printer": "Printer",
  30. "/scheduling/rough": "Demand Forecast",
  31. "/scheduling/rough/edit": "FG & Material Demand Forecast Detail",
  32. "/scheduling/detailed": "Detail Scheduling",
  33. "/scheduling/detailed/edit": "FG Production Schedule",
  34. "/inventory": "Inventory",
  35. "/settings/importTesting": "Import Testing",
  36. "/do": "Delivery Order",
  37. "/pickOrder": "Pick Order",
  38. "/po": "Purchase Order",
  39. "/dashboard": "dashboard",
  40. "/jo": "Job Order",
  41. "/jo/edit": "Edit Job Order",
  42. "/putAway": "Put Away",
  43. "/stockIssue": "Stock Issue",
  44. "/report": "Report",
  45. "/bagPrint": "打袋機",
  46. };
  47. const Breadcrumb = () => {
  48. const pathname = usePathname();
  49. const segments = pathname.split("/");
  50. const { t } = useTranslation("common");
  51. return (
  52. <Breadcrumbs>
  53. {segments.map((segment, index) => {
  54. const href = segments.slice(0, index + 1).join("/");
  55. const label = pathToLabelMap[href] || segment;
  56. if (index === segments.length - 1) {
  57. return (
  58. <Typography key={index} color="text.primary">
  59. {t(label)}
  60. </Typography>
  61. );
  62. } else {
  63. return (
  64. <MUILink
  65. underline="hover"
  66. color="inherit"
  67. key={index}
  68. component={Link}
  69. href={href || "/"}
  70. >
  71. {t(label)}
  72. </MUILink>
  73. );
  74. }
  75. })}
  76. </Breadcrumbs>
  77. );
  78. };
  79. export default Breadcrumb;