From ff3c5dec75fe6de3d30b6cfaf0ffc884dd02c706 Mon Sep 17 00:00:00 2001 From: Amin Ghasempoor Date: Sat, 8 Mar 2025 12:51:29 +0000 Subject: [PATCH] Feature/permission table --- .../dashboard/permission-table/page.js | 13 ++ .../dashboard/damageItems/DamagesList.jsx | 4 +- .../create/Forms/CreateFormContent.jsx | 1 + .../Actions/create/Forms/DamageInfo.jsx | 54 +---- .../create/Forms/LogesticController.jsx | 64 +++++ .../operator/Actions/create/Forms/index.jsx | 8 +- .../operator/Form/EditForm/EditController.jsx | 6 + .../Actions/Create/Form/CreateFormContent.jsx | 219 ++++++++++++++++++ .../Actions/Create/Form/index.jsx | 66 ++++++ .../permissionTable/Actions/Create/index.jsx | 36 +++ .../Actions/Edit/EditController.jsx | 46 ++++ .../permissionTable/Actions/Edit/index.jsx | 51 ++++ .../permissionTable/PermissionList.jsx | 157 +++++++++++++ .../RowActions/DeleteDialog/DeleteContent.jsx | 39 ++++ .../RowActions/DeleteDialog/index.jsx | 34 +++ .../permissionTable/RowActions/index.jsx | 12 + .../dashboard/permissionTable/Toolbar.jsx | 9 + .../dashboard/permissionTable/index.jsx | 13 ++ src/core/components/PersianTextField.jsx | 4 +- src/core/utils/pageMenu.js | 9 + src/core/utils/routes.js | 6 + 21 files changed, 795 insertions(+), 56 deletions(-) create mode 100644 src/app/(withAuth)/dashboard/permission-table/page.js create mode 100644 src/components/dashboard/damages/operator/Actions/create/Forms/LogesticController.jsx create mode 100644 src/components/dashboard/permissionTable/Actions/Create/Form/CreateFormContent.jsx create mode 100644 src/components/dashboard/permissionTable/Actions/Create/Form/index.jsx create mode 100644 src/components/dashboard/permissionTable/Actions/Create/index.jsx create mode 100644 src/components/dashboard/permissionTable/Actions/Edit/EditController.jsx create mode 100644 src/components/dashboard/permissionTable/Actions/Edit/index.jsx create mode 100644 src/components/dashboard/permissionTable/PermissionList.jsx create mode 100644 src/components/dashboard/permissionTable/RowActions/DeleteDialog/DeleteContent.jsx create mode 100644 src/components/dashboard/permissionTable/RowActions/DeleteDialog/index.jsx create mode 100644 src/components/dashboard/permissionTable/RowActions/index.jsx create mode 100644 src/components/dashboard/permissionTable/Toolbar.jsx create mode 100644 src/components/dashboard/permissionTable/index.jsx diff --git a/src/app/(withAuth)/dashboard/permission-table/page.js b/src/app/(withAuth)/dashboard/permission-table/page.js new file mode 100644 index 0000000..8a825a5 --- /dev/null +++ b/src/app/(withAuth)/dashboard/permission-table/page.js @@ -0,0 +1,13 @@ +import WithPermission from "@/core/middlewares/withPermission"; +import PermissionTablePage from "@/components/dashboard/permissionTable"; +export const metadata = { + title: "سطح دسترسی ها", +}; +const Page = () => { + return ( + + + + ); +}; +export default Page; diff --git a/src/components/dashboard/damageItems/DamagesList.jsx b/src/components/dashboard/damageItems/DamagesList.jsx index e93d216..2050359 100644 --- a/src/components/dashboard/damageItems/DamagesList.jsx +++ b/src/components/dashboard/damageItems/DamagesList.jsx @@ -70,8 +70,8 @@ const DamagesList = () => { columns={columns} sorting={[{ id: "id", desc: true }]} table_url={GET_RECEIPT_DAMAGE_ITEMS_LIST} - page_name={"receiptDamanagePage"} - table_name={"damanageList"} + page_name={"receiptDamagePage"} + table_name={"receiptDamageList"} TableToolbar={Toolbar} enableRowActions positionActionsColumn={"last"} diff --git a/src/components/dashboard/damages/operator/Actions/create/Forms/CreateFormContent.jsx b/src/components/dashboard/damages/operator/Actions/create/Forms/CreateFormContent.jsx index 11ec3b4..2123236 100644 --- a/src/components/dashboard/damages/operator/Actions/create/Forms/CreateFormContent.jsx +++ b/src/components/dashboard/damages/operator/Actions/create/Forms/CreateFormContent.jsx @@ -80,6 +80,7 @@ const CreateFormContent = ({ setOpen, SubmitDamage, defaultData }) => { accident_type: defaultData.accident_type, province_id: defaultData.province_id, city_id: defaultData.city_id, + is_province: defaultData.is_province, axis_name: defaultData.axis_name, driver_name: defaultData.driver_name, phone_number: defaultData.phone_number, diff --git a/src/components/dashboard/damages/operator/Actions/create/Forms/DamageInfo.jsx b/src/components/dashboard/damages/operator/Actions/create/Forms/DamageInfo.jsx index 797610c..7f823a5 100644 --- a/src/components/dashboard/damages/operator/Actions/create/Forms/DamageInfo.jsx +++ b/src/components/dashboard/damages/operator/Actions/create/Forms/DamageInfo.jsx @@ -3,66 +3,18 @@ import { Grid, Stack, TextField } from "@mui/material"; import MuiDatePicker from "@/core/components/MuiDatePicker"; import MuiTimePicker from "@/core/components/MuiTimePicker"; import SelectBox from "@/core/components/SelectBox"; -import useProvinces from "@/lib/hooks/useProvince"; import PlateNumber from "@/core/components/PlateNumber"; import ImageUpload from "./ImageUpload"; import MapInfoOneMarker from "@/core/components/MapInfoOneMarker"; -import CityController from "@/components/dashboard/damages/operator/Actions/create/Forms/CityController"; import PersianTextField from "@/core/components/PersianTextField"; +import LogesticController from "./LogesticController"; const DamageInfo = ({ control, setValue, errors }) => { const StartPoint = useWatch({ control, name: "start_point" }); - const { provinces, errorProvinces, loadingProvinces } = useProvinces(); return ( - - - { - return ( - - ); - }} - /> - - - - - - ( - - )} - /> - - + { value={field.value} variant="outlined" name="driver_name" - fieldOnChange={field.onChange} + onChange={field.onChange} label="نام و نام خانوادگی راننده" placeholder={"نام و نام خانوادگی فارسی را وارد کنید"} fullWidth diff --git a/src/components/dashboard/damages/operator/Actions/create/Forms/LogesticController.jsx b/src/components/dashboard/damages/operator/Actions/create/Forms/LogesticController.jsx new file mode 100644 index 0000000..a53059b --- /dev/null +++ b/src/components/dashboard/damages/operator/Actions/create/Forms/LogesticController.jsx @@ -0,0 +1,64 @@ +import { Controller, useWatch } from "react-hook-form"; +import SelectBox from "@/core/components/SelectBox"; +import useProvinces from "@/lib/hooks/useProvince"; +import { Grid } from "@mui/material"; +import CityController from "./CityController"; +import PersianTextField from "@/core/components/PersianTextField"; + +const LogesticController = ({ control }) => { + const { provinces, errorProvinces, loadingProvinces } = useProvinces(); + const isProvince = useWatch({ control, name: "is_province" }); + return ( + + {!isProvince ? ( + + { + return ( + + ); + }} + /> + + ) : null} + + + + + ( + + )} + /> + + + ); +}; +export default LogesticController; diff --git a/src/components/dashboard/damages/operator/Actions/create/Forms/index.jsx b/src/components/dashboard/damages/operator/Actions/create/Forms/index.jsx index ab50184..01d0141 100644 --- a/src/components/dashboard/damages/operator/Actions/create/Forms/index.jsx +++ b/src/components/dashboard/damages/operator/Actions/create/Forms/index.jsx @@ -5,9 +5,14 @@ import { format } from "date-fns"; import { CREATE_DAMAGE } from "@/core/utils/routes"; import useRequest from "@/lib/hooks/useRequest"; import CloseIcon from "@mui/icons-material/Close"; +import { usePermissions } from "@/lib/hooks/usePermissions"; +import { useAuth } from "@/lib/contexts/auth"; const OperatorCreateForm = ({ open, setOpen, mutate }) => { const requestServer = useRequest({ notificationSuccess: true }); + const { user } = useAuth(); + const { data: userPermissions } = usePermissions(); + const hasCreateProvincePermission = userPermissions.some((item) => ["add-receipt"].includes(item)); const SubmitCreateDamage = async (result) => { const PlateNumber = `${result.plate_part1}-${result.plate_part2}-${result.plate_part3}-${result.plate_part4}`; const formData = new FormData(); @@ -52,7 +57,8 @@ const OperatorCreateForm = ({ open, setOpen, mutate }) => { accident_date: "", accident_time: "", accident_type: "", - province_id: null, + province_id: !hasCreateProvincePermission ? user.province_id : null, + is_province: !hasCreateProvincePermission, city_id: null, axis_name: "", driver_name: "", diff --git a/src/components/dashboard/damages/operator/Form/EditForm/EditController.jsx b/src/components/dashboard/damages/operator/Form/EditForm/EditController.jsx index f545cc6..d6e2b3d 100644 --- a/src/components/dashboard/damages/operator/Form/EditForm/EditController.jsx +++ b/src/components/dashboard/damages/operator/Form/EditForm/EditController.jsx @@ -5,11 +5,16 @@ import { GET_DAMAGE_ITEM_DETAILS, UPDATE_DAMAGE_ITEM } from "@/core/utils/routes import DialogLoading from "@/core/components/DialogLoading"; import { format } from "date-fns"; import moment from "jalali-moment"; +import { useAuth } from "@/lib/contexts/auth"; +import { usePermissions } from "@/lib/hooks/usePermissions"; const EditController = ({ rowId, mutate, setOpenEditDialog }) => { const requestServer = useRequest(); const [damageItemDetails, setDamageItemDetails] = useState(null); const [damageItemDetailsLoading, setDamageItemDetailsLoading] = useState(false); + const { user } = useAuth(); + const { data: userPermissions } = usePermissions(); + const hasCreateProvincePermission = userPermissions.some((item) => ["add-receipt"].includes(item)); useEffect(() => { setDamageItemDetailsLoading(true); @@ -46,6 +51,7 @@ const EditController = ({ rowId, mutate, setOpenEditDialog }) => { radio_button: damageItemDetails?.report_base === 1 ? "report_base" : "police_file_checkbox", report_base: damageItemDetails?.report_base, province_id: damageItemDetails?.province_id || null, + is_province: !hasCreateProvincePermission, city_id: damageItemDetails?.city_id || null, start_point: { lat: damageItemDetails?.lat || "", lng: damageItemDetails?.lng || "" }, }; diff --git a/src/components/dashboard/permissionTable/Actions/Create/Form/CreateFormContent.jsx b/src/components/dashboard/permissionTable/Actions/Create/Form/CreateFormContent.jsx new file mode 100644 index 0000000..3a84a08 --- /dev/null +++ b/src/components/dashboard/permissionTable/Actions/Create/Form/CreateFormContent.jsx @@ -0,0 +1,219 @@ +import StyledForm from "@/core/components/StyledForm"; +import { yupResolver } from "@hookform/resolvers/yup"; +import { Beenhere, ExitToApp } from "@mui/icons-material"; +import { + Button, + DialogActions, + DialogContent, + Grid, + Stack, + TextField, + FormControlLabel, + Checkbox, +} from "@mui/material"; +import { Controller, useForm } from "react-hook-form"; +import { object, string } from "yup"; +import PersianTextField from "@/core/components/PersianTextField"; + +const validationSchema = object({ + name: string().required("وارد کردن نام انگلیسی الزامیست!"), + name_fa: string().required("وارد کردن نام فارسی الزامیست!"), + description: string().required("وارد کردن توضیحات الزامیست!"), + type: string().required("وارد کردن گروه (انگلیسی) الزامیست!"), + type_fa: string().required("وارد کردن گروه (فارسی) الزامیست!"), +}); + +const CreateFormContent = ({ setOpen, defaultValues, onSubmitBase }) => { + const { + control, + handleSubmit, + formState: { isSubmitting, errors }, + } = useForm({ + defaultValues, + resolver: yupResolver(validationSchema), + mode: "onBlur", + }); + const handleOnSubmit = async (data) => { + await onSubmitBase(data); + }; + + return ( + <> + + + + + + + ( + + )} + /> + + + ( + + )} + /> + + + + + + + ( + + )} + /> + + + ( + + )} + /> + + + + + + + ( + + )} + /> + + + + + + + ( + + } + label="دسترسی استانی" + /> + )} + /> + + + ( + + } + label="دسترسی اداره شهری" + /> + )} + /> + + + + + + + + + + + + ); +}; +export default CreateFormContent; diff --git a/src/components/dashboard/permissionTable/Actions/Create/Form/index.jsx b/src/components/dashboard/permissionTable/Actions/Create/Form/index.jsx new file mode 100644 index 0000000..2c01835 --- /dev/null +++ b/src/components/dashboard/permissionTable/Actions/Create/Form/index.jsx @@ -0,0 +1,66 @@ +import { Dialog, DialogTitle, IconButton } from "@mui/material"; +import CreateFormContent from "./CreateFormContent"; +import CloseIcon from "@mui/icons-material/Close"; +import useRequest from "@/lib/hooks/useRequest"; +import { CREATE_PERMISSION } from "@/core/utils/routes"; +import { DialogHeader } from "next/dist/client/components/react-dev-overlay/internal/components/Dialog"; + +const CreateForm = ({ open, setOpen, mutate }) => { + const requestServer = useRequest({ notificationSuccess: true }); + const defaultValues = { + name: "", + name_fa: "", + description: "", + type: "", + type_fa: "", + need_province: false, + need_edare_shahri: false, + }; + const onSubmit = async (result) => { + const formData = new FormData(); + formData.append("name", result.name); + formData.append("name_fa", result.name_fa); + formData.append("description", result.description); + formData.append("type", result.type); + formData.append("type_fa", result.type_fa); + formData.append("need_province", result.need_province ? 1 : 0); + formData.append("need_edare_shahri", result.need_edare_shahri ? 1 : 0); + await requestServer(CREATE_PERMISSION, "post", { + data: formData, + }) + .then(() => { + mutate(); + setOpen(false); + }) + .catch(() => {}); + }; + return ( + + setOpen(false)} + sx={(theme) => ({ + position: "absolute", + right: 8, + top: 8, + zIndex: 50, + color: theme.palette.grey[500], + })} + > + + + + ثبت سطح دسترسی جدید + + {open && ( + + )} + + ); +}; +export default CreateForm; diff --git a/src/components/dashboard/permissionTable/Actions/Create/index.jsx b/src/components/dashboard/permissionTable/Actions/Create/index.jsx new file mode 100644 index 0000000..c558a8b --- /dev/null +++ b/src/components/dashboard/permissionTable/Actions/Create/index.jsx @@ -0,0 +1,36 @@ +import { AddCircle } from "@mui/icons-material"; +import { Button, IconButton, useMediaQuery, useTheme } from "@mui/material"; +import CreateForm from "./Form"; +import { useState } from "react"; + +const CreatePermission = ({ mutate }) => { + const theme = useTheme(); + const isMobile = useMediaQuery(theme.breakpoints.down("sm")); + const [open, setOpen] = useState(false); + + const handleOpen = () => { + setOpen(true); + }; + + return ( + <> + {isMobile ? ( + + + + ) : ( + + )} + + + ); +}; +export default CreatePermission; diff --git a/src/components/dashboard/permissionTable/Actions/Edit/EditController.jsx b/src/components/dashboard/permissionTable/Actions/Edit/EditController.jsx new file mode 100644 index 0000000..b5ff432 --- /dev/null +++ b/src/components/dashboard/permissionTable/Actions/Edit/EditController.jsx @@ -0,0 +1,46 @@ +import useRequest from "@/lib/hooks/useRequest"; +import CreateFormContent from "../Create/Form/CreateFormContent"; +import { UPDATE_PERMISSION } from "@/core/utils/routes"; +import { DialogTitle } from "@mui/material"; +import { DialogHeader } from "next/dist/client/components/react-dev-overlay/internal/components/Dialog"; + +const EditController = ({ rowId, mutate, setOpen, row }) => { + const requestServer = useRequest({ notificationSuccess: true }); + + const defaultData = { + name: row.original?.name || "", + name_fa: row.original?.name_fa || "", + description: row.original?.description || "", + type: row.original?.type || "", + type_fa: row.original?.type_fa || "", + need_province: row.original?.need_province || false, + need_edare_shahri: row.original?.need_edare_shahri || false, + }; + const handleSubmit = async (result) => { + const formData = new FormData(); + formData.append("name", result.name); + formData.append("name_fa", result.name_fa); + formData.append("description", result.description); + formData.append("type", result.type); + formData.append("type_fa", result.type_fa); + formData.append("need_province", result.need_province ? 1 : 0); + formData.append("need_edare_shahri", result.need_edare_shahri ? 1 : 0); + await requestServer(`${UPDATE_PERMISSION}/${rowId}`, "post", { + data: formData, + }) + .then(() => { + mutate(); + setOpen(false); + }) + .catch(() => {}); + }; + return ( + <> + + ویرایش سطح دسترسی جدید + + + + ); +}; +export default EditController; diff --git a/src/components/dashboard/permissionTable/Actions/Edit/index.jsx b/src/components/dashboard/permissionTable/Actions/Edit/index.jsx new file mode 100644 index 0000000..b7d98a9 --- /dev/null +++ b/src/components/dashboard/permissionTable/Actions/Edit/index.jsx @@ -0,0 +1,51 @@ +import { useState } from "react"; +import { Dialog, IconButton, Tooltip } from "@mui/material"; +import BorderColorIcon from "@mui/icons-material/BorderColor"; +import CloseIcon from "@mui/icons-material/Close"; +import EditController from "./EditController"; + +const EditPermission = ({ mutate, row, rowId }) => { + const [open, setOpen] = useState(false); + + return ( + <> + + { + setOpen(true); + }} + > + + + + + setOpen(false)} + sx={(theme) => ({ + position: "absolute", + right: 8, + top: 8, + zIndex: 50, + color: theme.palette.grey[500], + })} + > + + + {open && } + + + ); +}; +export default EditPermission; diff --git a/src/components/dashboard/permissionTable/PermissionList.jsx b/src/components/dashboard/permissionTable/PermissionList.jsx new file mode 100644 index 0000000..05f53af --- /dev/null +++ b/src/components/dashboard/permissionTable/PermissionList.jsx @@ -0,0 +1,157 @@ +"use client"; +import DataTableWithAuth from "@/core/components/DataTableWithAuth"; +import { GET_PERMISSION_TABLE_LIST } from "@/core/utils/routes"; +import { Box, Stack, Typography } from "@mui/material"; +import { useMemo } from "react"; +import Toolbar from "./Toolbar"; +import RowActions from "./RowActions"; +import moment from "jalali-moment"; +import DoneIcon from "@mui/icons-material/Done"; +import ClearIcon from "@mui/icons-material/Clear"; + +const PermissionList = () => { + const columns = useMemo( + () => [ + { + accessorKey: "id", + header: "کد یکتا", + id: "id", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + }, + { + accessorKey: "type", + header: "گروه (انگلیسی)", + id: "type", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + }, + { + accessorKey: "type_fa", + header: "گروه (فارسی)", + id: "type_fa", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + }, + { + accessorKey: "name", + header: "نام انگلیسی", + id: "name", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + }, + { + accessorKey: "name_fa", + header: "نام فارسی", + id: "name_fa", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + }, + { + accessorKey: "need_province", + header: "دسترسی استانی", + id: "need_province", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ renderedCellValue }) => ( + <> + {renderedCellValue === 1 ? ( + + + + ) : ( + + + + )} + + ), + }, + { + accessorKey: "need_edare_shahri", + header: "دسترسی اداره شهری", + id: "need_edare_shahri", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ renderedCellValue }) => ( + <> + {renderedCellValue === 1 ? ( + + + + ) : ( + + + + )} + + ), + }, + { + accessorFn: (row) => { + const date = row.created_at ? new Date(row.created_at) : null; + return date ? moment(date).locale("fa").format("HH:mm | jYYYY/jMM/jDD") : "-"; + }, + header: "تاریخ ثبت", + id: "created_at", + enableColumnFilter: true, + datatype: "date", + filterMode: "between", + grow: false, + size: 100, + }, + ], + [] + ); + + return ( + <> + + + + + ); +}; +export default PermissionList; diff --git a/src/components/dashboard/permissionTable/RowActions/DeleteDialog/DeleteContent.jsx b/src/components/dashboard/permissionTable/RowActions/DeleteDialog/DeleteContent.jsx new file mode 100644 index 0000000..2bf7bc1 --- /dev/null +++ b/src/components/dashboard/permissionTable/RowActions/DeleteDialog/DeleteContent.jsx @@ -0,0 +1,39 @@ +import { Button, DialogActions, DialogContent, Stack, Typography } from "@mui/material"; +import React, { useState } from "react"; +import useRequest from "@/lib/hooks/useRequest"; +import { DELETE_PERMISSION } from "@/core/utils/routes"; + +const DeleteContent = ({ rowId, mutate, setOpenDeleteDialog }) => { + const [submitting, setSubmitting] = useState(false); + const requestServer = useRequest({ notificationSuccess: true }); + const handleClick = () => { + setSubmitting(true); + requestServer(`${DELETE_PERMISSION}/${rowId}`, "delete") + .then(() => { + mutate(); + setSubmitting(false); + setOpenDeleteDialog(false); + }) + .catch(() => { + setSubmitting(false); + }); + }; + return ( + <> + + + آیا از حذف سطح دسترسی اطمینان دارید؟ + + + + + + + + ); +}; +export default DeleteContent; diff --git a/src/components/dashboard/permissionTable/RowActions/DeleteDialog/index.jsx b/src/components/dashboard/permissionTable/RowActions/DeleteDialog/index.jsx new file mode 100644 index 0000000..2578e2a --- /dev/null +++ b/src/components/dashboard/permissionTable/RowActions/DeleteDialog/index.jsx @@ -0,0 +1,34 @@ +import DeleteIcon from "@mui/icons-material/Delete"; +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { useState } from "react"; +import DeleteContent from "./DeleteContent"; +const DeleteDialog = ({ rowId, mutate }) => { + const [openDeleteDialog, setOpenDeleteDialog] = useState(false); + + return ( + <> + + setOpenDeleteDialog(true)}> + + + + setOpenDeleteDialog(false)} + PaperProps={{ + sx: { + boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px", + }, + }} + dir="rtl" + maxWidth={"md"} + > + حذف سطح دسترسی + {openDeleteDialog && ( + + )} + + + ); +}; +export default DeleteDialog; diff --git a/src/components/dashboard/permissionTable/RowActions/index.jsx b/src/components/dashboard/permissionTable/RowActions/index.jsx new file mode 100644 index 0000000..cb78144 --- /dev/null +++ b/src/components/dashboard/permissionTable/RowActions/index.jsx @@ -0,0 +1,12 @@ +import { Box } from "@mui/material"; +import EditPermission from "../Actions/Edit"; +import DeleteDialog from "./DeleteDialog"; +const RowActions = ({ row, mutate }) => { + return ( + + + + + ); +}; +export default RowActions; diff --git a/src/components/dashboard/permissionTable/Toolbar.jsx b/src/components/dashboard/permissionTable/Toolbar.jsx new file mode 100644 index 0000000..1f6422e --- /dev/null +++ b/src/components/dashboard/permissionTable/Toolbar.jsx @@ -0,0 +1,9 @@ +import CreatePermission from "./Actions/Create"; +const Toolbar = ({ mutate }) => { + return ( + <> + + + ); +}; +export default Toolbar; diff --git a/src/components/dashboard/permissionTable/index.jsx b/src/components/dashboard/permissionTable/index.jsx new file mode 100644 index 0000000..bbbce86 --- /dev/null +++ b/src/components/dashboard/permissionTable/index.jsx @@ -0,0 +1,13 @@ +import PageTitle from "@/core/components/PageTitle"; +import { Stack } from "@mui/material"; +import PermissionList from "./PermissionList"; + +const PermissionTablePage = () => { + return ( + + + + + ); +}; +export default PermissionTablePage; diff --git a/src/core/components/PersianTextField.jsx b/src/core/components/PersianTextField.jsx index 286564f..1b2b490 100644 --- a/src/core/components/PersianTextField.jsx +++ b/src/core/components/PersianTextField.jsx @@ -3,11 +3,11 @@ import { TextField } from "@mui/material"; import { useRef } from "react"; const PersianTextField = (props) => { - const { fieldOnChange, ...rest } = props; + const { onChange, ...rest } = props; const inputRef = useRef(null); const handleChange = (value) => { - fieldOnChange(value); + onChange(value); }; usePersianInput(inputRef, handleChange); diff --git a/src/core/utils/pageMenu.js b/src/core/utils/pageMenu.js index 8e512a7..f6d458a 100644 --- a/src/core/utils/pageMenu.js +++ b/src/core/utils/pageMenu.js @@ -17,6 +17,7 @@ import SpeedIcon from "@mui/icons-material/Speed"; import EngineeringIcon from "@mui/icons-material/Engineering"; import AssessmentIcon from "@mui/icons-material/Assessment"; import AssignmentLateIcon from "@mui/icons-material/AssignmentLate"; +import LockPersonIcon from "@mui/icons-material/LockPerson"; import LineAxisIcon from "@mui/icons-material/LineAxis"; import ScienceIcon from "@mui/icons-material/Science"; import DriveEtaIcon from "@mui/icons-material/DriveEta"; @@ -490,6 +491,14 @@ export const pageMenu = [ icon: , permissions: ["azmayesh-type-management"], }, + { + id: "permissionItem", + label: "سطح دسترسی ها", + type: "page", + route: "/dashboard/permission-table", + icon: , + permissions: ["show-permissions-page"], + }, { id: "CarDetails", label: "اطلاعات خودرو", diff --git a/src/core/utils/routes.js b/src/core/utils/routes.js index fbacb6b..7cfb764 100644 --- a/src/core/utils/routes.js +++ b/src/core/utils/routes.js @@ -139,3 +139,9 @@ export const THIRD_STEP_STORE = api + "/api/v3/safety_and_privacy/third_step_sto export const EXPORT_OPERATOR_ROAD_SAFETY = api + "/api/v3/safety_and_privacy/excel_report"; export const GET_ROAD_SAFETY_PROVINCE_ACTIVITY_REPORT = api + "/api/v3/safety_and_privacy_report/country_activity"; export const GET_ROAD_SAFETY_CITY_ACTIVITY_REPORT = api + "/api/v3/safety_and_privacy_report/province_activity"; + +//permission table +export const GET_PERMISSION_TABLE_LIST = api + "/api/v3/permissions"; +export const DELETE_PERMISSION = api + "/api/v3/permissions"; +export const UPDATE_PERMISSION = api + "/api/v3/permissions"; +export const CREATE_PERMISSION = api + "/api/v3/permissions";