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.
 
 
 

61 lines
1.6 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. const pathToLabelMap: { [path: string]: string } = {
  8. "": "Overview",
  9. "/projects": "Projects",
  10. "/projects/create": "Create Project",
  11. "/tasks": "Task Template",
  12. "/tasks/create": "Create Task Template",
  13. "/settings/qcItem": "Qc Item",
  14. "/settings/rss": "Demand Forecast Setting",
  15. "/scheduling/rough": "Demand Forecast",
  16. "/scheduling/rough/edit": "FG & Material Demand Forecast Detail",
  17. "/scheduling/detail": "Detail Scheduling",
  18. "/scheduling/detail/edit": "FG Production Schedule",
  19. "/inventory": "Inventory",
  20. "/settings/importTesting": "Import Testing",
  21. "/do": "Delivery Order",
  22. };
  23. const Breadcrumb = () => {
  24. const pathname = usePathname();
  25. const segments = pathname.split("/");
  26. return (
  27. <Breadcrumbs>
  28. {segments.map((segment, index) => {
  29. const href = segments.slice(0, index + 1).join("/");
  30. const label = pathToLabelMap[href] || segment;
  31. if (index === segments.length - 1) {
  32. return (
  33. <Typography key={index} color="text.primary">
  34. {label}
  35. </Typography>
  36. );
  37. } else {
  38. return (
  39. <MUILink
  40. underline="hover"
  41. color="inherit"
  42. key={index}
  43. component={Link}
  44. href={href || "/"}
  45. >
  46. {label}
  47. </MUILink>
  48. );
  49. }
  50. })}
  51. </Breadcrumbs>
  52. );
  53. };
  54. export default Breadcrumb;