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.
 
 

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