Merge branch 'develop' of https://gitlab.com/witel3/loan-facilities-expert into feature/debug_upload_file
This commit is contained in:
@@ -24,10 +24,10 @@
|
||||
},
|
||||
"sidebar": {
|
||||
"dashboard": "داشبورد",
|
||||
"passenger-office": "اداره مسافر",
|
||||
"machinary-office": "ماشین آلات",
|
||||
"passenger-office-chief": "اداره مسافر",
|
||||
"machinary-expert": "ماشین آلات",
|
||||
"passenger-boss": "رئیس مسافر ",
|
||||
"transportation-assistance": "معاونت حمل و نقل",
|
||||
"transportation-assistant": "معاونت حمل و نقل",
|
||||
"province-manager": "مدیر کل استانی",
|
||||
"change-password": "تغییر رمز عبور",
|
||||
"edit-profile": "ویرایش پروفایل"
|
||||
@@ -43,6 +43,10 @@
|
||||
"typography_routing_previuos_page": "صفحه قبل...",
|
||||
"typography_routing_dashbaord_page": "داشبورد..."
|
||||
},
|
||||
"Permission": {
|
||||
"typography_you_dont_have_access": "شما دسترسی لازم برای مشاهده این صفحه را ندارید!",
|
||||
"button_back_dashboard": "بازگشت به صفحه اصلی"
|
||||
},
|
||||
"LoginPage": {
|
||||
"text_field_user_name": "نام کاربری",
|
||||
"text_field_enter_your_username": "نام کاربری خود را وارد کنید",
|
||||
|
||||
@@ -16,18 +16,18 @@ const sidebarMenu = [
|
||||
role: "all",
|
||||
},
|
||||
{
|
||||
key: "sidebar.passenger-office",
|
||||
key: "sidebar.passenger-office-chief",
|
||||
secondary: "secondary.passenger-office",
|
||||
type: "page",
|
||||
route: "/dashboard/passenger-office",
|
||||
route: "/dashboard/passenger-office-chief",
|
||||
icon: <AirlineSeatReclineNormalIcon />,
|
||||
selected: false,
|
||||
role: "passenger_office_chief",
|
||||
},
|
||||
{
|
||||
key: "sidebar.machinary-office",
|
||||
key: "sidebar.machinary-expert",
|
||||
type: "page",
|
||||
route: "/dashboard/machinary-office",
|
||||
route: "/dashboard/machinary-expert",
|
||||
icon: <DirectionsCarFilledIcon />,
|
||||
selected: false,
|
||||
role: "machinery_expert",
|
||||
@@ -42,9 +42,9 @@ const sidebarMenu = [
|
||||
role: "passenger_office_chief",
|
||||
},
|
||||
{
|
||||
key: "sidebar.transportation-assistance",
|
||||
key: "sidebar.transportation-assistant",
|
||||
type: "page",
|
||||
route: "/dashboard/transportation-assistance",
|
||||
route: "/dashboard/transportation-assistant",
|
||||
icon: <DirectionsRailwayIcon />,
|
||||
selected: false,
|
||||
role: "transportation_assistant",
|
||||
|
||||
43
src/middlewares/RolePermission.jsx
Normal file
43
src/middlewares/RolePermission.jsx
Normal file
@@ -0,0 +1,43 @@
|
||||
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";
|
||||
|
||||
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>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return <>{children}</>;
|
||||
};
|
||||
|
||||
export default RolePermission;
|
||||
@@ -1,13 +1,16 @@
|
||||
import DashboardMachinaryOfficeComponent from "@/components/dashboard/machinary-office";
|
||||
import TitlePage from "@/core/components/TitlePage";
|
||||
import RolePermission from "@/middlewares/RolePermission";
|
||||
import WithAuthMiddleware from "@/middlewares/WithAuth";
|
||||
import { parse } from "next-useragent";
|
||||
|
||||
const requiredPermissions = ["machinery_expert"];
|
||||
export default function PassengerOffice() {
|
||||
return (
|
||||
<WithAuthMiddleware>
|
||||
<TitlePage text="Dashboard.machinary_office_page" />
|
||||
<DashboardMachinaryOfficeComponent />
|
||||
<RolePermission requiredPermissions={requiredPermissions}>
|
||||
<TitlePage text="Dashboard.machinary_office_page" />
|
||||
<DashboardMachinaryOfficeComponent />
|
||||
</RolePermission>
|
||||
</WithAuthMiddleware>
|
||||
);
|
||||
}
|
||||
@@ -1,13 +1,16 @@
|
||||
import DashboardPassengerBossComponent from "@/components/dashboard/passenger-boss";
|
||||
import TitlePage from "@/core/components/TitlePage";
|
||||
import RolePermission from "@/middlewares/RolePermission";
|
||||
import WithAuthMiddleware from "@/middlewares/WithAuth";
|
||||
import { parse } from "next-useragent";
|
||||
|
||||
const requiredPermissions = ["passenger_office_chief"];
|
||||
export default function PassengerBoss() {
|
||||
return (
|
||||
<WithAuthMiddleware>
|
||||
<TitlePage text="Dashboard.passenger_boss_page" />
|
||||
<DashboardPassengerBossComponent />
|
||||
<RolePermission requiredPermissions={requiredPermissions}>
|
||||
<TitlePage text="Dashboard.passenger_boss_page" />
|
||||
<DashboardPassengerBossComponent />
|
||||
</RolePermission>
|
||||
</WithAuthMiddleware>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
import DashboardPassengerOfficeComponent from "@/components/dashboard/passenger-office";
|
||||
import TitlePage from "@/core/components/TitlePage";
|
||||
import RolePermission from "@/middlewares/RolePermission";
|
||||
import WithAuthMiddleware from "@/middlewares/WithAuth";
|
||||
import { parse } from "next-useragent";
|
||||
|
||||
const requiredPermissions = ["passenger_office_chief"];
|
||||
export default function PassengerOffice() {
|
||||
return (
|
||||
<WithAuthMiddleware>
|
||||
<TitlePage text="Dashboard.passenger_office_page" />
|
||||
<DashboardPassengerOfficeComponent />
|
||||
<RolePermission requiredPermissions={requiredPermissions}>
|
||||
<TitlePage text="Dashboard.passenger_office_page" />
|
||||
<DashboardPassengerOfficeComponent />
|
||||
</RolePermission>
|
||||
</WithAuthMiddleware>
|
||||
);
|
||||
}
|
||||
@@ -1,13 +1,16 @@
|
||||
import DashboardProvinceManagerComponent from "@/components/dashboard/province-manager";
|
||||
import TitlePage from "@/core/components/TitlePage";
|
||||
import RolePermission from "@/middlewares/RolePermission";
|
||||
import WithAuthMiddleware from "@/middlewares/WithAuth";
|
||||
import { parse } from "next-useragent";
|
||||
|
||||
const requiredPermissions = ["province_manager"];
|
||||
export default function PassengerOffice() {
|
||||
return (
|
||||
<WithAuthMiddleware>
|
||||
<TitlePage text="Dashboard.province_manager_page" />
|
||||
<DashboardProvinceManagerComponent />
|
||||
<RolePermission requiredPermissions={requiredPermissions}>
|
||||
<TitlePage text="Dashboard.province_manager_page" />
|
||||
<DashboardProvinceManagerComponent />
|
||||
</RolePermission>
|
||||
</WithAuthMiddleware>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
import DashboardTransportationAssistanceComponent from "@/components/dashboard/transportation-assistance";
|
||||
import TitlePage from "@/core/components/TitlePage";
|
||||
import RolePermission from "@/middlewares/RolePermission";
|
||||
import WithAuthMiddleware from "@/middlewares/WithAuth";
|
||||
import { parse } from "next-useragent";
|
||||
|
||||
const requiredPermissions = ["transportation_assistant"];
|
||||
export default function TransportationAssistance() {
|
||||
return (
|
||||
<WithAuthMiddleware>
|
||||
<TitlePage text="Dashboard.transportation_assistance" />
|
||||
<DashboardTransportationAssistanceComponent />
|
||||
<RolePermission requiredPermissions={requiredPermissions}>
|
||||
<TitlePage text="Dashboard.transportation_assistance" />
|
||||
<DashboardTransportationAssistanceComponent />
|
||||
</RolePermission>
|
||||
</WithAuthMiddleware>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user