FPSMS-frontend
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

68 lines
1.9 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/detailed": "Detail Scheduling",
  19. "/scheduling/detailed/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. "/jo": "Job Order",
  27. "/jo/edit": "Edit Job Order",
  28. };
  29. const Breadcrumb = () => {
  30. const pathname = usePathname();
  31. const segments = pathname.split("/");
  32. const { t } = useTranslation("common");
  33. return (
  34. <Breadcrumbs>
  35. {segments.map((segment, index) => {
  36. const href = segments.slice(0, index + 1).join("/");
  37. const label = pathToLabelMap[href] || segment;
  38. if (index === segments.length - 1) {
  39. return (
  40. <Typography key={index} color="text.primary">
  41. {t(label)}
  42. </Typography>
  43. );
  44. } else {
  45. return (
  46. <MUILink
  47. underline="hover"
  48. color="inherit"
  49. key={index}
  50. component={Link}
  51. href={href || "/"}
  52. >
  53. {t(label)}
  54. </MUILink>
  55. );
  56. }
  57. })}
  58. </Breadcrumbs>
  59. );
  60. };
  61. export default Breadcrumb;