From 6288ac926c6f6f5ad9c89e87f18420e0df8ab02c Mon Sep 17 00:00:00 2001 From: Amirhossein Mahmoodi Date: Mon, 8 Jul 2024 15:45:39 +0330 Subject: [PATCH 01/13] update --- public/images/headerLogo.png | Bin 0 -> 12522 bytes public/images/rmsLogo.svg | 1 + src/app/default.js | 3 + src/app/page.js | 8 +- .../headerWithLogo/HaederBottom/index.jsx | 40 ++ .../headerWithLogo/HaederTop/index.jsx | 17 + .../dashboard/headerWithLogo/index.jsx | 18 +- .../headerWithSidebar/HeaderMenu/index.jsx | 4 + .../dashboard/headerWithSidebar/index.jsx | 186 +++++---- src/core/components/SidebarListItems.jsx | 119 ++++-- src/core/components/SidebarMenu.jsx | 315 ++++++-------- src/core/components/SidebarSubitems.jsx | 147 +++---- src/core/utils/pageMenu.js | 386 ++++++++++++++++++ src/core/utils/theme.js | 12 +- 14 files changed, 853 insertions(+), 403 deletions(-) create mode 100644 public/images/headerLogo.png create mode 100644 public/images/rmsLogo.svg create mode 100644 src/app/default.js create mode 100644 src/components/layouts/dashboard/headerWithLogo/HaederBottom/index.jsx create mode 100644 src/components/layouts/dashboard/headerWithLogo/HaederTop/index.jsx create mode 100644 src/components/layouts/dashboard/headerWithSidebar/HeaderMenu/index.jsx create mode 100644 src/core/utils/pageMenu.js diff --git a/public/images/headerLogo.png b/public/images/headerLogo.png new file mode 100644 index 0000000000000000000000000000000000000000..86dbfcdec68e82cd257652da38e41f13e4464345 GIT binary patch literal 12522 zcmaKSRajijmUcJp?jD>Fq;VQ|2<{NHai@XCJrLa8gF6HX7Bsj!1WRxW4hb$l-?W#yM6*){aGBf}HfTgsG|>tG20c&+4Wdg>+L5Q(neSYqo)E}hq>I|Ku0>8eqNar6suk^qoU96a%X zPZ4N31cbOb^4k3$7trK$BewFHTdgIcB0fZG8w#9Kua!0V`<$JeJp6d**w5L2ob;Z; z4#LG_Ox!E90|;t-5(Y0($E(Wsk8}pX5z22M(BSNi^;#ni008Ik-d+K)I~7}!vw&E_{@%{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9BUk($p&_?i^esKL0AFP7`aUSifG6^`s6Y z{z(Rt+uW5@$`mHu9*Q4os?t6D^hlv~9${u0dMJR(;L6pbU8HPUK3hwhxv#&usjEiLiF=sD|@&$rQV36Gk(Qfr$I}1twGD_Nt68# zkD_ZiY3UxDn7&q!`3z4X3td$Xr@@4Prh}w}0uarauy9;Q_JybzMLKz-)P`^ouja_E zK;8DO?n^P+J}>ty_iR0EIa?q%J-nw!{A*my*BsC;airV^X|S z!<*_0ZGH(E56);DWxd(%d$KjK$jV`hukBCP(+!ajWY}_yuXXUZ_EVHVS6`aT^rR0u zy*LzDLtO*W_(kpRXH+kn$kZLuJ31k+2XAJ(?X0-?_#qPT$OY!%ST?h*sIb392g>8s zM69nTz@cu4h)Z4mLbG#XgB6-(2kR?M_PRXQlQ}oJD)Xe)6#T(a92M~JhwE@Je>uJg zYs$+nNc!EN9h~o1rc&rOApb%+P}^{0n4AVV#&o+Q;s zOjc@m-|n)FB-z({twJIO;ehbRKl!|M?wQOLLOx#UtZHWwGtpOrPM+8=IIB^s3SU?R zd^LXI1%72SYIk4t2cPkDqLfcqp%;mA7`Fz2iiU2Hn)*W%(Mth zG0;NpW!0_C_r9_c6IpBisY<5Ynd;)=f*X!aJ!{nARliz~&$MFP?W6thu&{oVnwBP5 zp{ELk)>TV*JsG?yD6npao#w0;T8{O(A1#Wc$Tu9-oe9Hu&r#aeTpXhr&F?ww6x(K&vh{c85QYTNz;%257u#B AtN;K2 literal 0 HcmV?d00001 diff --git a/public/images/rmsLogo.svg b/public/images/rmsLogo.svg new file mode 100644 index 0000000..5c47991 --- /dev/null +++ b/public/images/rmsLogo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/app/default.js b/src/app/default.js new file mode 100644 index 0000000..73d13c1 --- /dev/null +++ b/src/app/default.js @@ -0,0 +1,3 @@ +export default function Default() { + return null +} \ No newline at end of file diff --git a/src/app/page.js b/src/app/page.js index 9d660d7..3fab3b7 100644 --- a/src/app/page.js +++ b/src/app/page.js @@ -1,8 +1,8 @@ -'use client' -import HomeComponent from "@/components/home"; +import { redirect } from "next/navigation" function Page() { - return ; + redirect('/dashboard', 'replace') + return null } -export default Page; +export default Page \ No newline at end of file diff --git a/src/components/layouts/dashboard/headerWithLogo/HaederBottom/index.jsx b/src/components/layouts/dashboard/headerWithLogo/HaederBottom/index.jsx new file mode 100644 index 0000000..501dadc --- /dev/null +++ b/src/components/layouts/dashboard/headerWithLogo/HaederBottom/index.jsx @@ -0,0 +1,40 @@ +"use client"; +import { Stack, Typography } from "@mui/material"; +import Image from "next/image"; + +const HeaderBottom = () => { + return ( + theme.palette.primary2.main, + }} + spacing={4} + alignItems={"center"} + direction={"row"} + > + + + theme.palette.primary2.contrastText }} + > + سامانه جامع راهداری + + theme.palette.primary2.contrastText }} + > + rms.rmto.ir + + + + ); +}; +export default HeaderBottom; diff --git a/src/components/layouts/dashboard/headerWithLogo/HaederTop/index.jsx b/src/components/layouts/dashboard/headerWithLogo/HaederTop/index.jsx new file mode 100644 index 0000000..27cd26a --- /dev/null +++ b/src/components/layouts/dashboard/headerWithLogo/HaederTop/index.jsx @@ -0,0 +1,17 @@ +import { Stack } from "@mui/material"; +import Image from "next/image"; + +const HeaderTop = () => { + return ( + + + + ); +}; +export default HeaderTop; diff --git a/src/components/layouts/dashboard/headerWithLogo/index.jsx b/src/components/layouts/dashboard/headerWithLogo/index.jsx index f16f58c..f628e49 100644 --- a/src/components/layouts/dashboard/headerWithLogo/index.jsx +++ b/src/components/layouts/dashboard/headerWithLogo/index.jsx @@ -1,9 +1,13 @@ -import {Box, Stack} from "@mui/material"; +import { Box, Stack } from "@mui/material"; +import HeaderTop from "./HaederTop"; +import HeaderBottom from "./HaederBottom"; const HeaderWithLogo = () => { - return ( - header1 - header2 - ) -} -export default HeaderWithLogo \ No newline at end of file + return ( + + + + + ); +}; +export default HeaderWithLogo; diff --git a/src/components/layouts/dashboard/headerWithSidebar/HeaderMenu/index.jsx b/src/components/layouts/dashboard/headerWithSidebar/HeaderMenu/index.jsx new file mode 100644 index 0000000..01fd681 --- /dev/null +++ b/src/components/layouts/dashboard/headerWithSidebar/HeaderMenu/index.jsx @@ -0,0 +1,4 @@ +const HeaderMenu = () => { + return <>منو; +}; +export default HeaderMenu; diff --git a/src/components/layouts/dashboard/headerWithSidebar/index.jsx b/src/components/layouts/dashboard/headerWithSidebar/index.jsx index eeb88a3..be0a284 100644 --- a/src/components/layouts/dashboard/headerWithSidebar/index.jsx +++ b/src/components/layouts/dashboard/headerWithSidebar/index.jsx @@ -1,94 +1,116 @@ -'use client' -import {useState} from "react"; -import {Box, Drawer, IconButton, Paper, styled, Toolbar, Typography} from "@mui/material"; -import MuiAppBar from '@mui/material/AppBar'; -import MenuIcon from '@mui/icons-material/Menu'; -import ChevronRightIcon from '@mui/icons-material/ChevronRight'; +"use client"; import SidebarMenu from "@/core/components/SidebarMenu"; +import ChevronRightIcon from "@mui/icons-material/ChevronRight"; +import MenuIcon from "@mui/icons-material/Menu"; +import { Box, Drawer, IconButton, Paper, styled, Toolbar } from "@mui/material"; +import MuiAppBar from "@mui/material/AppBar"; +import { useState } from "react"; +import HeaderMenu from "./HeaderMenu"; -const drawerWidth = 260; +const drawerWidth = 300; -const Main = styled(Paper, {shouldForwardProp: (prop) => prop !== 'open'})(({theme, open}) => ({ - flexGrow: 1, transition: theme.transitions.create('margin', { - easing: theme.transitions.easing.sharp, duration: theme.transitions.duration.leavingScreen, - }), marginLeft: `-${drawerWidth}px`, ...(open && { - transition: theme.transitions.create('margin', { - easing: theme.transitions.easing.easeOut, duration: theme.transitions.duration.enteringScreen, - }), marginLeft: 0, +const Main = styled(Paper, { shouldForwardProp: (prop) => prop !== "open" })( + ({ theme, open }) => ({ + flexGrow: 1, + transition: theme.transitions.create("margin", { + easing: theme.transitions.easing.sharp, + duration: theme.transitions.duration.leavingScreen, }), -}),); + marginLeft: `-${drawerWidth}px`, + ...(open && { + transition: theme.transitions.create("margin", { + easing: theme.transitions.easing.easeOut, + duration: theme.transitions.duration.enteringScreen, + }), + marginLeft: 0, + }), + }) +); const AppBar = styled(MuiAppBar, { - shouldForwardProp: (prop) => prop !== 'open', -})(({theme, open}) => ({ - transition: theme.transitions.create(['margin', 'width'], { - easing: theme.transitions.easing.sharp, duration: theme.transitions.duration.leavingScreen, - }), ...(open && { - width: `calc(100% - ${drawerWidth}px)`, - marginLeft: `${drawerWidth}px`, - transition: theme.transitions.create(['margin', 'width'], { - easing: theme.transitions.easing.easeOut, duration: theme.transitions.duration.enteringScreen, - }), + shouldForwardProp: (prop) => prop !== "open", +})(({ theme, open }) => ({ + transition: theme.transitions.create(["margin", "width"], { + easing: theme.transitions.easing.sharp, + duration: theme.transitions.duration.leavingScreen, + }), + ...(open && { + width: `calc(100% - ${drawerWidth}px)`, + marginLeft: `${drawerWidth}px`, + transition: theme.transitions.create(["margin", "width"], { + easing: theme.transitions.easing.easeOut, + duration: theme.transitions.duration.enteringScreen, }), + }), })); -const DrawerHeader = styled('div')(({theme}) => ({ - display: 'flex', alignItems: 'center', padding: theme.spacing(0, 1), // necessary for content to be below app bar - ...theme.mixins.toolbar, justifyContent: 'flex-end', +const DrawerHeader = styled("div")(({ theme }) => ({ + display: "flex", + alignItems: "center", + padding: theme.spacing(0, 1), + ...theme.mixins.toolbar, + justifyContent: "flex-end", })); -const HeaderWithSidebar = ({children}) => { - const [open, setOpen] = useState(false); +const HeaderWithSidebar = ({ children }) => { + const [open, setOpen] = useState(true); - const handleDrawerOpen = () => { - setOpen(true); - }; - - const handleDrawerClose = () => { - setOpen(false); - }; - return ( - - - - - - - menu - - - - - - - - - - - -
- - {children} -
-
) -} -export default HeaderWithSidebar \ No newline at end of file + const handleDrawerOpen = () => { + setOpen(true); + }; + const handleDrawerClose = () => { + setOpen(false); + }; + return ( + + + + + + + + + + + + + + + + + + + +
+ + {children} +
+
+ ); +}; +export default HeaderWithSidebar; diff --git a/src/core/components/SidebarListItems.jsx b/src/core/components/SidebarListItems.jsx index 9ffcac2..d300d7f 100644 --- a/src/core/components/SidebarListItems.jsx +++ b/src/core/components/SidebarListItems.jsx @@ -1,46 +1,77 @@ -import {Collapse, ListItem, ListItemButton, ListItemIcon, ListItemText} from "@mui/material"; -import { ExpandLess, ExpandMore } from '@mui/icons-material'; -import WifiIcon from '@mui/icons-material/Wifi'; import SidebarSubitems from "@/core/components/SidebarSubitems"; +import { ExpandLess, ExpandMore } from "@mui/icons-material"; +import { + Collapse, + List, + ListItem, + ListItemButton, + ListItemIcon, + ListItemText, +} from "@mui/material"; +import Link from "next/link"; -const SidebarListItems = ({menuItem, dispatch}) => { - return( - <> - - { - dispatch({type: "COLLAPSE_MENU", id: menuItem.id}) - }}> - - {menuItem.icon} - - - {menuItem.hasSubitems ? (menuItem.showSubitems ? : ) : null } - - - - { - menuItem.hasSubitems ? (menuItem.Subitems.map((subitem,index)=>{ - return( - - ) - })) : null - } - - - - ) -} -export default SidebarListItems \ No newline at end of file +const SidebarListItems = ({ menuItem, dispatch }) => { + return ( + <> + + { + dispatch({ type: "COLLAPSE_MENU", id: menuItem.id }); + }} + > + + {menuItem.icon} + + + {menuItem.hasSubitems ? ( + menuItem.showSubitems ? ( + + ) : ( + + ) + ) : null} + + + + {menuItem.hasSubitems ? ( + + {menuItem.Subitems.map((subitem, index) => { + return ( + + ); + })} + + ) : null} + + + ); +}; +export default SidebarListItems; diff --git a/src/core/components/SidebarMenu.jsx b/src/core/components/SidebarMenu.jsx index f7589c3..c9f6a73 100644 --- a/src/core/components/SidebarMenu.jsx +++ b/src/core/components/SidebarMenu.jsx @@ -1,201 +1,132 @@ -"use client" -import {List} from "@mui/material"; +"use client"; import SidebarListItems from "@/core/components/SidebarListItems"; -import {useEffect, useReducer, useState} from "react"; -import {usePathname} from 'next/navigation' -import SecurityIcon from '@mui/icons-material/Security'; -import SpaceDashboardIcon from "@mui/icons-material/SpaceDashboard"; -import AssessmentIcon from '@mui/icons-material/Assessment'; -import AirlineSeatReclineNormalIcon from "@mui/icons-material/AirlineSeatReclineNormal"; -import RepartitionIcon from '@mui/icons-material/Repartition'; - -const data = [ - { - id: "hello", - type: "menu", - route: "/hello", - icon: , - selected: false, - Subitems: [ - { - id: "amin", - route: "/s", - icon: , - firstName: "amin", - lastName: "ali", - Subitems: [ - { - id: "shahrokh", shahrokh: "shahrokh", type: "page", selected: false, route: "/dashbssoard", icon: - }, - { - id: "shasdasdsahrokh", shahrokh: "shahroasdasdkh", type: "page", selected: false, route: "/dashboardsd", icon: - } - ], - hasSubitems: true, - showSubitems: false, - type: "menu", - selected: false, - }, - { - id: "amir", - route: "/dashboarsad", - icon: , - firstName: "amir", - lastName: "akbar", - hasSubitems: false, - showSubitems: false, - selected: false, - type: "page", - }, - ], - hasSubitems: true, - showSubitems: false - }, - { - id: "hi", - type: "menu", - icon: , - route: "/hi", - selected: false, - Subitems: [ - { - id: "ali", - route: "/dashboardss", - firstName: "ali", - lastName: "ali", - icon: , - hasSubitems: false, - showSubitems: false, - type: "page", - selected: false, - }, - { - id: "akbar", - route: "/akbar", - firstName: "akbar", - icon: , - lastName: "akbar", - hasSubitems: false, - showSubitems: false, - type: "page", - selected: false, - }, - ], - hasSubitems: true, - showSubitems: false - }, - { - id: "hoo", - type: "page", - route: "/dashboard", - icon: , - selected: false, - hasSubitems: false, - showSubitems: false - } -] +import { List } from "@mui/material"; +import { usePathname } from "next/navigation"; +import { useEffect, useReducer, useState } from "react"; +import { pageMenu } from "../utils/pageMenu"; function reducer(state, action) { - switch (action.type) { - case "COLLAPSE_MENU": - return state.map((item) => action.id == item.id ? { - ...item, showSubitems: !item.showSubitems - } : item) - case "COLLAPSE_SUB_ITEMS" : - return state.map((item) => { - return item.hasSubitems ? { - ...item, Subitems: item.Subitems.map((subitem) => action.id === subitem.id ? { - ...subitem, showSubitems: !subitem.showSubitems - } : subitem) - } : item - }) - case "COLLAPSE_SUB_SECOND_ITEMS" : - return state.map((item) => { - return item.hasSubitems ? { - ...item, Subitems: item.Subitems.map((subitem) => { - return subitem.hasSubitems ? { - ...subitem, - Subitems: subitem.Subitems.map((secondSubitem) => action.id === secondSubitem.id ? { - ...secondSubitem, showSubitems: !secondSubitem.showSubitems - } : secondSubitem) - } : subitem - }) - } : item - }) - case "SELECTED": - return state.map((item) => { - return item.type === "page" ? { - ...item, selected: action.route === item.route,showSubitems: item.route === action.route - } : item.Subitems && Array.isArray(item.Subitems) ? { - ...item, Subitems: item.Subitems.map((subitem) => { - return subitem.type === "page" ? { - ...subitem, selected: action.route === subitem.route,showSubitems: subitem.route === action.route - } : subitem.Subitems && Array.isArray(subitem.Subitems) ? { - ...subitem, Subitems: subitem.Subitems.map((secondSubItem) => ({ - ...secondSubItem, selected: secondSubItem.route === action.route - })),showSubitems: subitem.Subitems.some((secondSubItem) => secondSubItem.route === action.route), - } : subitem - }),showSubitems: item.Subitems.some((subitem) => subitem.showSubitems), - } : item - }); - // case "SELECTED": - // return state.map((item) => { - // return item.type === "page" ? { - // ...item, - // selected: action.route === item.route - // } : item.Subitems && Array.isArray(item.Subitems) ? { - // ...item, - // Subitems: item.Subitems.map((subitem) => { - // const updatedSubitem = subitem.type === "page" ? { - // ...subitem, - // selected: action.route === subitem.route - // } : subitem.Subitems && Array.isArray(subitem.Subitems) ? { - // ...subitem, - // Subitems: subitem.Subitems.map((secondSubItem) => ({ - // ...secondSubItem, - // selected: secondSubItem.route === action.route - // })), - // showSubitems: subitem.Subitems.some((secondSubItem) => secondSubItem.route === action.route), - // } : subitem; - // - // console.log("Updated subitem:", updatedSubitem); // Log the updated subitem - // return updatedSubitem; - // }), - // showSubitems: item.Subitems.some((subitem) => subitem.showSubitems), - // } : item - // }); + switch (action.type) { + case "COLLAPSE_MENU": + return state.map((item) => + action.id == item.id + ? { + ...item, + showSubitems: !item.showSubitems, + } + : item + ); + case "COLLAPSE_SUB_ITEMS": + return state.map((item) => { + return item.hasSubitems + ? { + ...item, + Subitems: item.Subitems.map((subitem) => + action.id === subitem.id + ? { + ...subitem, + showSubitems: !subitem.showSubitems, + } + : subitem + ), + } + : item; + }); + case "COLLAPSE_SUB_SECOND_ITEMS": + return state.map((item) => { + return item.hasSubitems + ? { + ...item, + Subitems: item.Subitems.map((subitem) => { + return subitem.hasSubitems + ? { + ...subitem, + Subitems: subitem.Subitems.map((secondSubitem) => + action.id === secondSubitem.id + ? { + ...secondSubitem, + showSubitems: !secondSubitem.showSubitems, + } + : secondSubitem + ), + } + : subitem; + }), + } + : item; + }); + case "SELECTED": + return state.map((item) => { + return item.type === "page" + ? { + ...item, + selected: action.route === item.route, + showSubitems: item.route === action.route, + } + : item.Subitems && Array.isArray(item.Subitems) + ? { + ...item, + Subitems: item.Subitems.map((subitem) => { + return subitem.type === "page" + ? { + ...subitem, + selected: action.route === subitem.route, + showSubitems: subitem.route === action.route, + } + : subitem.Subitems && Array.isArray(subitem.Subitems) + ? { + ...subitem, + Subitems: subitem.Subitems.map((secondSubItem) => ({ + ...secondSubItem, + selected: secondSubItem.route === action.route, + })), + showSubitems: subitem.Subitems.some( + (secondSubItem) => secondSubItem.route === action.route + ), + } + : subitem; + }), + showSubitems: item.Subitems.some( + (subitem) => subitem.showSubitems + ), + } + : item; + }); - - default: - throw new Error(); - } + default: + throw new Error(); + } } const SidebarMenu = () => { - const [menuItems, dispatch] = useReducer(reducer, data); - const pathname = usePathname() - const [selectedKey, setSelectedKey] = useState(null); - useEffect(() => { - dispatch({type: "SELECTED", route: pathname}); - setSelectedKey(pathname); - }, [pathname]); + const [menuItems, dispatch] = useReducer(reducer, pageMenu); + const pathname = usePathname(); + const [selectedKey, setSelectedKey] = useState(null); + useEffect(() => { + dispatch({ type: "SELECTED", route: pathname }); + setSelectedKey(pathname); + }, [pathname]); - useEffect(() => { - selectedKey && document.querySelector(`[data-route="${selectedKey}"]`)?.scrollIntoView({ - behavior: "smooth", block: "center" - }); - }, [selectedKey]); + useEffect(() => { + selectedKey && + document.querySelector(`[data-route="${selectedKey}"]`)?.scrollIntoView({ + behavior: "smooth", + block: "center", + }); + }, [selectedKey]); - return ( - - { - menuItems.map((menuItem) => { - return ( - - ) - }) - } - - ) -} -export default SidebarMenu \ No newline at end of file + return ( + + {menuItems.map((menuItem) => { + return ( + + ); + })} + + ); +}; +export default SidebarMenu; diff --git a/src/core/components/SidebarSubitems.jsx b/src/core/components/SidebarSubitems.jsx index 275befb..b54d3a9 100644 --- a/src/core/components/SidebarSubitems.jsx +++ b/src/core/components/SidebarSubitems.jsx @@ -1,74 +1,75 @@ -import {Collapse, List, ListItem, ListItemButton, ListItemIcon, ListItemText} from "@mui/material"; -import {ExpandLess, ExpandMore} from "@mui/icons-material"; +import { ExpandLess, ExpandMore } from "@mui/icons-material"; +import { + Collapse, + List, + ListItem, + ListItemButton, + ListItemIcon, + ListItemText, +} from "@mui/material"; +import Link from "next/link"; -const SidebarSubitems = ({subitem, dispatch}) => { - return ( - <> - - - { - dispatch({type: "COLLAPSE_SUB_ITEMS", id: subitem.id}) - }}> - - {subitem.icon} - - - {subitem.hasSubitems ? (subitem.showSubitems ? : ) : null - } - - - - { - subitem.hasSubitems ? (subitem.Subitems.map((subSubitem, index) => { - return ( - - - - { - dispatch({type: "COLLAPSE_SUB_SECOND_ITEMS", id: subSubitem.id}) - }} - selected={subSubitem.selected} - sx={{ - '&.Mui-selected': { - backgroundColor: 'rgba(0, 0, 0, 0.05)', - }, - }} - > - - {subSubitem.icon} - - - - - - - ) - })) : null - } - - ) -} -export default SidebarSubitems \ No newline at end of file +const SidebarSubitems = ({ subitem, dispatch }) => { + return ( + <> + + { + dispatch({ type: "COLLAPSE_SUB_ITEMS", id: subitem.id }); + }} + > + + {subitem.icon} + + + {subitem.hasSubitems ? ( + subitem.showSubitems ? ( + + ) : ( + + ) + ) : null} + + + + {subitem.hasSubitems ? ( + + {subitem.Subitems.map((subSubitem, index) => { + return ( + + ); + })} + + ) : null} + + + ); +}; +export default SidebarSubitems; diff --git a/src/core/utils/pageMenu.js b/src/core/utils/pageMenu.js new file mode 100644 index 0000000..b97199a --- /dev/null +++ b/src/core/utils/pageMenu.js @@ -0,0 +1,386 @@ +import { AirlineSeatReclineNormal, Assessment, Repartition, Security, SpaceDashboard } from "@mui/icons-material"; + +export const pageMenu = [ + { + id: 'dashboard', + label: 'پیشخوان', + type: "page", + route: "/dashboard", + icon: , + }, + { + id: 'userManagement', + label: 'مدیریت کاربران', + type: "page", + route: "./v2/user_management", + icon: , + }, + { + id: 'projectsManagment', + label: 'پروژه های راهداری', + type: "menu", + icon: , + hasSubitems: true, + Subitems: [ + { + id: 'projectsManagmentFinance', + label: 'ثبت قرارداد و پروژه', + type: "page", + route: "./v2/rahdari_projects/finance", + icon: , + }, + { + id: 'projectsManagmentList', + label: 'لیست پروژه ها', + type: "page", + route: "./v2/rahdari_projects/projects_list", + icon: , + }, + { + id: 'projectsManagmentProposal', + label: 'پروژه های پیشنهادی', + type: "page", + route: "./v2/rahdari_projects/proposal", + icon: , + }, + { + id: 'projectsManagmentLawmaker', + label: 'درخواست نمایندگان', + type: "page", + route: "./v2/rahdari_projects/lawmakers", + icon: , + }, + { + id: 'projectsManagmentMap', + label: 'پراکندگی بر روی نقشه', + type: "page", + route: "./v2/map?type=rahdari_projects", + icon: , + }, + ] + }, + { + id: 'roadItemManagment', + label: 'فعالیت های روزانه', + type: "menu", + icon: , + hasSubitems: true, + Subitems: [ + { + id: 'roadItemManagmentSupervisor', + label: 'ارزیابی', + type: "menu", + icon: , + hasSubitems: true, + Subitems: [ + { + id: 'roadItemManagmentSupervisorCartable', + label: 'کارتابل', + type: "page", + route: "./v2/road_items/supervisor/cartable", + }, + ] + }, + { + id: 'roadItemManagmentOparation', + label: 'عملیات', + type: "menu", + icon: , + hasSubitems: true, + Subitems: [ + { + id: 'roadItemManagmentOparationCreate', + label: 'ثبت فعالیت', + type: "page", + route: "./v2/road_items/operator/create", + }, + { + id: 'roadItemManagmentOparationCartable', + label: 'کارتابل', + type: "page", + route: "./v2/road_items/operator/cartable", + }, + ] + }, + { + id: 'roadItemManagmentMap', + label: 'پراکندگی بر روی نقشه', + type: "page", + route: "./v2/map?type=road_items", + icon: , + }, + { + id: 'roadItemManagmentReport', + label: 'گزارش ها', + type: "page", + route: "./v2/road_items/report", + icon: , + }, + ] + }, + { + id: 'roadPatrolManagment', + label: 'گشت راهداری و ترابری', + type: "menu", + icon: , + hasSubitems: true, + Subitems: [ + { + id: 'roadPatrolManagmentSupervisor', + label: 'ارزیابی', + type: "menu", + icon: , + hasSubitems: true, + Subitems: [ + { + id: 'roadPatrolManagmentSupervisorCartable', + label: 'کارتابل', + type: "page", + route: "./road_patrols/supervisor/cartable", + }, + ] + }, + { + id: 'roadPatrolManagmentOparation', + label: 'عملیات', + type: "menu", + icon: , + hasSubitems: true, + Subitems: [ + { + id: 'roadPatrolManagmentOparationCreate', + label: 'ثبت اقدام', + type: "page", + route: "./v2/road_patrols/operator/create", + }, + { + id: 'roadPatrolManagmentOparationCartable', + label: 'کارتابل', + type: "page", + route: "./v2/road_patrols/operator/cartable", + }, + ] + }, + { + id: 'roadPatrolManagmentMap', + label: 'پراکندگی بر روی نقشه', + type: "page", + route: "./v2/map?type=road_patrols", + icon: , + }, + { + id: 'roadPatrolManagmentReport', + label: 'گزارش ها', + type: "page", + route: "./v2/road_patrols/report", + icon: , + }, + ] + }, + { + id: 'safetyAndPrivacyManagment', + label: 'نگهداری حریم راه', + type: "menu", + icon: , + hasSubitems: true, + Subitems: [ + { + id: 'safetyAndPrivacyManagmentOparation', + label: 'عملیات', + type: "menu", + icon: , + hasSubitems: true, + Subitems: [ + { + id: 'safetyAndPrivacyManagmentOparationCreate', + label: 'ثبت فعالیت', + type: "page", + route: "./safety_and_privacy/operator/first_step", + }, + { + id: 'safetyAndPrivacyManagmentOparationCartable', + label: 'کارتابل', + type: "page", + route: "./v2/safety_and_privacy/operator/cartable", + }, + ] + }, + { + id: 'safetyAndPrivacyManagmentMap', + label: 'پراکندگی بر روی نقشه', + type: "page", + route: "./v2/map?type=safety_and_privacy", + icon: , + }, + { + id: 'safetyAndPrivacyManagmentReport', + label: 'گزارش ها', + type: "page", + route: "./v2/safety_and_privacy/report", + icon: , + }, + ] + }, + { + id: 'roadObservationsManagment', + label: 'واکنش سریع', + type: "menu", + icon: , + hasSubitems: true, + Subitems: [ + { + id: 'roadObservationsManagmentSupervisor', + label: 'ارزیابی', + type: "menu", + icon: , + hasSubitems: true, + Subitems: [ + { + id: 'roadObservationsManagmentSupervisorCartable', + label: 'کارتابل', + type: "page", + route: "./v2/road_observations/supervisor/cartable", + }, + ] + }, + { + id: 'roadObservationsManagmentList', + label: 'رسیدگی به شکایات', + type: "page", + route: "./v2/road_observations", + icon: , + }, + { + id: 'roadObservationsManagmentOparation', + label: 'عملیات', + type: "menu", + icon: , + hasSubitems: true, + Subitems: [ + { + id: 'roadObservationsManagmentOparationCartable', + label: 'کارتابل', + type: "page", + route: "./v2/road_observations/operator/cartable", + }, + ] + }, + { + id: 'roadObservationsManagmentMap', + label: 'پراکندگی بر روی نقشه', + type: "page", + route: "./v2/map?type=road_observations", + icon: , + }, + { + id: 'roadObservationsManagmentReport', + label: 'گزارش ها', + type: "page", + route: "./v2/road_observations/report/index", + icon: , + }, + ] + }, + { + id: 'winterCampManagment', + label: 'قرارگاه زمستانی', + type: "menu", + icon: , + hasSubitems: true, + Subitems: [ + { + id: 'winterCampManagmentBlocking', + label: 'محور های انسدادی', + type: "page", + route: "./v2/winter_camp", + icon: , + }, + { + id: 'winterCampManagmentFirstRing', + label: 'محور های حلقه اول', + type: "page", + route: "./v2/map?type=camp", + icon: , + }, + { + id: 'winterCampManagmentReport', + label: 'گزارش ها', + type: "page", + route: "./v2/map?type=campNew", + icon: , + }, + ] + }, + { + id: 'receiptManagment', + label: 'خسارات وارده بر ابنیه فنی و تاسیسات راه', + type: "menu", + icon: , + hasSubitems: true, + Subitems: [ + { + id: 'receiptManagmentOparation', + label: 'عملیات', + type: "menu", + icon: , + hasSubitems: true, + Subitems: [ + { + id: 'receiptManagmentOparationCartable', + label: 'کارتابل', + type: "page", + route: "./v2/receipt", + }, + ] + }, + { + id: 'receiptManagmentReport', + label: 'گزارش ها', + type: "page", + route: "./v2/receipt/report", + icon: , + }, + ] + } + // { + // id: "hello", + // type: "menu", + // route: "/hello", + // icon: , + // selected: false, + // Subitems: [ + // { + // id: "amin", + // route: "/s", + // icon: , + // firstName: "amin", + // lastName: "ali", + // Subitems: [ + // { + // id: "shahrokh", shahrokh: "shahrokh", type: "page", selected: false, route: "/dashbssoard", icon: + // }, + // { + // id: "shasdasdsahrokh", shahrokh: "shahroasdasdkh", type: "page", selected: false, route: "/dashboardsd", icon: + // } + // ], + // hasSubitems: true, + // showSubitems: false, + // type: "menu", + // selected: false, + // }, + // { + // id: "amir", + // route: "/dashboarsad", + // icon: , + // firstName: "amir", + // lastName: "akbar", + // hasSubitems: false, + // showSubitems: false, + // selected: false, + // type: "page", + // }, + // ], + // hasSubitems: true, + // showSubitems: false + // }, +] \ No newline at end of file diff --git a/src/core/utils/theme.js b/src/core/utils/theme.js index d96fc53..581e23e 100644 --- a/src/core/utils/theme.js +++ b/src/core/utils/theme.js @@ -1,5 +1,5 @@ 'use client' -import {createTheme} from "@mui/material"; +import { createTheme } from "@mui/material"; const theme = createTheme({ direction: 'rtl', @@ -7,6 +7,16 @@ const theme = createTheme({ fontFamily: `IRANSansFaNum, sans-serif`, fontSize: 12 }, + palette: { + primary: { + main: '#2070af', + contrastText: '#fff' + }, + primary2: { + main: '#015688', + contrastText: '#fff' + }, + } }); export default theme \ No newline at end of file From 863bdaca95bbf5087777a0e9f8c5c9453a6d5ace Mon Sep 17 00:00:00 2001 From: Amirhossein Mahmoodi Date: Tue, 9 Jul 2024 11:28:59 +0330 Subject: [PATCH 02/13] add auth and base functions and fixed bug --- .env.local.example | 1 + package.json | 1 + public/global.scss | 6 +- src/app/(withAuth)/dashboard/layout.js | 11 - src/app/(withAuth)/dashboard/page.js | 24 ++- src/app/(withAuth)/dashboard/template.js | 22 +- src/app/(withAuth)/layout.js | 14 ++ src/app/layout.js | 14 +- src/app/lfwd/page.js | 51 +++++ src/app/template.js | 16 +- src/core/components/Toasts/error.jsx | 191 ++++++++++++++++++ src/core/components/Toasts/success.jsx | 35 ++++ src/core/middlewares/withAuth.js | 22 ++ src/core/utils/errorResponse.js | 61 ++++++ src/core/utils/pageMenu.js | 60 +++--- src/core/utils/routes.js | 4 + src/core/utils/successRequest.js | 10 + .../contexts/{DataTable.jsx => DataTable.js} | 0 src/lib/contexts/auth.js | 76 +++++++ .../{tableSetting.jsx => tableSetting.js} | 0 .../{useDataTable.jsx => useDataTable.js} | 0 src/lib/hooks/useRequest.js | 42 ++++ ...useTableSetting.jsx => useTableSetting.js} | 0 23 files changed, 592 insertions(+), 69 deletions(-) delete mode 100644 src/app/(withAuth)/dashboard/layout.js create mode 100644 src/app/(withAuth)/layout.js create mode 100644 src/app/lfwd/page.js create mode 100644 src/core/components/Toasts/error.jsx create mode 100644 src/core/components/Toasts/success.jsx create mode 100644 src/core/middlewares/withAuth.js create mode 100644 src/core/utils/errorResponse.js create mode 100644 src/core/utils/routes.js create mode 100644 src/core/utils/successRequest.js rename src/lib/contexts/{DataTable.jsx => DataTable.js} (100%) create mode 100644 src/lib/contexts/auth.js rename src/lib/contexts/{tableSetting.jsx => tableSetting.js} (100%) rename src/lib/hooks/{useDataTable.jsx => useDataTable.js} (100%) create mode 100644 src/lib/hooks/useRequest.js rename src/lib/hooks/{useTableSetting.jsx => useTableSetting.js} (100%) diff --git a/.env.local.example b/.env.local.example index e69de29..05bae5f 100644 --- a/.env.local.example +++ b/.env.local.example @@ -0,0 +1 @@ +NEXT_PUBLIC_API_URL="https://rms.witel.ir" \ No newline at end of file diff --git a/package.json b/package.json index b4ddfd0..4beef0b 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "@mui/material": "^5.15.6", "@mui/material-nextjs": "^5.15.6", "@mui/x-date-pickers": "^6.19.5", + "axios": "^1.7.2", "date-fns": "^3.3.1", "date-fns-jalali": "^2.13.0-0", "dayjs": "^1.11.10", diff --git a/public/global.scss b/public/global.scss index a383b5f..1af3ae3 100644 --- a/public/global.scss +++ b/public/global.scss @@ -1,7 +1,9 @@ @import "fontiran"; +@import "react-toastify/dist/ReactToastify.css"; .filter-toast { - box-shadow: rgba(50, 50, 93, 0.25) 0px 13px 27px -5px, rgba(0, 0, 0, 0.3) 0px 8px 16px -8px; + box-shadow: rgba(50, 50, 93, 0.25) 0px 13px 27px -5px, + rgba(0, 0, 0, 0.3) 0px 8px 16px -8px; background-color: #d0dfe8; border: 1px dashed #095b8c; -} \ No newline at end of file +} diff --git a/src/app/(withAuth)/dashboard/layout.js b/src/app/(withAuth)/dashboard/layout.js deleted file mode 100644 index 213bb0a..0000000 --- a/src/app/(withAuth)/dashboard/layout.js +++ /dev/null @@ -1,11 +0,0 @@ -import 'react-toastify/dist/ReactToastify.css'; - -const Layout = ({children}) => { - return ( - <> - {children} - - ) -} - -export default Layout \ No newline at end of file diff --git a/src/app/(withAuth)/dashboard/page.js b/src/app/(withAuth)/dashboard/page.js index f0731fe..915b3de 100644 --- a/src/app/(withAuth)/dashboard/page.js +++ b/src/app/(withAuth)/dashboard/page.js @@ -1,6 +1,28 @@ +'use client' +import { Button } from "@mui/material" +import axios from "axios" + const Page = () => { + const handler = () => { + try { + axios.get('https://rms.witel.ir/test_login?username=witel', { withCredentials: true }) + } catch (error) { + console.log(error); + } + } + const handler2 = () => { + try { + const res = axios.get('https://rms.witel.ir/webapi/user/get-permission', { withCredentials: true }) + console.log(res); + } catch (error) { + console.log(error); + } + } return ( -
dashboard
+ <> + + + ) } diff --git a/src/app/(withAuth)/dashboard/template.js b/src/app/(withAuth)/dashboard/template.js index 62759c6..eb7d2ef 100644 --- a/src/app/(withAuth)/dashboard/template.js +++ b/src/app/(withAuth)/dashboard/template.js @@ -1,17 +1,19 @@ -import {Box, Stack} from "@mui/material"; +import { Box, Stack } from "@mui/material"; import HeaderWithLogo from "@/components/layouts/dashboard/headerWithLogo"; import HeaderWithSidebar from "@/components/layouts/dashboard/headerWithSidebar"; import 'react-toastify/dist/ReactToastify.css'; -const Template = ({children}) => { - return ( - - - - {children} - - - ) +const Template = ({ children }) => { + return ( + + + + + {children} + + + + ) } export default Template \ No newline at end of file diff --git a/src/app/(withAuth)/layout.js b/src/app/(withAuth)/layout.js new file mode 100644 index 0000000..5a5cca8 --- /dev/null +++ b/src/app/(withAuth)/layout.js @@ -0,0 +1,14 @@ +import WithAuthMiddleware from "@/core/middlewares/withAuth" +import { AuthProvider } from "@/lib/contexts/auth" + +const Layout = ({ children }) => { + return ( + + + {children} + + + ) +} + +export default Layout \ No newline at end of file diff --git a/src/app/layout.js b/src/app/layout.js index c23a7ec..1d4819e 100644 --- a/src/app/layout.js +++ b/src/app/layout.js @@ -1,17 +1,17 @@ -import {TableSettingProvider} from "@/lib/contexts/tableSetting"; +import { TableSettingProvider } from "@/lib/contexts/tableSetting"; export const metadata = { title: 'سامانه جامع راهداری', } -export default function RootLayout({children}) { +export default function RootLayout({ children }) { return ( - - - {children} - - + + + {children} + + ) } diff --git a/src/app/lfwd/page.js b/src/app/lfwd/page.js new file mode 100644 index 0000000..55eca31 --- /dev/null +++ b/src/app/lfwd/page.js @@ -0,0 +1,51 @@ +'use client' + +import { GET_LOGIN_ROUTE } from "@/core/utils/routes" +import useRequest from "@/lib/hooks/useRequest" +import { Button, Stack, Typography, Zoom } from "@mui/material" +import Link from "next/link" +import { useEffect, useState } from "react" + +const Page = () => { + const [login, setLogin] = useState(0) + const request = useRequest() + + useEffect(() => { + const login = async () => { + try { + const res = await request(`${GET_LOGIN_ROUTE}?username=witel`) + setLogin(1) + } catch (error) { + setLogin(2) + } + } + + login() + }, []) + + const retry = async () => { + setLogin(0) + try { + const res = await request(`${GET_LOGIN_ROUTE}?username=witel`) + setLogin(1) + } catch (error) { + setLogin(2) + } + } + + + return ( + + + {login === 0 ? 'درحال دریافت مجوز برای ارتباط با سرور...' : login === 1 ? 'ارتباط با سرور برقرار شد.' : 'ارتباط با سرور برقرار نشد. مشکلی وجود دارد.'} + + + + + + + + + ) +} +export default Page \ No newline at end of file diff --git a/src/app/template.js b/src/app/template.js index 14f15b6..71830af 100644 --- a/src/app/template.js +++ b/src/app/template.js @@ -1,18 +1,18 @@ import cacheProviderRtl from "@/core/utils/cacheRtl"; -import {CssBaseline, ThemeProvider} from "@mui/material"; +import { CssBaseline, ThemeProvider } from "@mui/material"; import theme from "@/core/utils/theme"; -import {AppRouterCacheProvider} from "@mui/material-nextjs/v14-appRouter"; -import 'react-toastify/dist/ReactToastify.css'; +import { AppRouterCacheProvider } from "@mui/material-nextjs/v14-appRouter"; import "^/global.scss"; -import {ToastContainer} from "react-toastify"; +import { ToastContainer } from "react-toastify"; -const Template = ({children}) => { +const Template = ({ children }) => { return ( - + - + {children} - + + ) diff --git a/src/core/components/Toasts/error.jsx b/src/core/components/Toasts/error.jsx new file mode 100644 index 0000000..d0d9760 --- /dev/null +++ b/src/core/components/Toasts/error.jsx @@ -0,0 +1,191 @@ +import { toast } from "react-toastify"; +import { Box, Typography } from "@mui/material"; +import { Dangerous } from "@mui/icons-material"; + +export const errorServerToast = (toastContainer) => + toast.error( + () => ( + + + + + + {"The request failed due to an internal error."} + + + + + ), + { + icon: false, + containerId: toastContainer, + autoClose: 5000, + hideProgressBar: true, + pauseOnHover: true, + closeOnClick: false, + draggable: true, + } + ); + +export const errorUnauthorizedToast = (toastContainer) => + toast.error( + () => ( + + + + + + {"The user is not authorized to make the request."} + + + + + ), + { + icon: false, + containerId: toastContainer, + autoClose: 3000, + hideProgressBar: true, + pauseOnHover: true, + closeOnClick: false, + draggable: true, + } + ); + +export const errorLogicToast = (message, toastContainer) => + toast.error( + () => ( + + + + + + {message || + "The request was well-formed but was unable to be followed due to semantic errors."} + + + + + ), + { + icon: false, + containerId: toastContainer, + autoClose: false, + closeOnClick: false, + draggable: false, + } + ); + +export const errorValidationToast = (message, toastContainer) => + toast.error( + () => ( + + + + + + {message || + "The request was well-formed but was unable to be followed due to semantic errors."} + + + + + ), + { + icon: false, + containerId: toastContainer, + autoClose: false, + closeOnClick: false, + draggable: false, + } + ); + +export const errorTooManyToast = (toastContainer) => + toast.error( + () => ( + + + + + + {"Too many requests have been sent within a given time span."} + + + + + ), + { + icon: false, + containerId: toastContainer, + autoClose: false, + closeOnClick: false, + draggable: false, + } + ); + +export const errorClientToast = (toastContainer) => + toast.error( + () => ( + + + + + + { + "The API request is invalid or improperly formed. Consequently, the API server could not understand the request." + } + + + + + ), + { + icon: false, + containerId: toastContainer, + autoClose: false, + closeOnClick: false, + draggable: false, + } + ); diff --git a/src/core/components/Toasts/success.jsx b/src/core/components/Toasts/success.jsx new file mode 100644 index 0000000..b405a04 --- /dev/null +++ b/src/core/components/Toasts/success.jsx @@ -0,0 +1,35 @@ +import { toast } from "react-toastify"; +import { Box, Typography } from "@mui/material"; +import { Beenhere } from "@mui/icons-material"; + +export const successToast = (toastContainer) => + toast.success( + () => ( + + + + + + {"Your operation was successful"} + + + + + ), + { + icon: false, + containerId: toastContainer, + autoClose: 3000, + hideProgressBar: true, + pauseOnHover: true, + closeOnClick: false, + draggable: true, + } + ); diff --git a/src/core/middlewares/withAuth.js b/src/core/middlewares/withAuth.js new file mode 100644 index 0000000..1b93025 --- /dev/null +++ b/src/core/middlewares/withAuth.js @@ -0,0 +1,22 @@ +'use client' +import { useAuth } from "@/lib/contexts/auth"; +import { usePathname, useRouter } from "next/navigation"; +import { useEffect } from "react"; + +function WithAuthMiddleware({ children }) { + const router = useRouter() + const pathName = usePathname() + const { isAuth, initAuthState } = useAuth(); + + useEffect(() => { + if (!initAuthState) return + if (!isAuth) { + router.replace(`${process.env.NEXT_PUBLIC_API_URL}/login?_back=${encodeURIComponent(pathName)}`) + } + }, [isAuth, initAuthState]) + + if (!initAuthState || !isAuth) return null; + return <>{children} +} + +export default WithAuthMiddleware \ No newline at end of file diff --git a/src/core/utils/errorResponse.js b/src/core/utils/errorResponse.js new file mode 100644 index 0000000..3accb8f --- /dev/null +++ b/src/core/utils/errorResponse.js @@ -0,0 +1,61 @@ +'use client' +import { toast } from "react-toastify"; +import { + errorClientToast, + errorLogicToast, + errorServerToast, + errorTooManyToast, + errorUnauthorizedToast, + errorValidationToast +} from "@/core/components/toasts/error"; + +const isServerError = status => status >= 500 && status <= 599; +const isClientError = status => status >= 400 && status <= 499; + +const errorServer = (response, notification, toastContainer) => { + if (notification) errorServerToast(toastContainer) +} + +const errorClient = (response, notification, toastContainer) => { + switch (response.status) { + case 401: + if (notification) errorUnauthorizedToast(toastContainer) + break; + case 422: + if ('type' in response.data) { + if (Array.isArray(response.data.message)) { + response.data.message.map((item) => { + if (notification) errorLogicToast(item, toastContainer) + }) + } else { + if (notification) errorLogicToast(response.data.message, toastContainer) + } + break; + } + if (notification) { + const errorsMap = Object.keys(response.data.errors) + const errorsArray = response.data.errors + + errorsMap.map((item, index) => { + errorValidationToast(errorsArray[item][0], toastContainer); + }) + + } + break; + case 429: + if (notification) errorTooManyToast(toastContainer) + break + default: + if (notification) errorClientToast(toastContainer) + break + } +} + +export const errorResponse = (response, notification, toastContainer) => { + if (notification) toast.dismiss({ container: toastContainer }) + if (isServerError(response.status)) { + errorServer(response, notification, toastContainer) + } else if (isClientError(response.status)) { + errorClient(response, notification, toastContainer) + } +} diff --git a/src/core/utils/pageMenu.js b/src/core/utils/pageMenu.js index b97199a..81cb873 100644 --- a/src/core/utils/pageMenu.js +++ b/src/core/utils/pageMenu.js @@ -12,7 +12,7 @@ export const pageMenu = [ id: 'userManagement', label: 'مدیریت کاربران', type: "page", - route: "./v2/user_management", + route: process.env.NEXT_PUBLIC_API_URL + "/v2/user_management", icon: , }, { @@ -26,35 +26,35 @@ export const pageMenu = [ id: 'projectsManagmentFinance', label: 'ثبت قرارداد و پروژه', type: "page", - route: "./v2/rahdari_projects/finance", + route: process.env.NEXT_PUBLIC_API_URL + "/v2/rahdari_projects/finance", icon: , }, { id: 'projectsManagmentList', label: 'لیست پروژه ها', type: "page", - route: "./v2/rahdari_projects/projects_list", + route: process.env.NEXT_PUBLIC_API_URL + "/v2/rahdari_projects/projects_list", icon: , }, { id: 'projectsManagmentProposal', label: 'پروژه های پیشنهادی', type: "page", - route: "./v2/rahdari_projects/proposal", + route: process.env.NEXT_PUBLIC_API_URL + "/v2/rahdari_projects/proposal", icon: , }, { id: 'projectsManagmentLawmaker', label: 'درخواست نمایندگان', type: "page", - route: "./v2/rahdari_projects/lawmakers", + route: process.env.NEXT_PUBLIC_API_URL + "/v2/rahdari_projects/lawmakers", icon: , }, { id: 'projectsManagmentMap', label: 'پراکندگی بر روی نقشه', type: "page", - route: "./v2/map?type=rahdari_projects", + route: process.env.NEXT_PUBLIC_API_URL + "/v2/map?type=rahdari_projects", icon: , }, ] @@ -77,7 +77,7 @@ export const pageMenu = [ id: 'roadItemManagmentSupervisorCartable', label: 'کارتابل', type: "page", - route: "./v2/road_items/supervisor/cartable", + route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_items/supervisor/cartable", }, ] }, @@ -92,13 +92,13 @@ export const pageMenu = [ id: 'roadItemManagmentOparationCreate', label: 'ثبت فعالیت', type: "page", - route: "./v2/road_items/operator/create", + route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_items/operator/create", }, { id: 'roadItemManagmentOparationCartable', label: 'کارتابل', type: "page", - route: "./v2/road_items/operator/cartable", + route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_items/operator/cartable", }, ] }, @@ -106,14 +106,14 @@ export const pageMenu = [ id: 'roadItemManagmentMap', label: 'پراکندگی بر روی نقشه', type: "page", - route: "./v2/map?type=road_items", + route: process.env.NEXT_PUBLIC_API_URL + "/v2/map?type=road_items", icon: , }, { id: 'roadItemManagmentReport', label: 'گزارش ها', type: "page", - route: "./v2/road_items/report", + route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_items/report", icon: , }, ] @@ -136,7 +136,7 @@ export const pageMenu = [ id: 'roadPatrolManagmentSupervisorCartable', label: 'کارتابل', type: "page", - route: "./road_patrols/supervisor/cartable", + route: process.env.NEXT_PUBLIC_API_URL + "/road_patrols/supervisor/cartable", }, ] }, @@ -151,13 +151,13 @@ export const pageMenu = [ id: 'roadPatrolManagmentOparationCreate', label: 'ثبت اقدام', type: "page", - route: "./v2/road_patrols/operator/create", + route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_patrols/operator/create", }, { id: 'roadPatrolManagmentOparationCartable', label: 'کارتابل', type: "page", - route: "./v2/road_patrols/operator/cartable", + route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_patrols/operator/cartable", }, ] }, @@ -165,14 +165,14 @@ export const pageMenu = [ id: 'roadPatrolManagmentMap', label: 'پراکندگی بر روی نقشه', type: "page", - route: "./v2/map?type=road_patrols", + route: process.env.NEXT_PUBLIC_API_URL + "/v2/map?type=road_patrols", icon: , }, { id: 'roadPatrolManagmentReport', label: 'گزارش ها', type: "page", - route: "./v2/road_patrols/report", + route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_patrols/report", icon: , }, ] @@ -195,13 +195,13 @@ export const pageMenu = [ id: 'safetyAndPrivacyManagmentOparationCreate', label: 'ثبت فعالیت', type: "page", - route: "./safety_and_privacy/operator/first_step", + route: process.env.NEXT_PUBLIC_API_URL + "/safety_and_privacy/operator/first_step", }, { id: 'safetyAndPrivacyManagmentOparationCartable', label: 'کارتابل', type: "page", - route: "./v2/safety_and_privacy/operator/cartable", + route: process.env.NEXT_PUBLIC_API_URL + "/v2/safety_and_privacy/operator/cartable", }, ] }, @@ -209,14 +209,14 @@ export const pageMenu = [ id: 'safetyAndPrivacyManagmentMap', label: 'پراکندگی بر روی نقشه', type: "page", - route: "./v2/map?type=safety_and_privacy", + route: process.env.NEXT_PUBLIC_API_URL + "/v2/map?type=safety_and_privacy", icon: , }, { id: 'safetyAndPrivacyManagmentReport', label: 'گزارش ها', type: "page", - route: "./v2/safety_and_privacy/report", + route: process.env.NEXT_PUBLIC_API_URL + "/v2/safety_and_privacy/report", icon: , }, ] @@ -239,7 +239,7 @@ export const pageMenu = [ id: 'roadObservationsManagmentSupervisorCartable', label: 'کارتابل', type: "page", - route: "./v2/road_observations/supervisor/cartable", + route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_observations/supervisor/cartable", }, ] }, @@ -247,7 +247,7 @@ export const pageMenu = [ id: 'roadObservationsManagmentList', label: 'رسیدگی به شکایات', type: "page", - route: "./v2/road_observations", + route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_observations", icon: , }, { @@ -261,7 +261,7 @@ export const pageMenu = [ id: 'roadObservationsManagmentOparationCartable', label: 'کارتابل', type: "page", - route: "./v2/road_observations/operator/cartable", + route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_observations/operator/cartable", }, ] }, @@ -269,14 +269,14 @@ export const pageMenu = [ id: 'roadObservationsManagmentMap', label: 'پراکندگی بر روی نقشه', type: "page", - route: "./v2/map?type=road_observations", + route: process.env.NEXT_PUBLIC_API_URL + "/v2/map?type=road_observations", icon: , }, { id: 'roadObservationsManagmentReport', label: 'گزارش ها', type: "page", - route: "./v2/road_observations/report/index", + route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_observations/report/index", icon: , }, ] @@ -292,21 +292,21 @@ export const pageMenu = [ id: 'winterCampManagmentBlocking', label: 'محور های انسدادی', type: "page", - route: "./v2/winter_camp", + route: process.env.NEXT_PUBLIC_API_URL + "/v2/winter_camp", icon: , }, { id: 'winterCampManagmentFirstRing', label: 'محور های حلقه اول', type: "page", - route: "./v2/map?type=camp", + route: process.env.NEXT_PUBLIC_API_URL + "/v2/map?type=camp", icon: , }, { id: 'winterCampManagmentReport', label: 'گزارش ها', type: "page", - route: "./v2/map?type=campNew", + route: process.env.NEXT_PUBLIC_API_URL + "/v2/map?type=campNew", icon: , }, ] @@ -329,7 +329,7 @@ export const pageMenu = [ id: 'receiptManagmentOparationCartable', label: 'کارتابل', type: "page", - route: "./v2/receipt", + route: process.env.NEXT_PUBLIC_API_URL + "/v2/receipt", }, ] }, @@ -337,7 +337,7 @@ export const pageMenu = [ id: 'receiptManagmentReport', label: 'گزارش ها', type: "page", - route: "./v2/receipt/report", + route: process.env.NEXT_PUBLIC_API_URL + "/v2/receipt/report", icon: , }, ] diff --git a/src/core/utils/routes.js b/src/core/utils/routes.js new file mode 100644 index 0000000..39b6b09 --- /dev/null +++ b/src/core/utils/routes.js @@ -0,0 +1,4 @@ +const api = process.env.NEXT_PUBLIC_API_URL + +export const GET_USER_ROUTE = api + '/webapi/user/get-permission' +export const GET_LOGIN_ROUTE = api + '/test_login' \ No newline at end of file diff --git a/src/core/utils/successRequest.js b/src/core/utils/successRequest.js new file mode 100644 index 0000000..5138d7a --- /dev/null +++ b/src/core/utils/successRequest.js @@ -0,0 +1,10 @@ +'use client' +import { toast } from "react-toastify"; +import { successToast } from "@/core/components/toasts/success"; + +export const successRequest = (notification, toastContainer) => { + if (notification) { + toast.dismiss({ container: toastContainer }) + successToast(toastContainer) + } +} \ No newline at end of file diff --git a/src/lib/contexts/DataTable.jsx b/src/lib/contexts/DataTable.js similarity index 100% rename from src/lib/contexts/DataTable.jsx rename to src/lib/contexts/DataTable.js diff --git a/src/lib/contexts/auth.js b/src/lib/contexts/auth.js new file mode 100644 index 0000000..e60f413 --- /dev/null +++ b/src/lib/contexts/auth.js @@ -0,0 +1,76 @@ +'use client' +import { createContext, useCallback, useContext, useEffect, useReducer } from 'react'; +import useRequest from '../hooks/useRequest'; +import { GET_USER_ROUTE } from '@/core/utils/routes'; + +const initAuth = { + initAuthState: false, + isAuth: false, + user: {} +}; + +const authReducer = (state, action) => { + switch (action.type) { + case "CLEAR_USER": + return { ...state, user: {} }; + case "CHANGE_USER": + return { ...state, user: action.user }; + case "CHANGE_AUTH_STATE": + return { ...state, isAuth: action.isAuth }; + case "CHANGE_INIT_AUTH": + return { ...state, initAuthState: action.initAuthState }; + default: + return state; + } +}; + +const AuthContext = createContext(); + +export const AuthProvider = ({ children }) => { + const [state, dispatch] = useReducer(authReducer, initAuth); + const request = useRequest() + + const clearUser = useCallback(() => { + dispatch({ type: "CLEAR_USER" }); + }, []); + + const changeUser = useCallback((user) => { + dispatch({ type: "CHANGE_USER", user }); + }, []); + + const changeAuthState = useCallback((isAuth) => { + dispatch({ type: "CHANGE_AUTH_STATE", isAuth }); + }, []); + + const changeInitAuth = useCallback((initAuthState) => { + dispatch({ type: "CHANGE_INIT_AUTH", initAuthState }); + }, []); + + const getUser = useCallback(async () => { + try { + const { data } = await request(GET_USER_ROUTE, 'get') + changeUser(data); + changeAuthState(true); + changeInitAuth(true); + } catch (error) { + if (error.response && error.response.status === 401) { + clearUser(); + changeAuthState(false); + changeInitAuth(true); + } + } + }, [clearUser, changeUser, changeAuthState, changeInitAuth]); + + useEffect(() => { + getUser() + }, []) + + return {children}; +}; + +export const useAuth = () => useContext(AuthContext); \ No newline at end of file diff --git a/src/lib/contexts/tableSetting.jsx b/src/lib/contexts/tableSetting.js similarity index 100% rename from src/lib/contexts/tableSetting.jsx rename to src/lib/contexts/tableSetting.js diff --git a/src/lib/hooks/useDataTable.jsx b/src/lib/hooks/useDataTable.js similarity index 100% rename from src/lib/hooks/useDataTable.jsx rename to src/lib/hooks/useDataTable.js diff --git a/src/lib/hooks/useRequest.js b/src/lib/hooks/useRequest.js new file mode 100644 index 0000000..8beee2e --- /dev/null +++ b/src/lib/hooks/useRequest.js @@ -0,0 +1,42 @@ +import { errorResponse } from "@/core/utils/errorResponse"; +import { successRequest } from "@/core/utils/successRequest"; +import axios from "axios"; + +const defaultOptions = { + data: {}, + requestOptions: { + headers: {} + }, + notification: { + show: true, + success: false, + failed: true + }, +} + +const useRequest = (initOptions) => { + const _options = Object.assign({}, defaultOptions, initOptions); + + return async (url = '', method = 'get', options) => { + const mergedOptions = Object.assign({}, _options, options); + + try { + const response = await axios({ + url, + method, + data: method === 'get' ? null : mergedOptions.data, + withCredentials: true, + ...mergedOptions.requestOptions + }); + successRequest(mergedOptions.notification.show && mergedOptions.notification.success, 'request_data'); + return response; + } catch (error) { + if (error.response) { + errorResponse(error.response, mergedOptions.notification.show && mergedOptions.notification.failed, 'request_data'); + } + throw error; + } + } +} + +export default useRequest \ No newline at end of file diff --git a/src/lib/hooks/useTableSetting.jsx b/src/lib/hooks/useTableSetting.js similarity index 100% rename from src/lib/hooks/useTableSetting.jsx rename to src/lib/hooks/useTableSetting.js From bc73725138b24a732d9f58561ee4a5e29cdb5c1e Mon Sep 17 00:00:00 2001 From: Amirhossein Mahmoodi Date: Tue, 9 Jul 2024 13:58:13 +0330 Subject: [PATCH 03/13] formatted --- .eslintrc.json | 2 +- .prettierrc | 12 + editorconfig | 485 ------------------ package.json | 7 +- src/app/(withAuth)/dashboard/page.js | 24 +- src/app/(withAuth)/dashboard/template.js | 12 +- src/app/(withAuth)/layout.js | 14 +- src/app/default.js | 4 +- src/app/layout.js | 14 +- src/app/lfwd/page.js | 60 ++- src/app/page.js | 8 +- src/app/template.js | 6 +- src/components/home/Toolbar.jsx | 22 +- src/components/home/index.jsx | 109 ++-- .../headerWithLogo/HaederBottom/index.jsx | 51 +- .../headerWithLogo/HaederTop/index.jsx | 16 +- .../dashboard/headerWithLogo/index.jsx | 12 +- .../headerWithSidebar/HeaderMenu/index.jsx | 2 +- .../dashboard/headerWithSidebar/index.jsx | 164 +++--- src/core/components/DataTable/Main.js | 177 ++++--- .../components/DataTable/body/TableBody.js | 160 +++--- .../DataTable/body/TableBodyCell.js | 173 +++---- .../DataTable/body/TableBodyCellValue.js | 189 ++++--- .../components/DataTable/body/TableBodyRow.js | 179 +++---- .../DataTable/body/TableDetailPanel.js | 32 +- .../DataTable/buttons/CopyButton.js | 41 +- .../DataTable/buttons/GrabHandleButton.js | 36 +- .../buttons/ShowHideColumnsButton.js | 19 +- .../DataTable/buttons/ToggleFiltersButton.js | 6 +- .../DataTable/filter/FilterBody.jsx | 225 ++++---- .../DataTable/filter/FilterBodyField.jsx | 28 +- .../DataTable/filter/FilterButton.jsx | 19 +- .../DataTable/filter/FilterHeader.jsx | 26 +- .../DataTable/filter/FilterOptionList.jsx | 49 +- .../CustomDate/CustomDatePicker.jsx | 10 +- .../CustomDate/CustomDatePickerRange.jsx | 10 +- .../fieldsType/CustomDate/MuiDatePicker.jsx | 38 +- .../filter/fieldsType/CustomSelect.jsx | 19 +- .../fieldsType/CustomSelectMultiple.jsx | 30 +- .../filter/fieldsType/CustomTextField.jsx | 35 +- .../fieldsType/CustomTextFieldRange.jsx | 41 +- .../components/DataTable/filter/index.jsx | 18 +- .../components/DataTable/head/TableHead.js | 57 +- .../DataTable/head/TableHeadCell.js | 239 ++++----- .../components/DataTable/head/TableHeadRow.js | 44 +- src/core/components/DataTable/index.js | 4 +- .../DataTable/localization/fa/datatable.js | 5 +- .../DataTable/menus/ActionMenuItem.js | 32 +- .../DataTable/menus/CellActionMenu.js | 26 +- .../DataTable/menus/ShowHideColumnsMenu.js | 52 +- .../menus/ShowHideColumnsMenuItems.js | 42 +- .../DataTable/refactor/RefactorTable.jsx | 18 +- src/core/components/DataTable/table/Paper.js | 68 +-- src/core/components/DataTable/table/Table.js | 20 +- .../DataTable/table/TableContainer.js | 53 +- .../DataTable/table/TableLoadingOverlay.js | 22 +- .../DataTable/toolbar/BottomToolbar.js | 60 +-- .../DataTable/toolbar/LinearProgressBar.js | 16 +- .../DataTable/toolbar/TablePagination.js | 79 +-- .../toolbar/ToolbarInternalButtons.js | 31 +- .../DataTable/toolbar/TopToolbar.js | 83 +-- .../NotificationDesign/AskForKeep.jsx | 78 +-- src/core/components/SidebarListItems.jsx | 116 ++--- src/core/components/SidebarMenu.jsx | 224 ++++---- src/core/components/SidebarSubitems.jsx | 114 ++-- src/core/components/Toasts/error.jsx | 348 +++++++------ src/core/components/Toasts/success.jsx | 58 +-- src/core/middlewares/withAuth.js | 16 +- src/core/utils/cacheRtl.js | 12 +- src/core/utils/errorResponse.js | 47 +- src/core/utils/flattenArrayOfObjects.js | 2 +- src/core/utils/pageMenu.js | 288 +++++------ src/core/utils/routes.js | 6 +- src/core/utils/successRequest.js | 8 +- src/core/utils/theme.js | 18 +- src/core/utils/utils.js | 240 ++++----- src/lib/contexts/DataTable.js | 12 +- src/lib/contexts/auth.js | 38 +- src/lib/contexts/tableSetting.js | 85 +-- src/lib/hooks/useDataTable.js | 8 +- src/lib/hooks/useRequest.js | 26 +- src/lib/hooks/useTableSetting.js | 9 +- 82 files changed, 2206 insertions(+), 3082 deletions(-) create mode 100644 .prettierrc delete mode 100644 editorconfig diff --git a/.eslintrc.json b/.eslintrc.json index bffb357..121cefd 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,3 +1,3 @@ { - "extends": "next/core-web-vitals" + "extends": ["next/core-web-vitals","prettier"] } diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..7eeebb6 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,12 @@ +{ + "printWidth": 120, + "tabWidth": 4, + "useTabs": false, + "semi": true, + "singleQuote": false, + "trailingComma": "es5", + "bracketSpacing": true, + "jsxBracketSameLine": false, + "arrowParens": "always", + "endOfLine": "crlf" +} \ No newline at end of file diff --git a/editorconfig b/editorconfig deleted file mode 100644 index 05e5a39..0000000 --- a/editorconfig +++ /dev/null @@ -1,485 +0,0 @@ -root = true - -[*] -charset = utf-8 -end_of_line = crlf -indent_size = 4 -indent_style = space -insert_final_newline = false -max_line_length = 120 -tab_width = 4 -ij_continuation_indent_size = 4 -ij_formatter_off_tag = @formatter:off -ij_formatter_on_tag = @formatter:on -ij_formatter_tags_enabled = true -ij_smart_tabs = false -ij_visual_guides = none -ij_wrap_on_typing = false - -[*.css] -ij_css_align_closing_brace_with_properties = false -ij_css_blank_lines_around_nested_selector = 1 -ij_css_blank_lines_between_blocks = 1 -ij_css_block_comment_add_space = false -ij_css_brace_placement = end_of_line -ij_css_enforce_quotes_on_format = false -ij_css_hex_color_long_format = false -ij_css_hex_color_lower_case = false -ij_css_hex_color_short_format = false -ij_css_hex_color_upper_case = false -ij_css_keep_blank_lines_in_code = 2 -ij_css_keep_indents_on_empty_lines = false -ij_css_keep_single_line_blocks = false -ij_css_properties_order = font, font-family, font-size, font-weight, font-style, font-variant, font-size-adjust, font-stretch, line-height, position, z-index, top, right, bottom, left, display, visibility, float, clear, overflow, overflow-x, overflow-y, clip, zoom, align-content, align-items, align-self, flex, flex-flow, flex-basis, flex-direction, flex-grow, flex-shrink, flex-wrap, justify-content, order, box-sizing, width, min-width, max-width, height, min-height, max-height, margin, margin-top, margin-right, margin-bottom, margin-left, padding, padding-top, padding-right, padding-bottom, padding-left, table-layout, empty-cells, caption-side, border-spacing, border-collapse, list-style, list-style-position, list-style-type, list-style-image, content, quotes, counter-reset, counter-increment, resize, cursor, user-select, nav-index, nav-up, nav-right, nav-down, nav-left, transition, transition-delay, transition-timing-function, transition-duration, transition-property, transform, transform-origin, animation, animation-name, animation-duration, animation-play-state, animation-timing-function, animation-delay, animation-iteration-count, animation-direction, text-align, text-align-last, vertical-align, white-space, text-decoration, text-emphasis, text-emphasis-color, text-emphasis-style, text-emphasis-position, text-indent, text-justify, letter-spacing, word-spacing, text-outline, text-transform, text-wrap, text-overflow, text-overflow-ellipsis, text-overflow-mode, word-wrap, word-break, tab-size, hyphens, pointer-events, opacity, color, border, border-width, border-style, border-color, border-top, border-top-width, border-top-style, border-top-color, border-right, border-right-width, border-right-style, border-right-color, border-bottom, border-bottom-width, border-bottom-style, border-bottom-color, border-left, border-left-width, border-left-style, border-left-color, border-radius, border-top-left-radius, border-top-right-radius, border-bottom-right-radius, border-bottom-left-radius, border-image, border-image-source, border-image-slice, border-image-width, border-image-outset, border-image-repeat, outline, outline-width, outline-style, outline-color, outline-offset, background, background-color, background-image, background-repeat, background-attachment, background-position, background-position-x, background-position-y, background-clip, background-origin, background-size, box-decoration-break, box-shadow, text-shadow -ij_css_space_after_colon = true -ij_css_space_before_opening_brace = true -ij_css_use_double_quotes = true -ij_css_value_alignment = do_not_align - -[*.sass] -indent_size = 2 -ij_sass_align_closing_brace_with_properties = false -ij_sass_blank_lines_around_nested_selector = 1 -ij_sass_blank_lines_between_blocks = 1 -ij_sass_brace_placement = 0 -ij_sass_enforce_quotes_on_format = false -ij_sass_hex_color_long_format = false -ij_sass_hex_color_lower_case = false -ij_sass_hex_color_short_format = false -ij_sass_hex_color_upper_case = false -ij_sass_keep_blank_lines_in_code = 2 -ij_sass_keep_indents_on_empty_lines = false -ij_sass_keep_single_line_blocks = false -ij_sass_line_comment_add_space = false -ij_sass_line_comment_at_first_column = false -ij_sass_properties_order = font, font-family, font-size, font-weight, font-style, font-variant, font-size-adjust, font-stretch, line-height, position, z-index, top, right, bottom, left, display, visibility, float, clear, overflow, overflow-x, overflow-y, clip, zoom, align-content, align-items, align-self, flex, flex-flow, flex-basis, flex-direction, flex-grow, flex-shrink, flex-wrap, justify-content, order, box-sizing, width, min-width, max-width, height, min-height, max-height, margin, margin-top, margin-right, margin-bottom, margin-left, padding, padding-top, padding-right, padding-bottom, padding-left, table-layout, empty-cells, caption-side, border-spacing, border-collapse, list-style, list-style-position, list-style-type, list-style-image, content, quotes, counter-reset, counter-increment, resize, cursor, user-select, nav-index, nav-up, nav-right, nav-down, nav-left, transition, transition-delay, transition-timing-function, transition-duration, transition-property, transform, transform-origin, animation, animation-name, animation-duration, animation-play-state, animation-timing-function, animation-delay, animation-iteration-count, animation-direction, text-align, text-align-last, vertical-align, white-space, text-decoration, text-emphasis, text-emphasis-color, text-emphasis-style, text-emphasis-position, text-indent, text-justify, letter-spacing, word-spacing, text-outline, text-transform, text-wrap, text-overflow, text-overflow-ellipsis, text-overflow-mode, word-wrap, word-break, tab-size, hyphens, pointer-events, opacity, color, border, border-width, border-style, border-color, border-top, border-top-width, border-top-style, border-top-color, border-right, border-right-width, border-right-style, border-right-color, border-bottom, border-bottom-width, border-bottom-style, border-bottom-color, border-left, border-left-width, border-left-style, border-left-color, border-radius, border-top-left-radius, border-top-right-radius, border-bottom-right-radius, border-bottom-left-radius, border-image, border-image-source, border-image-slice, border-image-width, border-image-outset, border-image-repeat, outline, outline-width, outline-style, outline-color, outline-offset, background, background-color, background-image, background-repeat, background-attachment, background-position, background-position-x, background-position-y, background-clip, background-origin, background-size, box-decoration-break, box-shadow, text-shadow -ij_sass_space_after_colon = true -ij_sass_space_before_opening_brace = true -ij_sass_use_double_quotes = true -ij_sass_value_alignment = 0 - -[*.scss] -indent_size = 2 -ij_scss_align_closing_brace_with_properties = false -ij_scss_blank_lines_around_nested_selector = 1 -ij_scss_blank_lines_between_blocks = 1 -ij_scss_block_comment_add_space = false -ij_scss_brace_placement = 0 -ij_scss_enforce_quotes_on_format = false -ij_scss_hex_color_long_format = false -ij_scss_hex_color_lower_case = false -ij_scss_hex_color_short_format = false -ij_scss_hex_color_upper_case = false -ij_scss_keep_blank_lines_in_code = 2 -ij_scss_keep_indents_on_empty_lines = false -ij_scss_keep_single_line_blocks = false -ij_scss_line_comment_add_space = false -ij_scss_line_comment_at_first_column = false -ij_scss_properties_order = font, font-family, font-size, font-weight, font-style, font-variant, font-size-adjust, font-stretch, line-height, position, z-index, top, right, bottom, left, display, visibility, float, clear, overflow, overflow-x, overflow-y, clip, zoom, align-content, align-items, align-self, flex, flex-flow, flex-basis, flex-direction, flex-grow, flex-shrink, flex-wrap, justify-content, order, box-sizing, width, min-width, max-width, height, min-height, max-height, margin, margin-top, margin-right, margin-bottom, margin-left, padding, padding-top, padding-right, padding-bottom, padding-left, table-layout, empty-cells, caption-side, border-spacing, border-collapse, list-style, list-style-position, list-style-type, list-style-image, content, quotes, counter-reset, counter-increment, resize, cursor, user-select, nav-index, nav-up, nav-right, nav-down, nav-left, transition, transition-delay, transition-timing-function, transition-duration, transition-property, transform, transform-origin, animation, animation-name, animation-duration, animation-play-state, animation-timing-function, animation-delay, animation-iteration-count, animation-direction, text-align, text-align-last, vertical-align, white-space, text-decoration, text-emphasis, text-emphasis-color, text-emphasis-style, text-emphasis-position, text-indent, text-justify, letter-spacing, word-spacing, text-outline, text-transform, text-wrap, text-overflow, text-overflow-ellipsis, text-overflow-mode, word-wrap, word-break, tab-size, hyphens, pointer-events, opacity, color, border, border-width, border-style, border-color, border-top, border-top-width, border-top-style, border-top-color, border-right, border-right-width, border-right-style, border-right-color, border-bottom, border-bottom-width, border-bottom-style, border-bottom-color, border-left, border-left-width, border-left-style, border-left-color, border-radius, border-top-left-radius, border-top-right-radius, border-bottom-right-radius, border-bottom-left-radius, border-image, border-image-source, border-image-slice, border-image-width, border-image-outset, border-image-repeat, outline, outline-width, outline-style, outline-color, outline-offset, background, background-color, background-image, background-repeat, background-attachment, background-position, background-position-x, background-position-y, background-clip, background-origin, background-size, box-decoration-break, box-shadow, text-shadow -ij_scss_space_after_colon = true -ij_scss_space_before_opening_brace = true -ij_scss_use_double_quotes = true -ij_scss_value_alignment = 0 - -[{*.ats,*.cts,*.mts,*.ts}] -ij_continuation_indent_size = 4 -ij_typescript_align_imports = false -ij_typescript_align_multiline_array_initializer_expression = false -ij_typescript_align_multiline_binary_operation = false -ij_typescript_align_multiline_chained_methods = false -ij_typescript_align_multiline_extends_list = false -ij_typescript_align_multiline_for = true -ij_typescript_align_multiline_parameters = true -ij_typescript_align_multiline_parameters_in_calls = false -ij_typescript_align_multiline_ternary_operation = false -ij_typescript_align_object_properties = 0 -ij_typescript_align_union_types = false -ij_typescript_align_var_statements = 0 -ij_typescript_array_initializer_new_line_after_left_brace = false -ij_typescript_array_initializer_right_brace_on_new_line = false -ij_typescript_array_initializer_wrap = off -ij_typescript_assignment_wrap = off -ij_typescript_binary_operation_sign_on_next_line = false -ij_typescript_binary_operation_wrap = off -ij_typescript_blacklist_imports = rxjs/Rx, node_modules/**, **/node_modules/**, @angular/material, @angular/material/typings/** -ij_typescript_blank_lines_after_imports = 1 -ij_typescript_blank_lines_around_class = 1 -ij_typescript_blank_lines_around_field = 0 -ij_typescript_blank_lines_around_field_in_interface = 0 -ij_typescript_blank_lines_around_function = 1 -ij_typescript_blank_lines_around_method = 1 -ij_typescript_blank_lines_around_method_in_interface = 1 -ij_typescript_block_brace_style = end_of_line -ij_typescript_block_comment_add_space = false -ij_typescript_block_comment_at_first_column = true -ij_typescript_call_parameters_new_line_after_left_paren = false -ij_typescript_call_parameters_right_paren_on_new_line = false -ij_typescript_call_parameters_wrap = off -ij_typescript_catch_on_new_line = false -ij_typescript_chained_call_dot_on_new_line = true -ij_typescript_class_brace_style = end_of_line -ij_typescript_comma_on_new_line = false -ij_typescript_do_while_brace_force = never -ij_typescript_else_on_new_line = false -ij_typescript_enforce_trailing_comma = keep -ij_typescript_enum_constants_wrap = on_every_item -ij_typescript_extends_keyword_wrap = off -ij_typescript_extends_list_wrap = off -ij_typescript_field_prefix = _ -ij_typescript_file_name_style = relaxed -ij_typescript_finally_on_new_line = false -ij_typescript_for_brace_force = never -ij_typescript_for_statement_new_line_after_left_paren = false -ij_typescript_for_statement_right_paren_on_new_line = false -ij_typescript_for_statement_wrap = off -ij_typescript_force_quote_style = false -ij_typescript_force_semicolon_style = false -ij_typescript_function_expression_brace_style = end_of_line -ij_typescript_if_brace_force = never -ij_typescript_import_merge_members = global -ij_typescript_import_prefer_absolute_path = global -ij_typescript_import_sort_members = true -ij_typescript_import_sort_module_name = false -ij_typescript_import_use_node_resolution = true -ij_typescript_imports_wrap = on_every_item -ij_typescript_indent_case_from_switch = true -ij_typescript_indent_chained_calls = true -ij_typescript_indent_package_children = 0 -ij_typescript_jsdoc_include_types = false -ij_typescript_jsx_attribute_value = braces -ij_typescript_keep_blank_lines_in_code = 2 -ij_typescript_keep_first_column_comment = true -ij_typescript_keep_indents_on_empty_lines = false -ij_typescript_keep_line_breaks = true -ij_typescript_keep_simple_blocks_in_one_line = false -ij_typescript_keep_simple_methods_in_one_line = false -ij_typescript_line_comment_add_space = true -ij_typescript_line_comment_at_first_column = false -ij_typescript_method_brace_style = end_of_line -ij_typescript_method_call_chain_wrap = off -ij_typescript_method_parameters_new_line_after_left_paren = false -ij_typescript_method_parameters_right_paren_on_new_line = false -ij_typescript_method_parameters_wrap = off -ij_typescript_object_literal_wrap = on_every_item -ij_typescript_object_types_wrap = on_every_item -ij_typescript_parentheses_expression_new_line_after_left_paren = false -ij_typescript_parentheses_expression_right_paren_on_new_line = false -ij_typescript_place_assignment_sign_on_next_line = false -ij_typescript_prefer_as_type_cast = false -ij_typescript_prefer_explicit_types_function_expression_returns = false -ij_typescript_prefer_explicit_types_function_returns = false -ij_typescript_prefer_explicit_types_vars_fields = false -ij_typescript_prefer_parameters_wrap = false -ij_typescript_reformat_c_style_comments = false -ij_typescript_space_after_colon = true -ij_typescript_space_after_comma = true -ij_typescript_space_after_dots_in_rest_parameter = false -ij_typescript_space_after_generator_mult = true -ij_typescript_space_after_property_colon = true -ij_typescript_space_after_quest = true -ij_typescript_space_after_type_colon = true -ij_typescript_space_after_unary_not = false -ij_typescript_space_before_async_arrow_lparen = true -ij_typescript_space_before_catch_keyword = true -ij_typescript_space_before_catch_left_brace = true -ij_typescript_space_before_catch_parentheses = true -ij_typescript_space_before_class_lbrace = true -ij_typescript_space_before_class_left_brace = true -ij_typescript_space_before_colon = true -ij_typescript_space_before_comma = false -ij_typescript_space_before_do_left_brace = true -ij_typescript_space_before_else_keyword = true -ij_typescript_space_before_else_left_brace = true -ij_typescript_space_before_finally_keyword = true -ij_typescript_space_before_finally_left_brace = true -ij_typescript_space_before_for_left_brace = true -ij_typescript_space_before_for_parentheses = true -ij_typescript_space_before_for_semicolon = false -ij_typescript_space_before_function_left_parenth = true -ij_typescript_space_before_generator_mult = false -ij_typescript_space_before_if_left_brace = true -ij_typescript_space_before_if_parentheses = true -ij_typescript_space_before_method_call_parentheses = false -ij_typescript_space_before_method_left_brace = true -ij_typescript_space_before_method_parentheses = false -ij_typescript_space_before_property_colon = false -ij_typescript_space_before_quest = true -ij_typescript_space_before_switch_left_brace = true -ij_typescript_space_before_switch_parentheses = true -ij_typescript_space_before_try_left_brace = true -ij_typescript_space_before_type_colon = false -ij_typescript_space_before_unary_not = false -ij_typescript_space_before_while_keyword = true -ij_typescript_space_before_while_left_brace = true -ij_typescript_space_before_while_parentheses = true -ij_typescript_spaces_around_additive_operators = true -ij_typescript_spaces_around_arrow_function_operator = true -ij_typescript_spaces_around_assignment_operators = true -ij_typescript_spaces_around_bitwise_operators = true -ij_typescript_spaces_around_equality_operators = true -ij_typescript_spaces_around_logical_operators = true -ij_typescript_spaces_around_multiplicative_operators = true -ij_typescript_spaces_around_relational_operators = true -ij_typescript_spaces_around_shift_operators = true -ij_typescript_spaces_around_unary_operator = false -ij_typescript_spaces_within_array_initializer_brackets = false -ij_typescript_spaces_within_brackets = false -ij_typescript_spaces_within_catch_parentheses = false -ij_typescript_spaces_within_for_parentheses = false -ij_typescript_spaces_within_if_parentheses = false -ij_typescript_spaces_within_imports = false -ij_typescript_spaces_within_interpolation_expressions = false -ij_typescript_spaces_within_method_call_parentheses = false -ij_typescript_spaces_within_method_parentheses = false -ij_typescript_spaces_within_object_literal_braces = false -ij_typescript_spaces_within_object_type_braces = true -ij_typescript_spaces_within_parentheses = false -ij_typescript_spaces_within_switch_parentheses = false -ij_typescript_spaces_within_type_assertion = false -ij_typescript_spaces_within_union_types = true -ij_typescript_spaces_within_while_parentheses = false -ij_typescript_special_else_if_treatment = true -ij_typescript_ternary_operation_signs_on_next_line = false -ij_typescript_ternary_operation_wrap = off -ij_typescript_union_types_wrap = on_every_item -ij_typescript_use_chained_calls_group_indents = false -ij_typescript_use_double_quotes = true -ij_typescript_use_explicit_js_extension = auto -ij_typescript_use_path_mapping = always -ij_typescript_use_public_modifier = false -ij_typescript_use_semicolon_after_statement = true -ij_typescript_var_declaration_wrap = normal -ij_typescript_while_brace_force = never -ij_typescript_while_on_new_line = false -ij_typescript_wrap_comments = false - -[{*.cjs,*.js}] -ij_continuation_indent_size = 4 -ij_javascript_align_imports = false -ij_javascript_align_multiline_array_initializer_expression = false -ij_javascript_align_multiline_binary_operation = false -ij_javascript_align_multiline_chained_methods = false -ij_javascript_align_multiline_extends_list = false -ij_javascript_align_multiline_for = true -ij_javascript_align_multiline_parameters = true -ij_javascript_align_multiline_parameters_in_calls = false -ij_javascript_align_multiline_ternary_operation = false -ij_javascript_align_object_properties = 0 -ij_javascript_align_union_types = false -ij_javascript_align_var_statements = 0 -ij_javascript_array_initializer_new_line_after_left_brace = false -ij_javascript_array_initializer_right_brace_on_new_line = false -ij_javascript_array_initializer_wrap = off -ij_javascript_assignment_wrap = off -ij_javascript_binary_operation_sign_on_next_line = false -ij_javascript_binary_operation_wrap = off -ij_javascript_blacklist_imports = rxjs/Rx, node_modules/**, **/node_modules/**, @angular/material, @angular/material/typings/** -ij_javascript_blank_lines_after_imports = 1 -ij_javascript_blank_lines_around_class = 1 -ij_javascript_blank_lines_around_field = 0 -ij_javascript_blank_lines_around_function = 1 -ij_javascript_blank_lines_around_method = 1 -ij_javascript_block_brace_style = end_of_line -ij_javascript_block_comment_add_space = false -ij_javascript_block_comment_at_first_column = true -ij_javascript_call_parameters_new_line_after_left_paren = false -ij_javascript_call_parameters_right_paren_on_new_line = false -ij_javascript_call_parameters_wrap = off -ij_javascript_catch_on_new_line = false -ij_javascript_chained_call_dot_on_new_line = true -ij_javascript_class_brace_style = end_of_line -ij_javascript_comma_on_new_line = false -ij_javascript_do_while_brace_force = never -ij_javascript_else_on_new_line = false -ij_javascript_enforce_trailing_comma = keep -ij_javascript_extends_keyword_wrap = off -ij_javascript_extends_list_wrap = off -ij_javascript_field_prefix = _ -ij_javascript_file_name_style = relaxed -ij_javascript_finally_on_new_line = false -ij_javascript_for_brace_force = never -ij_javascript_for_statement_new_line_after_left_paren = false -ij_javascript_for_statement_right_paren_on_new_line = false -ij_javascript_for_statement_wrap = off -ij_javascript_force_quote_style = false -ij_javascript_force_semicolon_style = false -ij_javascript_function_expression_brace_style = end_of_line -ij_javascript_if_brace_force = never -ij_javascript_import_merge_members = global -ij_javascript_import_prefer_absolute_path = global -ij_javascript_import_sort_members = true -ij_javascript_import_sort_module_name = false -ij_javascript_import_use_node_resolution = true -ij_javascript_imports_wrap = on_every_item -ij_javascript_indent_case_from_switch = true -ij_javascript_indent_chained_calls = true -ij_javascript_indent_package_children = 0 -ij_javascript_jsx_attribute_value = braces -ij_javascript_keep_blank_lines_in_code = 2 -ij_javascript_keep_first_column_comment = true -ij_javascript_keep_indents_on_empty_lines = false -ij_javascript_keep_line_breaks = true -ij_javascript_keep_simple_blocks_in_one_line = false -ij_javascript_keep_simple_methods_in_one_line = false -ij_javascript_line_comment_add_space = true -ij_javascript_line_comment_at_first_column = false -ij_javascript_method_brace_style = end_of_line -ij_javascript_method_call_chain_wrap = off -ij_javascript_method_parameters_new_line_after_left_paren = false -ij_javascript_method_parameters_right_paren_on_new_line = false -ij_javascript_method_parameters_wrap = off -ij_javascript_object_literal_wrap = on_every_item -ij_javascript_object_types_wrap = on_every_item -ij_javascript_parentheses_expression_new_line_after_left_paren = false -ij_javascript_parentheses_expression_right_paren_on_new_line = false -ij_javascript_place_assignment_sign_on_next_line = false -ij_javascript_prefer_as_type_cast = false -ij_javascript_prefer_explicit_types_function_expression_returns = false -ij_javascript_prefer_explicit_types_function_returns = false -ij_javascript_prefer_explicit_types_vars_fields = false -ij_javascript_prefer_parameters_wrap = false -ij_javascript_reformat_c_style_comments = false -ij_javascript_space_after_colon = true -ij_javascript_space_after_comma = true -ij_javascript_space_after_dots_in_rest_parameter = false -ij_javascript_space_after_generator_mult = true -ij_javascript_space_after_property_colon = true -ij_javascript_space_after_quest = true -ij_javascript_space_after_type_colon = true -ij_javascript_space_after_unary_not = false -ij_javascript_space_before_async_arrow_lparen = true -ij_javascript_space_before_catch_keyword = true -ij_javascript_space_before_catch_left_brace = true -ij_javascript_space_before_catch_parentheses = true -ij_javascript_space_before_class_lbrace = true -ij_javascript_space_before_class_left_brace = true -ij_javascript_space_before_colon = true -ij_javascript_space_before_comma = false -ij_javascript_space_before_do_left_brace = true -ij_javascript_space_before_else_keyword = true -ij_javascript_space_before_else_left_brace = true -ij_javascript_space_before_finally_keyword = true -ij_javascript_space_before_finally_left_brace = true -ij_javascript_space_before_for_left_brace = true -ij_javascript_space_before_for_parentheses = true -ij_javascript_space_before_for_semicolon = false -ij_javascript_space_before_function_left_parenth = true -ij_javascript_space_before_generator_mult = false -ij_javascript_space_before_if_left_brace = true -ij_javascript_space_before_if_parentheses = true -ij_javascript_space_before_method_call_parentheses = false -ij_javascript_space_before_method_left_brace = true -ij_javascript_space_before_method_parentheses = false -ij_javascript_space_before_property_colon = false -ij_javascript_space_before_quest = true -ij_javascript_space_before_switch_left_brace = true -ij_javascript_space_before_switch_parentheses = true -ij_javascript_space_before_try_left_brace = true -ij_javascript_space_before_type_colon = false -ij_javascript_space_before_unary_not = false -ij_javascript_space_before_while_keyword = true -ij_javascript_space_before_while_left_brace = true -ij_javascript_space_before_while_parentheses = true -ij_javascript_spaces_around_additive_operators = true -ij_javascript_spaces_around_arrow_function_operator = true -ij_javascript_spaces_around_assignment_operators = true -ij_javascript_spaces_around_bitwise_operators = true -ij_javascript_spaces_around_equality_operators = true -ij_javascript_spaces_around_logical_operators = true -ij_javascript_spaces_around_multiplicative_operators = true -ij_javascript_spaces_around_relational_operators = true -ij_javascript_spaces_around_shift_operators = true -ij_javascript_spaces_around_unary_operator = false -ij_javascript_spaces_within_array_initializer_brackets = false -ij_javascript_spaces_within_brackets = false -ij_javascript_spaces_within_catch_parentheses = false -ij_javascript_spaces_within_for_parentheses = false -ij_javascript_spaces_within_if_parentheses = false -ij_javascript_spaces_within_imports = false -ij_javascript_spaces_within_interpolation_expressions = false -ij_javascript_spaces_within_method_call_parentheses = false -ij_javascript_spaces_within_method_parentheses = false -ij_javascript_spaces_within_object_literal_braces = false -ij_javascript_spaces_within_object_type_braces = true -ij_javascript_spaces_within_parentheses = false -ij_javascript_spaces_within_switch_parentheses = false -ij_javascript_spaces_within_type_assertion = false -ij_javascript_spaces_within_union_types = true -ij_javascript_spaces_within_while_parentheses = false -ij_javascript_special_else_if_treatment = true -ij_javascript_ternary_operation_signs_on_next_line = false -ij_javascript_ternary_operation_wrap = off -ij_javascript_union_types_wrap = on_every_item -ij_javascript_use_chained_calls_group_indents = false -ij_javascript_use_double_quotes = true -ij_javascript_use_explicit_js_extension = auto -ij_javascript_use_path_mapping = always -ij_javascript_use_public_modifier = false -ij_javascript_use_semicolon_after_statement = true -ij_javascript_var_declaration_wrap = normal -ij_javascript_while_brace_force = never -ij_javascript_while_on_new_line = false -ij_javascript_wrap_comments = false - -[{*.har,*.jsb2,*.jsb3,*.json,.babelrc,.eslintrc,.prettierrc,.stylelintrc,bowerrc,jest.config}] -indent_size = 2 -ij_json_array_wrapping = split_into_lines -ij_json_keep_blank_lines_in_code = 0 -ij_json_keep_indents_on_empty_lines = false -ij_json_keep_line_breaks = true -ij_json_keep_trailing_comma = false -ij_json_object_wrapping = split_into_lines -ij_json_property_alignment = do_not_align -ij_json_space_after_colon = true -ij_json_space_after_comma = true -ij_json_space_before_colon = false -ij_json_space_before_comma = false -ij_json_spaces_within_braces = false -ij_json_spaces_within_brackets = false -ij_json_wrap_long_lines = false - -[{*.htm,*.html,*.ng,*.sht,*.shtm,*.shtml}] -ij_html_add_new_line_before_tags = body, div, p, form, h1, h2, h3 -ij_html_align_attributes = true -ij_html_align_text = false -ij_html_attribute_wrap = normal -ij_html_block_comment_add_space = false -ij_html_block_comment_at_first_column = true -ij_html_do_not_align_children_of_min_lines = 0 -ij_html_do_not_break_if_inline_tags = title, h1, h2, h3, h4, h5, h6, p -ij_html_do_not_indent_children_of_tags = html, body, thead, tbody, tfoot -ij_html_enforce_quotes = false -ij_html_inline_tags = a, abbr, acronym, b, basefont, bdo, big, br, cite, cite, code, dfn, em, font, i, img, input, kbd, label, q, s, samp, select, small, span, strike, strong, sub, sup, textarea, tt, u, var -ij_html_keep_blank_lines = 2 -ij_html_keep_indents_on_empty_lines = false -ij_html_keep_line_breaks = true -ij_html_keep_line_breaks_in_text = true -ij_html_keep_whitespaces = false -ij_html_keep_whitespaces_inside = span, pre, textarea -ij_html_line_comment_at_first_column = true -ij_html_new_line_after_last_attribute = never -ij_html_new_line_before_first_attribute = never -ij_html_quote_style = double -ij_html_remove_new_line_before_tags = br -ij_html_space_after_tag_name = false -ij_html_space_around_equality_in_attribute = false -ij_html_space_inside_empty_tag = false -ij_html_text_wrap = normal - -[{*.markdown,*.md}] -ij_markdown_force_one_space_after_blockquote_symbol = true -ij_markdown_force_one_space_after_header_symbol = true -ij_markdown_force_one_space_after_list_bullet = true -ij_markdown_force_one_space_between_words = true -ij_markdown_format_tables = true -ij_markdown_insert_quote_arrows_on_wrap = true -ij_markdown_keep_indents_on_empty_lines = false -ij_markdown_keep_line_breaks_inside_text_blocks = true -ij_markdown_max_lines_around_block_elements = 1 -ij_markdown_max_lines_around_header = 1 -ij_markdown_max_lines_between_paragraphs = 1 -ij_markdown_min_lines_around_block_elements = 1 -ij_markdown_min_lines_around_header = 1 -ij_markdown_min_lines_between_paragraphs = 1 -ij_markdown_wrap_text_if_long = true -ij_markdown_wrap_text_inside_blockquotes = true diff --git a/package.json b/package.json index 4beef0b..b7f9320 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,8 @@ "dev": "next dev", "build": "next build", "start": "next start", - "lint": "next lint" + "lint": "next lint", + "format": "prettier --write \"src/**/*.{js,jsx,ts,tsx,html,css,scss}\"" }, "dependencies": { "@emotion/cache": "^11.11.0", @@ -35,6 +36,8 @@ }, "devDependencies": { "eslint": "^8", - "eslint-config-next": "14.1.0" + "eslint-config-next": "14.1.0", + "eslint-config-prettier": "^9.1.0", + "prettier": "^3.3.2" } } diff --git a/src/app/(withAuth)/dashboard/page.js b/src/app/(withAuth)/dashboard/page.js index 915b3de..c06d81d 100644 --- a/src/app/(withAuth)/dashboard/page.js +++ b/src/app/(withAuth)/dashboard/page.js @@ -1,29 +1,33 @@ -'use client' -import { Button } from "@mui/material" -import axios from "axios" +"use client"; +import { Button } from "@mui/material"; +import axios from "axios"; const Page = () => { const handler = () => { try { - axios.get('https://rms.witel.ir/test_login?username=witel', { withCredentials: true }) + axios.get("https://rms.witel.ir/test_login?username=witel", { + withCredentials: true, + }); } catch (error) { console.log(error); } - } + }; const handler2 = () => { try { - const res = axios.get('https://rms.witel.ir/webapi/user/get-permission', { withCredentials: true }) + const res = axios.get("https://rms.witel.ir/webapi/user/get-permission", { + withCredentials: true, + }); console.log(res); } catch (error) { console.log(error); } - } + }; return ( <> - ) -} + ); +}; -export default Page \ No newline at end of file +export default Page; diff --git a/src/app/(withAuth)/dashboard/template.js b/src/app/(withAuth)/dashboard/template.js index eb7d2ef..28b4ea0 100644 --- a/src/app/(withAuth)/dashboard/template.js +++ b/src/app/(withAuth)/dashboard/template.js @@ -1,19 +1,17 @@ import { Box, Stack } from "@mui/material"; import HeaderWithLogo from "@/components/layouts/dashboard/headerWithLogo"; import HeaderWithSidebar from "@/components/layouts/dashboard/headerWithSidebar"; -import 'react-toastify/dist/ReactToastify.css'; +import "react-toastify/dist/ReactToastify.css"; const Template = ({ children }) => { return ( - - {children} - + {children} - ) -} + ); +}; -export default Template \ No newline at end of file +export default Template; diff --git a/src/app/(withAuth)/layout.js b/src/app/(withAuth)/layout.js index 5a5cca8..400bbc9 100644 --- a/src/app/(withAuth)/layout.js +++ b/src/app/(withAuth)/layout.js @@ -1,14 +1,12 @@ -import WithAuthMiddleware from "@/core/middlewares/withAuth" -import { AuthProvider } from "@/lib/contexts/auth" +import WithAuthMiddleware from "@/core/middlewares/withAuth"; +import { AuthProvider } from "@/lib/contexts/auth"; const Layout = ({ children }) => { return ( - - {children} - + {children} - ) -} + ); +}; -export default Layout \ No newline at end of file +export default Layout; diff --git a/src/app/default.js b/src/app/default.js index 73d13c1..d157a71 100644 --- a/src/app/default.js +++ b/src/app/default.js @@ -1,3 +1,3 @@ export default function Default() { - return null -} \ No newline at end of file + return null; +} diff --git a/src/app/layout.js b/src/app/layout.js index 1d4819e..64aea89 100644 --- a/src/app/layout.js +++ b/src/app/layout.js @@ -1,17 +1,15 @@ import { TableSettingProvider } from "@/lib/contexts/tableSetting"; export const metadata = { - title: 'سامانه جامع راهداری', -} + title: "سامانه جامع راهداری", +}; export default function RootLayout({ children }) { return ( - - - - {children} - + + + {children} - ) + ); } diff --git a/src/app/lfwd/page.js b/src/app/lfwd/page.js index 55eca31..b3456a3 100644 --- a/src/app/lfwd/page.js +++ b/src/app/lfwd/page.js @@ -1,51 +1,57 @@ -'use client' +"use client"; -import { GET_LOGIN_ROUTE } from "@/core/utils/routes" -import useRequest from "@/lib/hooks/useRequest" -import { Button, Stack, Typography, Zoom } from "@mui/material" -import Link from "next/link" -import { useEffect, useState } from "react" +import { GET_LOGIN_ROUTE } from "@/core/utils/routes"; +import useRequest from "@/lib/hooks/useRequest"; +import { Button, Stack, Typography, Zoom } from "@mui/material"; +import Link from "next/link"; +import { useEffect, useState } from "react"; -const Page = () => { - const [login, setLogin] = useState(0) - const request = useRequest() +const Page = ({ searchParams }) => { + const { username } = searchParams; + const [login, setLogin] = useState(0); + const request = useRequest(); useEffect(() => { const login = async () => { try { - const res = await request(`${GET_LOGIN_ROUTE}?username=witel`) - setLogin(1) + await request(`${GET_LOGIN_ROUTE}?username=${username}`); + setLogin(1); } catch (error) { - setLogin(2) + setLogin(2); } - } + }; - login() - }, []) + login(); + }, []); const retry = async () => { - setLogin(0) + setLogin(0); try { - const res = await request(`${GET_LOGIN_ROUTE}?username=witel`) - setLogin(1) + await request(`${GET_LOGIN_ROUTE}?username=${username}`); + setLogin(1); } catch (error) { - setLogin(2) + setLogin(2); } - } - + }; return ( - + - {login === 0 ? 'درحال دریافت مجوز برای ارتباط با سرور...' : login === 1 ? 'ارتباط با سرور برقرار شد.' : 'ارتباط با سرور برقرار نشد. مشکلی وجود دارد.'} + {login === 0 + ? "درحال دریافت مجوز برای ارتباط با سرور..." + : login === 1 + ? "ارتباط با سرور برقرار شد." + : "ارتباط با سرور برقرار نشد. مشکلی وجود دارد."} - + - ) -} -export default Page \ No newline at end of file + ); +}; +export default Page; diff --git a/src/app/page.js b/src/app/page.js index 3fab3b7..2997c35 100644 --- a/src/app/page.js +++ b/src/app/page.js @@ -1,8 +1,8 @@ -import { redirect } from "next/navigation" +import { redirect } from "next/navigation"; function Page() { - redirect('/dashboard', 'replace') - return null + redirect("/dashboard", "replace"); + return null; } -export default Page \ No newline at end of file +export default Page; diff --git a/src/app/template.js b/src/app/template.js index 71830af..3ffc656 100644 --- a/src/app/template.js +++ b/src/app/template.js @@ -15,7 +15,7 @@ const Template = ({ children }) => { - ) -} + ); +}; -export default Template \ No newline at end of file +export default Template; diff --git a/src/components/home/Toolbar.jsx b/src/components/home/Toolbar.jsx index 1270b92..82f2646 100644 --- a/src/components/home/Toolbar.jsx +++ b/src/components/home/Toolbar.jsx @@ -1,22 +1,10 @@ -import {Button} from "@mui/material"; +import { Button } from "@mui/material"; -const Toolbar = ({columns}) => { +const Toolbar = ({ columns }) => { return ( <> - ) -} -export default Toolbar - - - - - - - - - - - - + ); +}; +export default Toolbar; diff --git a/src/components/home/index.jsx b/src/components/home/index.jsx index 090a572..7344232 100644 --- a/src/components/home/index.jsx +++ b/src/components/home/index.jsx @@ -1,149 +1,128 @@ -'use client' +"use client"; import DataTable from "@/core/components/DataTable"; -import {useMemo} from "react"; +import { useMemo } from "react"; function HomeComponent() { const columns = useMemo( () => [ { - accessorKey: 'fullname', - header: 'نام کامل', + accessorKey: "fullname", + header: "نام کامل", id: "fullname", columns: [ { - accessorKey: 'name.firstName', - header: 'نام', + accessorKey: "name.firstName", + header: "نام", id: "firstName", enableColumnFilter: true, datatype: "text", filterFn: "contains", enableClickToCopy: true, - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains" - ], + columnFilterModeOptions: ["equals", "notEquals", "contains"], }, { - accessorKey: 'name.lastName', - header: 'نام خانوادگی', + accessorKey: "name.lastName", + header: "نام خانوادگی", id: "lastName", enableColumnFilter: true, datatype: "text", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains" - ], + columnFilterModeOptions: ["equals", "notEquals", "contains"], }, ], }, { - accessorKey: 'address', - header: 'آدرس', + accessorKey: "address", + header: "آدرس", id: "address", enableColumnFilter: true, datatype: "text", filterFn: "notEquals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains" - ], + columnFilterModeOptions: ["equals", "notEquals", "contains"], }, { - accessorKey: 'city', - header: 'شهر', + accessorKey: "city", + header: "شهر", id: "city", enableColumnFilter: true, datatype: "text", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "fuzzy" - ], + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "fuzzy"], }, { - accessorKey: 'state', - header: 'وضعیت', + accessorKey: "state", + header: "وضعیت", id: "state", enableColumnFilter: true, datatype: "text", filterFn: "contains", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains" - ], + columnFilterModeOptions: ["equals", "notEquals", "contains"], }, { - accessorKey: 'price', - header: 'محدوده', + accessorKey: "price", + header: "محدوده", id: "price", enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - ], + columnFilterModeOptions: ["equals", "notEquals"], }, { - accessorKey: 'created_at', - header: 'تاریخ ساخت', + accessorKey: "created_at", + header: "تاریخ ساخت", id: "created_at", enableColumnFilter: true, datatype: "date", filterFn: "between", }, { - accessorKey: 'updated_at', - header: 'تاریخ بروزرسانی', + accessorKey: "updated_at", + header: "تاریخ بروزرسانی", id: "updated_at", enableColumnFilter: true, datatype: "date", filterFn: "equals", }, { - accessorKey: 'company', - header: 'نام شرکت', + accessorKey: "company", + header: "نام شرکت", id: "company", enableColumnFilter: true, datatype: "numeric", filterFn: "equals", columnSelectOption: [ - {value: 1, label: "وایتل"}, - {value: 2, label: "اسنپ"}, - {value: 3, label: "تپسی"} + { value: 1, label: "وایتل" }, + { value: 2, label: "اسنپ" }, + { value: 3, label: "تپسی" }, ], }, { - accessorKey: 'area', - header: 'منطقه', + accessorKey: "area", + header: "منطقه", id: "area", enableColumnFilter: true, datatype: "array", filterFn: "equals", columnSelectOption: [ - {value: 1, label: "وایتل"}, - {value: 2, label: "اسنپ"}, - {value: 3, label: "تپسی"} + { value: 1, label: "وایتل" }, + { value: 2, label: "اسنپ" }, + { value: 3, label: "تپسی" }, ], }, ], - [], + [] ); return ( <> - + - ); } diff --git a/src/components/layouts/dashboard/headerWithLogo/HaederBottom/index.jsx b/src/components/layouts/dashboard/headerWithLogo/HaederBottom/index.jsx index 501dadc..62ec234 100644 --- a/src/components/layouts/dashboard/headerWithLogo/HaederBottom/index.jsx +++ b/src/components/layouts/dashboard/headerWithLogo/HaederBottom/index.jsx @@ -3,38 +3,25 @@ import { Stack, Typography } from "@mui/material"; import Image from "next/image"; const HeaderBottom = () => { - return ( - theme.palette.primary2.main, - }} - spacing={4} - alignItems={"center"} - direction={"row"} - > - - - theme.palette.primary2.contrastText }} + return ( + theme.palette.primary2.main, + }} + spacing={4} + alignItems={"center"} + direction={"row"} > - سامانه جامع راهداری - - theme.palette.primary2.contrastText }} - > - rms.rmto.ir - - - - ); + + + theme.palette.primary2.contrastText }}> + سامانه جامع راهداری + + theme.palette.primary2.contrastText }}>rms.rmto.ir + + + ); }; export default HeaderBottom; diff --git a/src/components/layouts/dashboard/headerWithLogo/HaederTop/index.jsx b/src/components/layouts/dashboard/headerWithLogo/HaederTop/index.jsx index 27cd26a..6899881 100644 --- a/src/components/layouts/dashboard/headerWithLogo/HaederTop/index.jsx +++ b/src/components/layouts/dashboard/headerWithLogo/HaederTop/index.jsx @@ -2,16 +2,10 @@ import { Stack } from "@mui/material"; import Image from "next/image"; const HeaderTop = () => { - return ( - - - - ); + return ( + + + + ); }; export default HeaderTop; diff --git a/src/components/layouts/dashboard/headerWithLogo/index.jsx b/src/components/layouts/dashboard/headerWithLogo/index.jsx index f628e49..16ef4b2 100644 --- a/src/components/layouts/dashboard/headerWithLogo/index.jsx +++ b/src/components/layouts/dashboard/headerWithLogo/index.jsx @@ -3,11 +3,11 @@ import HeaderTop from "./HaederTop"; import HeaderBottom from "./HaederBottom"; const HeaderWithLogo = () => { - return ( - - - - - ); + return ( + + + + + ); }; export default HeaderWithLogo; diff --git a/src/components/layouts/dashboard/headerWithSidebar/HeaderMenu/index.jsx b/src/components/layouts/dashboard/headerWithSidebar/HeaderMenu/index.jsx index 01fd681..c705242 100644 --- a/src/components/layouts/dashboard/headerWithSidebar/HeaderMenu/index.jsx +++ b/src/components/layouts/dashboard/headerWithSidebar/HeaderMenu/index.jsx @@ -1,4 +1,4 @@ const HeaderMenu = () => { - return <>منو; + return <>منو; }; export default HeaderMenu; diff --git a/src/components/layouts/dashboard/headerWithSidebar/index.jsx b/src/components/layouts/dashboard/headerWithSidebar/index.jsx index be0a284..c8febb6 100644 --- a/src/components/layouts/dashboard/headerWithSidebar/index.jsx +++ b/src/components/layouts/dashboard/headerWithSidebar/index.jsx @@ -9,108 +9,102 @@ import HeaderMenu from "./HeaderMenu"; const drawerWidth = 300; -const Main = styled(Paper, { shouldForwardProp: (prop) => prop !== "open" })( - ({ theme, open }) => ({ +const Main = styled(Paper, { shouldForwardProp: (prop) => prop !== "open" })(({ theme, open }) => ({ flexGrow: 1, transition: theme.transitions.create("margin", { - easing: theme.transitions.easing.sharp, - duration: theme.transitions.duration.leavingScreen, + easing: theme.transitions.easing.sharp, + duration: theme.transitions.duration.leavingScreen, }), marginLeft: `-${drawerWidth}px`, ...(open && { - transition: theme.transitions.create("margin", { - easing: theme.transitions.easing.easeOut, - duration: theme.transitions.duration.enteringScreen, - }), - marginLeft: 0, + transition: theme.transitions.create("margin", { + easing: theme.transitions.easing.easeOut, + duration: theme.transitions.duration.enteringScreen, + }), + marginLeft: 0, }), - }) -); +})); const AppBar = styled(MuiAppBar, { - shouldForwardProp: (prop) => prop !== "open", + shouldForwardProp: (prop) => prop !== "open", })(({ theme, open }) => ({ - transition: theme.transitions.create(["margin", "width"], { - easing: theme.transitions.easing.sharp, - duration: theme.transitions.duration.leavingScreen, - }), - ...(open && { - width: `calc(100% - ${drawerWidth}px)`, - marginLeft: `${drawerWidth}px`, transition: theme.transitions.create(["margin", "width"], { - easing: theme.transitions.easing.easeOut, - duration: theme.transitions.duration.enteringScreen, + easing: theme.transitions.easing.sharp, + duration: theme.transitions.duration.leavingScreen, + }), + ...(open && { + width: `calc(100% - ${drawerWidth}px)`, + marginLeft: `${drawerWidth}px`, + transition: theme.transitions.create(["margin", "width"], { + easing: theme.transitions.easing.easeOut, + duration: theme.transitions.duration.enteringScreen, + }), }), - }), })); const DrawerHeader = styled("div")(({ theme }) => ({ - display: "flex", - alignItems: "center", - padding: theme.spacing(0, 1), - ...theme.mixins.toolbar, - justifyContent: "flex-end", + display: "flex", + alignItems: "center", + padding: theme.spacing(0, 1), + ...theme.mixins.toolbar, + justifyContent: "flex-end", })); const HeaderWithSidebar = ({ children }) => { - const [open, setOpen] = useState(true); + const [open, setOpen] = useState(true); - const handleDrawerOpen = () => { - setOpen(true); - }; - const handleDrawerClose = () => { - setOpen(false); - }; - return ( - - - - - - - - - - - - - - - - - - - -
- - {children} -
-
- ); + const handleDrawerOpen = () => { + setOpen(true); + }; + const handleDrawerClose = () => { + setOpen(false); + }; + return ( + + + + + + + + + + + + + + + + + + + +
+ + {children} +
+
+ ); }; export default HeaderWithSidebar; diff --git a/src/core/components/DataTable/Main.js b/src/core/components/DataTable/Main.js index ec33f55..db8aebd 100644 --- a/src/core/components/DataTable/Main.js +++ b/src/core/components/DataTable/Main.js @@ -1,91 +1,96 @@ import DataTable_Paper from "./table/Paper"; -import {useMaterialReactTable} from "material-react-table"; -import {FA_DATATABLE_LOCALIZATION} from "./localization/fa/datatable"; +import { useMaterialReactTable } from "material-react-table"; +import { FA_DATATABLE_LOCALIZATION } from "./localization/fa/datatable"; import useTableSetting from "@/lib/hooks/useTableSetting"; -import {flattenArrayOfObjects} from "@/core/utils/flattenArrayOfObjects"; +import { flattenArrayOfObjects } from "@/core/utils/flattenArrayOfObjects"; import Toolbar from "@/components/home/Toolbar"; import useDataTable from "@/lib/hooks/useDataTable"; -import {useMemo, useState} from "react"; +import { useMemo, useState } from "react"; const data = [ { name: { - firstName: 'امین', - lastName: 'قاسمپور', + firstName: "امین", + lastName: "قاسمپور", }, - address: 'فلان جا', - city: 'تهران', - state: 'بررسی شده', - price: '20', - updated_at: '2024/05/02', - company: 'همراه اول', - area: 'منطقه 5', + address: "فلان جا", + city: "تهران", + state: "بررسی شده", + price: "20", + updated_at: "2024/05/02", + company: "همراه اول", + area: "منطقه 5", }, { name: { - firstName: 'امیر حسین', - lastName: 'محمودی', + firstName: "امیر حسین", + lastName: "محمودی", }, - address: 'فلان جا', - city: 'تهران', - state: 'تکمیل شده', - price: '27', - updated_at: '2024/05/02', - company: 'وایتل', - area: 'منطقه 27', + address: "فلان جا", + city: "تهران", + state: "تکمیل شده", + price: "27", + updated_at: "2024/05/02", + company: "وایتل", + area: "منطقه 27", }, { name: { - firstName: 'یاسمن', - lastName: 'علی اکبری', + firstName: "یاسمن", + lastName: "علی اکبری", }, - address: 'فلان جا', - city: 'شیراز', - state: 'بررسی شده', - price: '32', - updated_at: '2024/05/02', - company: 'ایرانسل', - area: 'منطقه 23', + address: "فلان جا", + city: "شیراز", + state: "بررسی شده", + price: "32", + updated_at: "2024/05/02", + company: "ایرانسل", + area: "منطقه 23", }, { name: { - firstName: 'حمیدرضا', - lastName: 'رنجبرپور', + firstName: "حمیدرضا", + lastName: "رنجبرپور", }, - address: 'فلان جا', - city: 'اصفهان', - state: 'بررسی شده', - price: '45', - updated_at: '2024/05/02', - company: 'ایرانول', - area: 'منطقه 21', + address: "فلان جا", + city: "اصفهان", + state: "بررسی شده", + price: "45", + updated_at: "2024/05/02", + company: "ایرانول", + area: "منطقه 21", }, { name: { - firstName: 'محمد', - lastName: 'جلالی', + firstName: "محمد", + lastName: "جلالی", }, - address: 'فلان جا', - city: 'رشت', - state: 'درحال بررسی', - price: '8', - updated_at: '2024/05/02', - company: 'فیلیمو', - area: 'منطقه 8', + address: "فلان جا", + city: "رشت", + state: "درحال بررسی", + price: "8", + updated_at: "2024/05/02", + company: "فیلیمو", + area: "منطقه 8", }, ]; const DataTable_Main = (props) => { - const {filterData} = useDataTable(); - const {table_url, user_id, page_name, table_name, columns, initialStateProps} = props - const flatColumns = flattenArrayOfObjects(columns, 'columns') - const {settingStore, hideAction, sortAction} = useTableSetting(); - const [pagination, setPagination] = useState({pageIndex: 0, pageSize: 10}); + const { filterData } = useDataTable(); + const { table_url, user_id, page_name, table_name, columns, initialStateProps } = props; + const flatColumns = flattenArrayOfObjects(columns, "columns"); + const { settingStore, hideAction, sortAction } = useTableSetting(); + const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: 10 }); const filters = Object.keys(filterData) - .map(key => { + .map((key) => { const value = filterData[key].value; - if (value !== "" && - !(Array.isArray(value) && (value.length === 0 || (value.length === 2 && value[0] === "" && value[1] === "")))) { + if ( + value !== "" && + !( + Array.isArray(value) && + (value.length === 0 || (value.length === 2 && value[0] === "" && value[1] === "")) + ) + ) { return filterData[key]; } }) @@ -98,7 +103,7 @@ const DataTable_Main = (props) => { params.set("start", `${pagination.pageIndex * pagination.pageSize}`); params.set("size", pagination.pageSize); params.set("filters", JSON.stringify(finalFilters ?? [])); - params.set("sorting", JSON.stringify(settingStore?.[user_id]?.[page_name]?.[table_name]?.['sorts'] ?? [])); + params.set("sorting", JSON.stringify(settingStore?.[user_id]?.[page_name]?.[table_name]?.["sorts"] ?? [])); return `${table_url}?${params}`; }, [table_url, finalFilters, pagination, columns]); @@ -107,52 +112,52 @@ const DataTable_Main = (props) => { hideAction(user_id, page_name, table_name, settingValue, flatColumns); }; const onSortingChange = (event) => { - const settingValue = event(settingStore?.[user_id]?.[page_name]?.[table_name]?.['sorts'] || []); + const settingValue = event(settingStore?.[user_id]?.[page_name]?.[table_name]?.["sorts"] || []); sortAction(user_id, page_name, table_name, settingValue, flatColumns); - } + }; const table = useMaterialReactTable({ localization: FA_DATATABLE_LOCALIZATION, columns, data: data, // manualSorting: true, - renderTopToolbarCustomActions: ({table}) => (<> - - ), + renderTopToolbarCustomActions: ({ table }) => ( + <> + + + ), initialState: { - density: 'compact', - columnVisibility: settingStore?.[user_id]?.[page_name]?.[table_name]?.['hides'], - sorting: settingStore?.[user_id]?.[page_name]?.[table_name]?.['sorts'] || [], - ...initialStateProps + density: "compact", + columnVisibility: settingStore?.[user_id]?.[page_name]?.[table_name]?.["hides"], + sorting: settingStore?.[user_id]?.[page_name]?.[table_name]?.["sorts"] || [], + ...initialStateProps, }, state: { - columnVisibility: settingStore?.[user_id]?.[page_name]?.[table_name]?.['hides'], - sorting: settingStore?.[user_id]?.[page_name]?.[table_name]?.['sorts'] || [], - pagination + columnVisibility: settingStore?.[user_id]?.[page_name]?.[table_name]?.["hides"], + sorting: settingStore?.[user_id]?.[page_name]?.[table_name]?.["sorts"] || [], + pagination, }, muiTableHeadProps: { sx: { borderTop: "1px solid #e1e1e1", borderBottom: "2px solid #e1e1e1", - } + }, }, muiTableHeadCellProps: { sx: { color: "primary.main", borderLeft: "1px solid #e1e1e1", "&:first-of-type": { - borderLeft: "unset" - } + borderLeft: "unset", + }, }, }, muiTableBodyCellProps: { sx: { borderLeft: "1px solid #e1e1e1", "&:first-of-type": { - borderLeft: "unset" - } + borderLeft: "unset", + }, }, }, manualFiltering: true, @@ -161,14 +166,18 @@ const DataTable_Main = (props) => { manualSorting: true, onColumnVisibilityChange: onColumnVisibilityChange, onSortingChange: onSortingChange, - ...props - }) + ...props, + }); - return ; + return ( + + ); }; export default DataTable_Main; - - - diff --git a/src/core/components/DataTable/body/TableBody.js b/src/core/components/DataTable/body/TableBody.js index e1620a3..b0750be 100644 --- a/src/core/components/DataTable/body/TableBody.js +++ b/src/core/components/DataTable/body/TableBody.js @@ -4,11 +4,7 @@ import { useMRT_RowVirtualizer, useMRT_Rows } from "material-react-table"; import { memo, useMemo } from "react"; import DataTable_TableBodyRow, { Memo_DataTable_TableBodyRow } from "./TableBodyRow"; -const DataTable_TableBody = ({ - columnVirtualizer, - table, - ...rest -}) => { +const DataTable_TableBody = ({ columnVirtualizer, table, ...rest }) => { const { getBottomRows, getIsSomeRowsPinned, @@ -35,12 +31,8 @@ const DataTable_TableBody = ({ ...rest, }; - const tableHeadHeight = - ((enableStickyHeader || isFullScreen) && - tableHeadRef.current?.clientHeight) || - 0; - const tableFooterHeight = - (enableStickyFooter && tableFooterRef.current?.clientHeight) || 0; + const tableHeadHeight = ((enableStickyHeader || isFullScreen) && tableHeadRef.current?.clientHeight) || 0; + const tableFooterHeight = (enableStickyFooter && tableFooterRef.current?.clientHeight) || 0; const pinnedRowIds = useMemo(() => { if (!rowPinning.bottom?.length && !rowPinning.top?.length) return []; @@ -63,67 +55,63 @@ const DataTable_TableBody = ({ return ( <> - {!rowPinningDisplayMode?.includes('sticky') && - getIsSomeRowsPinned('top') && ( - ({ - display: layoutMode?.startsWith('grid') ? 'grid' : undefined, - position: 'sticky', - top: tableHeadHeight - 1, - zIndex: 1, - ...(parseFromValuesOrFunc(tableBodyProps?.sx, theme)), - })} - > - {getTopRows().map((row, staticRowIndex) => { - const props = { - ...commonRowProps, - row, - staticRowIndex, - }; - return memoMode === 'rows' ? ( - - ) : ( - - ); - })} - - )} + {!rowPinningDisplayMode?.includes("sticky") && getIsSomeRowsPinned("top") && ( + ({ + display: layoutMode?.startsWith("grid") ? "grid" : undefined, + position: "sticky", + top: tableHeadHeight - 1, + zIndex: 1, + ...parseFromValuesOrFunc(tableBodyProps?.sx, theme), + })} + > + {getTopRows().map((row, staticRowIndex) => { + const props = { + ...commonRowProps, + row, + staticRowIndex, + }; + return memoMode === "rows" ? ( + + ) : ( + + ); + })} + + )} ({ - display: layoutMode?.startsWith('grid') ? 'grid' : undefined, - height: rowVirtualizer - ? `${rowVirtualizer.getTotalSize()}px` - : undefined, - minHeight: !rows.length ? '100px' : undefined, - position: 'relative', - ...(parseFromValuesOrFunc(tableBodyProps?.sx, theme)), + display: layoutMode?.startsWith("grid") ? "grid" : undefined, + height: rowVirtualizer ? `${rowVirtualizer.getTotalSize()}px` : undefined, + minHeight: !rows.length ? "100px" : undefined, + position: "relative", + ...parseFromValuesOrFunc(tableBodyProps?.sx, theme), })} > {tableBodyProps?.children ?? (!rows.length ? ( {renderEmptyRowsFallback?.({ table }) ?? ( {globalFilter || columnFilters.length @@ -155,12 +143,10 @@ const DataTable_TableBody = ({ row, rowVirtualizer, staticRowIndex, - virtualRow: rowVirtualizer - ? (rowOrVirtualRow) - : undefined, + virtualRow: rowVirtualizer ? rowOrVirtualRow : undefined, }; const key = `${row.id}-${row.index}`; - return memoMode === 'rows' ? ( + return memoMode === "rows" ? ( ) : ( @@ -169,39 +155,37 @@ const DataTable_TableBody = ({ ))} - {!rowPinningDisplayMode?.includes('sticky') && - getIsSomeRowsPinned('bottom') && ( - ({ - bottom: tableFooterHeight - 1, - display: layoutMode?.startsWith('grid') ? 'grid' : undefined, - position: 'sticky', - zIndex: 1, - ...(parseFromValuesOrFunc(tableBodyProps?.sx, theme)), - })} - > - {getBottomRows().map((row, staticRowIndex) => { - const props = { - ...commonRowProps, - row, - staticRowIndex, - }; - return memoMode === 'rows' ? ( - - ) : ( - - ); - })} - - )} + {!rowPinningDisplayMode?.includes("sticky") && getIsSomeRowsPinned("bottom") && ( + ({ + bottom: tableFooterHeight - 1, + display: layoutMode?.startsWith("grid") ? "grid" : undefined, + position: "sticky", + zIndex: 1, + ...parseFromValuesOrFunc(tableBodyProps?.sx, theme), + })} + > + {getBottomRows().map((row, staticRowIndex) => { + const props = { + ...commonRowProps, + row, + staticRowIndex, + }; + return memoMode === "rows" ? ( + + ) : ( + + ); + })} + + )} ); - -} -export default DataTable_TableBody +}; +export default DataTable_TableBody; export const Memo_DataTable_TableBody = memo( DataTable_TableBody, - (prev, next) => prev.table.options.data === next.table.options.data, -); \ No newline at end of file + (prev, next) => prev.table.options.data === next.table.options.data +); diff --git a/src/core/components/DataTable/body/TableBodyCell.js b/src/core/components/DataTable/body/TableBodyCell.js index 9ef022d..4c1804b 100644 --- a/src/core/components/DataTable/body/TableBodyCell.js +++ b/src/core/components/DataTable/body/TableBodyCell.js @@ -7,15 +7,7 @@ const { useState, useEffect, useMemo, memo } = require("react"); const { default: DataTable_CopyButton } = require("../buttons/CopyButton"); const { default: DataTable_TableBodyCellValue } = require("./TableBodyCellValue"); -const DataTable_TableBodyCell = ({ - cell, - numRows, - rowRef, - staticColumnIndex, - staticRowIndex, - table, - ...rest -}) => { +const DataTable_TableBodyCell = ({ cell, numRows, rowRef, staticColumnIndex, staticRowIndex, table, ...rest }) => { const theme = useTheme(); const { getState, @@ -73,9 +65,7 @@ const DataTable_TableBodyCell = ({ if ((!isLoading && !showSkeletons) || skeletonWidth !== 100) return; const size = column.getSize(); setSkeletonWidth( - columnDefType === 'display' - ? size / 2 - : Math.round(Math.random() * (size - size / 3) + size / 3), + columnDefType === "display" ? size / 2 : Math.round(Math.random() * (size - size / 3) + size / 3) ); }, [isLoading, showSkeletons]); @@ -88,77 +78,55 @@ const DataTable_TableBodyCell = ({ const isLastColumn = column.getIsLastColumn(); const isLastRow = numRows && staticRowIndex === numRows - 1; const isResizingColumn = columnSizingInfo.isResizingColumn === column.id; - const showResizeBorder = - isResizingColumn && columnResizeMode === 'onChange'; + const showResizeBorder = isResizingColumn && columnResizeMode === "onChange"; const borderStyle = showResizeBorder ? `2px solid ${draggingBorderColor} !important` : isDraggingColumn || isDraggingRow - ? `1px dashed ${theme.palette.grey[500]} !important` - : isHoveredColumn || isHoveredRow || isResizingColumn - ? `2px dashed ${draggingBorderColor} !important` - : undefined; + ? `1px dashed ${theme.palette.grey[500]} !important` + : isHoveredColumn || isHoveredRow || isResizingColumn + ? `2px dashed ${draggingBorderColor} !important` + : undefined; if (showResizeBorder) { - return columnResizeDirection === 'ltr' - ? { borderRight: borderStyle } - : { borderLeft: borderStyle }; + return columnResizeDirection === "ltr" ? { borderRight: borderStyle } : { borderLeft: borderStyle }; } return borderStyle ? { - borderBottom: - isDraggingRow || isHoveredRow || (isLastRow && !isResizingColumn) - ? borderStyle - : undefined, - borderLeft: - isDraggingColumn || - isHoveredColumn || - ((isDraggingRow || isHoveredRow) && isFirstColumn) - ? borderStyle - : undefined, - borderRight: - isDraggingColumn || - isHoveredColumn || - ((isDraggingRow || isHoveredRow) && isLastColumn) - ? borderStyle - : undefined, - borderTop: isDraggingRow || isHoveredRow ? borderStyle : undefined, - } + borderBottom: + isDraggingRow || isHoveredRow || (isLastRow && !isResizingColumn) ? borderStyle : undefined, + borderLeft: + isDraggingColumn || isHoveredColumn || ((isDraggingRow || isHoveredRow) && isFirstColumn) + ? borderStyle + : undefined, + borderRight: + isDraggingColumn || isHoveredColumn || ((isDraggingRow || isHoveredRow) && isLastColumn) + ? borderStyle + : undefined, + borderTop: isDraggingRow || isHoveredRow ? borderStyle : undefined, + } : undefined; - }, [ - columnSizingInfo.isResizingColumn, - draggingColumn, - draggingRow, - hoveredColumn, - hoveredRow, - staticRowIndex, - ]); + }, [columnSizingInfo.isResizingColumn, draggingColumn, draggingRow, hoveredColumn, hoveredRow, staticRowIndex]); - const isColumnPinned = - enableColumnPinning && - columnDef.columnDefType !== 'group' && - column.getIsPinned(); + const isColumnPinned = enableColumnPinning && columnDef.columnDefType !== "group" && column.getIsPinned(); const isEditable = isCellEditable({ cell, table }); const isEditing = isEditable && - !['custom', 'modal'].includes(editDisplayMode) && - (editDisplayMode === 'table' || - editingRow?.id === row.id || - editingCell?.id === cell.id) && + !["custom", "modal"].includes(editDisplayMode) && + (editDisplayMode === "table" || editingRow?.id === row.id || editingCell?.id === cell.id) && !row.getIsGrouped(); - const isCreating = - isEditable && createDisplayMode === 'row' && creatingRow?.id === row.id; + const isCreating = isEditable && createDisplayMode === "row" && creatingRow?.id === row.id; const showClickToCopyButton = (parseFromValuesOrFunc(enableClickToCopy, cell) === true || parseFromValuesOrFunc(columnDef.enableClickToCopy, cell) === true) && - !['context-menu', false].includes( + !["context-menu", false].includes( // @ts-ignore - parseFromValuesOrFunc(columnDef.enableClickToCopy, cell), + parseFromValuesOrFunc(columnDef.enableClickToCopy, cell) ); const isRightClickable = parseFromValuesOrFunc(enableCellActions, cell); @@ -175,13 +143,11 @@ const DataTable_TableBodyCell = ({ const handleDragEnter = (e) => { tableCellProps?.onDragEnter?.(e); - if (enableGrouping && hoveredColumn?.id === 'drop-zone') { + if (enableGrouping && hoveredColumn?.id === "drop-zone") { setHoveredColumn(null); } if (enableColumnOrdering && draggingColumn) { - setHoveredColumn( - columnDef.enableColumnOrdering !== false ? column : null, - ); + setHoveredColumn(columnDef.enableColumnOrdering !== false ? column : null); } }; @@ -210,43 +176,39 @@ const DataTable_TableBodyCell = ({ onDragEnter={handleDragEnter} onDragOver={handleDragOver} sx={(theme) => ({ - '&:hover': { + "&:hover": { outline: actionCell?.id === cell.id || - (editDisplayMode === 'cell' && isEditable) || - (editDisplayMode === 'table' && (isCreating || isEditing)) + (editDisplayMode === "cell" && isEditable) || + (editDisplayMode === "table" && (isCreating || isEditing)) ? `1px solid ${theme.palette.grey[500]}` : undefined, - textOverflow: 'clip', + textOverflow: "clip", }, - alignItems: layoutMode?.startsWith('grid') ? 'center' : undefined, + alignItems: layoutMode?.startsWith("grid") ? "center" : undefined, cursor: isRightClickable - ? 'context-menu' - : isEditable && editDisplayMode === 'cell' - ? 'pointer' - : 'inherit', - outline: - actionCell?.id === cell.id - ? `1px solid ${theme.palette.grey[500]}` - : undefined, - outlineOffset: '-1px', - overflow: 'hidden', + ? "context-menu" + : isEditable && editDisplayMode === "cell" + ? "pointer" + : "inherit", + outline: actionCell?.id === cell.id ? `1px solid ${theme.palette.grey[500]}` : undefined, + outlineOffset: "-1px", + overflow: "hidden", p: - density === 'compact' - ? columnDefType === 'display' - ? '0 0.5rem' - : '0.5rem' - : density === 'comfortable' - ? columnDefType === 'display' - ? '0.5rem 0.75rem' - : '1rem' - : columnDefType === 'display' - ? '1rem 1.25rem' - : '1.5rem', + density === "compact" + ? columnDefType === "display" + ? "0 0.5rem" + : "0.5rem" + : density === "comfortable" + ? columnDefType === "display" + ? "0.5rem 0.75rem" + : "1rem" + : columnDefType === "display" + ? "1rem 1.25rem" + : "1.5rem", - textOverflow: columnDefType !== 'display' ? 'ellipsis' : undefined, - whiteSpace: - row.getIsPinned() || density === 'compact' ? 'nowrap' : 'normal', + textOverflow: columnDefType !== "display" ? "ellipsis" : undefined, + whiteSpace: row.getIsPinned() || density === "compact" ? "nowrap" : "normal", ...getCommonMRTCellStyles({ column, table, @@ -261,17 +223,10 @@ const DataTable_TableBodyCell = ({ {cell.getIsPlaceholder() ? ( columnDef.PlaceholderCell?.({ cell, column, row, table }) ?? null ) : showSkeletons !== false && (isLoading || showSkeletons) ? ( - - ) : columnDefType === 'display' && - (['mrt-row-expand', 'mrt-row-numbers', 'mrt-row-select'].includes( - column.id, - ) || - !row.getIsGrouped()) ? ( + + ) : columnDefType === "display" && + (["mrt-row-expand", "mrt-row-numbers", "mrt-row-select"].includes(column.id) || + !row.getIsGrouped()) ? ( columnDef.Cell?.({ cell, column, @@ -289,18 +244,12 @@ const DataTable_TableBodyCell = ({ ) : ( )} - {cell.getIsGrouped() && !columnDef.GroupedCell && ( - <> ({row.subRows?.length}) - )} + {cell.getIsGrouped() && !columnDef.GroupedCell && <> ({row.subRows?.length})} )} ); - -} +}; export default DataTable_TableBodyCell; -export const Memo_DataTable_TableBodyCell = memo( - DataTable_TableBodyCell, - (prev, next) => next.cell === prev.cell, -); \ No newline at end of file +export const Memo_DataTable_TableBodyCell = memo(DataTable_TableBodyCell, (prev, next) => next.cell === prev.cell); diff --git a/src/core/components/DataTable/body/TableBodyCellValue.js b/src/core/components/DataTable/body/TableBodyCellValue.js index 6d4f05f..aea105f 100644 --- a/src/core/components/DataTable/body/TableBodyCellValue.js +++ b/src/core/components/DataTable/body/TableBodyCellValue.js @@ -2,111 +2,102 @@ import { Box } from "@mui/material"; const allowedTypes = ["string", "number"]; -const DataTable_TableBodyCellValue = ({ - cell, - rowRef, - staticColumnIndex, - staticRowIndex, - table, -}) => { - const { - getState, - options: { - enableFilterMatchHighlighting, - mrtTheme: { matchHighlightColor }, - }, - } = table; - const { column, row } = cell; - const { columnDef } = column; - const { globalFilter, globalFilterFn } = getState(); - const filterValue = column.getFilterValue(); +const DataTable_TableBodyCellValue = ({ cell, rowRef, staticColumnIndex, staticRowIndex, table }) => { + const { + getState, + options: { + enableFilterMatchHighlighting, + mrtTheme: { matchHighlightColor }, + }, + } = table; + const { column, row } = cell; + const { columnDef } = column; + const { globalFilter, globalFilterFn } = getState(); + const filterValue = column.getFilterValue(); - let renderedCellValue = - cell.getIsAggregated() && columnDef.AggregatedCell - ? columnDef.AggregatedCell({ - cell, - column, - row, - table, - }) - : row.getIsGrouped() && !cell.getIsGrouped() - ? null - : cell.getIsGrouped() && columnDef.GroupedCell - ? columnDef.GroupedCell({ + let renderedCellValue = + cell.getIsAggregated() && columnDef.AggregatedCell + ? columnDef.AggregatedCell({ + cell, + column, + row, + table, + }) + : row.getIsGrouped() && !cell.getIsGrouped() + ? null + : cell.getIsGrouped() && columnDef.GroupedCell + ? columnDef.GroupedCell({ + cell, + column, + row, + table, + }) + : undefined; + + const isGroupedValue = renderedCellValue !== undefined; + + if (!isGroupedValue) { + renderedCellValue = cell.renderValue(); + } + + if ( + enableFilterMatchHighlighting && + columnDef.enableFilterMatchHighlighting !== false && + String(renderedCellValue) && + allowedTypes.includes(typeof renderedCellValue) && + ((filterValue && + allowedTypes.includes(typeof filterValue) && + ["autocomplete", "text"].includes(columnDef.filterVariant)) || + (globalFilter && allowedTypes.includes(typeof globalFilter) && column.getCanGlobalFilter())) + ) { + const chunks = highlightWords?.({ + matchExactly: (filterValue ? columnDef._filterFn : globalFilterFn) !== "fuzzy", + query: (filterValue ?? globalFilter ?? "").toString(), + text: renderedCellValue?.toString(), + }); + if (chunks?.length > 1 || chunks?.[0]?.match) { + renderedCellValue = ( + + {chunks?.map(({ key, match, text }) => ( + + )) ?? renderedCellValue} + + ); + } + } + + if (columnDef.Cell && !isGroupedValue) { + renderedCellValue = columnDef.Cell({ cell, column, + renderedCellValue, row, + rowRef, + staticColumnIndex, + staticRowIndex, table, - }) - : undefined; - - const isGroupedValue = renderedCellValue !== undefined; - - if (!isGroupedValue) { - renderedCellValue = cell.renderValue(); - } - - if ( - enableFilterMatchHighlighting && - columnDef.enableFilterMatchHighlighting !== false && - String(renderedCellValue) && - allowedTypes.includes(typeof renderedCellValue) && - ((filterValue && - allowedTypes.includes(typeof filterValue) && - ["autocomplete", "text"].includes(columnDef.filterVariant)) || - (globalFilter && - allowedTypes.includes(typeof globalFilter) && - column.getCanGlobalFilter())) - ) { - const chunks = highlightWords?.({ - matchExactly: - (filterValue ? columnDef._filterFn : globalFilterFn) !== "fuzzy", - query: (filterValue ?? globalFilter ?? "").toString(), - text: renderedCellValue?.toString(), - }); - if (chunks?.length > 1 || chunks?.[0]?.match) { - renderedCellValue = ( - - {chunks?.map(({ key, match, text }) => ( - - )) ?? renderedCellValue} - - ); + }); } - } - if (columnDef.Cell && !isGroupedValue) { - renderedCellValue = columnDef.Cell({ - cell, - column, - renderedCellValue, - row, - rowRef, - staticColumnIndex, - staticRowIndex, - table, - }); - } - - return renderedCellValue; + return renderedCellValue; }; export default DataTable_TableBodyCellValue; diff --git a/src/core/components/DataTable/body/TableBodyRow.js b/src/core/components/DataTable/body/TableBodyRow.js index e500eb0..a041d66 100644 --- a/src/core/components/DataTable/body/TableBodyRow.js +++ b/src/core/components/DataTable/body/TableBodyRow.js @@ -28,11 +28,7 @@ const DataTable_TableBodyRow = ({ enableStickyHeader, layoutMode, memoMode, - mrtTheme: { - baseBackgroundColor, - pinnedRowBackgroundColor, - selectedRowBackgroundColor, - }, + mrtTheme: { baseBackgroundColor, pinnedRowBackgroundColor, selectedRowBackgroundColor }, muiTableBodyRowProps, renderDetailPanel, rowPinningDisplayMode, @@ -40,21 +36,12 @@ const DataTable_TableBodyRow = ({ refs: { tableFooterRef, tableHeadRef }, setHoveredRow, } = table; - const { - density, - draggingColumn, - draggingRow, - editingCell, - editingRow, - hoveredRow, - isFullScreen, - rowPinning, - } = getState(); + const { density, draggingColumn, draggingRow, editingCell, editingRow, hoveredRow, isFullScreen, rowPinning } = + getState(); const visibleCells = row.getVisibleCells(); - const { virtualColumns, virtualPaddingLeft, virtualPaddingRight } = - columnVirtualizer ?? {}; + const { virtualColumns, virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer ?? {}; const isRowSelected = getIsRowSelected({ row, table }); const isRowPinned = enableRowPinning && row.getIsPinned(); @@ -71,30 +58,17 @@ const DataTable_TableBodyRow = ({ }; const [bottomPinnedIndex, topPinnedIndex] = useMemo(() => { - if ( - !enableRowPinning || - !rowPinningDisplayMode?.includes('sticky') || - !pinnedRowIds || - !row.getIsPinned() - ) + if (!enableRowPinning || !rowPinningDisplayMode?.includes("sticky") || !pinnedRowIds || !row.getIsPinned()) return []; - return [ - [...pinnedRowIds].reverse().indexOf(row.id), - pinnedRowIds.indexOf(row.id), - ]; + return [[...pinnedRowIds].reverse().indexOf(row.id), pinnedRowIds.indexOf(row.id)]; }, [pinnedRowIds, rowPinning]); - const tableHeadHeight = - ((enableStickyHeader || isFullScreen) && - tableHeadRef.current?.clientHeight) || - 0; - const tableFooterHeight = - (enableStickyFooter && tableFooterRef.current?.clientHeight) || 0; + const tableHeadHeight = ((enableStickyHeader || isFullScreen) && tableHeadRef.current?.clientHeight) || 0; + const tableFooterHeight = (enableStickyFooter && tableFooterRef.current?.clientHeight) || 0; const sx = parseFromValuesOrFunc(tableRowProps?.sx, theme); - const defaultRowHeight = - density === 'compact' ? 37 : density === 'comfortable' ? 53 : 69; + const defaultRowHeight = density === "compact" ? 37 : density === "comfortable" ? 53 : 69; const customRowHeight = // @ts-ignore @@ -117,16 +91,16 @@ const DataTable_TableBodyRow = ({ const cellHighlightColor = isRowSelected ? selectedRowBackgroundColor : isRowPinned - ? pinnedRowBackgroundColor - : undefined; + ? pinnedRowBackgroundColor + : undefined; const cellHighlightColorHover = tableRowProps?.hover !== false ? isRowSelected ? cellHighlightColor - : theme.palette.mode === 'dark' - ? `${lighten(baseBackgroundColor, 0.3)}` - : `${darken(baseBackgroundColor, 0.3)}` + : theme.palette.mode === "dark" + ? `${lighten(baseBackgroundColor, 0.3)}` + : `${darken(baseBackgroundColor, 0.3)}` : undefined; return ( @@ -146,91 +120,81 @@ const DataTable_TableBodyRow = ({ selected={isRowSelected} {...tableRowProps} style={{ - transform: virtualRow - ? `translateY(${virtualRow.start}px)` - : undefined, + transform: virtualRow ? `translateY(${virtualRow.start}px)` : undefined, ...tableRowProps?.style, }} sx={(theme) => ({ - '&:hover td:after': cellHighlightColorHover + "&:hover td:after": cellHighlightColorHover ? { - backgroundColor: alpha(cellHighlightColorHover, 0.3), - ...commonCellBeforeAfterStyles, - } + backgroundColor: alpha(cellHighlightColorHover, 0.3), + ...commonCellBeforeAfterStyles, + } : undefined, backgroundColor: `${baseBackgroundColor} !important`, bottom: !virtualRow && bottomPinnedIndex !== undefined && isRowPinned - ? `${bottomPinnedIndex * rowHeight + - (enableStickyFooter ? tableFooterHeight - 1 : 0) - }px` + ? `${bottomPinnedIndex * rowHeight + (enableStickyFooter ? tableFooterHeight - 1 : 0)}px` : undefined, - boxSizing: 'border-box', - display: layoutMode?.startsWith('grid') ? 'flex' : undefined, + boxSizing: "border-box", + display: layoutMode?.startsWith("grid") ? "flex" : undefined, opacity: isRowPinned ? 0.97 : isDraggingRow || isHoveredRow ? 0.5 : 1, position: virtualRow - ? 'absolute' - : rowPinningDisplayMode?.includes('sticky') && isRowPinned - ? 'sticky' - : 'relative', + ? "absolute" + : rowPinningDisplayMode?.includes("sticky") && isRowPinned + ? "sticky" + : "relative", td: { ...getCommonPinnedCellStyles({ table, theme }), }, - 'td:after': cellHighlightColor + "td:after": cellHighlightColor ? { - backgroundColor: cellHighlightColor, - ...commonCellBeforeAfterStyles, - } + backgroundColor: cellHighlightColor, + ...commonCellBeforeAfterStyles, + } : undefined, top: virtualRow ? 0 : topPinnedIndex !== undefined && isRowPinned - ? `${topPinnedIndex * rowHeight + - (enableStickyHeader || isFullScreen ? tableHeadHeight - 1 : 0) + ? `${ + topPinnedIndex * rowHeight + + (enableStickyHeader || isFullScreen ? tableHeadHeight - 1 : 0) }px` - : undefined, - transition: virtualRow ? 'none' : 'all 150ms ease-in-out', - width: '100%', - zIndex: - rowPinningDisplayMode?.includes('sticky') && isRowPinned ? 2 : 0, - ...(sx), + : undefined, + transition: virtualRow ? "none" : "all 150ms ease-in-out", + width: "100%", + zIndex: rowPinningDisplayMode?.includes("sticky") && isRowPinned ? 2 : 0, + ...sx, })} > - {virtualPaddingLeft ? ( - - ) : null} - {(virtualColumns ?? visibleCells).map( - (cellOrVirtualCell, staticColumnIndex) => { - let cell = cellOrVirtualCell; - if (columnVirtualizer) { - staticColumnIndex = (cellOrVirtualCell).index; - cell = visibleCells[staticColumnIndex]; - } - const props = { - cell, - numRows, - rowRef, - staticColumnIndex, - staticRowIndex, - table, - }; - return cell ? ( - memoMode === 'cells' && - cell.column.columnDef.columnDefType === 'data' && - !draggingColumn && - !draggingRow && - editingCell?.id !== cell.id && - editingRow?.id !== row.id ? ( - - ) : ( - - ) - ) : null; - }, - )} - {virtualPaddingRight ? ( - - ) : null} + {virtualPaddingLeft ? : null} + {(virtualColumns ?? visibleCells).map((cellOrVirtualCell, staticColumnIndex) => { + let cell = cellOrVirtualCell; + if (columnVirtualizer) { + staticColumnIndex = cellOrVirtualCell.index; + cell = visibleCells[staticColumnIndex]; + } + const props = { + cell, + numRows, + rowRef, + staticColumnIndex, + staticRowIndex, + table, + }; + return cell ? ( + memoMode === "cells" && + cell.column.columnDef.columnDefType === "data" && + !draggingColumn && + !draggingRow && + editingCell?.id !== cell.id && + editingRow?.id !== row.id ? ( + + ) : ( + + ) + ) : null; + })} + {virtualPaddingRight ? : null} {renderDetailPanel && !row.getIsGrouped() && ( ); -} -export default DataTable_TableBodyRow +}; +export default DataTable_TableBodyRow; export const Memo_DataTable_TableBodyRow = memo( DataTable_TableBodyRow, - (prev, next) => - prev.row === next.row && prev.staticRowIndex === next.staticRowIndex, -); \ No newline at end of file + (prev, next) => prev.row === next.row && prev.staticRowIndex === next.staticRowIndex +); diff --git a/src/core/components/DataTable/body/TableDetailPanel.js b/src/core/components/DataTable/body/TableDetailPanel.js index 0c9f8a9..853aab5 100644 --- a/src/core/components/DataTable/body/TableDetailPanel.js +++ b/src/core/components/DataTable/body/TableDetailPanel.js @@ -23,7 +23,6 @@ const DataTable_TableDetailPanel = ({ } = table; const { isLoading } = getState(); - const tableRowProps = parseFromValuesOrFunc(muiTableBodyRowProps, { isDetailPanel: true, row, @@ -52,16 +51,12 @@ const DataTable_TableDetailPanel = ({ }} {...tableRowProps} sx={(theme) => ({ - display: layoutMode?.startsWith('grid') ? 'flex' : undefined, - position: virtualRow ? 'absolute' : undefined, - top: virtualRow - ? `${parentRowRef.current?.getBoundingClientRect()?.height}px` - : undefined, - transform: virtualRow - ? `translateY(${virtualRow?.start}px)` - : undefined, - width: '100%', - ...(parseFromValuesOrFunc(tableRowProps?.sx, theme)), + display: layoutMode?.startsWith("grid") ? "flex" : undefined, + position: virtualRow ? "absolute" : undefined, + top: virtualRow ? `${parentRowRef.current?.getBoundingClientRect()?.height}px` : undefined, + transform: virtualRow ? `translateY(${virtualRow?.start}px)` : undefined, + width: "100%", + ...parseFromValuesOrFunc(tableRowProps?.sx, theme), })} > ({ backgroundColor: virtualRow ? baseBackgroundColor : undefined, - borderBottom: !row.getIsExpanded() ? 'none' : undefined, - display: layoutMode?.startsWith('grid') ? 'flex' : undefined, - py: !!DetailPanel && row.getIsExpanded() ? '1rem' : 0, - transition: !virtualRow ? 'all 150ms ease-in-out' : undefined, + borderBottom: !row.getIsExpanded() ? "none" : undefined, + display: layoutMode?.startsWith("grid") ? "flex" : undefined, + py: !!DetailPanel && row.getIsExpanded() ? "1rem" : 0, + transition: !virtualRow ? "all 150ms ease-in-out" : undefined, width: `100%`, - ...(parseFromValuesOrFunc(tableCellProps?.sx, theme)), + ...parseFromValuesOrFunc(tableCellProps?.sx, theme), })} > {virtualRow ? ( @@ -88,6 +83,5 @@ const DataTable_TableDetailPanel = ({ ); - -} -export default DataTable_TableDetailPanel \ No newline at end of file +}; +export default DataTable_TableDetailPanel; diff --git a/src/core/components/DataTable/buttons/CopyButton.js b/src/core/components/DataTable/buttons/CopyButton.js index c8878e0..c4dfe4b 100644 --- a/src/core/components/DataTable/buttons/CopyButton.js +++ b/src/core/components/DataTable/buttons/CopyButton.js @@ -2,11 +2,7 @@ import { getCommonTooltipProps, parseFromValuesOrFunc } from "@/core/utils/utils import { Button, Tooltip } from "@mui/material"; import { useState } from "react"; -const DataTable_CopyButton = ({ - cell, - table, - ...rest -}) => { +const DataTable_CopyButton = ({ cell, table, ...rest }) => { const { options: { localization, muiCopyButtonProps }, } = table; @@ -40,11 +36,8 @@ const DataTable_CopyButton = ({ return ( - - - )} + + {({ + values, + handleChange, + handleBlur, + setFieldValue, + errors, + touched, + isSubmitting, + isValid, + dirty, + resetForm, + }) => ( +
+ + {columns.map( + (column) => + column.enableColumnFilter && ( + + ) + )} + + + + +
+ )}
)} @@ -204,4 +221,4 @@ function FilterBody({columns, drawerState, setDrawerState, user_id, page_name, t ); } -export default FilterBody; \ No newline at end of file +export default FilterBody; diff --git a/src/core/components/DataTable/filter/FilterBodyField.jsx b/src/core/components/DataTable/filter/FilterBodyField.jsx index b12e770..a9bef12 100644 --- a/src/core/components/DataTable/filter/FilterBodyField.jsx +++ b/src/core/components/DataTable/filter/FilterBodyField.jsx @@ -1,4 +1,4 @@ -import {useState} from "react"; +import { useState } from "react"; import FilterOptionList from "@/core/components/DataTable/filter/FilterOptionList"; import CustomSelect from "@/core/components/DataTable/filter/fieldsType/CustomSelect"; import CustomTextField from "@/core/components/DataTable/filter/fieldsType/CustomTextField"; @@ -14,19 +14,19 @@ const columnFilterModeOptionFa = { lessThan: "کوچکتر", greaterThan: "بزرگتر", fuzzy: "فازی", - between: "مابین" + between: "مابین", }; function FilterBodyField({ - column, - filterParameters, - handleChange, - handleBlur, - setFieldValue, - errors, - touched, - resetForm - }) { + column, + filterParameters, + handleChange, + handleBlur, + setFieldValue, + errors, + touched, + resetForm, +}) { const [anchorEl, setAnchorEl] = useState(null); const defaultFilterTranslation = columnFilterModeOptionFa[filterParameters.filterFn] || filterParameters.filterFn; @@ -47,7 +47,9 @@ function FilterBodyField({ errors={errors} touched={touched} /> - ) : filterParameters.datatype === "numeric" && filterParameters.filterFn === "equals" && Array.isArray(column.columnSelectOption) ? ( + ) : filterParameters.datatype === "numeric" && + filterParameters.filterFn === "equals" && + Array.isArray(column.columnSelectOption) ? ( - { - setDrawerState(!drawerState) - }} aria-label="filter table"> - + { + setDrawerState(!drawerState); + }} + aria-label="filter table" + > +
); diff --git a/src/core/components/DataTable/filter/FilterHeader.jsx b/src/core/components/DataTable/filter/FilterHeader.jsx index 2acd0b7..76980ce 100644 --- a/src/core/components/DataTable/filter/FilterHeader.jsx +++ b/src/core/components/DataTable/filter/FilterHeader.jsx @@ -1,10 +1,10 @@ -'use client' +"use client"; -import {Box, IconButton, Typography} from "@mui/material"; -import CancelIcon from '@mui/icons-material/Cancel'; -import FilterAltIcon from '@mui/icons-material/FilterAlt'; +import { Box, IconButton, Typography } from "@mui/material"; +import CancelIcon from "@mui/icons-material/Cancel"; +import FilterAltIcon from "@mui/icons-material/FilterAlt"; -function FilterHeader({setDrawerState}) { +function FilterHeader({ setDrawerState }) { return ( - - - فیلتر + + + + فیلتر + - setDrawerState(false)}> - + setDrawerState(false)}> + ); } -export default FilterHeader; \ No newline at end of file +export default FilterHeader; diff --git a/src/core/components/DataTable/filter/FilterOptionList.jsx b/src/core/components/DataTable/filter/FilterOptionList.jsx index ce02c23..e088832 100644 --- a/src/core/components/DataTable/filter/FilterOptionList.jsx +++ b/src/core/components/DataTable/filter/FilterOptionList.jsx @@ -1,17 +1,17 @@ -'use client' +"use client"; -import {ListItem, Menu} from "@mui/material"; -import {useState} from "react"; +import { ListItem, Menu } from "@mui/material"; +import { useState } from "react"; function FilterOptionList({ - column, - filterType, - filterOption, - anchorEl, - columnFilterModeOptionFa, - setAnchorEl, - setFieldValue - }) { + column, + filterType, + filterOption, + anchorEl, + columnFilterModeOptionFa, + setAnchorEl, + setFieldValue, +}) { const [selectedFilter, setSelectedFilter] = useState(filterType); const handleChangeItem = (event, index) => { @@ -19,25 +19,26 @@ function FilterOptionList({ setFieldValue(`${column.id}.filterFn`, filterOption[index]); setSelectedFilter(filterOption[index]); setAnchorEl(null); - } + }; const handleCloseFilterBox = () => { setAnchorEl(null); }; return ( - + {filterOption.map((option, index) => ( - handleChangeItem(event, index)} - selected={option === selectedFilter} - sx={{cursor: 'pointer', width: "100px", display: "flex", justifyContent: "center"}}> + handleChangeItem(event, index)} + selected={option === selectedFilter} + sx={{ + cursor: "pointer", + width: "100px", + display: "flex", + justifyContent: "center", + }} + > {columnFilterModeOptionFa[option]} ))} @@ -45,4 +46,4 @@ function FilterOptionList({ ); } -export default FilterOptionList; \ No newline at end of file +export default FilterOptionList; diff --git a/src/core/components/DataTable/filter/fieldsType/CustomDate/CustomDatePicker.jsx b/src/core/components/DataTable/filter/fieldsType/CustomDate/CustomDatePicker.jsx index e92a426..fe5d2e0 100644 --- a/src/core/components/DataTable/filter/fieldsType/CustomDate/CustomDatePicker.jsx +++ b/src/core/components/DataTable/filter/fieldsType/CustomDate/CustomDatePicker.jsx @@ -1,8 +1,8 @@ -import React from 'react'; +import React from "react"; import MuiDatePicker from "@/core/components/DataTable/filter/fieldsType/CustomDate/MuiDatePicker"; -import {Typography} from "@mui/material"; +import { Typography } from "@mui/material"; -function CustomDatePicker({column, filterParameters, defaultFilterTranslation, setFieldValue}) { +function CustomDatePicker({ column, filterParameters, defaultFilterTranslation, setFieldValue }) { return ( + نوع فیلتر: {defaultFilterTranslation} (تاریخ) } @@ -18,4 +18,4 @@ function CustomDatePicker({column, filterParameters, defaultFilterTranslation, s ); } -export default CustomDatePicker; \ No newline at end of file +export default CustomDatePicker; diff --git a/src/core/components/DataTable/filter/fieldsType/CustomDate/CustomDatePickerRange.jsx b/src/core/components/DataTable/filter/fieldsType/CustomDate/CustomDatePickerRange.jsx index b870061..116af77 100644 --- a/src/core/components/DataTable/filter/fieldsType/CustomDate/CustomDatePickerRange.jsx +++ b/src/core/components/DataTable/filter/fieldsType/CustomDate/CustomDatePickerRange.jsx @@ -1,12 +1,12 @@ -'use client' +"use client"; import React from "react"; -import {Box, Typography} from "@mui/material"; +import { Box, Typography } from "@mui/material"; import MuiDatePicker from "@/core/components/DataTable/filter/fieldsType/CustomDate/MuiDatePicker"; -function CustomDatePickerRange({column, filterParameters, defaultFilterTranslation, setFieldValue, errors, touched}) { +function CustomDatePickerRange({ column, filterParameters, defaultFilterTranslation, setFieldValue, errors, touched }) { return ( - + + نوع فیلتر: {defaultFilterTranslation} (تاریخ) } diff --git a/src/core/components/DataTable/filter/fieldsType/CustomDate/MuiDatePicker.jsx b/src/core/components/DataTable/filter/fieldsType/CustomDate/MuiDatePicker.jsx index 5031372..d715192 100644 --- a/src/core/components/DataTable/filter/fieldsType/CustomDate/MuiDatePicker.jsx +++ b/src/core/components/DataTable/filter/fieldsType/CustomDate/MuiDatePicker.jsx @@ -1,33 +1,31 @@ -import React from 'react'; -import {LocalizationProvider, MobileDatePicker} from "@mui/x-date-pickers"; -import {AdapterDateFnsJalali} from "@mui/x-date-pickers/AdapterDateFnsJalali"; -import {faIR} from "@mui/x-date-pickers/locales"; -import {Box, FormHelperText, IconButton, InputAdornment} from "@mui/material"; +import React from "react"; +import { LocalizationProvider, MobileDatePicker } from "@mui/x-date-pickers"; +import { AdapterDateFnsJalali } from "@mui/x-date-pickers/AdapterDateFnsJalali"; +import { faIR } from "@mui/x-date-pickers/locales"; +import { Box, FormHelperText, IconButton, InputAdornment } from "@mui/material"; import ClearIcon from "@mui/icons-material/Clear"; import moment from "jalali-moment"; -function MuiDatePicker({value, setFieldValue, name, minDate, maxDate, helperText, placeholder, error}) { - +function MuiDatePicker({ value, setFieldValue, name, minDate, maxDate, helperText, placeholder, error }) { // console.log("error", error); // // console.log("helperText", helperText) return ( - - + { const date = new Date(value); - const formattedDate = moment(date) - .locale("en") - .format("YYYY-MM-DD"); + const formattedDate = moment(date).locale("en").format("YYYY-MM-DD"); setFieldValue(name, formattedDate); }} minDate={minDate ? new Date(minDate) : null} @@ -47,13 +45,13 @@ function MuiDatePicker({value, setFieldValue, name, minDate, maxDate, helperText }} sx={{ color: "#bfbfbf", - '&:hover': { - backgroundColor: 'rgba(189, 189, 189, 0.1)', - color: "#363434" + "&:hover": { + backgroundColor: "rgba(189, 189, 189, 0.1)", + color: "#363434", }, }} > - + ), @@ -61,7 +59,7 @@ function MuiDatePicker({value, setFieldValue, name, minDate, maxDate, helperText }, }} /> - + {helperText ? helperText : ""} @@ -69,4 +67,4 @@ function MuiDatePicker({value, setFieldValue, name, minDate, maxDate, helperText ); } -export default MuiDatePicker; \ No newline at end of file +export default MuiDatePicker; diff --git a/src/core/components/DataTable/filter/fieldsType/CustomSelect.jsx b/src/core/components/DataTable/filter/fieldsType/CustomSelect.jsx index 44f0599..bd038e2 100644 --- a/src/core/components/DataTable/filter/fieldsType/CustomSelect.jsx +++ b/src/core/components/DataTable/filter/fieldsType/CustomSelect.jsx @@ -1,35 +1,32 @@ -'use client' +"use client"; -import {FormControl, FormHelperText, InputLabel, MenuItem, OutlinedInput, Select, Typography} from "@mui/material"; +import { FormControl, FormHelperText, InputLabel, MenuItem, OutlinedInput, Select, Typography } from "@mui/material"; -function CustomSelect({column, filterParameters, defaultFilterTranslation, setFieldValue}) { +function CustomSelect({ column, filterParameters, defaultFilterTranslation, setFieldValue }) { const columnSelectOption = column.columnSelectOption; return ( - + {column.header} - + نوع فیلتر: {defaultFilterTranslation} diff --git a/src/core/components/DataTable/filter/fieldsType/CustomSelectMultiple.jsx b/src/core/components/DataTable/filter/fieldsType/CustomSelectMultiple.jsx index ae027fe..130f98f 100644 --- a/src/core/components/DataTable/filter/fieldsType/CustomSelectMultiple.jsx +++ b/src/core/components/DataTable/filter/fieldsType/CustomSelectMultiple.jsx @@ -1,4 +1,4 @@ -'use client' +"use client"; import { Box, @@ -9,49 +9,47 @@ import { MenuItem, OutlinedInput, Select, - Typography + Typography, } from "@mui/material"; -function CustomSelectMultiple({column, filterParameters, defaultFilterTranslation, setFieldValue}) { +function CustomSelectMultiple({ column, filterParameters, defaultFilterTranslation, setFieldValue }) { const columnSelectOption = column.columnSelectOption; const getLabelForValue = (value) => { - const option = columnSelectOption.find(opt => opt.value === value); + const option = columnSelectOption.find((opt) => opt.value === value); return option ? option.label : value; }; return ( - - {column.header} + + + {column.header} + - + نوع فیلتر: {defaultFilterTranslation} diff --git a/src/core/components/DataTable/filter/fieldsType/CustomTextField.jsx b/src/core/components/DataTable/filter/fieldsType/CustomTextField.jsx index eacd820..05b44ce 100644 --- a/src/core/components/DataTable/filter/fieldsType/CustomTextField.jsx +++ b/src/core/components/DataTable/filter/fieldsType/CustomTextField.jsx @@ -1,15 +1,14 @@ -import {InputAdornment, TextField, Typography} from "@mui/material"; -import FilterListIcon from '@mui/icons-material/FilterList'; +import { InputAdornment, TextField, Typography } from "@mui/material"; +import FilterListIcon from "@mui/icons-material/FilterList"; function CustomTextField({ - column, - filterParameters, - defaultFilterTranslation, - handleOpenFilterBox, - handleChange, - handleBlur - }) { - + column, + filterParameters, + defaultFilterTranslation, + handleOpenFilterBox, + handleChange, + handleBlur, +}) { return ( - نوع فیلتر: {defaultFilterTranslation} - } + helperText={ + + نوع فیلتر: {defaultFilterTranslation} + + } variant="outlined" size="normal" - sx={{marginY: 1}} + sx={{ marginY: 1 }} InputProps={{ endAdornment: ( - - + + ), }} @@ -36,4 +37,4 @@ function CustomTextField({ ); } -export default CustomTextField; \ No newline at end of file +export default CustomTextField; diff --git a/src/core/components/DataTable/filter/fieldsType/CustomTextFieldRange.jsx b/src/core/components/DataTable/filter/fieldsType/CustomTextFieldRange.jsx index 35c9358..fea4169 100644 --- a/src/core/components/DataTable/filter/fieldsType/CustomTextFieldRange.jsx +++ b/src/core/components/DataTable/filter/fieldsType/CustomTextFieldRange.jsx @@ -1,18 +1,18 @@ -import {Box, InputAdornment, TextField, Typography} from "@mui/material"; -import FilterListIcon from '@mui/icons-material/FilterList'; +import { Box, InputAdornment, TextField, Typography } from "@mui/material"; +import FilterListIcon from "@mui/icons-material/FilterList"; function CustomTextFieldRange({ - column, - filterParameters, - defaultFilterTranslation, - handleOpenFilterBox, - handleChange, - handleBlur, - errors, - touched - }) { + column, + filterParameters, + defaultFilterTranslation, + handleOpenFilterBox, + handleChange, + handleBlur, + errors, + touched, +}) { return ( - + نوع - فیلتر: {defaultFilterTranslation}} + helperText={ + + نوع فیلتر: {defaultFilterTranslation} + + } variant="outlined" size="normal" - sx={{marginY: 1, marginRight: 1}} + sx={{ marginY: 1, marginRight: 1 }} /> - + + ), }} @@ -53,4 +56,4 @@ function CustomTextFieldRange({ ); } -export default CustomTextFieldRange; \ No newline at end of file +export default CustomTextFieldRange; diff --git a/src/core/components/DataTable/filter/index.jsx b/src/core/components/DataTable/filter/index.jsx index 65a93d2..8d26594 100644 --- a/src/core/components/DataTable/filter/index.jsx +++ b/src/core/components/DataTable/filter/index.jsx @@ -1,17 +1,23 @@ -'use client' +"use client"; -import {useState} from "react"; +import { useState } from "react"; import FilterButton from "@/core/components/DataTable/filter/FilterButton"; import FilterBody from "@/core/components/DataTable/filter/FilterBody"; -function FilterColumn({columns, user_id, page_name, table_name}) { +function FilterColumn({ columns, user_id, page_name, table_name }) { const [open, setOpen] = useState(false); return ( <> - - + + ); } diff --git a/src/core/components/DataTable/head/TableHead.js b/src/core/components/DataTable/head/TableHead.js index 5e5dd99..39ee214 100644 --- a/src/core/components/DataTable/head/TableHead.js +++ b/src/core/components/DataTable/head/TableHead.js @@ -1,26 +1,17 @@ -import {parseFromValuesOrFunc} from "@/core/utils/utils"; -import {TableHead} from "@mui/material"; +import { parseFromValuesOrFunc } from "@/core/utils/utils"; +import { TableHead } from "@mui/material"; import DataTable_TableHeadRow from "./TableHeadRow"; -const DataTable_TableHead = ({ - columnVirtualizer, - table, - ...rest - }) => { +const DataTable_TableHead = ({ columnVirtualizer, table, ...rest }) => { const { getState, - options: { - enableStickyHeader, - layoutMode, - muiTableHeadProps, - positionToolbarAlertBanner, - }, - refs: {tableHeadRef}, + options: { enableStickyHeader, layoutMode, muiTableHeadProps, positionToolbarAlertBanner }, + refs: { tableHeadRef }, } = table; - const {isFullScreen, showAlertBanner} = getState(); + const { isFullScreen, showAlertBanner } = getState(); const tableHeadProps = { - ...parseFromValuesOrFunc(muiTableHeadProps, {table}), + ...parseFromValuesOrFunc(muiTableHeadProps, { table }), ...rest, }; @@ -37,28 +28,24 @@ const DataTable_TableHead = ({ } }} sx={(theme) => ({ - display: layoutMode?.startsWith('grid') ? 'grid' : undefined, + display: layoutMode?.startsWith("grid") ? "grid" : undefined, opacity: 0.97, - position: stickyHeader ? 'sticky' : 'relative', - top: stickyHeader && layoutMode?.startsWith('grid') ? 0 : undefined, + position: stickyHeader ? "sticky" : "relative", + top: stickyHeader && layoutMode?.startsWith("grid") ? 0 : undefined, zIndex: stickyHeader ? 2 : undefined, - ...(parseFromValuesOrFunc(tableHeadProps?.sx, theme)), + ...parseFromValuesOrFunc(tableHeadProps?.sx, theme), })} > - {table - .getHeaderGroups() - .map((headerGroup, index) => ( - - )) - } + {table.getHeaderGroups().map((headerGroup, index) => ( + + ))} ); - -} -export default DataTable_TableHead \ No newline at end of file +}; +export default DataTable_TableHead; diff --git a/src/core/components/DataTable/head/TableHeadCell.js b/src/core/components/DataTable/head/TableHeadCell.js index 6248d63..a0b8fc5 100644 --- a/src/core/components/DataTable/head/TableHeadCell.js +++ b/src/core/components/DataTable/head/TableHeadCell.js @@ -1,16 +1,10 @@ -import {getCommonMRTCellStyles, parseFromValuesOrFunc} from "@/core/utils/utils"; -import {useTheme} from "@emotion/react"; -import {Box, TableCell} from "@mui/material"; -import {MRT_TableHeadCellSortLabel} from "material-react-table"; -import {useMemo} from "react"; +import { getCommonMRTCellStyles, parseFromValuesOrFunc } from "@/core/utils/utils"; +import { useTheme } from "@emotion/react"; +import { Box, TableCell } from "@mui/material"; +import { MRT_TableHeadCellSortLabel } from "material-react-table"; +import { useMemo } from "react"; -const DataTable_TableHeadCell = ({ - columnVirtualizer, - header, - staticColumnIndex, - table, - ...rest - }) => { +const DataTable_TableHeadCell = ({ columnVirtualizer, header, staticColumnIndex, table, ...rest }) => { const theme = useTheme(); const { getState, @@ -24,26 +18,19 @@ const DataTable_TableHeadCell = ({ enableGrouping, enableMultiSort, layoutMode, - mrtTheme: {draggingBorderColor}, + mrtTheme: { draggingBorderColor }, muiTableHeadCellProps, }, - refs: {tableHeadCellRefs}, + refs: { tableHeadCellRefs }, setHoveredColumn, } = table; - const { - columnSizingInfo, - density, - draggingColumn, - grouping, - hoveredColumn, - showColumnFilters, - } = getState(); - const {column} = header; - const {columnDef} = column; - const {columnDefType} = columnDef; + const { columnSizingInfo, density, draggingColumn, grouping, hoveredColumn, showColumnFilters } = getState(); + const { column } = header; + const { columnDef } = column; + const { columnDefType } = columnDef; const tableCellProps = { - ...parseFromValuesOrFunc(muiTableHeadCellProps, {column, table}), + ...parseFromValuesOrFunc(muiTableHeadCellProps, { column, table }), ...parseFromValuesOrFunc(columnDef.muiTableHeadCellProps, { column, table, @@ -51,23 +38,17 @@ const DataTable_TableHeadCell = ({ ...rest, }; - const isColumnPinned = - enableColumnPinning && - columnDef.columnDefType !== 'group' && - column.getIsPinned(); + const isColumnPinned = enableColumnPinning && columnDef.columnDefType !== "group" && column.getIsPinned(); const showColumnActions = - (enableColumnActions || columnDef.enableColumnActions) && - columnDef.enableColumnActions !== false; + (enableColumnActions || columnDef.enableColumnActions) && columnDef.enableColumnActions !== false; const showDragHandle = enableColumnDragging !== false && columnDef.enableColumnDragging !== false && (enableColumnDragging || (enableColumnOrdering && columnDef.enableColumnOrdering !== false) || - (enableGrouping && - columnDef.enableGrouping !== false && - !grouping.includes(column.id))); + (enableGrouping && columnDef.enableGrouping !== false && !grouping.includes(column.id))); const headerPL = useMemo(() => { let pl = 0; @@ -80,41 +61,37 @@ const DataTable_TableHeadCell = ({ const draggingBorders = useMemo(() => { const showResizeBorder = columnSizingInfo.isResizingColumn === column.id && - columnResizeMode === 'onChange' && + columnResizeMode === "onChange" && !header.subHeaders.length; const borderStyle = showResizeBorder ? `2px solid ${draggingBorderColor} !important` : draggingColumn?.id === column.id - ? `1px dashed ${theme.palette.grey[500]}` - : hoveredColumn?.id === column.id - ? `2px dashed ${draggingBorderColor}` - : undefined; + ? `1px dashed ${theme.palette.grey[500]}` + : hoveredColumn?.id === column.id + ? `2px dashed ${draggingBorderColor}` + : undefined; if (showResizeBorder) { - return columnResizeDirection === 'ltr' - ? {borderRight: borderStyle} - : {borderLeft: borderStyle}; + return columnResizeDirection === "ltr" ? { borderRight: borderStyle } : { borderLeft: borderStyle }; } const draggingBorders = borderStyle ? { - borderLeft: borderStyle, - borderRight: borderStyle, - borderTop: borderStyle, - } + borderLeft: borderStyle, + borderRight: borderStyle, + borderTop: borderStyle, + } : undefined; return draggingBorders; }, [draggingColumn, hoveredColumn, columnSizingInfo.isResizingColumn]); const handleDragEnter = (_e) => { - if (enableGrouping && hoveredColumn?.id === 'drop-zone') { + if (enableGrouping && hoveredColumn?.id === "drop-zone") { setHoveredColumn(null); } - if (enableColumnOrdering && draggingColumn && columnDefType !== 'group') { - setHoveredColumn( - columnDef.enableColumnOrdering !== false ? column : null, - ); + if (enableColumnOrdering && draggingColumn && columnDefType !== "group") { + setHoveredColumn(columnDef.enableColumnOrdering !== false ? column : null); } }; @@ -124,7 +101,6 @@ const DataTable_TableHeadCell = ({ } }; - const HeaderElement = parseFromValuesOrFunc(columnDef.Header, { column, @@ -132,12 +108,9 @@ const DataTable_TableHeadCell = ({ table, }) ?? columnDef.header; - const columnRelativeDepth = header.depth - column.depth; - if ( - columnRelativeDepth > 1 - ) { + if (columnRelativeDepth > 1) { return null; } @@ -149,13 +122,7 @@ const DataTable_TableHeadCell = ({ return ( { if (node) { tableHeadCellRefs.current[column.id] = node; - if (columnDefType !== 'group') { + if (columnDefType !== "group") { columnVirtualizer?.measureElement?.(node); } } }} {...tableCellProps} sx={(theme) => ({ - '& :hover': { - '.MuiButtonBase-root': { - opacity: 1, - }, + "& :hover": { + ".MuiButtonBase-root": { + opacity: 1, }, - flexDirection: layoutMode?.startsWith('grid') ? 'column' : undefined, - fontWeight: 'bold', - overflow: 'visible', - p: - density === 'compact' - ? '0.5rem' - : density === 'comfortable' - ? columnDefType === 'display' - ? '0.75rem' - : '1rem' - : columnDefType === 'display' - ? '1rem 1.25rem' - : '1.5rem', - pb: - columnDefType === 'display' - ? 0 - : showColumnFilters || density === 'compact' - ? '0.4rem' - : '0.6rem', - pt: - columnDefType === 'group' || density === 'compact' - ? '0.25rem' - : density === 'comfortable' - ? '.75rem' - : '1.25rem', - userSelect: enableMultiSort && column.getCanSort() ? 'none' : undefined, - verticalAlign: 'middle', - ...getCommonMRTCellStyles({ - column, - header, - table, - tableCellProps, - theme, - }), - ...draggingBorders, - } - )} + }, + flexDirection: layoutMode?.startsWith("grid") ? "column" : undefined, + fontWeight: "bold", + overflow: "visible", + p: + density === "compact" + ? "0.5rem" + : density === "comfortable" + ? columnDefType === "display" + ? "0.75rem" + : "1rem" + : columnDefType === "display" + ? "1rem 1.25rem" + : "1.5rem", + pb: columnDefType === "display" ? 0 : showColumnFilters || density === "compact" ? "0.4rem" : "0.6rem", + pt: + columnDefType === "group" || density === "compact" + ? "0.25rem" + : density === "comfortable" + ? ".75rem" + : "1.25rem", + userSelect: enableMultiSort && column.getCanSort() ? "none" : undefined, + verticalAlign: "middle", + ...getCommonMRTCellStyles({ + column, + header, + table, + tableCellProps, + theme, + }), + ...draggingBorders, + })} > {tableCellProps.children ?? ( {HeaderElement} - {(column.getCanSort() && columnDefType !== 'group') && ( - + {column.getCanSort() && columnDefType !== "group" && ( + )} )} ); - -} -export default DataTable_TableHeadCell; \ No newline at end of file +}; +export default DataTable_TableHeadCell; diff --git a/src/core/components/DataTable/head/TableHeadRow.js b/src/core/components/DataTable/head/TableHeadRow.js index 33a23e2..512147a 100644 --- a/src/core/components/DataTable/head/TableHeadRow.js +++ b/src/core/components/DataTable/head/TableHeadRow.js @@ -1,25 +1,20 @@ -import {parseFromValuesOrFunc} from "@/core/utils/utils"; -import {TableRow} from "@mui/material"; +import { parseFromValuesOrFunc } from "@/core/utils/utils"; +import { TableRow } from "@mui/material"; import DataTable_TableHeadCell from "./TableHeadCell"; const DataTable_TableHeadRow = ({ - columnVirtualizer, - headerGroup, - table, - index, // Add index prop - ...rest - }) => { + columnVirtualizer, + headerGroup, + table, + index, // Add index prop + ...rest +}) => { const { - options: { - enableStickyHeader, - layoutMode, - muiTableHeadRowProps, - }, + options: { enableStickyHeader, layoutMode, muiTableHeadRowProps }, } = table; - const {virtualColumns, virtualPaddingLeft, virtualPaddingRight} = - columnVirtualizer ?? {}; + const { virtualColumns, virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer ?? {}; - const backgroundColor = index % 2 === 0 ? '#015688' : '#ff5c0f'; + const backgroundColor = index % 2 === 0 ? "#015688" : "#ff5c0f"; const tableRowProps = { ...parseFromValuesOrFunc(muiTableHeadRowProps, { @@ -27,20 +22,23 @@ const DataTable_TableHeadRow = ({ table, }), ...rest, - sx: (theme) => ({ // Access theme from the sx function + sx: (theme) => ({ + // Access theme from the sx function ...(parseFromValuesOrFunc(muiTableHeadRowProps?.sx, theme) || {}), backgroundColor, // Apply background color - display: layoutMode?.startsWith('grid') ? 'flex' : undefined, - position: enableStickyHeader && layoutMode === 'semantic' ? 'sticky' : 'relative', + display: layoutMode?.startsWith("grid") ? "flex" : undefined, + position: enableStickyHeader && layoutMode === "semantic" ? "sticky" : "relative", top: 0, }), }; return ( - {virtualPaddingLeft && } + {virtualPaddingLeft && } {(virtualColumns ?? headerGroup.headers).map((headerOrVirtualHeader, staticColumnIndex) => { - const header = columnVirtualizer ? headerGroup.headers[headerOrVirtualHeader.index] : headerOrVirtualHeader; + const header = columnVirtualizer + ? headerGroup.headers[headerOrVirtualHeader.index] + : headerOrVirtualHeader; return header ? ( ) : null; })} - {virtualPaddingRight && } + {virtualPaddingRight && } ); }; -export default DataTable_TableHeadRow; \ No newline at end of file +export default DataTable_TableHeadRow; diff --git a/src/core/components/DataTable/index.js b/src/core/components/DataTable/index.js index e440895..f387d06 100644 --- a/src/core/components/DataTable/index.js +++ b/src/core/components/DataTable/index.js @@ -4,9 +4,9 @@ import DataTableProvider from "@/lib/contexts/DataTable"; const DataTable = (props) => { return ( - + ); }; -export default DataTable; \ No newline at end of file +export default DataTable; diff --git a/src/core/components/DataTable/localization/fa/datatable.js b/src/core/components/DataTable/localization/fa/datatable.js index f80b7e0..e36f366 100644 --- a/src/core/components/DataTable/localization/fa/datatable.js +++ b/src/core/components/DataTable/localization/fa/datatable.js @@ -67,8 +67,7 @@ export const FA_DATATABLE_LOCALIZATION = { rowsPerPage: "ردیف در هر صفحه", save: "ذخیره", search: "جستجو", - selectedCountOfRowCountRowsSelected: - "{selectedCount} از {rowCount} ردیف انتخاب شده", + selectedCountOfRowCountRowsSelected: "{selectedCount} از {rowCount} ردیف انتخاب شده", select: "انتخاب", showAll: "نمایش همه", showAllColumns: "نمایش همه ستون‌ها", @@ -89,4 +88,4 @@ export const FA_DATATABLE_LOCALIZATION = { unpin: "رها کردن", unpinAll: "رها کردن همه", unsorted: "بدون مرتب سازی", -}; \ No newline at end of file +}; diff --git a/src/core/components/DataTable/menus/ActionMenuItem.js b/src/core/components/DataTable/menus/ActionMenuItem.js index 2b208b9..012fcc5 100644 --- a/src/core/components/DataTable/menus/ActionMenuItem.js +++ b/src/core/components/DataTable/menus/ActionMenuItem.js @@ -1,12 +1,6 @@ import { Box, IconButton, ListItemIcon, MenuItem } from "@mui/material"; -const DataTable_ActionMenuItem = ({ - icon, - label, - onOpenSubMenu, - table, - ...rest -}) => { +const DataTable_ActionMenuItem = ({ icon, label, onOpenSubMenu, table, ...rest }) => { const { options: { icons: { ArrowRightIcon }, @@ -16,35 +10,29 @@ const DataTable_ActionMenuItem = ({ return ( {icon} {label} {onOpenSubMenu && ( - + )} ); - -} -export default DataTable_ActionMenuItem \ No newline at end of file +}; +export default DataTable_ActionMenuItem; diff --git a/src/core/components/DataTable/menus/CellActionMenu.js b/src/core/components/DataTable/menus/CellActionMenu.js index 36638e0..5b27ca9 100644 --- a/src/core/components/DataTable/menus/CellActionMenu.js +++ b/src/core/components/DataTable/menus/CellActionMenu.js @@ -2,10 +2,7 @@ import { parseFromValuesOrFunc } from "@/core/utils/utils"; import { Menu } from "@mui/material"; import DataTable_ActionMenuItem from "./ActionMenuItem"; -const DataTable_CellActionMenu = ({ - table, - ...rest -}) => { +const DataTable_CellActionMenu = ({ table, ...rest }) => { const { getState, options: { @@ -32,12 +29,11 @@ const DataTable_CellActionMenu = ({ }; const internalMenuItems = [ - (parseFromValuesOrFunc(enableClickToCopy, cell) === 'context-menu' || - parseFromValuesOrFunc(columnDef.enableClickToCopy, cell) === - 'context-menu') && ( + (parseFromValuesOrFunc(enableClickToCopy, cell) === "context-menu" || + parseFromValuesOrFunc(columnDef.enableClickToCopy, cell) === "context-menu") && ( } - key={'mrt-copy'} + key={"mrt-copy"} label={localization.copy} onClick={(event) => { event.stopPropagation(); @@ -47,10 +43,10 @@ const DataTable_CellActionMenu = ({ table={table} /> ), - parseFromValuesOrFunc(enableEditing, row) && editDisplayMode === 'cell' && ( + parseFromValuesOrFunc(enableEditing, row) && editDisplayMode === "cell" && ( } - key={'mrt-edit'} + key={"mrt-edit"} label={localization.edit} onClick={() => { openEditingCell({ cell, table }); @@ -71,14 +67,13 @@ const DataTable_CellActionMenu = ({ }; const menuItems = - columnDef.renderCellActionMenuItems?.(renderActionProps) ?? - renderCellActionMenuItems?.(renderActionProps); + columnDef.renderCellActionMenuItems?.(renderActionProps) ?? renderCellActionMenuItems?.(renderActionProps); return ( (!!menuItems?.length || !!internalMenuItems?.length) && ( ) ); - -} -export default DataTable_CellActionMenu \ No newline at end of file +}; +export default DataTable_CellActionMenu; diff --git a/src/core/components/DataTable/menus/ShowHideColumnsMenu.js b/src/core/components/DataTable/menus/ShowHideColumnsMenu.js index 12efae8..cb0423c 100644 --- a/src/core/components/DataTable/menus/ShowHideColumnsMenu.js +++ b/src/core/components/DataTable/menus/ShowHideColumnsMenu.js @@ -2,11 +2,7 @@ import { Box, Button, Divider, Menu } from "@mui/material"; import { useMemo, useState } from "react"; import DataTable_ShowHideColumnsMenuItems from "./ShowHideColumnsMenuItems"; -const DataTable_ShowHideColumnsMenu = ({ anchorEl, - setAnchorEl, - table, - ...rest -}) => { +const DataTable_ShowHideColumnsMenu = ({ anchorEl, setAnchorEl, table, ...rest }) => { const { getAllColumns, getAllLeafColumns, @@ -36,14 +32,11 @@ const DataTable_ShowHideColumnsMenu = ({ anchorEl, const allColumns = useMemo(() => { const columns = getAllColumns(); - if ( - columnOrder.length > 0 && - !columns.some((col) => col.columnDef.columnDefType === 'group') - ) { + if (columnOrder.length > 0 && !columns.some((col) => col.columnDef.columnDefType === "group")) { return [ ...getLeftLeafColumns(), ...Array.from(new Set(columnOrder)).map((colId) => - getCenterLeafColumns().find((col) => col?.id === colId), + getCenterLeafColumns().find((col) => col?.id === colId) ), ...getRightLeafColumns(), ].filter(Boolean); @@ -58,16 +51,14 @@ const DataTable_ShowHideColumnsMenu = ({ anchorEl, getRightLeafColumns(), ]); - const isNestedColumns = allColumns.some( - (col) => col.columnDef.columnDefType === 'group', - ); + const isNestedColumns = allColumns.some((col) => col.columnDef.columnDefType === "group"); const [hoveredColumn, setHoveredColumn] = useState(null); return ( {enableHiding && ( - )} {enableColumnOrdering && ( - )} {enableColumnPinning && ( - )} {enableHiding && ( - )} @@ -136,5 +112,5 @@ const DataTable_ShowHideColumnsMenu = ({ anchorEl, ))} ); -} -export default DataTable_ShowHideColumnsMenu \ No newline at end of file +}; +export default DataTable_ShowHideColumnsMenu; diff --git a/src/core/components/DataTable/menus/ShowHideColumnsMenuItems.js b/src/core/components/DataTable/menus/ShowHideColumnsMenuItems.js index 58425d9..97c2e5d 100644 --- a/src/core/components/DataTable/menus/ShowHideColumnsMenuItems.js +++ b/src/core/components/DataTable/menus/ShowHideColumnsMenuItems.js @@ -30,7 +30,7 @@ const DataTable_ShowHideColumnsMenuItems = ({ const switchChecked = column.getIsVisible(); const handleToggleColumnHidden = (column) => { - if (columnDefType === 'group') { + if (columnDefType === "group") { column?.columns?.forEach?.((childColumn) => { childColumn.toggleVisibility(!switchChecked); }); @@ -78,29 +78,29 @@ const DataTable_ShowHideColumnsMenuItems = ({ ref={menuItemRef} {...rest} sx={(theme) => ({ - alignItems: 'center', - justifyContent: 'flex-start', + alignItems: "center", + justifyContent: "flex-start", my: 0, opacity: isDragging ? 0.5 : 1, outline: isDragging ? `2px dashed ${theme.palette.grey[500]}` : hoveredColumn?.id === column.id - ? `2px dashed ${draggingBorderColor}` - : 'none', - outlineOffset: '-2px', + ? `2px dashed ${draggingBorderColor}` + : "none", + outlineOffset: "-2px", pl: `${(column.depth + 0.5) * 2}rem`, - py: '6px', - ...(parseFromValuesOrFunc(rest?.sx, theme)), + py: "6px", + ...parseFromValuesOrFunc(rest?.sx, theme), })} > - {columnDefType !== 'group' && + {columnDefType !== "group" && enableColumnOrdering && !isNestedColumns && (columnDef.enableColumnOrdering !== false ? ( @@ -110,7 +110,7 @@ const DataTable_ShowHideColumnsMenuItems = ({ table={table} /> ) : ( - + ))} {enableHiding ? ( + } @@ -136,9 +133,7 @@ const DataTable_ShowHideColumnsMenuItems = ({ onChange={() => handleToggleColumnHidden(column)} /> ) : ( - - {columnDef.header} - + {columnDef.header} )} @@ -155,6 +150,5 @@ const DataTable_ShowHideColumnsMenuItems = ({ ))} ); - -} -export default DataTable_ShowHideColumnsMenuItems; \ No newline at end of file +}; +export default DataTable_ShowHideColumnsMenuItems; diff --git a/src/core/components/DataTable/refactor/RefactorTable.jsx b/src/core/components/DataTable/refactor/RefactorTable.jsx index 71e302c..49217a0 100644 --- a/src/core/components/DataTable/refactor/RefactorTable.jsx +++ b/src/core/components/DataTable/refactor/RefactorTable.jsx @@ -1,14 +1,14 @@ -"use client" -import {IconButton, Tooltip} from '@mui/material'; -import RestartAltIcon from '@mui/icons-material/RestartAlt'; +"use client"; +import { IconButton, Tooltip } from "@mui/material"; +import RestartAltIcon from "@mui/icons-material/RestartAlt"; import useTableSetting from "@/lib/hooks/useTableSetting"; -import {useState} from "react"; +import { useState } from "react"; function RefactorTable() { - const {refactorAction} = useTableSetting(); + const { refactorAction } = useTableSetting(); const [userId, setUserId] = useState(0); - const [pageName, setPageName] = useState('testPage'); - const [tableName, setTableName] = useState('testTable'); + const [pageName, setPageName] = useState("testPage"); + const [tableName, setTableName] = useState("testTable"); const refactor = () => { refactorAction(userId, pageName, tableName); @@ -17,12 +17,10 @@ function RefactorTable() { return ( - + ); } export default RefactorTable; - - diff --git a/src/core/components/DataTable/table/Paper.js b/src/core/components/DataTable/table/Paper.js index 9a3be31..ede80b3 100644 --- a/src/core/components/DataTable/table/Paper.js +++ b/src/core/components/DataTable/table/Paper.js @@ -1,27 +1,27 @@ -import {parseFromValuesOrFunc} from "@/core/utils/utils"; -import {Paper} from "@mui/material"; +import { parseFromValuesOrFunc } from "@/core/utils/utils"; +import { Paper } from "@mui/material"; import DataTable_BottomToolbar from "../toolbar/BottomToolbar"; import DataTable_TopToolbar from "../toolbar/TopToolbar"; import DataTable_TableContainer from "./TableContainer"; -const DataTable_Paper = ({table, ...rest}) => { +const DataTable_Paper = ({ table, ...rest }) => { const { getState, options: { enableBottomToolbar, enableTopToolbar, - mrtTheme: {baseBackgroundColor}, + mrtTheme: { baseBackgroundColor }, muiTablePaperProps, renderBottomToolbar, renderTopToolbar, }, - refs: {tablePaperRef}, + refs: { tablePaperRef }, } = table; - const {isFullScreen} = getState(); + const { isFullScreen } = getState(); const paperProps = { - ...parseFromValuesOrFunc(muiTablePaperProps, {table}), + ...parseFromValuesOrFunc(muiTablePaperProps, { table }), ...rest, }; @@ -39,42 +39,44 @@ const DataTable_Paper = ({table, ...rest}) => { style={{ ...(isFullScreen ? { - bottom: 0, - height: '100dvh', - left: 0, - margin: 0, - maxHeight: '100dvh', - maxWidth: '100dvw', - padding: 0, - position: 'fixed', - right: 0, - top: 0, - width: '100dvw', - zIndex: 999, - } + bottom: 0, + height: "100dvh", + left: 0, + margin: 0, + maxHeight: "100dvh", + maxWidth: "100dvw", + padding: 0, + position: "fixed", + right: 0, + top: 0, + width: "100dvw", + zIndex: 999, + } : {}), ...paperProps?.style, }} sx={(theme) => ({ backgroundColor: baseBackgroundColor, - backgroundImage: 'unset', - overflow: 'hidden', - transition: 'all 100ms ease-in-out', - ...(parseFromValuesOrFunc(paperProps?.sx, theme)), + backgroundImage: "unset", + overflow: "hidden", + transition: "all 100ms ease-in-out", + ...parseFromValuesOrFunc(paperProps?.sx, theme), })} > {enableTopToolbar && - (parseFromValuesOrFunc(renderTopToolbar, {table}) ?? ( - + (parseFromValuesOrFunc(renderTopToolbar, { table }) ?? ( + ))} - + {enableBottomToolbar && - (parseFromValuesOrFunc(renderBottomToolbar, {table}) ?? ( - - ))} + (parseFromValuesOrFunc(renderBottomToolbar, { table }) ?? )} ); }; diff --git a/src/core/components/DataTable/table/Table.js b/src/core/components/DataTable/table/Table.js index ca49d0c..1bf6b69 100644 --- a/src/core/components/DataTable/table/Table.js +++ b/src/core/components/DataTable/table/Table.js @@ -5,10 +5,7 @@ import { useMemo } from "react"; import DataTable_TableBody, { Memo_DataTable_TableBody } from "../body/TableBody"; import DataTable_TableHead from "../head/TableHead"; -const DataTable_Table = ({ - table, - ...rest -}) => { +const DataTable_Table = ({ table, ...rest }) => { const { getFlatHeaders, getState, @@ -23,8 +20,7 @@ const DataTable_Table = ({ renderCaption, }, } = table; - const { columnSizing, columnSizingInfo, columnVisibility, isFullScreen } = - getState(); + const { columnSizing, columnSizingInfo, columnVisibility, isFullScreen } = getState(); const tableProps = { ...parseFromValuesOrFunc(muiTableProps, { table }), @@ -58,14 +54,14 @@ const DataTable_Table = ({ {...tableProps} style={{ ...columnSizeVars, ...tableProps?.style }} sx={(theme) => ({ - display: layoutMode?.startsWith('grid') ? 'grid' : undefined, - position: 'relative', - ...(parseFromValuesOrFunc(tableProps?.sx, theme)), + display: layoutMode?.startsWith("grid") ? "grid" : undefined, + position: "relative", + ...parseFromValuesOrFunc(tableProps?.sx, theme), })} > {!!Caption && {Caption}} {enableTableHead && } - {memoMode === 'table-body' || columnSizingInfo.isResizingColumn ? ( + {memoMode === "table-body" || columnSizingInfo.isResizingColumn ? ( ) : ( @@ -73,5 +69,5 @@ const DataTable_Table = ({ {/* {enableTableFooter && } */} ); -} -export default DataTable_Table \ No newline at end of file +}; +export default DataTable_Table; diff --git a/src/core/components/DataTable/table/TableContainer.js b/src/core/components/DataTable/table/TableContainer.js index aa4b625..bc1d80c 100644 --- a/src/core/components/DataTable/table/TableContainer.js +++ b/src/core/components/DataTable/table/TableContainer.js @@ -5,31 +5,17 @@ import DataTable_CellActionMenu from "../menus/CellActionMenu"; import DataTable_Table from "./Table"; import DataTable_TableLoadingOverlay from "./TableLoadingOverlay"; -const useIsomorphicLayoutEffect = - typeof window !== 'undefined' ? useLayoutEffect : useEffect; +const useIsomorphicLayoutEffect = typeof window !== "undefined" ? useLayoutEffect : useEffect; -const DataTable_TableContainer = ({ - table, - ...rest -}) => { +const DataTable_TableContainer = ({ table, ...rest }) => { const { getState, - options: { - enableCellActions, - enableStickyHeader, - muiTableContainerProps, - }, + options: { enableCellActions, enableStickyHeader, muiTableContainerProps }, refs: { bottomToolbarRef, tableContainerRef, topToolbarRef }, } = table; - const { - actionCell, - isFullScreen, - isLoading, - showLoadingOverlay, - } = getState(); + const { actionCell, isFullScreen, isLoading, showLoadingOverlay } = getState(); - const loading = - showLoadingOverlay !== false && (isLoading || showLoadingOverlay); + const loading = showLoadingOverlay !== false && (isLoading || showLoadingOverlay); const [totalToolbarHeight, setTotalToolbarHeight] = useState(0); @@ -41,15 +27,9 @@ const DataTable_TableContainer = ({ }; useIsomorphicLayoutEffect(() => { - const topToolbarHeight = - typeof document !== 'undefined' - ? topToolbarRef.current?.offsetHeight ?? 0 - : 0; + const topToolbarHeight = typeof document !== "undefined" ? topToolbarRef.current?.offsetHeight ?? 0 : 0; - const bottomToolbarHeight = - typeof document !== 'undefined' - ? bottomToolbarRef?.current?.offsetHeight ?? 0 - : 0; + const bottomToolbarHeight = typeof document !== "undefined" ? bottomToolbarRef?.current?.offsetHeight ?? 0 : 0; setTotalToolbarHeight(topToolbarHeight + bottomToolbarHeight); }); @@ -57,7 +37,7 @@ const DataTable_TableContainer = ({ return ( { if (node) { @@ -69,19 +49,17 @@ const DataTable_TableContainer = ({ } }} style={{ - maxHeight: isFullScreen - ? `calc(100vh - ${totalToolbarHeight}px)` - : undefined, + maxHeight: isFullScreen ? `calc(100vh - ${totalToolbarHeight}px)` : undefined, ...tableContainerProps?.style, }} sx={(theme) => ({ maxHeight: enableStickyHeader ? `clamp(350px, calc(100vh - ${totalToolbarHeight}px), 9999px)` : undefined, - maxWidth: '100%', - overflow: 'auto', - position: 'relative', - ...(parseFromValuesOrFunc(tableContainerProps?.sx, theme)), + maxWidth: "100%", + overflow: "auto", + position: "relative", + ...parseFromValuesOrFunc(tableContainerProps?.sx, theme), })} > {loading ? : null} @@ -89,6 +67,5 @@ const DataTable_TableContainer = ({ {enableCellActions && actionCell && } ); - -} -export default DataTable_TableContainer \ No newline at end of file +}; +export default DataTable_TableContainer; diff --git a/src/core/components/DataTable/table/TableLoadingOverlay.js b/src/core/components/DataTable/table/TableLoadingOverlay.js index 55e4ae5..0c417dd 100644 --- a/src/core/components/DataTable/table/TableLoadingOverlay.js +++ b/src/core/components/DataTable/table/TableLoadingOverlay.js @@ -1,9 +1,6 @@ import { Box, CircularProgress } from "@mui/material"; -const DataTable_TableLoadingOverlay = ({ - table, - ...rest -}) => { +const DataTable_TableLoadingOverlay = ({ table, ...rest }) => { const { options: { localization, @@ -20,17 +17,17 @@ const DataTable_TableLoadingOverlay = ({ return ( @@ -43,6 +40,5 @@ const DataTable_TableLoadingOverlay = ({ )} ); - -} -export default DataTable_TableLoadingOverlay \ No newline at end of file +}; +export default DataTable_TableLoadingOverlay; diff --git a/src/core/components/DataTable/toolbar/BottomToolbar.js b/src/core/components/DataTable/toolbar/BottomToolbar.js index 15e7f5a..ced2c06 100644 --- a/src/core/components/DataTable/toolbar/BottomToolbar.js +++ b/src/core/components/DataTable/toolbar/BottomToolbar.js @@ -3,23 +3,15 @@ import { Box, alpha, useMediaQuery } from "@mui/material"; import DataTable_LinearProgressBar from "./LinearProgressBar"; import DataTable_TablePagination from "./TablePagination"; -const DataTable_BottomToolbar = ({ - table, - ...rest -}) => { +const DataTable_BottomToolbar = ({ table, ...rest }) => { const { getState, - options: { - enablePagination, - muiBottomToolbarProps, - positionPagination, - renderBottomToolbarCustomActions, - }, + options: { enablePagination, muiBottomToolbarProps, positionPagination, renderBottomToolbarCustomActions }, refs: { bottomToolbarRef }, } = table; const { isFullScreen } = getState(); - const isMobile = useMediaQuery('(max-width:720px)'); + const isMobile = useMediaQuery("(max-width:720px)"); const toolbarProps = { ...parseFromValuesOrFunc(muiBottomToolbarProps, { table }), ...rest, @@ -40,49 +32,41 @@ const DataTable_BottomToolbar = ({ }} sx={(theme) => ({ ...getCommonToolbarStyles({ table, theme }), - bottom: isFullScreen ? '0' : undefined, - boxShadow: `0 1px 2px -1px ${alpha( - theme.palette.grey[700], - 0.5, - )} inset`, + bottom: isFullScreen ? "0" : undefined, + boxShadow: `0 1px 2px -1px ${alpha(theme.palette.grey[700], 0.5)} inset`, left: 0, - position: isFullScreen ? 'fixed' : 'relative', + position: isFullScreen ? "fixed" : "relative", right: 0, - ...(parseFromValuesOrFunc(toolbarProps?.sx, theme)), + ...parseFromValuesOrFunc(toolbarProps?.sx, theme), })} > - {renderBottomToolbarCustomActions ? ( - renderBottomToolbarCustomActions({ table }) - ) : ( - - )} + {renderBottomToolbarCustomActions ? renderBottomToolbarCustomActions({ table }) : } - {enablePagination && - ['both', 'bottom'].includes(positionPagination ?? '') && ( - - )} + {enablePagination && ["both", "bottom"].includes(positionPagination ?? "") && ( + + )} ); -} -export default DataTable_BottomToolbar \ No newline at end of file +}; +export default DataTable_BottomToolbar; diff --git a/src/core/components/DataTable/toolbar/LinearProgressBar.js b/src/core/components/DataTable/toolbar/LinearProgressBar.js index cdcbc0a..74c465f 100644 --- a/src/core/components/DataTable/toolbar/LinearProgressBar.js +++ b/src/core/components/DataTable/toolbar/LinearProgressBar.js @@ -1,11 +1,7 @@ import { parseFromValuesOrFunc } from "@/core/utils/utils"; import { Collapse, LinearProgress } from "@mui/material"; -const DataTable_LinearProgressBar = ({ - isTopToolbar, - table, - ...rest -}) => { +const DataTable_LinearProgressBar = ({ isTopToolbar, table, ...rest }) => { const { getState, options: { muiLinearProgressProps }, @@ -26,19 +22,19 @@ const DataTable_LinearProgressBar = ({ mountOnEnter sx={{ bottom: isTopToolbar ? 0 : undefined, - position: 'absolute', + position: "absolute", top: !isTopToolbar ? 0 : undefined, - width: '100%', + width: "100%", }} unmountOnExit > ); -} -export default DataTable_LinearProgressBar \ No newline at end of file +}; +export default DataTable_LinearProgressBar; diff --git a/src/core/components/DataTable/toolbar/TablePagination.js b/src/core/components/DataTable/toolbar/TablePagination.js index cd70fda..6492b41 100644 --- a/src/core/components/DataTable/toolbar/TablePagination.js +++ b/src/core/components/DataTable/toolbar/TablePagination.js @@ -1,16 +1,23 @@ import { flipIconStyles, getCommonTooltipProps, parseFromValuesOrFunc } from "@/core/utils/utils"; import { useTheme } from "@emotion/react"; -import { Box, IconButton, InputLabel, MenuItem, Pagination, PaginationItem, Select, Tooltip, Typography, useMediaQuery } from "@mui/material"; +import { + Box, + IconButton, + InputLabel, + MenuItem, + Pagination, + PaginationItem, + Select, + Tooltip, + Typography, + useMediaQuery, +} from "@mui/material"; const defaultRowsPerPage = [5, 10, 15, 20, 25, 30, 50, 100]; -const DataTable_TablePagination = ({ - position = 'bottom', - table, - ...rest -}) => { +const DataTable_TablePagination = ({ position = "bottom", table, ...rest }) => { const theme = useTheme(); - const isMobile = useMediaQuery('(max-width: 720px)'); + const isMobile = useMediaQuery("(max-width: 720px)"); const { getState, @@ -64,26 +71,21 @@ const DataTable_TablePagination = ({ {showRowsPerPage && ( - + {localization.rowsPerPage} @@ -92,22 +94,19 @@ const DataTable_TablePagination = ({ disableUnderline disabled={disabled} inputProps={{ - 'aria-label': localization.rowsPerPage, - id: 'mrt-rows-per-page', + "aria-label": localization.rowsPerPage, + id: "mrt-rows-per-page", }} label={localization.rowsPerPage} - onChange={(event) => - table.setPageSize(+(event.target.value)) - } + onChange={(event) => table.setPageSize(+event.target.value)} sx={{ mb: 0 }} value={pageSize} variant="standard" {...SelectProps} > {rowsPerPageOptions.map((option) => { - const value = typeof option !== 'number' ? option.value : option; - const label = - typeof option !== 'number' ? option.label : `${option}`; + const value = typeof option !== "number" ? option.value : option; + const label = typeof option !== "number" ? option.label : `${option}`; return ( SelectProps?.children ?? (SelectProps?.native ? ( @@ -124,7 +123,7 @@ const DataTable_TablePagination = ({ )} - {paginationDisplayMode === 'pages' ? ( + {paginationDisplayMode === "pages" ? ( - ) : paginationDisplayMode === 'default' ? ( + ) : paginationDisplayMode === "default" ? ( <> {`${lastRowIndex === 0 ? 0 : (firstRowIndex + 1).toLocaleString() - }-${lastRowIndex.toLocaleString()} ${localization.of - } ${totalRowCount.toLocaleString()}`} + >{`${ + lastRowIndex === 0 ? 0 : (firstRowIndex + 1).toLocaleString() + }-${lastRowIndex.toLocaleString()} ${ + localization.of + } ${totalRowCount.toLocaleString()}`} {showFirstButton && ( @@ -213,5 +214,5 @@ const DataTable_TablePagination = ({ ) : null} ); -} -export default DataTable_TablePagination \ No newline at end of file +}; +export default DataTable_TablePagination; diff --git a/src/core/components/DataTable/toolbar/ToolbarInternalButtons.js b/src/core/components/DataTable/toolbar/ToolbarInternalButtons.js index 606add0..9250b89 100644 --- a/src/core/components/DataTable/toolbar/ToolbarInternalButtons.js +++ b/src/core/components/DataTable/toolbar/ToolbarInternalButtons.js @@ -16,32 +16,29 @@ const DataTable_ToolbarInternalButtons = ({ table, ...rest }) => { }, } = table; - return ( ({ - alignItems: 'center', - display: 'flex', + alignItems: "center", + display: "flex", zIndex: 3, - ...(parseFromValuesOrFunc(rest?.sx, theme)), + ...parseFromValuesOrFunc(rest?.sx, theme), })} > {renderToolbarInternalActions?.({ table, }) ?? ( - <> - {enableFilters && - enableColumnFilters && - columnFilterDisplayMode !== 'popover' && ( - - )} - {(enableHiding || enableColumnOrdering || enableColumnPinning) && ( - - )} - - )} + <> + {enableFilters && enableColumnFilters && columnFilterDisplayMode !== "popover" && ( + + )} + {(enableHiding || enableColumnOrdering || enableColumnPinning) && ( + + )} + + )} ); -} -export default DataTable_ToolbarInternalButtons \ No newline at end of file +}; +export default DataTable_ToolbarInternalButtons; diff --git a/src/core/components/DataTable/toolbar/TopToolbar.js b/src/core/components/DataTable/toolbar/TopToolbar.js index 7a321e2..b0e5297 100644 --- a/src/core/components/DataTable/toolbar/TopToolbar.js +++ b/src/core/components/DataTable/toolbar/TopToolbar.js @@ -1,12 +1,12 @@ -import {getCommonToolbarStyles, parseFromValuesOrFunc} from "@/core/utils/utils"; -import {Box, useMediaQuery} from "@mui/material"; +import { getCommonToolbarStyles, parseFromValuesOrFunc } from "@/core/utils/utils"; +import { Box, useMediaQuery } from "@mui/material"; import DataTable_LinearProgressBar from "./LinearProgressBar"; import DataTable_TablePagination from "./TablePagination"; import DataTable_ToolbarInternalButtons from "./ToolbarInternalButtons"; import FilterColumn from "@/core/components/DataTable/filter"; import RefactorTable from "@/core/components/DataTable/refactor/RefactorTable"; -const DataTable_TopToolbar = ({table, columns, table_url, user_id, page_name, table_name}) => { +const DataTable_TopToolbar = ({ table, columns, table_url, user_id, page_name, table_name }) => { const { getState, options: { @@ -16,19 +16,16 @@ const DataTable_TopToolbar = ({table, columns, table_url, user_id, page_name, ta positionPagination, renderTopToolbarCustomActions, }, - refs: {topToolbarRef}, + refs: { topToolbarRef }, } = table; - const {isFullScreen, showGlobalFilter} = getState(); + const { isFullScreen, showGlobalFilter } = getState(); - const isMobile = useMediaQuery('(max-width:720px)'); - const isTablet = useMediaQuery('(max-width:1024px)'); + const isMobile = useMediaQuery("(max-width:720px)"); + const isTablet = useMediaQuery("(max-width:1024px)"); - const toolbarProps = parseFromValuesOrFunc(muiTopToolbarProps, {table}); + const toolbarProps = parseFromValuesOrFunc(muiTopToolbarProps, { table }); - const stackAlertBanner = - isMobile || - !!renderTopToolbarCustomActions || - (showGlobalFilter && isTablet); + const stackAlertBanner = isMobile || !!renderTopToolbarCustomActions || (showGlobalFilter && isTablet); return ( ({ - ...getCommonToolbarStyles({table, theme}), - position: isFullScreen ? 'sticky' : 'relative', - top: isFullScreen ? '0' : undefined, - ...(parseFromValuesOrFunc(toolbarProps?.sx, theme)), + ...getCommonToolbarStyles({ table, theme }), + position: isFullScreen ? "sticky" : "relative", + top: isFullScreen ? "0" : undefined, + ...parseFromValuesOrFunc(toolbarProps?.sx, theme), })} > - {renderTopToolbarCustomActions?.({table}) ?? } + {renderTopToolbarCustomActions?.({ table }) ?? } {enableToolbarInternalActions && ( - - - + + + )} - {enablePagination && - ['both', 'top'].includes(positionPagination ?? '') && ( - - )} - + {enablePagination && ["both", "top"].includes(positionPagination ?? "") && ( + + )} + ); -} +}; -export default DataTable_TopToolbar \ No newline at end of file +export default DataTable_TopToolbar; diff --git a/src/core/components/NotificationDesign/AskForKeep.jsx b/src/core/components/NotificationDesign/AskForKeep.jsx index 7a68d2f..d4721bb 100644 --- a/src/core/components/NotificationDesign/AskForKeep.jsx +++ b/src/core/components/NotificationDesign/AskForKeep.jsx @@ -1,47 +1,61 @@ -'use client' +"use client"; -import SaveIcon from '@mui/icons-material/Save'; -import {Box, Button, Typography} from "@mui/material"; -import DownloadIcon from '@mui/icons-material/Download'; -import {toast} from "react-toastify"; - -function AskForKeep({onSaveFilter}) { +import SaveIcon from "@mui/icons-material/Save"; +import { Box, Button, Typography } from "@mui/material"; +import DownloadIcon from "@mui/icons-material/Download"; +import { toast } from "react-toastify"; +function AskForKeep({ onSaveFilter }) { const handleDismiss = () => { - toast.dismiss({containerId: "filtering"}); + toast.dismiss({ containerId: "filtering" }); }; return ( - - - + + + ذخیره سازی اطلاعات - + - - - آیا مایل به ذخیره فیلتر های اعمال شده برای دفعات بعد هستید؟ - + + آیا مایل به ذخیره فیلتر های اعمال شده برای دفعات بعد هستید؟ - - - + + + ); } -export default AskForKeep; \ No newline at end of file +export default AskForKeep; diff --git a/src/core/components/SidebarListItems.jsx b/src/core/components/SidebarListItems.jsx index d300d7f..050d9a6 100644 --- a/src/core/components/SidebarListItems.jsx +++ b/src/core/components/SidebarListItems.jsx @@ -1,77 +1,53 @@ import SidebarSubitems from "@/core/components/SidebarSubitems"; import { ExpandLess, ExpandMore } from "@mui/icons-material"; -import { - Collapse, - List, - ListItem, - ListItemButton, - ListItemIcon, - ListItemText, -} from "@mui/material"; +import { Collapse, List, ListItem, ListItemButton, ListItemIcon, ListItemText } from "@mui/material"; import Link from "next/link"; const SidebarListItems = ({ menuItem, dispatch }) => { - return ( - <> - - { - dispatch({ type: "COLLAPSE_MENU", id: menuItem.id }); - }} - > - - {menuItem.icon} - - - {menuItem.hasSubitems ? ( - menuItem.showSubitems ? ( - - ) : ( - - ) - ) : null} - - - - {menuItem.hasSubitems ? ( - - {menuItem.Subitems.map((subitem, index) => { - return ( - - ); - })} - - ) : null} - - - ); + return ( + <> + + { + dispatch({ type: "COLLAPSE_MENU", id: menuItem.id }); + }} + > + + {menuItem.icon} + + + {menuItem.hasSubitems ? menuItem.showSubitems ? : : null} + + + + {menuItem.hasSubitems ? ( + + {menuItem.Subitems.map((subitem, index) => { + return ; + })} + + ) : null} + + + ); }; export default SidebarListItems; diff --git a/src/core/components/SidebarMenu.jsx b/src/core/components/SidebarMenu.jsx index c9f6a73..0ad01dc 100644 --- a/src/core/components/SidebarMenu.jsx +++ b/src/core/components/SidebarMenu.jsx @@ -6,127 +6,119 @@ import { useEffect, useReducer, useState } from "react"; import { pageMenu } from "../utils/pageMenu"; function reducer(state, action) { - switch (action.type) { - case "COLLAPSE_MENU": - return state.map((item) => - action.id == item.id - ? { - ...item, - showSubitems: !item.showSubitems, - } - : item - ); - case "COLLAPSE_SUB_ITEMS": - return state.map((item) => { - return item.hasSubitems - ? { - ...item, - Subitems: item.Subitems.map((subitem) => - action.id === subitem.id - ? { - ...subitem, - showSubitems: !subitem.showSubitems, - } - : subitem - ), - } - : item; - }); - case "COLLAPSE_SUB_SECOND_ITEMS": - return state.map((item) => { - return item.hasSubitems - ? { - ...item, - Subitems: item.Subitems.map((subitem) => { - return subitem.hasSubitems - ? { - ...subitem, - Subitems: subitem.Subitems.map((secondSubitem) => - action.id === secondSubitem.id - ? { - ...secondSubitem, - showSubitems: !secondSubitem.showSubitems, - } - : secondSubitem - ), - } - : subitem; - }), - } - : item; - }); - case "SELECTED": - return state.map((item) => { - return item.type === "page" - ? { - ...item, - selected: action.route === item.route, - showSubitems: item.route === action.route, - } - : item.Subitems && Array.isArray(item.Subitems) - ? { - ...item, - Subitems: item.Subitems.map((subitem) => { - return subitem.type === "page" - ? { - ...subitem, - selected: action.route === subitem.route, - showSubitems: subitem.route === action.route, - } - : subitem.Subitems && Array.isArray(subitem.Subitems) - ? { - ...subitem, - Subitems: subitem.Subitems.map((secondSubItem) => ({ - ...secondSubItem, - selected: secondSubItem.route === action.route, - })), - showSubitems: subitem.Subitems.some( - (secondSubItem) => secondSubItem.route === action.route - ), - } - : subitem; - }), - showSubitems: item.Subitems.some( - (subitem) => subitem.showSubitems - ), - } - : item; - }); + switch (action.type) { + case "COLLAPSE_MENU": + return state.map((item) => + action.id == item.id + ? { + ...item, + showSubitems: !item.showSubitems, + } + : item + ); + case "COLLAPSE_SUB_ITEMS": + return state.map((item) => { + return item.hasSubitems + ? { + ...item, + Subitems: item.Subitems.map((subitem) => + action.id === subitem.id + ? { + ...subitem, + showSubitems: !subitem.showSubitems, + } + : subitem + ), + } + : item; + }); + case "COLLAPSE_SUB_SECOND_ITEMS": + return state.map((item) => { + return item.hasSubitems + ? { + ...item, + Subitems: item.Subitems.map((subitem) => { + return subitem.hasSubitems + ? { + ...subitem, + Subitems: subitem.Subitems.map((secondSubitem) => + action.id === secondSubitem.id + ? { + ...secondSubitem, + showSubitems: !secondSubitem.showSubitems, + } + : secondSubitem + ), + } + : subitem; + }), + } + : item; + }); + case "SELECTED": + return state.map((item) => { + return item.type === "page" + ? { + ...item, + selected: action.route === item.route, + showSubitems: item.route === action.route, + } + : item.Subitems && Array.isArray(item.Subitems) + ? { + ...item, + Subitems: item.Subitems.map((subitem) => { + return subitem.type === "page" + ? { + ...subitem, + selected: action.route === subitem.route, + showSubitems: subitem.route === action.route, + } + : subitem.Subitems && Array.isArray(subitem.Subitems) + ? { + ...subitem, + Subitems: subitem.Subitems.map((secondSubItem) => ({ + ...secondSubItem, + selected: secondSubItem.route === action.route, + })), + showSubitems: subitem.Subitems.some( + (secondSubItem) => secondSubItem.route === action.route + ), + } + : subitem; + }), + showSubitems: item.Subitems.some((subitem) => subitem.showSubitems), + } + : item; + }); - default: - throw new Error(); - } + default: + throw new Error(); + } } const SidebarMenu = () => { - const [menuItems, dispatch] = useReducer(reducer, pageMenu); - const pathname = usePathname(); - const [selectedKey, setSelectedKey] = useState(null); - useEffect(() => { - dispatch({ type: "SELECTED", route: pathname }); - setSelectedKey(pathname); - }, [pathname]); + const [menuItems, dispatch] = useReducer(reducer, pageMenu); + const pathname = usePathname(); + const [selectedKey, setSelectedKey] = useState(null); + useEffect(() => { + dispatch({ type: "SELECTED", route: pathname }); + setSelectedKey(pathname); + }, [pathname]); - useEffect(() => { - selectedKey && - document.querySelector(`[data-route="${selectedKey}"]`)?.scrollIntoView({ - behavior: "smooth", - block: "center", - }); - }, [selectedKey]); + useEffect(() => { + selectedKey && + document.querySelector(`[data-route="${selectedKey}"]`)?.scrollIntoView({ + behavior: "smooth", + block: "center", + }); + }, [selectedKey]); - return ( - - {menuItems.map((menuItem) => { - return ( - - ); - })} - - ); + return ( + + {menuItems.map((menuItem) => { + return ; + })} + + ); }; export default SidebarMenu; diff --git a/src/core/components/SidebarSubitems.jsx b/src/core/components/SidebarSubitems.jsx index b54d3a9..69418ea 100644 --- a/src/core/components/SidebarSubitems.jsx +++ b/src/core/components/SidebarSubitems.jsx @@ -1,75 +1,51 @@ import { ExpandLess, ExpandMore } from "@mui/icons-material"; -import { - Collapse, - List, - ListItem, - ListItemButton, - ListItemIcon, - ListItemText, -} from "@mui/material"; +import { Collapse, List, ListItem, ListItemButton, ListItemIcon, ListItemText } from "@mui/material"; import Link from "next/link"; const SidebarSubitems = ({ subitem, dispatch }) => { - return ( - <> - - { - dispatch({ type: "COLLAPSE_SUB_ITEMS", id: subitem.id }); - }} - > - - {subitem.icon} - - - {subitem.hasSubitems ? ( - subitem.showSubitems ? ( - - ) : ( - - ) - ) : null} - - - - {subitem.hasSubitems ? ( - - {subitem.Subitems.map((subSubitem, index) => { - return ( - - ); - })} - - ) : null} - - - ); + return ( + <> + + { + dispatch({ type: "COLLAPSE_SUB_ITEMS", id: subitem.id }); + }} + > + + {subitem.icon} + + + {subitem.hasSubitems ? subitem.showSubitems ? : : null} + + + + {subitem.hasSubitems ? ( + + {subitem.Subitems.map((subSubitem, index) => { + return ; + })} + + ) : null} + + + ); }; export default SidebarSubitems; diff --git a/src/core/components/Toasts/error.jsx b/src/core/components/Toasts/error.jsx index d0d9760..e93138b 100644 --- a/src/core/components/Toasts/error.jsx +++ b/src/core/components/Toasts/error.jsx @@ -3,189 +3,185 @@ import { Box, Typography } from "@mui/material"; import { Dangerous } from "@mui/icons-material"; export const errorServerToast = (toastContainer) => - toast.error( - () => ( - - - - - - {"The request failed due to an internal error."} - - - - - ), - { - icon: false, - containerId: toastContainer, - autoClose: 5000, - hideProgressBar: true, - pauseOnHover: true, - closeOnClick: false, - draggable: true, - } - ); + toast.error( + () => ( + + + + + {"The request failed due to an internal error."} + + + + ), + { + icon: false, + containerId: toastContainer, + autoClose: 5000, + hideProgressBar: true, + pauseOnHover: true, + closeOnClick: false, + draggable: true, + } + ); export const errorUnauthorizedToast = (toastContainer) => - toast.error( - () => ( - - - - - - {"The user is not authorized to make the request."} - - - - - ), - { - icon: false, - containerId: toastContainer, - autoClose: 3000, - hideProgressBar: true, - pauseOnHover: true, - closeOnClick: false, - draggable: true, - } - ); + toast.error( + () => ( + + + + + {"The user is not authorized to make the request."} + + + + ), + { + icon: false, + containerId: toastContainer, + autoClose: 3000, + hideProgressBar: true, + pauseOnHover: true, + closeOnClick: false, + draggable: true, + } + ); export const errorLogicToast = (message, toastContainer) => - toast.error( - () => ( - - - - - - {message || - "The request was well-formed but was unable to be followed due to semantic errors."} - - - - - ), - { - icon: false, - containerId: toastContainer, - autoClose: false, - closeOnClick: false, - draggable: false, - } - ); + toast.error( + () => ( + + + + + + {message || + "The request was well-formed but was unable to be followed due to semantic errors."} + + + + + ), + { + icon: false, + containerId: toastContainer, + autoClose: false, + closeOnClick: false, + draggable: false, + } + ); export const errorValidationToast = (message, toastContainer) => - toast.error( - () => ( - - - - - - {message || - "The request was well-formed but was unable to be followed due to semantic errors."} - - - - - ), - { - icon: false, - containerId: toastContainer, - autoClose: false, - closeOnClick: false, - draggable: false, - } - ); + toast.error( + () => ( + + + + + + {message || + "The request was well-formed but was unable to be followed due to semantic errors."} + + + + + ), + { + icon: false, + containerId: toastContainer, + autoClose: false, + closeOnClick: false, + draggable: false, + } + ); export const errorTooManyToast = (toastContainer) => - toast.error( - () => ( - - - - - - {"Too many requests have been sent within a given time span."} - - - - - ), - { - icon: false, - containerId: toastContainer, - autoClose: false, - closeOnClick: false, - draggable: false, - } - ); + toast.error( + () => ( + + + + + + {"Too many requests have been sent within a given time span."} + + + + + ), + { + icon: false, + containerId: toastContainer, + autoClose: false, + closeOnClick: false, + draggable: false, + } + ); export const errorClientToast = (toastContainer) => - toast.error( - () => ( - - - - - - { - "The API request is invalid or improperly formed. Consequently, the API server could not understand the request." - } - - - - - ), - { - icon: false, - containerId: toastContainer, - autoClose: false, - closeOnClick: false, - draggable: false, - } - ); + toast.error( + () => ( + + + + + + { + "The API request is invalid or improperly formed. Consequently, the API server could not understand the request." + } + + + + + ), + { + icon: false, + containerId: toastContainer, + autoClose: false, + closeOnClick: false, + draggable: false, + } + ); diff --git a/src/core/components/Toasts/success.jsx b/src/core/components/Toasts/success.jsx index b405a04..36023c6 100644 --- a/src/core/components/Toasts/success.jsx +++ b/src/core/components/Toasts/success.jsx @@ -3,33 +3,31 @@ import { Box, Typography } from "@mui/material"; import { Beenhere } from "@mui/icons-material"; export const successToast = (toastContainer) => - toast.success( - () => ( - - - - - - {"Your operation was successful"} - - - - - ), - { - icon: false, - containerId: toastContainer, - autoClose: 3000, - hideProgressBar: true, - pauseOnHover: true, - closeOnClick: false, - draggable: true, - } - ); + toast.success( + () => ( + + + + + {"Your operation was successful"} + + + + ), + { + icon: false, + containerId: toastContainer, + autoClose: 3000, + hideProgressBar: true, + pauseOnHover: true, + closeOnClick: false, + draggable: true, + } + ); diff --git a/src/core/middlewares/withAuth.js b/src/core/middlewares/withAuth.js index 1b93025..216b55b 100644 --- a/src/core/middlewares/withAuth.js +++ b/src/core/middlewares/withAuth.js @@ -1,22 +1,22 @@ -'use client' +"use client"; import { useAuth } from "@/lib/contexts/auth"; import { usePathname, useRouter } from "next/navigation"; import { useEffect } from "react"; function WithAuthMiddleware({ children }) { - const router = useRouter() - const pathName = usePathname() + const router = useRouter(); + const pathName = usePathname(); const { isAuth, initAuthState } = useAuth(); useEffect(() => { - if (!initAuthState) return + if (!initAuthState) return; if (!isAuth) { - router.replace(`${process.env.NEXT_PUBLIC_API_URL}/login?_back=${encodeURIComponent(pathName)}`) + router.replace(`${process.env.NEXT_PUBLIC_API_URL}/login?_back=${encodeURIComponent(pathName)}`); } - }, [isAuth, initAuthState]) + }, [isAuth, initAuthState]); if (!initAuthState || !isAuth) return null; - return <>{children} + return <>{children}; } -export default WithAuthMiddleware \ No newline at end of file +export default WithAuthMiddleware; diff --git a/src/core/utils/cacheRtl.js b/src/core/utils/cacheRtl.js index bf8c809..1393e2e 100644 --- a/src/core/utils/cacheRtl.js +++ b/src/core/utils/cacheRtl.js @@ -1,16 +1,16 @@ -'use client' +"use client"; import createCache from "@emotion/cache"; -import {prefixer} from "stylis"; +import { prefixer } from "stylis"; import stylisRTLPlugin from "stylis-plugin-rtl"; -import {CacheProvider} from "@emotion/react"; +import { CacheProvider } from "@emotion/react"; const cache = createCache({ - key: 'mui-rtl', + key: "mui-rtl", stylisPlugins: [prefixer, stylisRTLPlugin], }); const cacheProviderRtl = (props) => { return {props.children}; -} +}; -export default cacheProviderRtl \ No newline at end of file +export default cacheProviderRtl; diff --git a/src/core/utils/errorResponse.js b/src/core/utils/errorResponse.js index 3accb8f..1802581 100644 --- a/src/core/utils/errorResponse.js +++ b/src/core/utils/errorResponse.js @@ -1,4 +1,4 @@ -'use client' +"use client"; import { toast } from "react-toastify"; import { errorClientToast, @@ -6,56 +6,55 @@ import { errorServerToast, errorTooManyToast, errorUnauthorizedToast, - errorValidationToast + errorValidationToast, } from "@/core/components/toasts/error"; -const isServerError = status => status >= 500 && status <= 599; -const isClientError = status => status >= 400 && status <= 499; +const isServerError = (status) => status >= 500 && status <= 599; +const isClientError = (status) => status >= 400 && status <= 499; const errorServer = (response, notification, toastContainer) => { - if (notification) errorServerToast(toastContainer) -} + if (notification) errorServerToast(toastContainer); +}; const errorClient = (response, notification, toastContainer) => { switch (response.status) { case 401: - if (notification) errorUnauthorizedToast(toastContainer) + if (notification) errorUnauthorizedToast(toastContainer); break; case 422: - if ('type' in response.data) { + if ("type" in response.data) { if (Array.isArray(response.data.message)) { response.data.message.map((item) => { - if (notification) errorLogicToast(item, toastContainer) - }) + if (notification) errorLogicToast(item, toastContainer); + }); } else { - if (notification) errorLogicToast(response.data.message, toastContainer) + if (notification) errorLogicToast(response.data.message, toastContainer); } break; } if (notification) { - const errorsMap = Object.keys(response.data.errors) - const errorsArray = response.data.errors + const errorsMap = Object.keys(response.data.errors); + const errorsArray = response.data.errors; errorsMap.map((item, index) => { errorValidationToast(errorsArray[item][0], toastContainer); - }) - + }); } break; case 429: - if (notification) errorTooManyToast(toastContainer) - break + if (notification) errorTooManyToast(toastContainer); + break; default: - if (notification) errorClientToast(toastContainer) - break + if (notification) errorClientToast(toastContainer); + break; } -} +}; export const errorResponse = (response, notification, toastContainer) => { - if (notification) toast.dismiss({ container: toastContainer }) + if (notification) toast.dismiss({ container: toastContainer }); if (isServerError(response.status)) { - errorServer(response, notification, toastContainer) + errorServer(response, notification, toastContainer); } else if (isClientError(response.status)) { - errorClient(response, notification, toastContainer) + errorClient(response, notification, toastContainer); } -} +}; diff --git a/src/core/utils/flattenArrayOfObjects.js b/src/core/utils/flattenArrayOfObjects.js index 4dd4612..5b1564c 100644 --- a/src/core/utils/flattenArrayOfObjects.js +++ b/src/core/utils/flattenArrayOfObjects.js @@ -7,4 +7,4 @@ export const flattenArrayOfObjects = (array, key) => { } return acc; }, []); -}; \ No newline at end of file +}; diff --git a/src/core/utils/pageMenu.js b/src/core/utils/pageMenu.js index 81cb873..6145ffd 100644 --- a/src/core/utils/pageMenu.js +++ b/src/core/utils/pageMenu.js @@ -2,346 +2,346 @@ import { AirlineSeatReclineNormal, Assessment, Repartition, Security, SpaceDashb export const pageMenu = [ { - id: 'dashboard', - label: 'پیشخوان', + id: "dashboard", + label: "پیشخوان", type: "page", route: "/dashboard", - icon: , + icon: , }, { - id: 'userManagement', - label: 'مدیریت کاربران', + id: "userManagement", + label: "مدیریت کاربران", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/user_management", - icon: , + icon: , }, { - id: 'projectsManagment', - label: 'پروژه های راهداری', + id: "projectsManagment", + label: "پروژه های راهداری", type: "menu", - icon: , + icon: , hasSubitems: true, Subitems: [ { - id: 'projectsManagmentFinance', - label: 'ثبت قرارداد و پروژه', + id: "projectsManagmentFinance", + label: "ثبت قرارداد و پروژه", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/rahdari_projects/finance", - icon: , + icon: , }, { - id: 'projectsManagmentList', - label: 'لیست پروژه ها', + id: "projectsManagmentList", + label: "لیست پروژه ها", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/rahdari_projects/projects_list", - icon: , + icon: , }, { - id: 'projectsManagmentProposal', - label: 'پروژه های پیشنهادی', + id: "projectsManagmentProposal", + label: "پروژه های پیشنهادی", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/rahdari_projects/proposal", - icon: , + icon: , }, { - id: 'projectsManagmentLawmaker', - label: 'درخواست نمایندگان', + id: "projectsManagmentLawmaker", + label: "درخواست نمایندگان", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/rahdari_projects/lawmakers", - icon: , + icon: , }, { - id: 'projectsManagmentMap', - label: 'پراکندگی بر روی نقشه', + id: "projectsManagmentMap", + label: "پراکندگی بر روی نقشه", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/map?type=rahdari_projects", - icon: , + icon: , }, - ] + ], }, { - id: 'roadItemManagment', - label: 'فعالیت های روزانه', + id: "roadItemManagment", + label: "فعالیت های روزانه", type: "menu", - icon: , + icon: , hasSubitems: true, Subitems: [ { - id: 'roadItemManagmentSupervisor', - label: 'ارزیابی', + id: "roadItemManagmentSupervisor", + label: "ارزیابی", type: "menu", - icon: , + icon: , hasSubitems: true, Subitems: [ { - id: 'roadItemManagmentSupervisorCartable', - label: 'کارتابل', + id: "roadItemManagmentSupervisorCartable", + label: "کارتابل", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_items/supervisor/cartable", }, - ] + ], }, { - id: 'roadItemManagmentOparation', - label: 'عملیات', + id: "roadItemManagmentOparation", + label: "عملیات", type: "menu", - icon: , + icon: , hasSubitems: true, Subitems: [ { - id: 'roadItemManagmentOparationCreate', - label: 'ثبت فعالیت', + id: "roadItemManagmentOparationCreate", + label: "ثبت فعالیت", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_items/operator/create", }, { - id: 'roadItemManagmentOparationCartable', - label: 'کارتابل', + id: "roadItemManagmentOparationCartable", + label: "کارتابل", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_items/operator/cartable", }, - ] + ], }, { - id: 'roadItemManagmentMap', - label: 'پراکندگی بر روی نقشه', + id: "roadItemManagmentMap", + label: "پراکندگی بر روی نقشه", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/map?type=road_items", - icon: , + icon: , }, { - id: 'roadItemManagmentReport', - label: 'گزارش ها', + id: "roadItemManagmentReport", + label: "گزارش ها", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_items/report", - icon: , + icon: , }, - ] + ], }, { - id: 'roadPatrolManagment', - label: 'گشت راهداری و ترابری', + id: "roadPatrolManagment", + label: "گشت راهداری و ترابری", type: "menu", - icon: , + icon: , hasSubitems: true, Subitems: [ { - id: 'roadPatrolManagmentSupervisor', - label: 'ارزیابی', + id: "roadPatrolManagmentSupervisor", + label: "ارزیابی", type: "menu", - icon: , + icon: , hasSubitems: true, Subitems: [ { - id: 'roadPatrolManagmentSupervisorCartable', - label: 'کارتابل', + id: "roadPatrolManagmentSupervisorCartable", + label: "کارتابل", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/road_patrols/supervisor/cartable", }, - ] + ], }, { - id: 'roadPatrolManagmentOparation', - label: 'عملیات', + id: "roadPatrolManagmentOparation", + label: "عملیات", type: "menu", - icon: , + icon: , hasSubitems: true, Subitems: [ { - id: 'roadPatrolManagmentOparationCreate', - label: 'ثبت اقدام', + id: "roadPatrolManagmentOparationCreate", + label: "ثبت اقدام", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_patrols/operator/create", }, { - id: 'roadPatrolManagmentOparationCartable', - label: 'کارتابل', + id: "roadPatrolManagmentOparationCartable", + label: "کارتابل", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_patrols/operator/cartable", }, - ] + ], }, { - id: 'roadPatrolManagmentMap', - label: 'پراکندگی بر روی نقشه', + id: "roadPatrolManagmentMap", + label: "پراکندگی بر روی نقشه", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/map?type=road_patrols", - icon: , + icon: , }, { - id: 'roadPatrolManagmentReport', - label: 'گزارش ها', + id: "roadPatrolManagmentReport", + label: "گزارش ها", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_patrols/report", - icon: , + icon: , }, - ] + ], }, { - id: 'safetyAndPrivacyManagment', - label: 'نگهداری حریم راه', + id: "safetyAndPrivacyManagment", + label: "نگهداری حریم راه", type: "menu", - icon: , + icon: , hasSubitems: true, Subitems: [ { - id: 'safetyAndPrivacyManagmentOparation', - label: 'عملیات', + id: "safetyAndPrivacyManagmentOparation", + label: "عملیات", type: "menu", - icon: , + icon: , hasSubitems: true, Subitems: [ { - id: 'safetyAndPrivacyManagmentOparationCreate', - label: 'ثبت فعالیت', + id: "safetyAndPrivacyManagmentOparationCreate", + label: "ثبت فعالیت", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/safety_and_privacy/operator/first_step", }, { - id: 'safetyAndPrivacyManagmentOparationCartable', - label: 'کارتابل', + id: "safetyAndPrivacyManagmentOparationCartable", + label: "کارتابل", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/safety_and_privacy/operator/cartable", }, - ] + ], }, { - id: 'safetyAndPrivacyManagmentMap', - label: 'پراکندگی بر روی نقشه', + id: "safetyAndPrivacyManagmentMap", + label: "پراکندگی بر روی نقشه", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/map?type=safety_and_privacy", - icon: , + icon: , }, { - id: 'safetyAndPrivacyManagmentReport', - label: 'گزارش ها', + id: "safetyAndPrivacyManagmentReport", + label: "گزارش ها", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/safety_and_privacy/report", - icon: , + icon: , }, - ] + ], }, { - id: 'roadObservationsManagment', - label: 'واکنش سریع', + id: "roadObservationsManagment", + label: "واکنش سریع", type: "menu", - icon: , + icon: , hasSubitems: true, Subitems: [ { - id: 'roadObservationsManagmentSupervisor', - label: 'ارزیابی', + id: "roadObservationsManagmentSupervisor", + label: "ارزیابی", type: "menu", - icon: , + icon: , hasSubitems: true, Subitems: [ { - id: 'roadObservationsManagmentSupervisorCartable', - label: 'کارتابل', + id: "roadObservationsManagmentSupervisorCartable", + label: "کارتابل", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_observations/supervisor/cartable", }, - ] + ], }, { - id: 'roadObservationsManagmentList', - label: 'رسیدگی به شکایات', + id: "roadObservationsManagmentList", + label: "رسیدگی به شکایات", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_observations", - icon: , + icon: , }, { - id: 'roadObservationsManagmentOparation', - label: 'عملیات', + id: "roadObservationsManagmentOparation", + label: "عملیات", type: "menu", - icon: , + icon: , hasSubitems: true, Subitems: [ { - id: 'roadObservationsManagmentOparationCartable', - label: 'کارتابل', + id: "roadObservationsManagmentOparationCartable", + label: "کارتابل", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_observations/operator/cartable", }, - ] + ], }, { - id: 'roadObservationsManagmentMap', - label: 'پراکندگی بر روی نقشه', + id: "roadObservationsManagmentMap", + label: "پراکندگی بر روی نقشه", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/map?type=road_observations", - icon: , + icon: , }, { - id: 'roadObservationsManagmentReport', - label: 'گزارش ها', + id: "roadObservationsManagmentReport", + label: "گزارش ها", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_observations/report/index", - icon: , + icon: , }, - ] + ], }, { - id: 'winterCampManagment', - label: 'قرارگاه زمستانی', + id: "winterCampManagment", + label: "قرارگاه زمستانی", type: "menu", - icon: , + icon: , hasSubitems: true, Subitems: [ { - id: 'winterCampManagmentBlocking', - label: 'محور های انسدادی', + id: "winterCampManagmentBlocking", + label: "محور های انسدادی", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/winter_camp", - icon: , + icon: , }, { - id: 'winterCampManagmentFirstRing', - label: 'محور های حلقه اول', + id: "winterCampManagmentFirstRing", + label: "محور های حلقه اول", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/map?type=camp", - icon: , + icon: , }, { - id: 'winterCampManagmentReport', - label: 'گزارش ها', + id: "winterCampManagmentReport", + label: "گزارش ها", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/map?type=campNew", - icon: , + icon: , }, - ] + ], }, { - id: 'receiptManagment', - label: 'خسارات وارده بر ابنیه فنی و تاسیسات راه', + id: "receiptManagment", + label: "خسارات وارده بر ابنیه فنی و تاسیسات راه", type: "menu", - icon: , + icon: , hasSubitems: true, Subitems: [ { - id: 'receiptManagmentOparation', - label: 'عملیات', + id: "receiptManagmentOparation", + label: "عملیات", type: "menu", - icon: , + icon: , hasSubitems: true, Subitems: [ { - id: 'receiptManagmentOparationCartable', - label: 'کارتابل', + id: "receiptManagmentOparationCartable", + label: "کارتابل", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/receipt", }, - ] + ], }, { - id: 'receiptManagmentReport', - label: 'گزارش ها', + id: "receiptManagmentReport", + label: "گزارش ها", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/receipt/report", - icon: , + icon: , }, - ] - } + ], + }, // { // id: "hello", // type: "menu", @@ -383,4 +383,4 @@ export const pageMenu = [ // hasSubitems: true, // showSubitems: false // }, -] \ No newline at end of file +]; diff --git a/src/core/utils/routes.js b/src/core/utils/routes.js index 39b6b09..8fae96f 100644 --- a/src/core/utils/routes.js +++ b/src/core/utils/routes.js @@ -1,4 +1,4 @@ -const api = process.env.NEXT_PUBLIC_API_URL +const api = process.env.NEXT_PUBLIC_API_URL; -export const GET_USER_ROUTE = api + '/webapi/user/get-permission' -export const GET_LOGIN_ROUTE = api + '/test_login' \ No newline at end of file +export const GET_USER_ROUTE = api + "/webapi/user/get-permission"; +export const GET_LOGIN_ROUTE = api + "/login_dev"; diff --git a/src/core/utils/successRequest.js b/src/core/utils/successRequest.js index 5138d7a..d23776a 100644 --- a/src/core/utils/successRequest.js +++ b/src/core/utils/successRequest.js @@ -1,10 +1,10 @@ -'use client' +"use client"; import { toast } from "react-toastify"; import { successToast } from "@/core/components/toasts/success"; export const successRequest = (notification, toastContainer) => { if (notification) { - toast.dismiss({ container: toastContainer }) - successToast(toastContainer) + toast.dismiss({ container: toastContainer }); + successToast(toastContainer); } -} \ No newline at end of file +}; diff --git a/src/core/utils/theme.js b/src/core/utils/theme.js index 581e23e..f32031b 100644 --- a/src/core/utils/theme.js +++ b/src/core/utils/theme.js @@ -1,22 +1,22 @@ -'use client' +"use client"; import { createTheme } from "@mui/material"; const theme = createTheme({ - direction: 'rtl', + direction: "rtl", typography: { fontFamily: `IRANSansFaNum, sans-serif`, - fontSize: 12 + fontSize: 12, }, palette: { primary: { - main: '#2070af', - contrastText: '#fff' + main: "#2070af", + contrastText: "#fff", }, primary2: { - main: '#015688', - contrastText: '#fff' + main: "#015688", + contrastText: "#fff", }, - } + }, }); -export default theme \ No newline at end of file +export default theme; diff --git a/src/core/utils/utils.js b/src/core/utils/utils.js index 98e0252..a0a320d 100644 --- a/src/core/utils/utils.js +++ b/src/core/utils/utils.js @@ -1,162 +1,120 @@ import { alpha, darken } from "@mui/material"; -export const parseCSSVarId = (id) => id.replace(/[^a-zA-Z0-9]/g, '_'); +export const parseCSSVarId = (id) => id.replace(/[^a-zA-Z0-9]/g, "_"); -export const parseFromValuesOrFunc = ( - fn, - arg -) => (fn instanceof Function ? fn(arg) : fn); +export const parseFromValuesOrFunc = (fn, arg) => (fn instanceof Function ? fn(arg) : fn); -export const getCommonToolbarStyles = ({ - table, -}) => ({ - alignItems: 'flex-start', - backgroundColor: table.options.mrtTheme.baseBackgroundColor, - display: 'grid', - flexWrap: 'wrap-reverse', - minHeight: '3.5rem', - overflow: 'hidden', - position: 'relative', - transition: 'all 150ms ease-in-out', - zIndex: 1, +export const getCommonToolbarStyles = ({ table }) => ({ + alignItems: "flex-start", + backgroundColor: table.options.mrtTheme.baseBackgroundColor, + display: "grid", + flexWrap: "wrap-reverse", + minHeight: "3.5rem", + overflow: "hidden", + position: "relative", + transition: "all 150ms ease-in-out", + zIndex: 1, }); -export const getCommonTooltipProps = ( - placement, -) => ({ - disableInteractive: true, - enterDelay: 500, - enterNextDelay: 500, - placement, +export const getCommonTooltipProps = (placement) => ({ + disableInteractive: true, + enterDelay: 500, + enterNextDelay: 500, + placement, }); export const flipIconStyles = (theme) => - theme.direction === 'rtl' - ? { style: { transform: 'scaleX(-1)' } } - : undefined; + theme.direction === "rtl" ? { style: { transform: "scaleX(-1)" } } : undefined; -export const getCommonPinnedCellStyles = ({ - column, - table, - theme, -}) => { - const { baseBackgroundColor } = table.options.mrtTheme; - const isPinned = column?.getIsPinned(); +export const getCommonPinnedCellStyles = ({ column, table, theme }) => { + const { baseBackgroundColor } = table.options.mrtTheme; + const isPinned = column?.getIsPinned(); - return { - '&[data-pinned="true"]': { - '&:before': { - backgroundColor: alpha( - darken( - baseBackgroundColor, - theme.palette.mode === 'dark' ? 0.05 : 0.01, - ), - 0.97, - ), - boxShadow: column - ? isPinned === 'left' && column.getIsLastColumn(isPinned) - ? `-4px 0 4px -4px ${alpha(theme.palette.grey[700], 0.5)} inset` - : isPinned === 'right' && column.getIsFirstColumn(isPinned) - ? `4px 0 4px -4px ${alpha(theme.palette.grey[700], 0.5)} inset` - : undefined - : undefined, - ...commonCellBeforeAfterStyles, - }, - }, - }; + return { + '&[data-pinned="true"]': { + "&:before": { + backgroundColor: alpha(darken(baseBackgroundColor, theme.palette.mode === "dark" ? 0.05 : 0.01), 0.97), + boxShadow: column + ? isPinned === "left" && column.getIsLastColumn(isPinned) + ? `-4px 0 4px -4px ${alpha(theme.palette.grey[700], 0.5)} inset` + : isPinned === "right" && column.getIsFirstColumn(isPinned) + ? `4px 0 4px -4px ${alpha(theme.palette.grey[700], 0.5)} inset` + : undefined + : undefined, + ...commonCellBeforeAfterStyles, + }, + }, + }; }; -export const getCommonMRTCellStyles = ({ - column, - header, - table, - tableCellProps, - theme, -}) => { - const { - getState, - options: { enableColumnVirtualization, layoutMode }, - } = table; - const { draggingColumn } = getState(); - const { columnDef } = column; - const { columnDefType } = columnDef; +export const getCommonMRTCellStyles = ({ column, header, table, tableCellProps, theme }) => { + const { + getState, + options: { enableColumnVirtualization, layoutMode }, + } = table; + const { draggingColumn } = getState(); + const { columnDef } = column; + const { columnDefType } = columnDef; - const isColumnPinned = - columnDef.columnDefType !== 'group' && column.getIsPinned(); + const isColumnPinned = columnDef.columnDefType !== "group" && column.getIsPinned(); - const widthStyles = { - minWidth: `max(calc(var(--${header ? 'header' : 'col'}-${parseCSSVarId( - header?.id ?? column.id, - )}-size) * 1px), ${columnDef.minSize ?? 30}px)`, - width: `calc(var(--${header ? 'header' : 'col'}-${parseCSSVarId( - header?.id ?? column.id, - )}-size) * 1px)`, - }; + const widthStyles = { + minWidth: `max(calc(var(--${header ? "header" : "col"}-${parseCSSVarId( + header?.id ?? column.id + )}-size) * 1px), ${columnDef.minSize ?? 30}px)`, + width: `calc(var(--${header ? "header" : "col"}-${parseCSSVarId(header?.id ?? column.id)}-size) * 1px)`, + }; - if (layoutMode === 'grid') { - widthStyles.flex = `${[0, false].includes(columnDef.grow) - ? 0 - : `var(--${header ? 'header' : 'col'}-${parseCSSVarId( - header?.id ?? column.id, - )}-size)` - } 0 auto`; - } else if (layoutMode === 'grid-no-grow') { - widthStyles.flex = `${+(columnDef.grow || 0)} 0 auto`; - } - - const pinnedStyles = isColumnPinned - ? { - ...getCommonPinnedCellStyles({ column, table, theme }), - left: - isColumnPinned === 'left' - ? `${column.getStart('left')}px` - : undefined, - opacity: 0.97, - position: 'sticky', - right: - isColumnPinned === 'right' - ? `${column.getAfter('right')}px` - : undefined, + if (layoutMode === "grid") { + widthStyles.flex = `${ + [0, false].includes(columnDef.grow) + ? 0 + : `var(--${header ? "header" : "col"}-${parseCSSVarId(header?.id ?? column.id)}-size)` + } 0 auto`; + } else if (layoutMode === "grid-no-grow") { + widthStyles.flex = `${+(columnDef.grow || 0)} 0 auto`; } - : {}; - return { - backgroundColor: 'inherit', - backgroundImage: 'inherit', - display: layoutMode?.startsWith('grid') ? 'flex' : undefined, - justifyContent: - columnDefType === 'group' - ? 'center' - : layoutMode?.startsWith('grid') - ? tableCellProps.align - : undefined, - opacity: - table.getState().draggingColumn?.id === column.id || - table.getState().hoveredColumn?.id === column.id - ? 0.5 - : 1, - position: 'relative', - transition: enableColumnVirtualization - ? 'none' - : `padding 150ms ease-in-out`, - zIndex: - column.getIsResizing() || draggingColumn?.id === column.id - ? 2 - : columnDefType !== 'group' && isColumnPinned - ? 1 - : 0, - ...pinnedStyles, - ...widthStyles, - ...(parseFromValuesOrFunc(tableCellProps?.sx, theme)), - }; + const pinnedStyles = isColumnPinned + ? { + ...getCommonPinnedCellStyles({ column, table, theme }), + left: isColumnPinned === "left" ? `${column.getStart("left")}px` : undefined, + opacity: 0.97, + position: "sticky", + right: isColumnPinned === "right" ? `${column.getAfter("right")}px` : undefined, + } + : {}; + + return { + backgroundColor: "inherit", + backgroundImage: "inherit", + display: layoutMode?.startsWith("grid") ? "flex" : undefined, + justifyContent: + columnDefType === "group" ? "center" : layoutMode?.startsWith("grid") ? tableCellProps.align : undefined, + opacity: + table.getState().draggingColumn?.id === column.id || table.getState().hoveredColumn?.id === column.id + ? 0.5 + : 1, + position: "relative", + transition: enableColumnVirtualization ? "none" : `padding 150ms ease-in-out`, + zIndex: + column.getIsResizing() || draggingColumn?.id === column.id + ? 2 + : columnDefType !== "group" && isColumnPinned + ? 1 + : 0, + ...pinnedStyles, + ...widthStyles, + ...parseFromValuesOrFunc(tableCellProps?.sx, theme), + }; }; export const commonCellBeforeAfterStyles = { - content: '""', - height: '100%', - left: 0, - position: 'absolute', - top: 0, - width: '100%', - zIndex: -1, -}; \ No newline at end of file + content: '""', + height: "100%", + left: 0, + position: "absolute", + top: 0, + width: "100%", + zIndex: -1, +}; diff --git a/src/lib/contexts/DataTable.js b/src/lib/contexts/DataTable.js index 975b859..fb03fd7 100644 --- a/src/lib/contexts/DataTable.js +++ b/src/lib/contexts/DataTable.js @@ -1,15 +1,11 @@ -import {createContext, useState} from "react"; +import { createContext, useState } from "react"; export const DataTableContext = createContext(); -const DataTableProvider = ({children}) => { +const DataTableProvider = ({ children }) => { const [filterData, setFilterData] = useState({}); - return ( - - {children} - - ); + return {children}; }; -export default DataTableProvider; \ No newline at end of file +export default DataTableProvider; diff --git a/src/lib/contexts/auth.js b/src/lib/contexts/auth.js index e60f413..f2df0e6 100644 --- a/src/lib/contexts/auth.js +++ b/src/lib/contexts/auth.js @@ -1,12 +1,12 @@ -'use client' -import { createContext, useCallback, useContext, useEffect, useReducer } from 'react'; -import useRequest from '../hooks/useRequest'; -import { GET_USER_ROUTE } from '@/core/utils/routes'; +"use client"; +import { createContext, useCallback, useContext, useEffect, useReducer } from "react"; +import useRequest from "../hooks/useRequest"; +import { GET_USER_ROUTE } from "@/core/utils/routes"; const initAuth = { initAuthState: false, isAuth: false, - user: {} + user: {}, }; const authReducer = (state, action) => { @@ -28,7 +28,7 @@ const AuthContext = createContext(); export const AuthProvider = ({ children }) => { const [state, dispatch] = useReducer(authReducer, initAuth); - const request = useRequest() + const request = useRequest(); const clearUser = useCallback(() => { dispatch({ type: "CLEAR_USER" }); @@ -48,7 +48,7 @@ export const AuthProvider = ({ children }) => { const getUser = useCallback(async () => { try { - const { data } = await request(GET_USER_ROUTE, 'get') + const { data } = await request(GET_USER_ROUTE, "get"); changeUser(data); changeAuthState(true); changeInitAuth(true); @@ -62,15 +62,21 @@ export const AuthProvider = ({ children }) => { }, [clearUser, changeUser, changeAuthState, changeInitAuth]); useEffect(() => { - getUser() - }, []) + getUser(); + }, []); - return {children}; + return ( + + {children} + + ); }; -export const useAuth = () => useContext(AuthContext); \ No newline at end of file +export const useAuth = () => useContext(AuthContext); diff --git a/src/lib/contexts/tableSetting.js b/src/lib/contexts/tableSetting.js index abc2ad7..3611df9 100644 --- a/src/lib/contexts/tableSetting.js +++ b/src/lib/contexts/tableSetting.js @@ -1,26 +1,26 @@ -'use client' -import {createContext, useCallback, useEffect, useState} from "react"; +"use client"; +import { createContext, useCallback, useEffect, useState } from "react"; export const TableSettingContext = createContext(); -export const TableSettingProvider = ({children}) => { +export const TableSettingProvider = ({ children }) => { const [settingStore, setSettingStore] = useState({}); useEffect(() => { - const _localStorage = localStorage.getItem("_setting-app") + const _localStorage = localStorage.getItem("_setting-app"); if (_localStorage) { - setSettingStore(JSON.parse(_localStorage)) + setSettingStore(JSON.parse(_localStorage)); } }, []); const hideAction = useCallback((user_id, page_name, table_name, settingValue, columns) => { updateSettingStorage(user_id, page_name, table_name, "hides", settingValue, columns); - }, []) + }, []); const sortAction = useCallback((user_id, page_name, table_name, settingValue, columns) => { updateSettingStorage(user_id, page_name, table_name, "sorts", settingValue, columns); - }, []) + }, []); const filterAction = (user_id, page_name, table_name, settingValue, columns) => { updateSettingStorage(user_id, page_name, table_name, "filters", settingValue, columns); - } + }; const updateSettingStorage = (user_id, page_name, table_name, settingType, settingValue, columns) => { const prevLocalStorage = JSON.parse(localStorage.getItem("_setting-app")) || {}; const userSettings = prevLocalStorage[user_id] || {}; @@ -30,7 +30,7 @@ export const TableSettingProvider = ({children}) => { if (settingType === "sorts" || settingType === "filters") { newSettings = [...settingValue]; } else { - newSettings = {...tableSettings[settingType] || {}, ...settingValue}; + newSettings = { ...(tableSettings[settingType] || {}), ...settingValue }; } const updatedLocalStorage = { ...prevLocalStorage, @@ -40,18 +40,21 @@ export const TableSettingProvider = ({children}) => { ...pageSettings, [table_name]: { ...tableSettings, - [settingType]: Array.isArray(settingValue) ? [...newSettings] : {...newSettings}, - summary: SummaryTextMessage({ - ...tableSettings, - [settingType]: Array.isArray(settingValue) ? [...newSettings] : {...newSettings}, - }, columns) + [settingType]: Array.isArray(settingValue) ? [...newSettings] : { ...newSettings }, + summary: SummaryTextMessage( + { + ...tableSettings, + [settingType]: Array.isArray(settingValue) ? [...newSettings] : { ...newSettings }, + }, + columns + ), }, }, }, }; localStorage.setItem("_setting-app", JSON.stringify(updatedLocalStorage)); setSettingStore(updatedLocalStorage); - } + }; const refactorAction = (user_id, page_name, table_name) => { const prevLocalStorage = JSON.parse(localStorage.getItem("_setting-app")) || {}; const userSettings = prevLocalStorage[user_id] || {}; @@ -68,7 +71,7 @@ export const TableSettingProvider = ({children}) => { }; localStorage.setItem("_setting-app", JSON.stringify(refactorData)); setSettingStore(refactorData); - } + }; const SummaryTextMessage = (values, columns) => { let SummaryText = ""; let HideText = ""; @@ -76,38 +79,35 @@ export const TableSettingProvider = ({children}) => { let SortText = ""; if (values.sorts && values.sorts.length > 0) { - const _list = [] + const _list = []; for (const sort of values.sorts) { - const _column = columns.find(column => column.id == sort.id) - if (_column) - _list.push(`${_column.header}` + `(${sort.desc ? "نزولی" : "صعودی"})`) + const _column = columns.find((column) => column.id == sort.id); + if (_column) _list.push(`${_column.header}` + `(${sort.desc ? "نزولی" : "صعودی"})`); } - if (_list.length > 0) - SortText = " مرتب شده بر اساس : " + _list.join(", ") + if (_list.length > 0) SortText = " مرتب شده بر اساس : " + _list.join(", "); } if (values.filters && values.filters.length > 0) { - const _list = [] + const _list = []; for (const filter of values.filters) { - const _column = columns.find(column => column.id == filter.id) - if (_column) - _list.push(`${_column.header}`) + const _column = columns.find((column) => column.id == filter.id); + if (_column) _list.push(`${_column.header}`); } - if (_list.length > 0) - FilterText = " فیلتر شده بر اساس : " + _list.join(", ") + if (_list.length > 0) FilterText = " فیلتر شده بر اساس : " + _list.join(", "); } if (values.hides) { - const hidesArray = Object.entries(values.hides).map((e) => ({id: e[0], value: e[1]})) + const hidesArray = Object.entries(values.hides).map((e) => ({ + id: e[0], + value: e[1], + })); if (hidesArray.length > 0) { - const _list = [] + const _list = []; for (const hide of hidesArray) { - if (hide.value) continue - const _column = columns.find(c => c.id == hide.id) - if (_column) - _list.push(_column.header) + if (hide.value) continue; + const _column = columns.find((c) => c.id == hide.id); + if (_column) _list.push(_column.header); } - if (_list.length > 0) - HideText = "ستون های مخفی شده : " + _list.join(", "); + if (_list.length > 0) HideText = "ستون های مخفی شده : " + _list.join(", "); } } @@ -128,7 +128,7 @@ export const TableSettingProvider = ({children}) => { } } if (FilterText) { - SummaryText += FilterText + SummaryText += FilterText; } } @@ -137,8 +137,15 @@ export const TableSettingProvider = ({children}) => { return ( + value={{ + settingStore, + hideAction, + sortAction, + filterAction, + refactorAction, + }} + > {children} ); -}; \ No newline at end of file +}; diff --git a/src/lib/hooks/useDataTable.js b/src/lib/hooks/useDataTable.js index ba7acb5..e396908 100644 --- a/src/lib/hooks/useDataTable.js +++ b/src/lib/hooks/useDataTable.js @@ -1,9 +1,9 @@ -import {useContext} from "react"; -import {DataTableContext} from "@/lib/contexts/DataTable"; +import { useContext } from "react"; +import { DataTableContext } from "@/lib/contexts/DataTable"; const useTableSetting = () => { - const {filterData, setFilterData} = useContext(DataTableContext); - return {filterData, setFilterData}; + const { filterData, setFilterData } = useContext(DataTableContext); + return { filterData, setFilterData }; }; export default useTableSetting; diff --git a/src/lib/hooks/useRequest.js b/src/lib/hooks/useRequest.js index 8beee2e..2e35512 100644 --- a/src/lib/hooks/useRequest.js +++ b/src/lib/hooks/useRequest.js @@ -5,38 +5,42 @@ import axios from "axios"; const defaultOptions = { data: {}, requestOptions: { - headers: {} + headers: {}, }, notification: { show: true, success: false, - failed: true + failed: true, }, -} +}; const useRequest = (initOptions) => { const _options = Object.assign({}, defaultOptions, initOptions); - return async (url = '', method = 'get', options) => { + return async (url = "", method = "get", options) => { const mergedOptions = Object.assign({}, _options, options); try { const response = await axios({ url, method, - data: method === 'get' ? null : mergedOptions.data, + data: method === "get" ? null : mergedOptions.data, withCredentials: true, - ...mergedOptions.requestOptions + ...mergedOptions.requestOptions, }); - successRequest(mergedOptions.notification.show && mergedOptions.notification.success, 'request_data'); + successRequest(mergedOptions.notification.show && mergedOptions.notification.success, "request_data"); return response; } catch (error) { if (error.response) { - errorResponse(error.response, mergedOptions.notification.show && mergedOptions.notification.failed, 'request_data'); + errorResponse( + error.response, + mergedOptions.notification.show && mergedOptions.notification.failed, + "request_data" + ); } throw error; } - } -} + }; +}; -export default useRequest \ No newline at end of file +export default useRequest; diff --git a/src/lib/hooks/useTableSetting.js b/src/lib/hooks/useTableSetting.js index 7617655..6588446 100644 --- a/src/lib/hooks/useTableSetting.js +++ b/src/lib/hooks/useTableSetting.js @@ -1,10 +1,9 @@ -import {useContext} from "react"; -import {TableSettingContext} from "../contexts/tableSetting"; +import { useContext } from "react"; +import { TableSettingContext } from "../contexts/tableSetting"; const useTableSetting = () => { - const {settingStore, hideAction, sortAction, filterAction, refactorAction} = - useContext(TableSettingContext); - return {settingStore, hideAction, sortAction, filterAction, refactorAction}; + const { settingStore, hideAction, sortAction, filterAction, refactorAction } = useContext(TableSettingContext); + return { settingStore, hideAction, sortAction, filterAction, refactorAction }; }; export default useTableSetting; From ad367284113d65dee3336b67936713e853702363 Mon Sep 17 00:00:00 2001 From: Amirhossein Mahmoodi Date: Tue, 9 Jul 2024 14:11:38 +0330 Subject: [PATCH 04/13] formatted --- src/app/(withAuth)/dashboard/page.js | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/src/app/(withAuth)/dashboard/page.js b/src/app/(withAuth)/dashboard/page.js index c06d81d..a7efa2a 100644 --- a/src/app/(withAuth)/dashboard/page.js +++ b/src/app/(withAuth)/dashboard/page.js @@ -1,31 +1,9 @@ "use client"; -import { Button } from "@mui/material"; -import axios from "axios"; const Page = () => { - const handler = () => { - try { - axios.get("https://rms.witel.ir/test_login?username=witel", { - withCredentials: true, - }); - } catch (error) { - console.log(error); - } - }; - const handler2 = () => { - try { - const res = axios.get("https://rms.witel.ir/webapi/user/get-permission", { - withCredentials: true, - }); - console.log(res); - } catch (error) { - console.log(error); - } - }; + return ( <> - - ); }; From 6b78309e37ffbcc3caf4f99491263ad9ad404676 Mon Sep 17 00:00:00 2001 From: Amirhossein Mahmoodi Date: Wed, 10 Jul 2024 11:21:32 +0330 Subject: [PATCH 05/13] permissions for sidebar --- .../fieldsType/CustomDate/MuiDatePicker.jsx | 3 - src/core/components/SidebarMenu.jsx | 96 +++++++++++-------- src/core/utils/filterMenuItems.js | 17 ++++ src/core/utils/pageMenu.js | 74 +++++++------- src/core/utils/routes.js | 2 + src/lib/hooks/usePermissions.js | 18 ++++ 6 files changed, 124 insertions(+), 86 deletions(-) create mode 100644 src/core/utils/filterMenuItems.js create mode 100644 src/lib/hooks/usePermissions.js diff --git a/src/core/components/DataTable/filter/fieldsType/CustomDate/MuiDatePicker.jsx b/src/core/components/DataTable/filter/fieldsType/CustomDate/MuiDatePicker.jsx index d715192..b4da7f5 100644 --- a/src/core/components/DataTable/filter/fieldsType/CustomDate/MuiDatePicker.jsx +++ b/src/core/components/DataTable/filter/fieldsType/CustomDate/MuiDatePicker.jsx @@ -7,9 +7,6 @@ import ClearIcon from "@mui/icons-material/Clear"; import moment from "jalali-moment"; function MuiDatePicker({ value, setFieldValue, name, minDate, maxDate, helperText, placeholder, error }) { - // console.log("error", error); - // - // console.log("helperText", helperText) return ( diff --git a/src/core/components/SidebarMenu.jsx b/src/core/components/SidebarMenu.jsx index 0ad01dc..326dd11 100644 --- a/src/core/components/SidebarMenu.jsx +++ b/src/core/components/SidebarMenu.jsx @@ -1,80 +1,86 @@ "use client"; import SidebarListItems from "@/core/components/SidebarListItems"; +import { usePermissions } from "@/lib/hooks/usePermissions"; import { List } from "@mui/material"; import { usePathname } from "next/navigation"; import { useEffect, useReducer, useState } from "react"; +import { filterMenuItems } from "../utils/filterMenuItems"; import { pageMenu } from "../utils/pageMenu"; function reducer(state, action) { switch (action.type) { + case "UPDATE_MENU": + const _permissions = action.permissions || [] + const filteredPageMenu = filterMenuItems(pageMenu, ['all', ..._permissions]) + return filteredPageMenu case "COLLAPSE_MENU": return state.map((item) => action.id == item.id ? { - ...item, - showSubitems: !item.showSubitems, - } + ...item, + showSubitems: !item.showSubitems, + } : item ); case "COLLAPSE_SUB_ITEMS": return state.map((item) => { return item.hasSubitems ? { - ...item, - Subitems: item.Subitems.map((subitem) => - action.id === subitem.id - ? { - ...subitem, - showSubitems: !subitem.showSubitems, - } - : subitem - ), - } + ...item, + Subitems: item.Subitems.map((subitem) => + action.id === subitem.id + ? { + ...subitem, + showSubitems: !subitem.showSubitems, + } + : subitem + ), + } : item; }); case "COLLAPSE_SUB_SECOND_ITEMS": return state.map((item) => { return item.hasSubitems ? { - ...item, - Subitems: item.Subitems.map((subitem) => { - return subitem.hasSubitems - ? { - ...subitem, - Subitems: subitem.Subitems.map((secondSubitem) => - action.id === secondSubitem.id - ? { - ...secondSubitem, - showSubitems: !secondSubitem.showSubitems, - } - : secondSubitem - ), - } - : subitem; - }), - } + ...item, + Subitems: item.Subitems.map((subitem) => { + return subitem.hasSubitems + ? { + ...subitem, + Subitems: subitem.Subitems.map((secondSubitem) => + action.id === secondSubitem.id + ? { + ...secondSubitem, + showSubitems: !secondSubitem.showSubitems, + } + : secondSubitem + ), + } + : subitem; + }), + } : item; }); case "SELECTED": return state.map((item) => { return item.type === "page" ? { - ...item, - selected: action.route === item.route, - showSubitems: item.route === action.route, - } + ...item, + selected: action.route === item.route, + showSubitems: item.route === action.route, + } : item.Subitems && Array.isArray(item.Subitems) - ? { + ? { ...item, Subitems: item.Subitems.map((subitem) => { return subitem.type === "page" ? { - ...subitem, - selected: action.route === subitem.route, - showSubitems: subitem.route === action.route, - } + ...subitem, + selected: action.route === subitem.route, + showSubitems: subitem.route === action.route, + } : subitem.Subitems && Array.isArray(subitem.Subitems) - ? { + ? { ...subitem, Subitems: subitem.Subitems.map((secondSubItem) => ({ ...secondSubItem, @@ -84,11 +90,11 @@ function reducer(state, action) { (secondSubItem) => secondSubItem.route === action.route ), } - : subitem; + : subitem; }), showSubitems: item.Subitems.some((subitem) => subitem.showSubitems), } - : item; + : item; }); default: @@ -97,9 +103,15 @@ function reducer(state, action) { } const SidebarMenu = () => { + const { data: userPermissions } = usePermissions() const [menuItems, dispatch] = useReducer(reducer, pageMenu); const pathname = usePathname(); const [selectedKey, setSelectedKey] = useState(null); + + useEffect(() => { + dispatch({ type: 'UPDATE_MENU', permissions: userPermissions }); + }, [userPermissions]) + useEffect(() => { dispatch({ type: "SELECTED", route: pathname }); setSelectedKey(pathname); diff --git a/src/core/utils/filterMenuItems.js b/src/core/utils/filterMenuItems.js new file mode 100644 index 0000000..7bceeb5 --- /dev/null +++ b/src/core/utils/filterMenuItems.js @@ -0,0 +1,17 @@ +export function filterMenuItems(items, _permissions = []) { + return items.reduce((acc, item) => { + if (item.permissions) { + if (item.permissions.some(permission => _permissions.includes(permission))) { + acc.push(item); + } + } else if (item.hasSubitems) { + const filteredSubItems = filterMenuItems(item.Subitems, _permissions); + if (filteredSubItems.length > 0) { + acc.push({ ...item, Subitems: filteredSubItems }); + } + } else { + acc.push(item); + } + return acc; + }, []); +} \ No newline at end of file diff --git a/src/core/utils/pageMenu.js b/src/core/utils/pageMenu.js index 6145ffd..9750e63 100644 --- a/src/core/utils/pageMenu.js +++ b/src/core/utils/pageMenu.js @@ -7,6 +7,7 @@ export const pageMenu = [ type: "page", route: "/dashboard", icon: , + permissions: ["all"] }, { id: "userManagement", @@ -14,6 +15,7 @@ export const pageMenu = [ type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/user_management", icon: , + permissions: ['full-user-management', 'limited-user-management'] }, { id: "projectsManagment", @@ -28,6 +30,7 @@ export const pageMenu = [ type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/rahdari_projects/finance", icon: , + permissions: ['show-contract', 'show-contract-province'], }, { id: "projectsManagmentList", @@ -35,6 +38,7 @@ export const pageMenu = [ type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/rahdari_projects/projects_list", icon: , + permissions: ["all"] }, { id: "projectsManagmentProposal", @@ -42,6 +46,7 @@ export const pageMenu = [ type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/rahdari_projects/proposal", icon: , + permissions: ['show-proposal', 'show-proposal-province'] }, { id: "projectsManagmentLawmaker", @@ -49,6 +54,7 @@ export const pageMenu = [ type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/rahdari_projects/lawmakers", icon: , + permissions: ['show-lawmaker', 'show-lawmaker-province'] }, { id: "projectsManagmentMap", @@ -56,6 +62,7 @@ export const pageMenu = [ type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/map?type=rahdari_projects", icon: , + permissions: ["all"] }, ], }, @@ -78,6 +85,7 @@ export const pageMenu = [ label: "کارتابل", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_items/supervisor/cartable", + permissions: ['show-road-item-supervise-cartable', 'show-road-item-supervise-cartable-province'] }, ], }, @@ -93,12 +101,14 @@ export const pageMenu = [ label: "ثبت فعالیت", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_items/operator/create", + permissions: ['create-road-item'] }, { id: "roadItemManagmentOparationCartable", label: "کارتابل", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_items/operator/cartable", + permissions: ['create-road-item'] }, ], }, @@ -108,6 +118,7 @@ export const pageMenu = [ type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/map?type=road_items", icon: , + permissions: ['show-road-item-supervise-cartable', 'show-road-item-supervise-cartable-province', 'create-road-item'] }, { id: "roadItemManagmentReport", @@ -115,6 +126,7 @@ export const pageMenu = [ type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_items/report", icon: , + permissions: ['show-road-item-supervise-cartable', 'show-road-item-supervise-cartable-province', 'create-road-item'] }, ], }, @@ -137,6 +149,7 @@ export const pageMenu = [ label: "کارتابل", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/road_patrols/supervisor/cartable", + permissions: ['show-road-patrol-supervise-cartable', 'show-road-patrol-supervise-cartable-province'] }, ], }, @@ -152,12 +165,14 @@ export const pageMenu = [ label: "ثبت اقدام", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_patrols/operator/create", + permissions: ['add-road-patrol'] }, { id: "roadPatrolManagmentOparationCartable", label: "کارتابل", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_patrols/operator/cartable", + permissions: ['add-road-patrol'] }, ], }, @@ -167,6 +182,7 @@ export const pageMenu = [ type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/map?type=road_patrols", icon: , + permissions: ['add-road-patrol', 'show-road-patrol-supervise-cartable', 'show-road-patrol-supervise-cartable-province'] }, { id: "roadPatrolManagmentReport", @@ -174,6 +190,7 @@ export const pageMenu = [ type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_patrols/report", icon: , + permissions: ['add-road-patrol', 'show-road-patrol-supervise-cartable', 'show-road-patrol-supervise-cartable-province'] }, ], }, @@ -196,12 +213,14 @@ export const pageMenu = [ label: "ثبت فعالیت", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/safety_and_privacy/operator/first_step", + permissions: ['add-safety-and-privacy'] }, { id: "safetyAndPrivacyManagmentOparationCartable", label: "کارتابل", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/safety_and_privacy/operator/cartable", + permissions: ['show-safety-and-privacy-operator-cartable', 'show-safety-and-privacy-operator-cartable-province', 'show-safety-and-privacy-operator-cartable-edarate-shahri'] }, ], }, @@ -211,6 +230,8 @@ export const pageMenu = [ type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/map?type=safety_and_privacy", icon: , + permissions: ['show-safety-and-privacy-operator-cartable', 'show-safety-and-privacy-operator-cartable-province', + 'show-safety-and-privacy-operator-cartable-edarate-shahri', 'add-safety-and-privacy'] }, { id: "safetyAndPrivacyManagmentReport", @@ -218,6 +239,8 @@ export const pageMenu = [ type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/safety_and_privacy/report", icon: , + permissions: ['show-safety-and-privacy-operator-cartable', 'show-safety-and-privacy-operator-cartable-province', + 'show-safety-and-privacy-operator-cartable-edarate-shahri', 'add-safety-and-privacy'] }, ], }, @@ -240,6 +263,7 @@ export const pageMenu = [ label: "کارتابل", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_observations/supervisor/cartable", + permissions: ['supervise-fast-react', 'supervise-fast-react-province'] }, ], }, @@ -249,6 +273,7 @@ export const pageMenu = [ type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_observations", icon: , + permissions: ['show-fast-react', 'show-fast-react-province', 'show-fast-react-edarate-shahri'] }, { id: "roadObservationsManagmentOparation", @@ -262,6 +287,7 @@ export const pageMenu = [ label: "کارتابل", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_observations/operator/cartable", + permissions: ['show-fast-react', 'show-fast-react-province', 'show-fast-react-edarate-shahri'] }, ], }, @@ -271,6 +297,7 @@ export const pageMenu = [ type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/map?type=road_observations", icon: , + permissions: ["all"] }, { id: "roadObservationsManagmentReport", @@ -278,6 +305,7 @@ export const pageMenu = [ type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_observations/report/index", icon: , + permissions: ["all"] }, ], }, @@ -294,6 +322,7 @@ export const pageMenu = [ type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/winter_camp", icon: , + permissions: ['show-camp', 'show-camp-province'] }, { id: "winterCampManagmentFirstRing", @@ -301,6 +330,7 @@ export const pageMenu = [ type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/map?type=camp", icon: , + permissions: ['show-camp', 'show-camp-province'] }, { id: "winterCampManagmentReport", @@ -308,6 +338,7 @@ export const pageMenu = [ type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/map?type=campNew", icon: , + permissions: ['show-camp', 'show-camp-province'] }, ], }, @@ -330,6 +361,7 @@ export const pageMenu = [ label: "کارتابل", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/receipt", + permissions: ["all"] }, ], }, @@ -339,48 +371,8 @@ export const pageMenu = [ type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/receipt/report", icon: , + permissions: ["all"] }, ], }, - // { - // id: "hello", - // type: "menu", - // route: "/hello", - // icon: , - // selected: false, - // Subitems: [ - // { - // id: "amin", - // route: "/s", - // icon: , - // firstName: "amin", - // lastName: "ali", - // Subitems: [ - // { - // id: "shahrokh", shahrokh: "shahrokh", type: "page", selected: false, route: "/dashbssoard", icon: - // }, - // { - // id: "shasdasdsahrokh", shahrokh: "shahroasdasdkh", type: "page", selected: false, route: "/dashboardsd", icon: - // } - // ], - // hasSubitems: true, - // showSubitems: false, - // type: "menu", - // selected: false, - // }, - // { - // id: "amir", - // route: "/dashboarsad", - // icon: , - // firstName: "amir", - // lastName: "akbar", - // hasSubitems: false, - // showSubitems: false, - // selected: false, - // type: "page", - // }, - // ], - // hasSubitems: true, - // showSubitems: false - // }, ]; diff --git a/src/core/utils/routes.js b/src/core/utils/routes.js index 8fae96f..81ac016 100644 --- a/src/core/utils/routes.js +++ b/src/core/utils/routes.js @@ -2,3 +2,5 @@ const api = process.env.NEXT_PUBLIC_API_URL; export const GET_USER_ROUTE = api + "/webapi/user/get-permission"; export const GET_LOGIN_ROUTE = api + "/login_dev"; + +export const GET_PERMISSIONS_ROUTE = api + "/webapi/user/get-permission"; \ No newline at end of file diff --git a/src/lib/hooks/usePermissions.js b/src/lib/hooks/usePermissions.js new file mode 100644 index 0000000..4f54b41 --- /dev/null +++ b/src/lib/hooks/usePermissions.js @@ -0,0 +1,18 @@ +import { GET_PERMISSIONS_ROUTE } from "@/core/utils/routes"; +import useSWR from "swr"; +import useRequest from "./useRequest"; + +export const usePermissions = () => { + const request = useRequest() + + const fetcher = async (url) => { + try { + const response = await request(url) + return response.data.data + } catch (error) { + throw new Error(); + } + }; + + return useSWR(GET_PERMISSIONS_ROUTE, fetcher, { keepPreviousData: true }); +} \ No newline at end of file From 41181eaadb3b92872bd97ce6e3d6e2c90afde0b6 Mon Sep 17 00:00:00 2001 From: Amirhossein Mahmoodi Date: Wed, 10 Jul 2024 11:45:30 +0330 Subject: [PATCH 06/13] add build:publish script in package --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index b7f9320..4a1bf6b 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,8 @@ "build": "next build", "start": "next start", "lint": "next lint", - "format": "prettier --write \"src/**/*.{js,jsx,ts,tsx,html,css,scss}\"" + "format": "prettier --write \"src/**/*.{js,jsx,ts,tsx,html,css,scss}\"", + "build:publish": "npm i && npm run build && pm2 restart ecosystem.config.js" }, "dependencies": { "@emotion/cache": "^11.11.0", @@ -40,4 +41,4 @@ "eslint-config-prettier": "^9.1.0", "prettier": "^3.3.2" } -} +} \ No newline at end of file From bf4c4c4ff294b382bff3b7672e6e4eaa1a717be7 Mon Sep 17 00:00:00 2001 From: Amirhossein Mahmoodi Date: Wed, 10 Jul 2024 11:57:05 +0330 Subject: [PATCH 07/13] chnage version --- .env.local.example | 1 + 1 file changed, 1 insertion(+) diff --git a/.env.local.example b/.env.local.example index 05bae5f..8d7f889 100644 --- a/.env.local.example +++ b/.env.local.example @@ -1 +1,2 @@ +NEXT_PUBLIC_VERSION="0.1.0" NEXT_PUBLIC_API_URL="https://rms.witel.ir" \ No newline at end of file From 693dbd88b3cf9621c8bf922311391da915c4f05f Mon Sep 17 00:00:00 2001 From: Amirhossein Mahmoodi Date: Wed, 10 Jul 2024 13:03:46 +0330 Subject: [PATCH 08/13] fixed bug --- src/core/utils/errorResponse.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/utils/errorResponse.js b/src/core/utils/errorResponse.js index 1802581..47317bd 100644 --- a/src/core/utils/errorResponse.js +++ b/src/core/utils/errorResponse.js @@ -7,7 +7,7 @@ import { errorTooManyToast, errorUnauthorizedToast, errorValidationToast, -} from "@/core/components/toasts/error"; +} from "@/core/components/Toasts/error"; const isServerError = (status) => status >= 500 && status <= 599; const isClientError = (status) => status >= 400 && status <= 499; From 6e735adb6b8f4cdc95d6cc13a9d615f7c76973ae Mon Sep 17 00:00:00 2001 From: Amirhossein Mahmoodi Date: Wed, 10 Jul 2024 13:04:46 +0330 Subject: [PATCH 09/13] chnage version --- .env.local.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.local.example b/.env.local.example index 8d7f889..d4084e1 100644 --- a/.env.local.example +++ b/.env.local.example @@ -1,2 +1,2 @@ -NEXT_PUBLIC_VERSION="0.1.0" +NEXT_PUBLIC_VERSION="0.1.1" NEXT_PUBLIC_API_URL="https://rms.witel.ir" \ No newline at end of file From e782060cf6e7e5d36bc7b14969c7627e3cf897f7 Mon Sep 17 00:00:00 2001 From: Amirhossein Mahmoodi Date: Wed, 10 Jul 2024 13:12:44 +0330 Subject: [PATCH 10/13] fixed bug --- src/core/utils/successRequest.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/utils/successRequest.js b/src/core/utils/successRequest.js index d23776a..b06d83d 100644 --- a/src/core/utils/successRequest.js +++ b/src/core/utils/successRequest.js @@ -1,6 +1,6 @@ "use client"; import { toast } from "react-toastify"; -import { successToast } from "@/core/components/toasts/success"; +import { successToast } from "@/core/components/Toasts/success"; export const successRequest = (notification, toastContainer) => { if (notification) { From 2a4359ff242a78a0e914ac284636cb780322adc5 Mon Sep 17 00:00:00 2001 From: Amirhossein Mahmoodi Date: Wed, 10 Jul 2024 14:14:09 +0330 Subject: [PATCH 11/13] update --- next.config.mjs | 3 +++ public/images/rmsLogo.png | Bin 0 -> 17747 bytes public/images/rmsLogo.svg | 1 - .../headerWithLogo/HaederBottom/index.jsx | 2 +- src/core/utils/pageMenu.js | 5 +++-- 5 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 public/images/rmsLogo.png delete mode 100644 public/images/rmsLogo.svg diff --git a/next.config.mjs b/next.config.mjs index bb49d74..72cfa4a 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -3,6 +3,9 @@ const isProd = process.env.NODE_ENV === 'production' /** @type {import('next').NextConfig} */ const nextConfig = { assetPrefix: isProd ? '/v3' : undefined, + images: { + path: isProd ? '/v3/_next/image' : undefined, + } }; export default nextConfig; diff --git a/public/images/rmsLogo.png b/public/images/rmsLogo.png new file mode 100644 index 0000000000000000000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axjPa%X`Oc}S={PYhzdwJjR=`5j*KT|tbLxIBx0Y#7F$17acz=-> z^dQiT4id;#X-8oY*N{XbJ&WG>@()40uwPE&Zl^X-I6ypX{!{DCS2N6?A|RGNcSDG} zc~vbu!eNc(TF3Bmu@}s|JDcU=N}_RW^4;)DNX6= zxwd??!yf=>`jkIA>d$oql-$&O3f)&_DlyV}>y_gNBJE0jnb;|y&5r1~xVk7nN3MM6 zHjrApcQeF|D1|+6jea&UyAmUPF;+pV$-h$Bj(9&2a_K-HLBH6tR32dp6h5Qt0%5^4PM5%7Ws zJ#E}u`7&}IN%wsah|de5EEtOj=adEB&+z0GkT&OM!Y(T_F@?A+0lz-|=!moK8W}Kg ze&!=f=h6o}s!zP*$opJmPaJR|K%^!!$tJXIrTIsfhJd{xR>&^m>U+eI7r%@P+~Xn$ z)WwhXSnr9-<{JWw@B&}2)XZ=KY2Uh@;ye;i)K}v5g`}tLOr>KT6Vlg#cVE~ognu52 z;xfjxKE2W)CkwnM;-xN(FtgH#JZ&80YPl{8yj|g?o=zg*e$uFu$@#BJEgQQr0}z84 zFOPqkO8$8A)eRg`;WLwaq2U(r&WGm?7Of6F_tGe%@tOmG2^KI5^;xekbXVONSA#Ha zRuFBN4F?D$7Ja)v(N7yxphGo#U*Ft%U}m+A7&;pVUN|wpJVA6dT@Z~r%x8RV(+oYk zy=^GR=3UI>sSPj>r9H%3NSiD+e)qt4O-^Qi%SpXzy^?foZ(?!w1ln<`Sb~)#00yfX eFp%KIvkOa6v*s@@)wu&qgA8;`wQFzRiT;0b!p?I5 literal 0 HcmV?d00001 diff --git a/public/images/rmsLogo.svg b/public/images/rmsLogo.svg deleted file mode 100644 index 5c47991..0000000 --- a/public/images/rmsLogo.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/components/layouts/dashboard/headerWithLogo/HaederBottom/index.jsx b/src/components/layouts/dashboard/headerWithLogo/HaederBottom/index.jsx index 62ec234..4f0b159 100644 --- a/src/components/layouts/dashboard/headerWithLogo/HaederBottom/index.jsx +++ b/src/components/layouts/dashboard/headerWithLogo/HaederBottom/index.jsx @@ -14,7 +14,7 @@ const HeaderBottom = () => { alignItems={"center"} direction={"row"} > - + theme.palette.primary2.contrastText }}> سامانه جامع راهداری diff --git a/src/core/utils/pageMenu.js b/src/core/utils/pageMenu.js index 9750e63..524468f 100644 --- a/src/core/utils/pageMenu.js +++ b/src/core/utils/pageMenu.js @@ -1,11 +1,12 @@ -import { AirlineSeatReclineNormal, Assessment, Repartition, Security, SpaceDashboard } from "@mui/icons-material"; +import { Security } from "@mui/icons-material"; +const prefix = process.env.NODE_ENV === 'production' ? '/v3' : '' export const pageMenu = [ { id: "dashboard", label: "پیشخوان", type: "page", - route: "/dashboard", + route: prefix + "/dashboard", icon: , permissions: ["all"] }, From 1f3d22f35232d77fea54222eca338d196289836d Mon Sep 17 00:00:00 2001 From: Amirhossein Mahmoodi Date: Wed, 10 Jul 2024 14:36:51 +0330 Subject: [PATCH 12/13] chnage version --- .env.local.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.local.example b/.env.local.example index d4084e1..c93a078 100644 --- a/.env.local.example +++ b/.env.local.example @@ -1,2 +1,2 @@ -NEXT_PUBLIC_VERSION="0.1.1" +NEXT_PUBLIC_VERSION="0.2.0" NEXT_PUBLIC_API_URL="https://rms.witel.ir" \ No newline at end of file From 043c91ca9aeadcde2fb6cc6bf006dde8565623a3 Mon Sep 17 00:00:00 2001 From: Amirhossein Mahmoodi Date: Wed, 10 Jul 2024 16:43:39 +0330 Subject: [PATCH 13/13] update --- .../dashboard/inquiry_privacy/fencing/page.js | 10 +++ .../dashboard/{template.js => layout.js} | 10 +-- src/app/(withAuth)/dashboard/page.js | 2 - .../dashboard/inquiryPrivacyFencing/index.jsx | 4 + src/core/components/SidebarMenu.jsx | 77 ++++++++----------- src/core/utils/pageMenu.js | 30 ++++++++ 6 files changed, 81 insertions(+), 52 deletions(-) create mode 100644 src/app/(withAuth)/dashboard/inquiry_privacy/fencing/page.js rename src/app/(withAuth)/dashboard/{template.js => layout.js} (77%) create mode 100644 src/components/dashboard/inquiryPrivacyFencing/index.jsx diff --git a/src/app/(withAuth)/dashboard/inquiry_privacy/fencing/page.js b/src/app/(withAuth)/dashboard/inquiry_privacy/fencing/page.js new file mode 100644 index 0000000..0a1b9ec --- /dev/null +++ b/src/app/(withAuth)/dashboard/inquiry_privacy/fencing/page.js @@ -0,0 +1,10 @@ +import InquiryPrivacyFencingPage from "@/components/dashboard/inquiryPrivacyFencing"; + +const Page = () => { + + return ( + + ); +}; + +export default Page; \ No newline at end of file diff --git a/src/app/(withAuth)/dashboard/template.js b/src/app/(withAuth)/dashboard/layout.js similarity index 77% rename from src/app/(withAuth)/dashboard/template.js rename to src/app/(withAuth)/dashboard/layout.js index 28b4ea0..cb48375 100644 --- a/src/app/(withAuth)/dashboard/template.js +++ b/src/app/(withAuth)/dashboard/layout.js @@ -1,9 +1,8 @@ -import { Box, Stack } from "@mui/material"; import HeaderWithLogo from "@/components/layouts/dashboard/headerWithLogo"; import HeaderWithSidebar from "@/components/layouts/dashboard/headerWithSidebar"; -import "react-toastify/dist/ReactToastify.css"; +import { Box, Stack } from "@mui/material"; -const Template = ({ children }) => { +const Layout = ({ children }) => { return ( @@ -12,6 +11,5 @@ const Template = ({ children }) => { ); -}; - -export default Template; +} +export default Layout; \ No newline at end of file diff --git a/src/app/(withAuth)/dashboard/page.js b/src/app/(withAuth)/dashboard/page.js index a7efa2a..c43c1ae 100644 --- a/src/app/(withAuth)/dashboard/page.js +++ b/src/app/(withAuth)/dashboard/page.js @@ -1,5 +1,3 @@ -"use client"; - const Page = () => { return ( diff --git a/src/components/dashboard/inquiryPrivacyFencing/index.jsx b/src/components/dashboard/inquiryPrivacyFencing/index.jsx new file mode 100644 index 0000000..539885d --- /dev/null +++ b/src/components/dashboard/inquiryPrivacyFencing/index.jsx @@ -0,0 +1,4 @@ +const InquiryPrivacyFencingPage = () => { + return <> +} +export default InquiryPrivacyFencingPage \ No newline at end of file diff --git a/src/core/components/SidebarMenu.jsx b/src/core/components/SidebarMenu.jsx index 326dd11..30a9297 100644 --- a/src/core/components/SidebarMenu.jsx +++ b/src/core/components/SidebarMenu.jsx @@ -7,11 +7,29 @@ import { useEffect, useReducer, useState } from "react"; import { filterMenuItems } from "../utils/filterMenuItems"; import { pageMenu } from "../utils/pageMenu"; +function selectPage(item, route) { + if (item.type === "page") { + return { + ...item, + selected: item.route === route, + showSubitems: item.route === route, + }; + } else if (item.Subitems && Array.isArray(item.Subitems)) { + const updatedSubitems = item.Subitems.map(subitem => selectPage(subitem, route)); + return { + ...item, + Subitems: updatedSubitems, + showSubitems: updatedSubitems.some(subitem => subitem.showSubitems || subitem.route === route), + }; + } + return item; +} + function reducer(state, action) { switch (action.type) { case "UPDATE_MENU": const _permissions = action.permissions || [] - const filteredPageMenu = filterMenuItems(pageMenu, ['all', ..._permissions]) + const filteredPageMenu = filterMenuItems(state, ['all', ..._permissions]) return filteredPageMenu case "COLLAPSE_MENU": return state.map((item) => @@ -62,40 +80,7 @@ function reducer(state, action) { : item; }); case "SELECTED": - return state.map((item) => { - return item.type === "page" - ? { - ...item, - selected: action.route === item.route, - showSubitems: item.route === action.route, - } - : item.Subitems && Array.isArray(item.Subitems) - ? { - ...item, - Subitems: item.Subitems.map((subitem) => { - return subitem.type === "page" - ? { - ...subitem, - selected: action.route === subitem.route, - showSubitems: subitem.route === action.route, - } - : subitem.Subitems && Array.isArray(subitem.Subitems) - ? { - ...subitem, - Subitems: subitem.Subitems.map((secondSubItem) => ({ - ...secondSubItem, - selected: secondSubItem.route === action.route, - })), - showSubitems: subitem.Subitems.some( - (secondSubItem) => secondSubItem.route === action.route - ), - } - : subitem; - }), - showSubitems: item.Subitems.some((subitem) => subitem.showSubitems), - } - : item; - }); + return state.map(item => selectPage(item, action.route)); default: throw new Error(); @@ -109,13 +94,15 @@ const SidebarMenu = () => { const [selectedKey, setSelectedKey] = useState(null); useEffect(() => { + dispatch({ type: "SELECTED", route: pathname }); + setSelectedKey(pathname); + }, [userPermissions, pathname]); + + useEffect(() => { + if (!userPermissions) return dispatch({ type: 'UPDATE_MENU', permissions: userPermissions }); }, [userPermissions]) - useEffect(() => { - dispatch({ type: "SELECTED", route: pathname }); - setSelectedKey(pathname); - }, [pathname]); useEffect(() => { selectedKey && @@ -126,11 +113,13 @@ const SidebarMenu = () => { }, [selectedKey]); return ( - - {menuItems.map((menuItem) => { - return ; - })} - + userPermissions && ( + + {menuItems.map((menuItem) => { + return ; + })} + + ) ); }; export default SidebarMenu; diff --git a/src/core/utils/pageMenu.js b/src/core/utils/pageMenu.js index 524468f..0129a78 100644 --- a/src/core/utils/pageMenu.js +++ b/src/core/utils/pageMenu.js @@ -195,6 +195,36 @@ export const pageMenu = [ }, ], }, + { + id: "inquiryPrivacyManagment", + label: "استعلام حریم راه", + type: "menu", + icon: , + hasSubitems: true, + Subitems: [ + { + id: "inquiryPrivacyManagmentFencing", + label: "احداث و بهره برداری دیوارکشی و مستحدثات", + type: "page", + route: prefix + "/dashboard/inquiry_privacy/fencing", + permissions: ['all'] + }, + { + id: "inquiryPrivacyManagmentRoad", + label: "احداث راه دسترسی اختصاصی", + type: "page", + route: prefix + "/dashboard/inquiry_privacy/road", + permissions: ['all'] + }, + { + id: "inquiryPrivacyManagmentInfrastructure", + label: "احداث و بهره برداری تاسیسات زیربنایی", + type: "page", + route: prefix + "/dashboard/inquiry_privacy/infrastructure", + permissions: ['all'] + }, + ] + }, { id: "safetyAndPrivacyManagment", label: "نگهداری حریم راه",