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.
 
 
 

314 lines
8.0 KiB

  1. import Divider from "@mui/material/Divider";
  2. import Box from "@mui/material/Box";
  3. import React, { useEffect } 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 { useTranslation } from "react-i18next";
  21. import Typography from "@mui/material/Typography";
  22. import { usePathname } from "next/navigation";
  23. import Link from "next/link";
  24. import { NAVIGATION_CONTENT_WIDTH } from "@/config/uiConfig";
  25. import Logo from "../Logo";
  26. interface NavigationItem {
  27. icon: React.ReactNode;
  28. label: string;
  29. path: string;
  30. children?: NavigationItem[];
  31. isHidden?: true | undefined
  32. }
  33. const NavigationContent: React.FC = () => {
  34. // const abilities = window.localStorage.getItem("abilites")
  35. // console.log(abilities)
  36. const navigationItems: NavigationItem[] = [
  37. {
  38. icon: <Dashboard />,
  39. label: "Dashboard",
  40. path: "",
  41. },
  42. {
  43. icon: <RequestQuote />,
  44. label: "Raw Material",
  45. path: "",
  46. children: [
  47. {
  48. icon: <RequestQuote />,
  49. label: "Purchase Order",
  50. path: "",
  51. },
  52. {
  53. icon: <RequestQuote />,
  54. label: "Pick Order",
  55. path: "",
  56. },
  57. {
  58. icon: <RequestQuote />,
  59. label: "Cons. Pick Order",
  60. path: "",
  61. },
  62. {
  63. icon: <RequestQuote />,
  64. label: "Delivery Pick Order",
  65. path: "",
  66. },
  67. {
  68. icon: <RequestQuote />,
  69. label: "Warehouse",
  70. path: "",
  71. },
  72. {
  73. icon: <RequestQuote />,
  74. label: "Location Transfer Order",
  75. path: "",
  76. },
  77. {
  78. icon: <RequestQuote />,
  79. label: "View item In-out And invertory Ledger",
  80. path: "",
  81. },
  82. ],
  83. },
  84. {
  85. icon: <RequestQuote />,
  86. label: "Production",
  87. path: "",
  88. children: [
  89. {
  90. icon: <RequestQuote />,
  91. label: "Job Order",
  92. path: "",
  93. },
  94. {
  95. icon: <RequestQuote />,
  96. label: "Job Order Traceablity ",
  97. path: "",
  98. },
  99. {
  100. icon: <RequestQuote />,
  101. label: "Work Order",
  102. path: "",
  103. },
  104. {
  105. icon: <RequestQuote />,
  106. label: "Work Order Traceablity ",
  107. path: "",
  108. },
  109. ],
  110. },
  111. {
  112. icon: <RequestQuote />,
  113. label: "Quality Control Log",
  114. path: "",
  115. children: [
  116. {
  117. icon: <RequestQuote />,
  118. label: "Quality Control Log",
  119. path: "",
  120. },
  121. ],
  122. },
  123. {
  124. icon: <RequestQuote />,
  125. label: "Delivery",
  126. path: "",
  127. children: [
  128. {
  129. icon: <RequestQuote />,
  130. label: "Delivery Order",
  131. path: "",
  132. },
  133. ],
  134. },
  135. {
  136. icon: <RequestQuote />,
  137. label: "Report",
  138. path: "",
  139. children: [
  140. {
  141. icon: <RequestQuote />,
  142. label: "report",
  143. path: "",
  144. },
  145. ],
  146. },
  147. {
  148. icon: <RequestQuote />,
  149. label: "Recipe",
  150. path: "",
  151. children: [
  152. {
  153. icon: <RequestQuote />,
  154. label: "FG Recipe",
  155. path: "",
  156. },
  157. {
  158. icon: <RequestQuote />,
  159. label: "SFG Recipe",
  160. path: "",
  161. },
  162. {
  163. icon: <RequestQuote />,
  164. label: "Recipe",
  165. path: "",
  166. },
  167. ],
  168. },
  169. {
  170. icon: <RequestQuote />,
  171. label: "Settings",
  172. path: "",
  173. children: [
  174. {
  175. icon: <RequestQuote />,
  176. label: "User",
  177. path: "/settings/user",
  178. },
  179. {
  180. icon: <RequestQuote />,
  181. label: "User Group",
  182. path: "/settings/user",
  183. },
  184. {
  185. icon: <RequestQuote />,
  186. label: "Material",
  187. path: "/settings/user",
  188. },
  189. {
  190. icon: <RequestQuote />,
  191. label: "Maintain By-product",
  192. path: "/settings/user",
  193. },
  194. {
  195. icon: <RequestQuote />,
  196. label: "Finished Goods",
  197. path: "/settings/user",
  198. },
  199. {
  200. icon: <RequestQuote />,
  201. label: "Equipment Type",
  202. path: "/settings/user",
  203. },
  204. {
  205. icon: <RequestQuote />,
  206. label: "Equipment",
  207. path: "/settings/user",
  208. },
  209. {
  210. icon: <RequestQuote />,
  211. label: "Warehouse",
  212. path: "/settings/user",
  213. },
  214. {
  215. icon: <RequestQuote />,
  216. label: "Supplier",
  217. path: "/settings/user",
  218. },
  219. {
  220. icon: <RequestQuote />,
  221. label: "Customer",
  222. path: "/settings/user",
  223. },
  224. {
  225. icon: <RequestQuote />,
  226. label: "QC Check Item",
  227. path: "/settings/user",
  228. },
  229. {
  230. icon: <RequestQuote />,
  231. label: "QC Category",
  232. path: "/settings/user",
  233. },
  234. {
  235. icon: <RequestQuote />,
  236. label: "QC Check Template",
  237. path: "/settings/user",
  238. },
  239. ],
  240. },
  241. ];
  242. const { t } = useTranslation("common");
  243. const pathname = usePathname();
  244. const [openItems, setOpenItems] = React.useState<string[]>([]);
  245. const toggleItem = (path: string) => {
  246. setOpenItems((prevOpenItems) =>
  247. prevOpenItems.includes(path)
  248. ? prevOpenItems.filter((item) => item !== path)
  249. : [...prevOpenItems, path],
  250. );
  251. };
  252. const renderNavigationItem = (item: NavigationItem) => {
  253. const isOpen = openItems.includes(item.path);
  254. return (
  255. <Box
  256. key={`${item.label}-${item.path}`}
  257. component={Link}
  258. href={item.path}
  259. sx={{ textDecoration: "none", color: "inherit" }}
  260. >
  261. <ListItemButton
  262. selected={pathname.includes(item.path)}
  263. onClick={() => item.children && toggleItem(item.path)}
  264. >
  265. <ListItemIcon>{item.icon}</ListItemIcon>
  266. <ListItemText primary={t(item.label)} />
  267. </ListItemButton>
  268. {item.children && isOpen && (
  269. <List sx={{ pl: 2 }}>
  270. {item.children.map((child) => (!child.isHidden && renderNavigationItem(child)))}
  271. </List>
  272. )}
  273. </Box>
  274. );
  275. };
  276. return (
  277. <Box sx={{ width: NAVIGATION_CONTENT_WIDTH }}>
  278. <Box sx={{ p: 3, display: "flex" }}>
  279. <Logo height={60} />
  280. {/* <button className="float-right bg-transparent border-transparent" >
  281. <ArrowCircleLeftRoundedIcon className="text-slate-400 hover:text-blue-400 hover:cursor-pointer " style={{ fontSize: '35px' }} />
  282. </button> */}
  283. </Box>
  284. <Divider />
  285. <List component="nav">
  286. {navigationItems.map((item) => renderNavigationItem(item))}
  287. {/* {navigationItems.map(({ icon, label, path }, index) => {
  288. return (
  289. <Box
  290. key={`${label}-${index}`}
  291. component={Link}
  292. href={path}
  293. sx={{ textDecoration: "none", color: "inherit" }}
  294. >
  295. <ListItemButton selected={pathname.includes(path)}>
  296. <ListItemIcon>{icon}</ListItemIcon>
  297. <ListItemText primary={t(label)} />
  298. </ListItemButton>
  299. </Box>
  300. );
  301. })} */}
  302. </List>
  303. </Box>
  304. );
  305. };
  306. export default NavigationContent;