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.
 
 

77 rivejä
2.2 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. };
  38. const Breadcrumb = () => {
  39. const pathname = usePathname();
  40. const segments = pathname.split("/");
  41. const { t } = useTranslation("common");
  42. return (
  43. <Breadcrumbs>
  44. {segments.map((segment, index) => {
  45. const href = segments.slice(0, index + 1).join("/");
  46. const label = pathToLabelMap[href] || segment;
  47. if (index === segments.length - 1) {
  48. return (
  49. <Typography key={index} color="text.primary">
  50. {t(label)}
  51. </Typography>
  52. );
  53. } else {
  54. return (
  55. <MUILink
  56. underline="hover"
  57. color="inherit"
  58. key={index}
  59. component={Link}
  60. href={href || "/"}
  61. >
  62. {t(label)}
  63. </MUILink>
  64. );
  65. }
  66. })}
  67. </Breadcrumbs>
  68. );
  69. };
  70. export default Breadcrumb;