From aaf885bc4d346420e0a4f2ec560318fb846fad44 Mon Sep 17 00:00:00 2001 From: Mohammad Jalali Date: Sat, 17 Aug 2024 15:32:22 +0330 Subject: [PATCH 1/3] change icons of page menu --- src/core/utils/pageMenu.js | 93 +++++++++++++++++++++++--------------- 1 file changed, 56 insertions(+), 37 deletions(-) diff --git a/src/core/utils/pageMenu.js b/src/core/utils/pageMenu.js index 75f7828..5718053 100644 --- a/src/core/utils/pageMenu.js +++ b/src/core/utils/pageMenu.js @@ -1,4 +1,23 @@ -import { Security } from "@mui/icons-material"; +import SpaceDashboardIcon from "@mui/icons-material/SpaceDashboard"; +import GroupsIcon from "@mui/icons-material/Groups"; +import AccountTreeIcon from "@mui/icons-material/AccountTree"; +import FactCheckIcon from "@mui/icons-material/FactCheck"; +import FireTruckIcon from "@mui/icons-material/FireTruck"; +import RouteIcon from "@mui/icons-material/Route"; +import DoorbellIcon from "@mui/icons-material/Doorbell"; +import ElectricBoltIcon from "@mui/icons-material/ElectricBolt"; +import CottageIcon from "@mui/icons-material/Cottage"; +import GppMaybeIcon from "@mui/icons-material/GppMaybe"; +import GavelIcon from "@mui/icons-material/Gavel"; +import BallotIcon from "@mui/icons-material/Ballot"; +import AssistantIcon from "@mui/icons-material/Assistant"; +import AdminPanelSettingsIcon from "@mui/icons-material/AdminPanelSettings"; +import MapIcon from "@mui/icons-material/Map"; +import SpeedIcon from "@mui/icons-material/Speed"; +import EngineeringIcon from "@mui/icons-material/Engineering"; +import ReportIcon from "@mui/icons-material/Report"; +import AssignmentLateIcon from "@mui/icons-material/AssignmentLate"; +import LineAxisIcon from "@mui/icons-material/LineAxis"; export const pageMenu = [ { @@ -6,7 +25,7 @@ export const pageMenu = [ label: "پیشخوان", type: "page", route: "/dashboard", - icon: , + icon: , permissions: ["all"], }, { @@ -14,14 +33,14 @@ export const pageMenu = [ label: "مدیریت کاربران", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/user_management", - icon: , + icon: , permissions: ["full-user-management", "limited-user-management"], }, { id: "projectsManagment", label: "پروژه های راهداری", type: "menu", - icon: , + icon: , hasSubitems: true, Subitems: [ { @@ -29,7 +48,7 @@ export const pageMenu = [ label: "ثبت قرارداد و پروژه", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/rahdari_projects/finance", - icon: , + icon: , permissions: ["show-contract", "show-contract-province"], }, { @@ -37,7 +56,7 @@ export const pageMenu = [ label: "لیست پروژه ها", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/rahdari_projects/projects_list", - icon: , + icon: , permissions: ["all"], }, { @@ -45,7 +64,7 @@ export const pageMenu = [ label: "پروژه های پیشنهادی", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/rahdari_projects/proposal", - icon: , + icon: , permissions: ["show-proposal", "show-proposal-province"], }, { @@ -53,7 +72,7 @@ export const pageMenu = [ label: "درخواست نمایندگان", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/rahdari_projects/lawmakers", - icon: , + icon: , permissions: ["show-lawmaker", "show-lawmaker-province"], }, { @@ -61,7 +80,7 @@ export const pageMenu = [ label: "پراکندگی بر روی نقشه", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/map?type=rahdari_projects", - icon: , + icon: , permissions: ["all"], }, ], @@ -70,14 +89,14 @@ export const pageMenu = [ id: "roadItemManagment", label: "فعالیت های روزانه", type: "menu", - icon: , + icon: , hasSubitems: true, Subitems: [ { id: "roadItemManagmentSupervisor", label: "ارزیابی", type: "menu", - icon: , + icon: , hasSubitems: true, Subitems: [ { @@ -96,7 +115,7 @@ export const pageMenu = [ id: "roadItemManagmentOparation", label: "عملیات", type: "menu", - icon: , + icon: , hasSubitems: true, Subitems: [ { @@ -120,7 +139,7 @@ export const pageMenu = [ label: "پراکندگی بر روی نقشه", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/map?type=road_items", - icon: , + icon: , permissions: [ "show-road-item-supervise-cartable", "show-road-item-supervise-cartable-province", @@ -132,7 +151,7 @@ export const pageMenu = [ label: "گزارش ها", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_items/report", - icon: , + icon: , permissions: [ "show-road-item-supervise-cartable", "show-road-item-supervise-cartable-province", @@ -145,14 +164,14 @@ export const pageMenu = [ id: "roadPatrolManagment", label: "گشت راهداری و ترابری", type: "menu", - icon: , + icon: , hasSubitems: true, Subitems: [ { id: "roadPatrolManagmentSupervisor", label: "ارزیابی", type: "menu", - icon: , + icon: , hasSubitems: true, Subitems: [ { @@ -171,7 +190,7 @@ export const pageMenu = [ id: "roadPatrolManagmentOparation", label: "عملیات", type: "menu", - icon: , + icon: , hasSubitems: true, Subitems: [ { @@ -195,7 +214,7 @@ export const pageMenu = [ label: "پراکندگی بر روی نقشه", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/map?type=road_patrols", - icon: , + icon: , permissions: [ "add-road-patrol", "show-road-patrol-supervise-cartable", @@ -207,7 +226,7 @@ export const pageMenu = [ label: "گزارش ها", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_patrols/report", - icon: , + icon: , permissions: [ "add-road-patrol", "show-road-patrol-supervise-cartable", @@ -220,7 +239,7 @@ export const pageMenu = [ id: "inquiryPrivacyManagment", label: "استعلام حریم راه", type: "menu", - icon: , + icon: , hasSubitems: true, Subitems: [ { @@ -250,14 +269,14 @@ export const pageMenu = [ id: "safetyAndPrivacyManagment", label: "نگهداری حریم راه", type: "menu", - icon: , + icon: , hasSubitems: true, Subitems: [ { id: "safetyAndPrivacyManagmentOparation", label: "عملیات", type: "menu", - icon: , + icon: , hasSubitems: true, Subitems: [ { @@ -285,7 +304,7 @@ export const pageMenu = [ label: "پراکندگی بر روی نقشه", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/map?type=safety_and_privacy", - icon: , + icon: , permissions: [ "show-safety-and-privacy-operator-cartable", "show-safety-and-privacy-operator-cartable-province", @@ -298,7 +317,7 @@ export const pageMenu = [ label: "گزارش ها", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/safety_and_privacy/report", - icon: , + icon: , permissions: [ "show-safety-and-privacy-operator-cartable", "show-safety-and-privacy-operator-cartable-province", @@ -312,14 +331,14 @@ export const pageMenu = [ id: "roadObservationsManagment", label: "واکنش سریع", type: "menu", - icon: , + icon: , hasSubitems: true, Subitems: [ { id: "roadObservationsManagmentSupervisor", label: "ارزیابی", type: "menu", - icon: , + icon: , hasSubitems: true, Subitems: [ { @@ -336,14 +355,14 @@ export const pageMenu = [ label: "رسیدگی به شکایات", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_observations", - icon: , + icon: , permissions: ["show-fast-react", "show-fast-react-province", "show-fast-react-edarate-shahri"], }, { id: "roadObservationsManagmentOparation", label: "عملیات", type: "menu", - icon: , + icon: , hasSubitems: true, Subitems: [ { @@ -360,7 +379,7 @@ export const pageMenu = [ label: "پراکندگی بر روی نقشه", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/map?type=road_observations", - icon: , + icon: , permissions: ["all"], }, { @@ -368,7 +387,7 @@ export const pageMenu = [ label: "گزارش ها", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_observations/report/index", - icon: , + icon: , permissions: ["all"], }, ], @@ -377,7 +396,7 @@ export const pageMenu = [ id: "winterCampManagment", label: "قرارگاه زمستانی", type: "menu", - icon: , + icon: , hasSubitems: true, Subitems: [ { @@ -385,7 +404,7 @@ export const pageMenu = [ label: "محور های انسدادی", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/winter_camp", - icon: , + icon: , permissions: ["show-camp", "show-camp-province"], }, { @@ -393,7 +412,7 @@ export const pageMenu = [ label: "محور های حلقه اول", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/map?type=camp", - icon: , + icon: , permissions: ["show-camp", "show-camp-province"], }, { @@ -401,7 +420,7 @@ export const pageMenu = [ label: "گزارش ها", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/map?type=campNew", - icon: , + icon: , permissions: ["show-camp", "show-camp-province"], }, ], @@ -410,14 +429,14 @@ export const pageMenu = [ id: "receiptManagment", label: "خسارات وارده بر ابنیه فنی و تاسیسات راه", type: "menu", - icon: , + icon: , hasSubitems: true, Subitems: [ { id: "receiptManagmentOparation", label: "عملیات", type: "menu", - icon: , + icon: , hasSubitems: true, Subitems: [ { @@ -434,7 +453,7 @@ export const pageMenu = [ label: "گزارش ها", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/receipt/report", - icon: , + icon: , permissions: ["all"], }, ], From be384141ac463def519894b9b0a3c76a203ef85a Mon Sep 17 00:00:00 2001 From: Mohammad Jalali Date: Sat, 17 Aug 2024 17:33:01 +0330 Subject: [PATCH 2/3] start working on profile --- src/core/components/SidebarMenu.jsx | 122 ++++++++++++++++++---------- 1 file changed, 79 insertions(+), 43 deletions(-) diff --git a/src/core/components/SidebarMenu.jsx b/src/core/components/SidebarMenu.jsx index 625972a..39d8079 100644 --- a/src/core/components/SidebarMenu.jsx +++ b/src/core/components/SidebarMenu.jsx @@ -1,10 +1,12 @@ "use client"; import SidebarListItems from "@/core/components/SidebarListItems"; import { usePermissions } from "@/lib/hooks/usePermissions"; -import { List } from "@mui/material"; +import { Avatar, Box, Divider, IconButton, List, Stack, Typography } from "@mui/material"; import { usePathname } from "next/navigation"; import { useEffect, useReducer, useState } from "react"; import { filterMenuItems } from "../utils/filterMenuItems"; +import PowerSettingsNewIcon from "@mui/icons-material/PowerSettingsNew"; +import ModeEditIcon from "@mui/icons-material/ModeEdit"; import { pageMenu } from "../utils/pageMenu"; function selectPage(item, route) { @@ -35,48 +37,48 @@ function reducer(state, action) { return state.map((item) => action.id == item.id ? { - ...item, - showSubitems: !item.showSubitems, - } - : item + ...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": @@ -105,20 +107,54 @@ const SidebarMenu = () => { useEffect(() => { selectedKey && - document.querySelector(`[data-route="${selectedKey}"]`)?.scrollIntoView({ - behavior: "smooth", - block: "center", - }); + document.querySelector(`[data-route="${selectedKey}"]`)?.scrollIntoView({ + behavior: "smooth", + block: "center", + }); }, [selectedKey]); return ( - userPermissions && ( - - {menuItems.map((menuItem) => { - return ; - })} - - ) + <> + + + + + + شرکت وایتل + (userName) + + .: اداره کل ستاد :. + + + + آخرین ورود + + 1 ساعت پیش + + + + + + + + + + + + { + userPermissions && ( + + {menuItems.map((menuItem) => { + return ; + })} + + ) + } + ); }; export default SidebarMenu; From 090e6d0b37a8e2280ecb0089dc91cecf2e4470f3 Mon Sep 17 00:00:00 2001 From: Mohammad Jalali Date: Mon, 19 Aug 2024 13:40:13 +0330 Subject: [PATCH 3/3] complete profile part and start working on update profile and changing password --- .../dashboard/headerWithSidebar/index.jsx | 9 ++- .../components/Profile/ChangePass/index.jsx | 52 +++++++++++++ src/core/components/Profile/Update/form.jsx | 0 src/core/components/Profile/Update/index.jsx | 52 +++++++++++++ src/core/components/Profile/index.jsx | 75 +++++++++++++++++++ src/core/components/SidebarMenu.jsx | 36 +-------- src/lib/contexts/tableSetting.js | 1 + 7 files changed, 189 insertions(+), 36 deletions(-) create mode 100644 src/core/components/Profile/ChangePass/index.jsx create mode 100644 src/core/components/Profile/Update/form.jsx create mode 100644 src/core/components/Profile/Update/index.jsx create mode 100644 src/core/components/Profile/index.jsx diff --git a/src/components/layouts/dashboard/headerWithSidebar/index.jsx b/src/components/layouts/dashboard/headerWithSidebar/index.jsx index 68f4bc6..4a66880 100644 --- a/src/components/layouts/dashboard/headerWithSidebar/index.jsx +++ b/src/components/layouts/dashboard/headerWithSidebar/index.jsx @@ -2,10 +2,11 @@ import SidebarMenu from "@/core/components/SidebarMenu"; import ChevronRightIcon from "@mui/icons-material/ChevronRight"; import MenuIcon from "@mui/icons-material/Menu"; -import { Box, Drawer, IconButton, Stack, styled, Toolbar } from "@mui/material"; +import { Box, Drawer, IconButton, Stack, styled, Toolbar, Typography } from "@mui/material"; import MuiAppBar from "@mui/material/AppBar"; import { useState } from "react"; import HeaderMenu from "./HeaderMenu"; +import moment from "jalali-moment"; const drawerWidth = 300; @@ -54,6 +55,7 @@ const DrawerHeader = styled("div")(({ theme }) => ({ const HeaderWithSidebar = ({ children }) => { const [open, setOpen] = useState(true); + const now = moment().locale("fa").format("HH:mm | YYYY/MM/DD"); const handleDrawerOpen = () => { setOpen(true); @@ -90,14 +92,15 @@ const HeaderWithSidebar = ({ children }) => { boxSizing: "border-box", borderTop: 1, borderTopColor: "divider", - position: 'inherit' + position: "inherit", }, }} variant="persistent" anchor="left" open={open} > - + + تاریخ امروز: {now} diff --git a/src/core/components/Profile/ChangePass/index.jsx b/src/core/components/Profile/ChangePass/index.jsx new file mode 100644 index 0000000..31df662 --- /dev/null +++ b/src/core/components/Profile/ChangePass/index.jsx @@ -0,0 +1,52 @@ +"use client"; + +import { + Box, + Button, + Dialog, + DialogActions, + DialogContent, + DialogTitle, + IconButton, + useMediaQuery, +} from "@mui/material"; +import { useTheme } from "@mui/material/styles"; +import CloseIcon from "@mui/icons-material/Close"; + +const ChangePass = ({ open, setOpen }) => { + const theme = useTheme(); + const fullScreen = useMediaQuery(theme.breakpoints.down("sm")); + + return ( + { + setOpen(false); + }}> + + + تغییر رمز عبور + + { + setOpen(false); + }} + sx={{ color: (theme) => theme.palette.grey[500] }} + > + + + + + تست + + + + + + ); +}; +export default ChangePass; \ No newline at end of file diff --git a/src/core/components/Profile/Update/form.jsx b/src/core/components/Profile/Update/form.jsx new file mode 100644 index 0000000..e69de29 diff --git a/src/core/components/Profile/Update/index.jsx b/src/core/components/Profile/Update/index.jsx new file mode 100644 index 0000000..bb244ea --- /dev/null +++ b/src/core/components/Profile/Update/index.jsx @@ -0,0 +1,52 @@ +"use client"; + +import { + Box, + Button, + Dialog, + DialogActions, + DialogContent, + DialogTitle, + IconButton, + useMediaQuery, +} from "@mui/material"; +import { useTheme } from "@mui/material/styles"; +import CloseIcon from "@mui/icons-material/Close"; + +const Update = ({ open, setOpen }) => { + const theme = useTheme(); + const fullScreen = useMediaQuery(theme.breakpoints.down("sm")); + + return ( + { + setOpen(false); + }}> + + + ویرایش پروفایل + + { + setOpen(false); + }} + sx={{ color: (theme) => theme.palette.grey[500] }} + > + + + + + form will come here + + + + + + ); +}; +export default Update; \ No newline at end of file diff --git a/src/core/components/Profile/index.jsx b/src/core/components/Profile/index.jsx new file mode 100644 index 0000000..0940b74 --- /dev/null +++ b/src/core/components/Profile/index.jsx @@ -0,0 +1,75 @@ +"use client"; + +import { Avatar, Box, Chip, Divider, IconButton, Stack, Tooltip, Typography } from "@mui/material"; +import PowerSettingsNewIcon from "@mui/icons-material/PowerSettingsNew"; +import ModeEditIcon from "@mui/icons-material/ModeEdit"; +import VpnKeyIcon from "@mui/icons-material/VpnKey"; +import { useState } from "react"; +import Update from "@/core/components/Profile/Update"; +import ChangePass from "@/core/components/Profile/ChangePass"; + +const Profile = () => { + const [openUpdate, setOpenUpdate] = useState(false); + const [openChangePass, setOpenChangePass] = useState(false); + + return ( + <> + + + + + + حسن محمد زاده عبدالله + + .: اداره کل ستاد :. + + + + آخرین ورود + + 1 ساعت پیش + + + + + + + + + { + setOpenUpdate(true); + }}> + + + + + + + + + + + + { + setOpenChangePass(true); + }}> + + + + + + + + + ); +}; +export default Profile; diff --git a/src/core/components/SidebarMenu.jsx b/src/core/components/SidebarMenu.jsx index 39d8079..2bd04e5 100644 --- a/src/core/components/SidebarMenu.jsx +++ b/src/core/components/SidebarMenu.jsx @@ -1,13 +1,12 @@ "use client"; import SidebarListItems from "@/core/components/SidebarListItems"; import { usePermissions } from "@/lib/hooks/usePermissions"; -import { Avatar, Box, Divider, IconButton, List, Stack, Typography } from "@mui/material"; +import { List } from "@mui/material"; import { usePathname } from "next/navigation"; import { useEffect, useReducer, useState } from "react"; import { filterMenuItems } from "../utils/filterMenuItems"; -import PowerSettingsNewIcon from "@mui/icons-material/PowerSettingsNew"; -import ModeEditIcon from "@mui/icons-material/ModeEdit"; import { pageMenu } from "../utils/pageMenu"; +import Profile from "@/core/components/Profile"; function selectPage(item, route) { if (item.type === "page") { @@ -115,36 +114,7 @@ const SidebarMenu = () => { return ( <> - - - - - - شرکت وایتل - (userName) - - .: اداره کل ستاد :. - - - - آخرین ورود - - 1 ساعت پیش - - - - - - - - - - - + { userPermissions && ( diff --git a/src/lib/contexts/tableSetting.js b/src/lib/contexts/tableSetting.js index 0484511..2458a36 100644 --- a/src/lib/contexts/tableSetting.js +++ b/src/lib/contexts/tableSetting.js @@ -1,4 +1,5 @@ "use client"; + import { createContext, useCallback, useEffect, useState } from "react"; import LZString from "lz-string";