formatting and complete permission part of pages and removing _fencing page...

This commit is contained in:
2024-11-19 07:39:30 +00:00
committed by AmirHossein Mahmoodi
parent f986c32f4a
commit 2c60db7712
17 changed files with 70 additions and 1284 deletions

View 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;