recode and add editor config file

This commit is contained in:
Amirhossein Mahmoodi
2023-07-31 09:34:59 +03:30
parent ba91b97e7c
commit 51b21957b9
108 changed files with 5993 additions and 5770 deletions

View File

@@ -1,43 +1,43 @@
import { NextLinkComposed } from "@/core/components/LinkRouting";
import {NextLinkComposed} from "@/core/components/LinkRouting";
import Message from "@/core/components/Messages";
import useUser from "@/lib/app/hooks/useUser";
import { Button, Typography } from "@mui/material";
import { useTranslations } from "next-intl";
import {Button, Typography} from "@mui/material";
import {useTranslations} from "next-intl";
const RolePermission = ({ children, requiredPermissions }) => {
const { user } = useUser();
const t = useTranslations();
const RolePermission = ({children, requiredPermissions}) => {
const {user} = useUser();
const t = useTranslations();
const hasPermission = requiredPermissions.some((permission) =>
user?.role?.includes(permission)
);
if (!hasPermission) {
return (
<Message
text={
<Typography sx={{ textAlign: "center" }}>
{t("Permission.typography_you_dont_have_access")}
</Typography>
}
actions={
<>
<Button
variant="contained"
component={NextLinkComposed}
to={{
pathname: "/dashboard",
}}
>
{t("Permission.button_back_dashboard")}
</Button>
</>
}
/>
const hasPermission = requiredPermissions.some((permission) =>
user?.role?.includes(permission)
);
}
return <>{children}</>;
if (!hasPermission) {
return (
<Message
text={
<Typography sx={{textAlign: "center"}}>
{t("Permission.typography_you_dont_have_access")}
</Typography>
}
actions={
<>
<Button
variant="contained"
component={NextLinkComposed}
to={{
pathname: "/dashboard",
}}
>
{t("Permission.button_back_dashboard")}
</Button>
</>
}
/>
);
}
return <>{children}</>;
};
export default RolePermission;