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.
 
 

92 line
2.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. import Clock from "./Clock";
  9. import { Box, Grid } from "@mui/material";
  10. import { I18nProvider } from "@/i18n";
  11. const pathToLabelMap: { [path: string]: string } = {
  12. "": "Overview",
  13. "/home": "User Workspace",
  14. "/projects": "Projects",
  15. "/projects/create": "Create Project",
  16. "/projects/create/sub": "Sub Project",
  17. "/projects/edit": "Edit Project",
  18. "/projects/edit/sub": "Sub Project",
  19. "/tasks": "Task Template",
  20. "/tasks/create": "Create Task Template",
  21. "/staffReimbursement": "Staff Reimbursement",
  22. "/settings/customer": "Client",
  23. "/settings/customer/create": "Create Client",
  24. "/settings/customer/edit": "Edit Client",
  25. "/settings/subsidiary": "Subsidiary",
  26. "/settings/subsidiary/create": "Create Subsidiary",
  27. "/settings/subsidiary/edit": "Edit Subsidiary",
  28. "/settings": "Settings",
  29. "/company": "Company",
  30. "/settings/department": "Department",
  31. "/settings/department/new": "Create Department",
  32. "/settings/department/edit": "Edit Department",
  33. "/settings/position": "Position",
  34. "/settings/position/edit": "Edit Position",
  35. "/settings/position/new": "Create Position",
  36. "/settings/company/edit": "Edit Company",
  37. "/settings/company/create": "Create Company",
  38. "/settings/salarys": "Salary",
  39. "/analytics/ProjectCashFlowReport": "Project Cash Flow Report",
  40. "/settings/holiday": "Holiday",
  41. };
  42. const Breadcrumb = () => {
  43. const pathname = usePathname();
  44. const segments = pathname.split("/");
  45. // const { t } = useTranslation("customer");
  46. return (
  47. <Box
  48. display="flex"
  49. flexDirection={{ xs: "column-reverse", sm: "row"}}
  50. justifyContent={{ sm: "space-between" }}
  51. >
  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. {label}
  60. {/* {t(label)} */}
  61. </Typography>
  62. );
  63. } else {
  64. return (
  65. <MUILink
  66. underline="hover"
  67. color="inherit"
  68. key={index}
  69. component={Link}
  70. href={href || "/"}
  71. >
  72. {label}
  73. </MUILink>
  74. );
  75. }
  76. })}
  77. </Breadcrumbs>
  78. <Box width={{ xs: "100%", sm: "auto" }} marginBlockEnd={{ xs: 1, sm: 0 }}>
  79. <Clock variant="body2" />
  80. </Box>
  81. </Box>
  82. );
  83. };
  84. export default Breadcrumb;