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.
 
 

317 lines
8.1 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: "/dashboard",
  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: "By-product",
  190. // path: "/settings/byProduct",
  191. // },
  192. {
  193. icon: <RequestQuote />,
  194. label: "Items",
  195. path: "/settings/items",
  196. },
  197. {
  198. icon: <RequestQuote />,
  199. label: "Rough Schedule Setting",
  200. path: "/settings/rss",
  201. },
  202. {
  203. icon: <RequestQuote />,
  204. label: "Equipment Type",
  205. path: "/settings/user",
  206. },
  207. {
  208. icon: <RequestQuote />,
  209. label: "Equipment",
  210. path: "/settings/user",
  211. },
  212. {
  213. icon: <RequestQuote />,
  214. label: "Warehouse",
  215. path: "/settings/user",
  216. },
  217. {
  218. icon: <RequestQuote />,
  219. label: "Supplier",
  220. path: "/settings/user",
  221. },
  222. {
  223. icon: <RequestQuote />,
  224. label: "Customer",
  225. path: "/settings/user",
  226. },
  227. {
  228. icon: <RequestQuote />,
  229. label: "QC Check Item",
  230. path: "/settings/qcItem",
  231. },
  232. {
  233. icon: <RequestQuote />,
  234. label: "QC Category",
  235. path: "/settings/qcCategory",
  236. },
  237. {
  238. icon: <RequestQuote />,
  239. label: "QC Check Template",
  240. path: "/settings/user",
  241. },
  242. ],
  243. },
  244. ];
  245. const { t } = useTranslation("common");
  246. const pathname = usePathname();
  247. const [openItems, setOpenItems] = React.useState<string[]>([]);
  248. const toggleItem = (label: string) => {
  249. setOpenItems((prevOpenItems) =>
  250. prevOpenItems.includes(label)
  251. ? prevOpenItems.filter((item) => item !== label)
  252. : [...prevOpenItems, label],
  253. );
  254. };
  255. const renderNavigationItem = (item: NavigationItem) => {
  256. const isOpen = openItems.includes(item.label);
  257. return (
  258. <Box
  259. key={`${item.label}-${item.path}`}
  260. component={Link}
  261. href={item.path}
  262. sx={{ textDecoration: "none", color: "inherit" }}
  263. >
  264. <ListItemButton
  265. selected={pathname.includes(item.label)}
  266. onClick={() => item.children && toggleItem(item.label)}
  267. >
  268. <ListItemIcon>{item.icon}</ListItemIcon>
  269. <ListItemText primary={t(item.label)} />
  270. </ListItemButton>
  271. {item.children && isOpen && (
  272. <List sx={{ pl: 2 }}>
  273. {item.children.map((child) => (!child.isHidden && renderNavigationItem(child)))}
  274. </List>
  275. )}
  276. </Box>
  277. );
  278. };
  279. return (
  280. <Box sx={{ width: NAVIGATION_CONTENT_WIDTH }}>
  281. <Box sx={{ p: 3, display: "flex" }}>
  282. <Logo height={60} />
  283. {/* <button className="float-right bg-transparent border-transparent" >
  284. <ArrowCircleLeftRoundedIcon className="text-slate-400 hover:text-blue-400 hover:cursor-pointer " style={{ fontSize: '35px' }} />
  285. </button> */}
  286. </Box>
  287. <Divider />
  288. <List component="nav">
  289. {navigationItems.map((item) => renderNavigationItem(item))}
  290. {/* {navigationItems.map(({ icon, label, path }, index) => {
  291. return (
  292. <Box
  293. key={`${label}-${index}`}
  294. component={Link}
  295. href={path}
  296. sx={{ textDecoration: "none", color: "inherit" }}
  297. >
  298. <ListItemButton selected={pathname.includes(path)}>
  299. <ListItemIcon>{icon}</ListItemIcon>
  300. <ListItemText primary={t(label)} />
  301. </ListItemButton>
  302. </Box>
  303. );
  304. })} */}
  305. </List>
  306. </Box>
  307. );
  308. };
  309. export default NavigationContent;