change permissions

This commit is contained in:
2025-12-22 13:07:09 +03:30
parent 36a0ab518c
commit 95e1fc3427
6 changed files with 71 additions and 17 deletions

View File

@@ -7,7 +7,14 @@ export const metadata = {
const Page = () => {
return (
<>
<WithPermission permission_name={["manage-control-unit"]}>
<WithPermission
permission_name={[
"manage-control-unit",
"manage-control-unit-city",
"manage-control-unit-country",
"manage-control-unit-station",
]}
>
<ControlPage />
{/* <ActivityCodeLog activity_code={1152} /> */}
</WithPermission>

View File

@@ -12,6 +12,7 @@ const Page = () => {
"manage-request-portal-country",
"manage-request-portal-province",
"manage-request-portal-city",
"manage-request-portal-station",
]}
>
<OperatorPage />

View File

@@ -7,7 +7,14 @@ export const metadata = {
const Page = () => {
return (
<>
<WithPermission permission_name={["manage-transportation-unit"]}>
<WithPermission
permission_name={[
"manage-transportation-unit-country",
"manage-transportation-unit-city",
"manage-transportation-unit-country",
"manage-transportation-unit-station",
]}
>
<TransportationPage />
{/* <ActivityCodeLog activity_code={1152} /> */}
</WithPermission>

View File

@@ -12,6 +12,9 @@ import ShowBound from "../../../Actions/showBound";
import DriversDialog from "./DriversDialog";
import MachinesDialog from "./MachinesDialog";
import Reject from "./Reject";
import SelectBox from "@/core/components/SelectBox";
import { Controller, useForm } from "react-hook-form";
const AllocationForm = ({ row, mutate, setOpenAllocationDialog }) => {
const latLngs = useMemo(() => {
return row.area.coordinates.map(([lng, lat]) => [lat, lng]);
@@ -25,6 +28,12 @@ const AllocationForm = ({ row, mutate, setOpenAllocationDialog }) => {
const [machine, setMachine] = useState();
const [driver, setDriver] = useState();
const [isSubmitting, setIsSubmitting] = useState(false);
const { control, watch } = useForm({
defaultValues: {
machine_type: row.requested_machines?.[0] ? [row.requested_machines[0]] : [],
},
});
const handleSubmit = async (_machine, _driver) => {
setIsSubmitting(true);
@@ -45,6 +54,7 @@ const AllocationForm = ({ row, mutate, setOpenAllocationDialog }) => {
});
};
const selectedMachineType = watch("machine_type")?.[0];
return (
<>
<DialogContent dividers>
@@ -53,12 +63,22 @@ const AllocationForm = ({ row, mutate, setOpenAllocationDialog }) => {
<Paper elevation={24}>
<Stack spacing={2} sx={{ p: 2 }}>
<Stack direction={"row"} alignItems={"center"} spacing={1}>
<Typography variant="body" fontWeight={"bold"} color={"primary"}>
نوع خودرو درخواستی
</Typography>
<Divider sx={{ flex: 1 }} />
<Chip
label={machineType.find((mt) => mt.id == row.requested_machines?.[0])?.name_fa}
<Controller
name="machine_type"
control={control}
render={({ field, fieldState: { error } }) => (
<SelectBox
value={field.value?.[0] || ""}
label="نوع خودرو درخواستی"
selectors={machineType}
schema={{ name: "name_fa", value: "id" }}
error={!!error}
helperText={error?.message}
onChange={(newValue) => {
field.onChange([newValue]);
}}
/>
)}
/>
</Stack>
<Stack direction={"row"} alignItems={"center"} spacing={1}>
@@ -76,16 +96,13 @@ const AllocationForm = ({ row, mutate, setOpenAllocationDialog }) => {
/>
<Divider sx={{ flex: 1 }} />
<MachinesDialog
machineType={row.requested_machines[0]}
machineType={selectedMachineType}
setMachine={setMachine}
mode={"edit"}
/>
</>
) : (
<MachinesDialog
machineType={row.requested_machines[0]}
setMachine={setMachine}
/>
<MachinesDialog machineType={selectedMachineType} setMachine={setMachine} />
)}
</Stack>
{machine && (

View File

@@ -119,6 +119,7 @@ export const pageMenu = [
"manage-request-portal-country",
"manage-request-portal-province",
"manage-request-portal-city",
"manage-request-portal-station",
],
},
{
@@ -128,7 +129,12 @@ export const pageMenu = [
icon: <DirectionsBusIcon sx={{ width: "inherit", height: "inherit" }} />,
route: "/dashboard/road-missions/transportation",
badges: [{ key: "mission.transportation" }],
permissions: ["manage-transportation-unit"],
permissions: [
"manage-transportation-unit-city",
"manage-transportation-unit-province",
"manage-transportation-unit-country",
"manage-transportation-unit-station",
],
},
{
id: "roadMissionsManagemnetControl",
@@ -137,7 +143,12 @@ export const pageMenu = [
icon: <SupervisedUserCircleIcon sx={{ width: "inherit", height: "inherit" }} />,
route: "/dashboard/road-missions/control",
badges: [{ key: "mission.control" }],
permissions: ["manage-control-unit"],
permissions: [
"manage-control-unit-province",
"manage-control-unit-city",
"manage-control-unit-country",
"manage-control-unit-station",
],
},
{
id: "roadMissionsViolations",

View File

@@ -118,6 +118,7 @@ export const pageMenuDev = [
"manage-request-portal-country",
"manage-request-portal-province",
"manage-request-portal-city",
"manage-request-portal-station",
],
},
{
@@ -127,7 +128,12 @@ export const pageMenuDev = [
icon: <DirectionsBusIcon sx={{ width: "inherit", height: "inherit" }} />,
route: "/dashboard/road-missions/transportation",
badges: [{ key: "mission.transportation" }],
permissions: ["manage-transportation-unit"],
permissions: [
"manage-transportation-unit-province",
"manage-transportation-unit-city",
"manage-transportation-unit-country",
"manage-transportation-unit-station",
],
},
{
id: "roadMissionsManagemnetControl",
@@ -136,7 +142,12 @@ export const pageMenuDev = [
icon: <SupervisedUserCircleIcon sx={{ width: "inherit", height: "inherit" }} />,
route: "/dashboard/road-missions/control",
badges: [{ key: "mission.control" }],
permissions: ["manage-control-unit"],
permissions: [
"manage-control-unit-province",
"manage-control-unit-city",
"manage-control-unit-country",
"manage-control-unit-station",
],
},
{
id: "roadMissionsViolations",