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.
 
 

186 line
6.2 KiB

  1. import Divider from "@mui/material/Divider";
  2. import Box from "@mui/material/Box";
  3. import React from "react";
  4. import List from "@mui/material/List";
  5. import ListItemButton from "@mui/material/ListItemButton";
  6. import ListItemText from "@mui/material/ListItemText";
  7. import ListItemIcon from "@mui/material/ListItemIcon";
  8. import WorkHistory from "@mui/icons-material/WorkHistory";
  9. import Dashboard from "@mui/icons-material/Dashboard";
  10. import SummarizeIcon from "@mui/icons-material/Summarize";
  11. import PaymentsIcon from "@mui/icons-material/Payments";
  12. import AccountTreeIcon from "@mui/icons-material/AccountTree";
  13. import RequestQuote from "@mui/icons-material/RequestQuote";
  14. import PeopleIcon from "@mui/icons-material/People";
  15. import Task from "@mui/icons-material/Task";
  16. import Assignment from "@mui/icons-material/Assignment";
  17. import Settings from "@mui/icons-material/Settings";
  18. import Analytics from "@mui/icons-material/Analytics";
  19. import Payments from "@mui/icons-material/Payments";
  20. import Staff from "@mui/icons-material/PeopleAlt";
  21. import Company from '@mui/icons-material/Store';
  22. import Department from '@mui/icons-material/Diversity3';
  23. import Position from '@mui/icons-material/Paragliding';
  24. import Salary from '@mui/icons-material/AttachMoney';
  25. import { useTranslation } from "react-i18next";
  26. import Typography from "@mui/material/Typography";
  27. import { usePathname } from "next/navigation";
  28. import Link from "next/link";
  29. import { NAVIGATION_CONTENT_WIDTH } from "@/config/uiConfig";
  30. import Logo from "../Logo";
  31. import GroupIcon from '@mui/icons-material/Group';
  32. import BusinessIcon from '@mui/icons-material/Business';
  33. interface NavigationItem {
  34. icon: React.ReactNode;
  35. label: string;
  36. path: string;
  37. children?: NavigationItem[];
  38. }
  39. const navigationItems: NavigationItem[] = [
  40. { icon: <WorkHistory />, label: "User Workspace", path: "/home" },
  41. {
  42. icon: <Dashboard />,
  43. label: "Dashboard",
  44. path: "",
  45. children: [
  46. {
  47. icon: <SummarizeIcon />,
  48. label: "Project Financial Summary",
  49. path: "/dashboard/ProjectFinancialSummary",
  50. },
  51. {
  52. icon: <PaymentsIcon />,
  53. label: "Company / Team Cash Flow",
  54. path: "/dashboard/CompanyTeamCashFlow",
  55. },
  56. {
  57. icon: <PaymentsIcon />,
  58. label: "Project Cash Flow",
  59. path: "/dashboard/ProjectCashFlow",
  60. },
  61. {
  62. icon: <AccountTreeIcon />,
  63. label: "Project Status by Client",
  64. path: "/dashboard/ProjectStatusByClient",
  65. },
  66. {
  67. icon: <AccountTreeIcon />,
  68. label: "Project Status by Team",
  69. path: "/dashboard/ProjectStatusByTeam",
  70. },
  71. {
  72. icon: <PeopleIcon />,
  73. label: "Staff Utilization",
  74. path: "/dashboard/StaffUtilization",
  75. },
  76. ],
  77. },
  78. {
  79. icon: <RequestQuote />,
  80. label: "Staff Reimbursement",
  81. path: "/staffReimbursement",
  82. children: [
  83. {
  84. icon: <RequestQuote />,
  85. label: "ClaimApproval",
  86. path: "/staffReimbursement/ClaimApproval",
  87. },
  88. {
  89. icon: <RequestQuote />,
  90. label: "ClaimSummary",
  91. path: "/staffReimbursement/ClaimSummary",
  92. },
  93. ],
  94. },
  95. { icon: <Assignment />, label: "Project Management", path: "/projects" },
  96. { icon: <Task />, label: "Task Template", path: "/tasks" },
  97. { icon: <Payments />, label: "Invoice", path: "/invoice" },
  98. { icon: <Analytics />, label: "Analysis Report", path: "/analytics" },
  99. {
  100. icon: <Settings />, label: "Setting", path: "",
  101. children: [
  102. { icon: <GroupIcon />, label: "Client", path: "/settings/customer" },
  103. { icon: <BusinessIcon />, label: "Subsidiary", path: "/settings/subsidiary" },
  104. { icon: <Staff />, label: "Staff", path: "/settings/staff" },
  105. { icon: <Company />, label: "Company", path: "/settings/company" },
  106. { icon: <Department />, label: "Department", path: "/settings/department" },
  107. { icon: <Position />, label: "Position", path: "/settings/position" },
  108. { icon: <Salary />, label: "Salary", path: "/settings/salary" },
  109. ],
  110. },
  111. ];
  112. const NavigationContent: React.FC = () => {
  113. const { t } = useTranslation("common");
  114. const pathname = usePathname();
  115. const [openItems, setOpenItems] = React.useState<string[]>([]);
  116. const toggleItem = (label: string) => {
  117. setOpenItems((prevOpenItems) =>
  118. prevOpenItems.includes(label)
  119. ? prevOpenItems.filter((item) => item !== label)
  120. : [...prevOpenItems, label],
  121. );
  122. };
  123. const renderNavigationItem = (item: NavigationItem) => {
  124. const isOpen = openItems.includes(item.label);
  125. return (
  126. <Box
  127. key={`${item.label}-${item.path}`}
  128. component={Link}
  129. href={item.path}
  130. sx={{ textDecoration: "none", color: "inherit" }}
  131. >
  132. <ListItemButton
  133. selected={pathname.includes(item.label)}
  134. onClick={() => item.children && toggleItem(item.label)}
  135. >
  136. <ListItemIcon>{item.icon}</ListItemIcon>
  137. <ListItemText primary={t(item.label)} />
  138. </ListItemButton>
  139. {item.children && isOpen && (
  140. <List sx={{ pl: 2 }}>
  141. {item.children.map((child) => renderNavigationItem(child))}
  142. </List>
  143. )}
  144. </Box>
  145. );
  146. };
  147. return (
  148. <Box sx={{ width: NAVIGATION_CONTENT_WIDTH }}>
  149. <Box sx={{ p: 3, display: "flex" }}>
  150. <Logo height={60} />
  151. {/* <button className="float-right bg-transparent border-transparent" >
  152. <ArrowCircleLeftRoundedIcon className="text-slate-400 hover:text-blue-400 hover:cursor-pointer " style={{ fontSize: '35px' }} />
  153. </button> */}
  154. </Box>
  155. <Divider />
  156. <List component="nav">
  157. {navigationItems.map((item) => renderNavigationItem(item))}
  158. {/* {navigationItems.map(({ icon, label, path }, index) => {
  159. return (
  160. <Box
  161. key={`${label}-${index}`}
  162. component={Link}
  163. href={path}
  164. sx={{ textDecoration: "none", color: "inherit" }}
  165. >
  166. <ListItemButton selected={pathname.includes(path)}>
  167. <ListItemIcon>{icon}</ListItemIcon>
  168. <ListItemText primary={t(label)} />
  169. </ListItemButton>
  170. </Box>
  171. );
  172. })} */}
  173. </List>
  174. </Box>
  175. );
  176. };
  177. export default NavigationContent;