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.
 
 

66 lines
1.8 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/rss": "Demand Forecast Setting",
  16. "/scheduling/rough": "Demand Forecast",
  17. "/scheduling/rough/edit": "FG & Material Demand Forecast Detail",
  18. "/scheduling/detail": "Detail Scheduling",
  19. "/scheduling/detail/edit": "FG Production Schedule",
  20. "/inventory": "Inventory",
  21. "/settings/importTesting": "Import Testing",
  22. "/do": "Delivery Order",
  23. "/pickOrder": "Pick Order",
  24. "/po": "Purchase Order",
  25. "/dashboard": "dashboard",
  26. };
  27. const Breadcrumb = () => {
  28. const pathname = usePathname();
  29. const segments = pathname.split("/");
  30. const { t } = useTranslation("common");
  31. return (
  32. <Breadcrumbs>
  33. {segments.map((segment, index) => {
  34. const href = segments.slice(0, index + 1).join("/");
  35. const label = pathToLabelMap[href] || segment;
  36. if (index === segments.length - 1) {
  37. return (
  38. <Typography key={index} color="text.primary">
  39. {t(label)}
  40. </Typography>
  41. );
  42. } else {
  43. return (
  44. <MUILink
  45. underline="hover"
  46. color="inherit"
  47. key={index}
  48. component={Link}
  49. href={href || "/"}
  50. >
  51. {t(label)}
  52. </MUILink>
  53. );
  54. }
  55. })}
  56. </Breadcrumbs>
  57. );
  58. };
  59. export default Breadcrumb;