formatting and complete permission part of pages and removing _fencing page...
This commit is contained in:
@@ -151,11 +151,7 @@ const Form = ({ handleCloseForm, setLoading }) => {
|
||||
<CloudUploadIcon sx={{ fontSize: "2rem" }} color="inherit" />
|
||||
</Backdrop>
|
||||
</Box>
|
||||
<VisuallyHiddenInput
|
||||
type="file"
|
||||
accept="image/*"
|
||||
onChange={handleFileChange}
|
||||
/>
|
||||
<VisuallyHiddenInput type="file" accept="image/*" onChange={handleFileChange} />
|
||||
</Button>
|
||||
</Box>
|
||||
<Grid container columns={{ xs: 1, sm: 2 }} spacing={2}>
|
||||
|
||||
29
src/core/middlewares/withPermission.js
Normal file
29
src/core/middlewares/withPermission.js
Normal file
@@ -0,0 +1,29 @@
|
||||
"use client";
|
||||
|
||||
import { Box, Typography } from "@mui/material";
|
||||
import { usePermissions } from "@/lib/hooks/usePermissions";
|
||||
|
||||
function WithPermission({ children, permission_name }) {
|
||||
const { data, error, isLoading } = usePermissions();
|
||||
|
||||
if (error || isLoading || !data || !permission_name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const hasPermission =
|
||||
permission_name.includes("all") || permission_name.some((permission) => data.includes(permission));
|
||||
|
||||
if (!hasPermission) {
|
||||
return (
|
||||
<Box sx={{ display: "flex", alignItems: "center", justifyContent: "center", height: "100%" }}>
|
||||
<Typography variant="h5" sx={{ letterSpacing: "2px", color: "error.main" }}>
|
||||
شما دسترسی لازم به این صفحه را ندارید
|
||||
</Typography>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
return <>{children}</>;
|
||||
}
|
||||
|
||||
export default WithPermission;
|
||||
@@ -255,28 +255,28 @@ export const pageMenu = [
|
||||
label: "استعلام حرائم پنجره واحد",
|
||||
type: "page",
|
||||
route: "/dashboard/inquiry-privacy/city-admin/zamin-gov",
|
||||
permissions: ["all"],
|
||||
permissions: [],
|
||||
},
|
||||
{
|
||||
id: "provinceAdminZaminGov",
|
||||
label: "استعلام حرائم پنجره واحد",
|
||||
type: "page",
|
||||
route: "/dashboard/inquiry-privacy/province-admin/zamin-gov",
|
||||
permissions: ["all"],
|
||||
permissions: [],
|
||||
},
|
||||
{
|
||||
id: "assistantZaminGov",
|
||||
label: "استعلام حرائم پنجره واحد",
|
||||
type: "page",
|
||||
route: "/dashboard/inquiry-privacy/assistant/zamin-gov",
|
||||
permissions: ["all"],
|
||||
permissions: [],
|
||||
},
|
||||
{
|
||||
id: "generalManagerZaminGov",
|
||||
label: "استعلام حرائم پنجره واحد",
|
||||
type: "page",
|
||||
route: "/dashboard/inquiry-privacy/general-manager/zamin-gov",
|
||||
permissions: ["all"],
|
||||
permissions: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user