(
+
+
+
+ )}
+ />
+ );
+};
+export default FastReactCode;
diff --git a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/GetItemInfo/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/GetItemInfo/index.jsx
index 3b3b513..6e3afa0 100644
--- a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/GetItemInfo/index.jsx
+++ b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/GetItemInfo/index.jsx
@@ -1,153 +1,149 @@
-import PersianTextField from "@/core/components/PersianTextField";
-import SelectBox from "@/core/components/SelectBox";
-import StyledForm from "@/core/components/StyledForm";
-import { missionCategoryTypes } from "@/core/utils/missionCategoryTypes";
-import { missionRegions } from "@/core/utils/missionRegions";
-import { yupResolver } from "@hookform/resolvers/yup";
-import { ExitToApp } from "@mui/icons-material";
-import { Box, Button, DialogActions, DialogContent, Grid, Stack } from "@mui/material";
-import { Controller, useForm } from "react-hook-form";
-import { object, string } from "yup";
-import FastReactCode from "./FastReactCode";
-
-const validationSchema = object({
- explanation: string().required("موضوع را مشخص کنید!"),
- end_point: string().required("مقصد را مشخص کنید!"),
- region: string().required("محور ماموریت را مشخص کنید!"),
- category_id: string().required("نوع ماموریت را مشخص کنید!"),
- road_observed_id: string().when("category_id", {
- is: "3",
- then: (schema) => schema.required("کد یکتا شکایت را مشخص کنید!"),
- otherwise: (schema) => schema.notRequired(),
- }),
-});
-
-const GetItemInfo = ({ allData, setAllData, handlePrev, setTabState }) => {
- const defaultValues = {
- explanation: allData.explanation,
- end_point: allData.end_point,
- region: allData.region,
- category_id: allData.category_id,
- road_observed_id: allData.road_observed_id,
- };
-
- const { control, handleSubmit } = useForm({
- defaultValues,
- resolver: yupResolver(validationSchema),
- mode: "all",
- });
-
- const handleNext = (data) => {
- setAllData(data);
- setTabState((s) => s + 1);
- };
-
- return (
-
-
-
-
-
-
- (
-
- )}
- />
-
-
- (
-
- )}
- />
-
-
- (
-
- )}
- />
-
-
-
-
-
- {
- return (
-
- );
- }}
- />
-
-
-
-
-
-
- }
- >
- {"بستن"}
-
-
-
-
- );
-};
-export default GetItemInfo;
+import PersianTextField from "@/core/components/PersianTextField";
+import SelectBox from "@/core/components/SelectBox";
+import StyledForm from "@/core/components/StyledForm";
+import { missionCategoryTypes } from "@/core/utils/missionCategoryTypes";
+import { missionRegions } from "@/core/utils/missionRegions";
+import { yupResolver } from "@hookform/resolvers/yup";
+import { ExitToApp } from "@mui/icons-material";
+import { Box, Button, DialogActions, DialogContent, Grid, Stack } from "@mui/material";
+import { Controller, useForm } from "react-hook-form";
+import { object, string } from "yup";
+
+const validationSchema = object({
+ explanation: string().required("موضوع را مشخص کنید!"),
+ end_point: string().required("مقصد را مشخص کنید!"),
+ region: string().required("محور ماموریت را مشخص کنید!"),
+ category_id: string().required("نوع ماموریت را مشخص کنید!"),
+ road_observed_id: string().when("category_id", {
+ is: "3",
+ then: (schema) => schema.required("کد یکتا شکایت را مشخص کنید!"),
+ otherwise: (schema) => schema.notRequired(),
+ }),
+});
+
+const GetItemInfo = ({ allData, setAllData, handlePrev, setTabState }) => {
+ const defaultValues = {
+ explanation: allData.explanation,
+ end_point: allData.end_point,
+ region: allData.region,
+ category_id: allData.category_id,
+ road_observed_id: allData.road_observed_id,
+ };
+
+ const { control, handleSubmit } = useForm({
+ defaultValues,
+ resolver: yupResolver(validationSchema),
+ mode: "all",
+ });
+
+ const handleNext = (data) => {
+ setAllData(data);
+ setTabState((s) => s + 1);
+ };
+
+ return (
+
+
+
+
+
+
+ (
+
+ )}
+ />
+
+
+ (
+
+ )}
+ />
+
+
+ (
+
+ )}
+ />
+
+
+ {
+ return (
+
+ );
+ }}
+ />
+
+
+
+
+
+
+ }
+ >
+ {"بستن"}
+
+
+
+
+ );
+};
+export default GetItemInfo;
diff --git a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/MachineAndDriver/DriversDialog/DriversSearch/Form/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/MachineAndDriver/DriversDialog/DriversSearch/Form/index.jsx
index 93bb1d6..9dbe4ed 100644
--- a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/MachineAndDriver/DriversDialog/DriversSearch/Form/index.jsx
+++ b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/MachineAndDriver/DriversDialog/DriversSearch/Form/index.jsx
@@ -1,61 +1,61 @@
-import RahdarNameOrCode from "@/core/components/RahdarNameOrCode";
-import StyledForm from "@/core/components/StyledForm";
-import { yupResolver } from "@hookform/resolvers/yup";
-import { Done } from "@mui/icons-material";
-import { Button, Stack } from "@mui/material";
-import { Controller, useForm } from "react-hook-form";
-import { object } from "yup";
-
-const schema = object().shape({
- rahdar: object().required("همراه الزامی است."),
-});
-const DriverForm = ({ setDriver, setOpenDriversDialog }) => {
- const defaultValues = {
- rahdar: null,
- };
-
- const {
- control,
- handleSubmit,
- formState: { isSubmitting, isValid },
- } = useForm({ defaultValues, resolver: yupResolver(schema), mode: "all" });
-
- const submit = (data) => {
- setDriver(data.rahdar);
- setOpenDriversDialog(false);
- };
-
- return (
-
-
-
- {
- return (
- field.onChange(value)}
- error={error}
- multiple={false}
- />
- );
- }}
- name={"rahdar"}
- />
-
- }
- >
- انتخاب
-
-
-
- );
-};
-export default DriverForm;
+import RahdarNameOrCode from "@/core/components/RahdarNameOrCode";
+import StyledForm from "@/core/components/StyledForm";
+import { yupResolver } from "@hookform/resolvers/yup";
+import { Done } from "@mui/icons-material";
+import { Button, Stack } from "@mui/material";
+import { Controller, useForm } from "react-hook-form";
+import { object } from "yup";
+
+const schema = object().shape({
+ rahdar: object().required("همراه الزامی است."),
+});
+const DriverForm = ({ setDriver, setOpenDriversDialog }) => {
+ const defaultValues = {
+ rahdar: null,
+ };
+
+ const {
+ control,
+ handleSubmit,
+ formState: { isSubmitting, isValid },
+ } = useForm({ defaultValues, resolver: yupResolver(schema), mode: "all" });
+
+ const submit = (data) => {
+ setDriver(data.rahdar);
+ setOpenDriversDialog(false);
+ };
+
+ return (
+
+
+
+ {
+ return (
+ field.onChange(value)}
+ error={error}
+ multiple={false}
+ />
+ );
+ }}
+ name={"rahdar"}
+ />
+
+ }
+ >
+ انتخاب
+
+
+
+ );
+};
+export default DriverForm;
diff --git a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/MachineAndDriver/DriversDialog/DriversSearch/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/MachineAndDriver/DriversDialog/DriversSearch/index.jsx
index b7136c9..2abc9ea 100644
--- a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/MachineAndDriver/DriversDialog/DriversSearch/index.jsx
+++ b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/MachineAndDriver/DriversDialog/DriversSearch/index.jsx
@@ -1,11 +1,11 @@
-import { DialogContent } from "@mui/material";
-import DriverForm from "./Form";
-
-const DriversSearch = ({ setDriver, setOpenDriversDialog }) => {
- return (
-
-
-
- );
-};
-export default DriversSearch;
+import { DialogContent } from "@mui/material";
+import DriverForm from "./Form";
+
+const DriversSearch = ({ setDriver, setOpenDriversDialog }) => {
+ return (
+
+
+
+ );
+};
+export default DriversSearch;
diff --git a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/MachineAndDriver/DriversDialog/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/MachineAndDriver/DriversDialog/index.jsx
index 3c1d406..0893ccf 100644
--- a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/MachineAndDriver/DriversDialog/index.jsx
+++ b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/MachineAndDriver/DriversDialog/index.jsx
@@ -1,41 +1,41 @@
-import { Close, Edit } from "@mui/icons-material";
-import { Button, Dialog, DialogTitle, IconButton } from "@mui/material";
-import { useState } from "react";
-import DriversSearch from "./DriversSearch";
-
-const DriversDialog = ({ setDriver, mode }) => {
- const [openDriversDialog, setOpenDriversDialog] = useState(false);
- return (
- <>
- {mode == "edit" ? (
- setOpenDriversDialog(true)} size="small">
-
-
- ) : (
-
- )}
-
- >
- );
-};
-export default DriversDialog;
+import { Close, Edit } from "@mui/icons-material";
+import { Button, Dialog, DialogTitle, IconButton } from "@mui/material";
+import { useState } from "react";
+import DriversSearch from "./DriversSearch";
+
+const DriversDialog = ({ setDriver, mode }) => {
+ const [openDriversDialog, setOpenDriversDialog] = useState(false);
+ return (
+ <>
+ {mode == "edit" ? (
+ setOpenDriversDialog(true)} size="small">
+
+
+ ) : (
+
+ )}
+
+ >
+ );
+};
+export default DriversDialog;
diff --git a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/MachineAndDriver/MachinesDialog/MachineList/RowActions/Allocate/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/MachineAndDriver/MachinesDialog/MachineList/RowActions/Allocate/index.jsx
index f03579a..9718815 100644
--- a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/MachineAndDriver/MachinesDialog/MachineList/RowActions/Allocate/index.jsx
+++ b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/MachineAndDriver/MachinesDialog/MachineList/RowActions/Allocate/index.jsx
@@ -1,20 +1,20 @@
-import { Done } from "@mui/icons-material";
-import { IconButton, Tooltip } from "@mui/material";
-
-const Allocate = ({ row, setMachine, setOpenMachinesDialog }) => {
- const handleClick = () => {
- setMachine(row.original);
- setOpenMachinesDialog(false);
- };
-
- return (
- <>
-
-
-
-
-
- >
- );
-};
-export default Allocate;
+import { Done } from "@mui/icons-material";
+import { IconButton, Tooltip } from "@mui/material";
+
+const Allocate = ({ row, setMachine, setOpenMachinesDialog }) => {
+ const handleClick = () => {
+ setMachine(row.original);
+ setOpenMachinesDialog(false);
+ };
+
+ return (
+ <>
+
+
+
+
+
+ >
+ );
+};
+export default Allocate;
diff --git a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/MachineAndDriver/MachinesDialog/MachineList/RowActions/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/MachineAndDriver/MachinesDialog/MachineList/RowActions/index.jsx
index bcfcc03..ba0a20d 100644
--- a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/MachineAndDriver/MachinesDialog/MachineList/RowActions/index.jsx
+++ b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/MachineAndDriver/MachinesDialog/MachineList/RowActions/index.jsx
@@ -1,6 +1,6 @@
-import Allocate from "./Allocate";
-
-const RowActions = ({ row, setMachine, setOpenMachinesDialog }) => {
- return ;
-};
-export default RowActions;
+import Allocate from "./Allocate";
+
+const RowActions = ({ row, setMachine, setOpenMachinesDialog }) => {
+ return ;
+};
+export default RowActions;
diff --git a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/MachineAndDriver/MachinesDialog/MachineList/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/MachineAndDriver/MachinesDialog/MachineList/index.jsx
index e070b01..fae083c 100644
--- a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/MachineAndDriver/MachinesDialog/MachineList/index.jsx
+++ b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/MachineAndDriver/MachinesDialog/MachineList/index.jsx
@@ -1,68 +1,68 @@
-import DataTableWithAuth from "@/core/components/DataTableWithAuth";
-import { Box } from "@mui/material";
-import { useMemo } from "react";
-import RowActions from "./RowActions";
-import { GET_MACHINES_TABLE_LIST } from "@/core/utils/routes";
-
-const MachinesList = ({ machineType, setMachine, setOpenMachinesDialog }) => {
- const columns = useMemo(
- () => [
- {
- accessorKey: "machine_code",
- header: "کد خودرو",
- id: "machine_code",
- enableColumnFilter: true,
- datatype: "text",
- filterMode: "equals",
- columnFilterModeOptions: ["equals", "contains"],
- grow: false,
- size: 100,
- },
- {
- accessorKey: "car_name",
- header: "نام خودرو",
- id: "car_name",
- enableColumnFilter: true,
- datatype: "text",
- filterMode: "equals",
- columnFilterModeOptions: ["equals", "contains"],
- grow: false,
- size: 100,
- },
- {
- accessorKey: "car_type",
- header: "نوع خودرو",
- id: "car_type",
- enableColumnFilter: false,
- datatype: "text",
- filterMode: "equals",
- columnFilterModeOptions: ["equals", "contains"],
- grow: false,
- size: 100,
- },
- ],
- []
- );
-
- return (
- <>
-
- (
-
- )}
- />
-
- >
- );
-};
-export default MachinesList;
+import DataTableWithAuth from "@/core/components/DataTableWithAuth";
+import { Box } from "@mui/material";
+import { useMemo } from "react";
+import RowActions from "./RowActions";
+import { GET_MACHINES_TABLE_LIST } from "@/core/utils/routes";
+
+const MachinesList = ({ machineType, setMachine, setOpenMachinesDialog }) => {
+ const columns = useMemo(
+ () => [
+ {
+ accessorKey: "machine_code",
+ header: "کد خودرو",
+ id: "machine_code",
+ enableColumnFilter: true,
+ datatype: "text",
+ filterMode: "equals",
+ columnFilterModeOptions: ["equals", "contains"],
+ grow: false,
+ size: 100,
+ },
+ {
+ accessorKey: "car_name",
+ header: "نام خودرو",
+ id: "car_name",
+ enableColumnFilter: true,
+ datatype: "text",
+ filterMode: "equals",
+ columnFilterModeOptions: ["equals", "contains"],
+ grow: false,
+ size: 100,
+ },
+ {
+ accessorKey: "car_type",
+ header: "نوع خودرو",
+ id: "car_type",
+ enableColumnFilter: false,
+ datatype: "text",
+ filterMode: "equals",
+ columnFilterModeOptions: ["equals", "contains"],
+ grow: false,
+ size: 100,
+ },
+ ],
+ []
+ );
+
+ return (
+ <>
+
+ (
+
+ )}
+ />
+
+ >
+ );
+};
+export default MachinesList;
diff --git a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/MachineAndDriver/MachinesDialog/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/MachineAndDriver/MachinesDialog/index.jsx
index 8750142..b85b6f6 100644
--- a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/MachineAndDriver/MachinesDialog/index.jsx
+++ b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/MachineAndDriver/MachinesDialog/index.jsx
@@ -1,40 +1,70 @@
-import { Close, Edit } from "@mui/icons-material";
-import { Button, Dialog, IconButton } from "@mui/material";
-import { useState } from "react";
-import MachinesList from "./MachineList";
-
-const MachinesDialog = ({ setMachine, mode }) => {
- const [openMachinesDialog, setOpenMachinesDialog] = useState(false);
- return (
- <>
- {mode == "edit" ? (
- setOpenMachinesDialog(true)} size="small">
-
-
- ) : (
-
- )}
-
- >
- );
-};
-export default MachinesDialog;
+import LtrTextField from "@/core/components/LtrTextField";
+import { Close, Edit } from "@mui/icons-material";
+import { Button, Dialog, IconButton, Stack } from "@mui/material";
+import { useState } from "react";
+
+const MachinesDialog = ({ setMachine, mode, machineCode, setShowMachineCodeDialog }) => {
+ const [openMachinesDialog, setOpenMachinesDialog] = useState(false);
+
+ return (
+ <>
+ {mode == "edit" ? (
+ setOpenMachinesDialog(true)} size="small">
+
+
+ ) : (
+
+ )}
+
+ >
+ );
+};
+export default MachinesDialog;
diff --git a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/MachineAndDriver/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/MachineAndDriver/index.jsx
index 24bfb15..03ce25e 100644
--- a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/MachineAndDriver/index.jsx
+++ b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/MachineAndDriver/index.jsx
@@ -1,77 +1,79 @@
-import { Box, Button, Chip, DialogActions, DialogContent, Divider, Stack, Typography } from "@mui/material";
-import DriversDialog from "./DriversDialog";
-import { useState } from "react";
-import MachinesDialog from "./MachinesDialog";
-
-const MachineAndDriver = ({ setTabState, allData, setAllData, handlePrev }) => {
- const [machine, setMachine] = useState(allData.machine);
- const [driver, setDriver] = useState(allData.driver);
-
- const handleNext = (data) => {
- setAllData(data);
- setTabState((s) => s + 1);
- };
-
- return (
- <>
-
-
-
-
- {machine ? (
- <>
- خودرو
-
-
-
-
- >
- ) : (
-
- )}
-
- {machine && (
-
- {driver ? (
- <>
- راننده
-
-
-
-
- >
- ) : (
-
- )}
-
- )}
-
-
-
-
-
-
-
- >
- );
-};
-export default MachineAndDriver;
+import { Box, Button, Chip, DialogActions, DialogContent, Divider, Stack, Typography } from "@mui/material";
+import { useState } from "react";
+import DriversDialog from "./DriversDialog";
+import MachinesDialog from "./MachinesDialog";
+
+const MachineAndDriver = ({ setTabState, allData, setAllData, handlePrev }) => {
+ const [showMachineCodeDialog, setShowMachineCodeDialog] = useState(allData.machine_code ? true : false);
+ const [machineCode, setMachineCode] = useState(allData.machine_code);
+ const [driver, setDriver] = useState(allData.driver);
+
+ const handleNext = (data) => {
+ setAllData(data);
+ setTabState((s) => s + 1);
+ };
+
+ return (
+ <>
+
+
+
+
+ {showMachineCodeDialog ? (
+ <>
+ خودرو
+
+
+
+
+ >
+ ) : (
+
+ )}
+
+
+
+ {driver ? (
+ <>
+ راننده
+
+
+
+
+ >
+ ) : (
+
+ )}
+
+
+
+
+
+
+
+
+ >
+ );
+};
+export default MachineAndDriver;
diff --git a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/Rahdaran/Form/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/Rahdaran/Form/index.jsx
index a4449fe..390974d 100644
--- a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/Rahdaran/Form/index.jsx
+++ b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/Rahdaran/Form/index.jsx
@@ -1,66 +1,66 @@
-import RahdarNameOrCode from "@/core/components/RahdarNameOrCode";
-import StyledForm from "@/core/components/StyledForm";
-import { yupResolver } from "@hookform/resolvers/yup";
-import { Add } from "@mui/icons-material";
-import { Button, Stack } from "@mui/material";
-import { Controller, useForm } from "react-hook-form";
-import { object } from "yup";
-
-const schema = object().shape({
- rahdar: object().required("همراه الزامی است."),
-});
-const RahdaranForm = ({ setRahdaran }) => {
- const defaultValues = {
- rahdar: null,
- };
-
- const {
- control,
- handleSubmit,
- reset,
- formState: { isSubmitting, isValid },
- } = useForm({ defaultValues, resolver: yupResolver(schema), mode: "all" });
-
- const submit = (data) => {
- setRahdaran((prev) => {
- const alreadyExists = prev.some((r) => r.id === data.rahdar.id);
- if (alreadyExists) return prev;
- return [...prev, data.rahdar];
- });
- reset();
- };
-
- return (
-
-
-
- {
- return (
- field.onChange(value)}
- error={error}
- multiple={false}
- />
- );
- }}
- name={"rahdar"}
- />
-
- }
- >
- افزودن همراه
-
-
-
- );
-};
-export default RahdaranForm;
+import RahdarNameOrCode from "@/core/components/RahdarNameOrCode";
+import StyledForm from "@/core/components/StyledForm";
+import { yupResolver } from "@hookform/resolvers/yup";
+import { Add } from "@mui/icons-material";
+import { Button, Stack } from "@mui/material";
+import { Controller, useForm } from "react-hook-form";
+import { object } from "yup";
+
+const schema = object().shape({
+ rahdar: object().required("همراه الزامی است."),
+});
+const RahdaranForm = ({ setRahdaran }) => {
+ const defaultValues = {
+ rahdar: null,
+ };
+
+ const {
+ control,
+ handleSubmit,
+ reset,
+ formState: { isSubmitting, isValid },
+ } = useForm({ defaultValues, resolver: yupResolver(schema), mode: "all" });
+
+ const submit = (data) => {
+ setRahdaran((prev) => {
+ const alreadyExists = prev.some((r) => r.id === data.rahdar.id);
+ if (alreadyExists) return prev;
+ return [...prev, data.rahdar];
+ });
+ reset();
+ };
+
+ return (
+
+
+
+ {
+ return (
+ field.onChange(value)}
+ error={error}
+ multiple={false}
+ />
+ );
+ }}
+ name={"rahdar"}
+ />
+
+ }
+ >
+ افزودن همراه
+
+
+
+ );
+};
+export default RahdaranForm;
diff --git a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/Rahdaran/List/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/Rahdaran/List/index.jsx
index ebc4edc..be31897 100644
--- a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/Rahdaran/List/index.jsx
+++ b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/Rahdaran/List/index.jsx
@@ -1,56 +1,56 @@
-import { AccountCircle, Delete } from "@mui/icons-material";
-import { Card, Collapse, IconButton, Stack, Typography } from "@mui/material";
-import { TransitionGroup } from "react-transition-group";
-
-const RahdaranList = ({ rahdaran, setRahdaran }) => {
- const handleRemove = (index) => {
- setRahdaran((prev) => prev.filter((_, i) => i !== index));
- };
-
- return (
-
-
- {rahdaran.map((rahdar, index) => (
-
-
-
-
-
-
- نام و نام خانوادگی:
- {rahdar.name}
-
-
- کدملی:
- {rahdar.code}
-
-
-
- handleRemove(index)}>
-
-
-
-
- ))}
- {rahdaran.length == 0 && (
-
- همراهی ثبت نشده است
-
- )}
-
-
- );
-};
-export default RahdaranList;
+import { AccountCircle, Delete } from "@mui/icons-material";
+import { Card, Collapse, IconButton, Stack, Typography } from "@mui/material";
+import { TransitionGroup } from "react-transition-group";
+
+const RahdaranList = ({ rahdaran, setRahdaran }) => {
+ const handleRemove = (index) => {
+ setRahdaran((prev) => prev.filter((_, i) => i !== index));
+ };
+
+ return (
+
+
+ {rahdaran.map((rahdar, index) => (
+
+
+
+
+
+
+ نام و نام خانوادگی:
+ {rahdar.name}
+
+
+ کدملی:
+ {rahdar.code}
+
+
+
+ handleRemove(index)}>
+
+
+
+
+ ))}
+ {rahdaran.length == 0 && (
+
+ همراهی ثبت نشده است
+
+ )}
+
+
+ );
+};
+export default RahdaranList;
diff --git a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/Rahdaran/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/Rahdaran/index.jsx
index af01fe6..b530af4 100644
--- a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/Rahdaran/index.jsx
+++ b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/Rahdaran/index.jsx
@@ -1,36 +1,36 @@
-import { Box, Button, Chip, DialogActions, DialogContent, Divider } from "@mui/material";
-import { useCallback, useState } from "react";
-import RahdaranForm from "./Form";
-import RahdaranList from "./List";
-
-const Rahdaran = ({ allData, setAllData, setTabState, handlePrev }) => {
- const [rahdaran, setRahdaran] = useState(allData.rahdaran);
-
- const handleNext = useCallback(() => {
- setAllData({ rahdaran: rahdaran });
- setTabState((s) => s + 1);
- }, [rahdaran]);
-
- return (
- <>
-
-
-
-
-
-
-
-
-
-
-
-
-
- >
- );
-};
-export default Rahdaran;
+import { Box, Button, Chip, DialogActions, DialogContent, Divider } from "@mui/material";
+import { useCallback, useState } from "react";
+import RahdaranForm from "./Form";
+import RahdaranList from "./List";
+
+const Rahdaran = ({ allData, setAllData, setTabState, handlePrev }) => {
+ const [rahdaran, setRahdaran] = useState(allData.rahdaran);
+
+ const handleNext = useCallback(() => {
+ setAllData({ rahdaran: rahdaran });
+ setTabState((s) => s + 1);
+ }, [rahdaran]);
+
+ return (
+ <>
+
+
+
+
+
+
+
+
+
+
+
+
+
+ >
+ );
+};
+export default Rahdaran;
diff --git a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/Verify/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/Verify/index.jsx
index 0393018..d55de17 100644
--- a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/Verify/index.jsx
+++ b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/Verify/index.jsx
@@ -1,130 +1,135 @@
-import MapLoading from "@/core/components/MapLayer/Loading";
-import { missionCategoryTypes } from "@/core/utils/missionCategoryTypes";
-import { missionRegions } from "@/core/utils/missionRegions";
-import { Box, Button, Chip, DialogActions, DialogContent, Divider, Stack, Typography } from "@mui/material";
-import moment from "jalali-moment";
-import dynamic from "next/dynamic";
-import { useCallback } from "react";
-import ShowBound from "../../../showBound";
-const MapLayer = dynamic(() => import("@/core/components/MapLayer"), {
- loading: () => ,
- ssr: false,
-});
-
-const Verify = ({ allData, handlePrev, submitForm, submitting }) => {
- const handleNext = useCallback(() => {
- submitForm(allData);
- }, [allData]);
-
- return (
- <>
-
-
-
-
-
-
-
-
-
-
-
-
-
- موضوع ماموریت
-
-
-
-
- محدوده
-
- r.id == allData.region).name_fa} />
-
-
- نوع ماموریت
-
- t.id == allData.category_id).name_fa}
- />
-
- {allData.category_id == 3 && (
-
- کد شکایت
-
-
-
- )}
-
- مقصد
-
-
-
-
- تاریخ شروع ماموریت
-
-
-
-
- تاریخ پایان ماموریت
-
-
-
-
-
-
-
-
-
- خودرو
-
-
-
-
- راننده
-
-
-
-
-
-
-
-
- {allData.rahdaran.length != 0 ? (
- allData.rahdaran.map((rahdar) => (
-
- {rahdar.name}
-
-
-
- ))
- ) : (
-
- همراهی ثبت نشده است
-
- )}
-
-
-
-
-
-
-
-
- >
- );
-};
-export default Verify;
+import { missionCategoryTypes } from "@/core/utils/missionCategoryTypes";
+import { missionRegions } from "@/core/utils/missionRegions";
+import { Box, Button, Chip, DialogActions, DialogContent, Divider, Stack, Typography } from "@mui/material";
+import moment from "jalali-moment";
+import { useCallback } from "react";
+// import ShowBound from "../../../showBound";
+// import MapLoading from "@/core/components/MapLayer/Loading";
+// import dynamic from "next/dynamic";
+//
+// const MapLayer = dynamic(() => import("@/core/components/MapLayer"), {
+// loading: () => ,
+// ssr: false,
+// });
+
+const Verify = ({ allData, handlePrev, submitForm, submitting }) => {
+ const handleNext = useCallback(() => {
+ submitForm(allData);
+ }, [allData]);
+
+ return (
+ <>
+
+
+
+ {/**/}
+ {/* */}
+ {/* */}
+ {/* */}
+ {/**/}
+
+
+
+
+
+ موضوع ماموریت
+
+
+
+
+ محدوده
+
+ r.id == allData.region).name_fa} />
+
+
+ نوع ماموریت
+
+ t.id == allData.category_id).name_fa}
+ />
+
+ {allData.category_id == 3 && (
+
+ کد شکایت
+
+
+
+ )}
+
+ مقصد
+
+
+
+
+ تاریخ شروع ماموریت
+
+
+
+
+ تاریخ پایان ماموریت
+
+
+
+
+
+
+
+
+
+
+ کد خودرو
+
+
+
+
+
+
+
+
+
+
+ راننده
+
+
+
+
+
+
+
+
+ {allData.rahdaran.length != 0 ? (
+ allData.rahdaran.map((rahdar) => (
+
+ {rahdar.name}
+
+
+
+ ))
+ ) : (
+
+ همراهی ثبت نشده است
+
+ )}
+
+
+
+
+
+
+
+
+ >
+ );
+};
+export default Verify;
diff --git a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/index.jsx
index 00f9ef1..a36981c 100644
--- a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/index.jsx
+++ b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/index.jsx
@@ -1,125 +1,125 @@
-import { AccessTime, Engineering, InsertDriveFile, LocalShipping, Route, Verified } from "@mui/icons-material";
-import { Box, Tab, Tabs } from "@mui/material";
-import { useReducer, useState } from "react";
-import Area from "./Area";
-import GetDateTime from "./GetDateTime";
-import GetItemInfo from "./GetItemInfo";
-import Rahdaran from "./Rahdaran";
-import Verify from "./Verify";
-import MachineAndDriver from "./MachineAndDriver";
-
-function TabPanel(props) {
- const { children, value, index } = props;
- return (
-
- {value === index && {children}}
-
- );
-}
-
-const reducer = (state, action) => {
- switch (action.type) {
- case "changeData":
- return { ...state, ...action.data };
- default:
- return state;
- }
-};
-
-const CreateForm = ({ defaultValues, submitForm, setOpen, submitting }) => {
- const [allData, dispatch] = useReducer(reducer, defaultValues);
- const [tabState, setTabState] = useState(0);
- const handleClose = () => {
- setOpen(false);
- };
- const handleChangeTab = (event, newValue) => {
- setTabState(newValue);
- };
-
- const handlePrev = () => {
- if (tabState === 0) {
- handleClose();
- } else {
- setTabState((t) => t - 1);
- }
- };
-
- return (
- <>
-
- } label="مشخصات" />
- } label="زمانبندی" />
- } label="منطقه عملیاتی" />
- } label="خودرو و راننده" />
- } label="همراهان" />
- } label="بررسی نهایی" />
-
-
- {
- dispatch({ type: "changeData", data });
- }}
- handlePrev={handlePrev}
- setTabState={setTabState}
- />
-
-
- {
- dispatch({ type: "changeData", data });
- }}
- handlePrev={handlePrev}
- setTabState={setTabState}
- />
-
-
- {
- dispatch({ type: "changeData", data });
- }}
- handlePrev={handlePrev}
- setTabState={setTabState}
- />
-
-
- {
- dispatch({ type: "changeData", data });
- }}
- handlePrev={handlePrev}
- setTabState={setTabState}
- />
-
-
- {
- dispatch({ type: "changeData", data });
- }}
- handlePrev={handlePrev}
- setTabState={setTabState}
- />
-
-
-
-
- >
- );
-};
-export default CreateForm;
+import { AccessTime, Engineering, InsertDriveFile, LocalShipping, Route, Verified } from "@mui/icons-material";
+import { Box, Tab, Tabs } from "@mui/material";
+import { useReducer, useState } from "react";
+import GetDateTime from "./GetDateTime";
+import GetItemInfo from "./GetItemInfo";
+import MachineAndDriver from "./MachineAndDriver";
+import Rahdaran from "./Rahdaran";
+import Verify from "./Verify";
+import Area from "@/components/dashboard/roadMissions/operator/Actions/Create/Form/Area";
+
+function TabPanel(props) {
+ const { children, value, index } = props;
+ return (
+
+ {value === index && {children}}
+
+ );
+}
+
+const reducer = (state, action) => {
+ switch (action.type) {
+ case "changeData":
+ return { ...state, ...action.data };
+ default:
+ return state;
+ }
+};
+
+const CreateForm = ({ defaultValues, submitForm, setOpen, submitting }) => {
+ const [allData, dispatch] = useReducer(reducer, defaultValues);
+ const [tabState, setTabState] = useState(0);
+ const handleClose = () => {
+ setOpen(false);
+ };
+ const handleChangeTab = (event, newValue) => {
+ setTabState(newValue);
+ };
+
+ const handlePrev = () => {
+ if (tabState === 0) {
+ handleClose();
+ } else {
+ setTabState((t) => t - 1);
+ }
+ };
+
+ return (
+ <>
+
+ } label="مشخصات" />
+ } label="زمانبندی" />
+ {/*} label="منطقه عملیاتی" />*/}
+ } label="خودرو و راننده" />
+ } label="همراهان" />
+ } label="بررسی نهایی" />
+
+
+ {
+ dispatch({ type: "changeData", data });
+ }}
+ handlePrev={handlePrev}
+ setTabState={setTabState}
+ />
+
+
+ {
+ dispatch({ type: "changeData", data });
+ }}
+ handlePrev={handlePrev}
+ setTabState={setTabState}
+ />
+
+ {/**/}
+ {/* {*/}
+ {/* dispatch({ type: "changeData", data });*/}
+ {/* }}*/}
+ {/* handlePrev={handlePrev}*/}
+ {/* setTabState={setTabState}*/}
+ {/* />*/}
+ {/**/}
+
+ {
+ dispatch({ type: "changeData", data });
+ }}
+ handlePrev={handlePrev}
+ setTabState={setTabState}
+ />
+
+
+ {
+ dispatch({ type: "changeData", data });
+ }}
+ handlePrev={handlePrev}
+ setTabState={setTabState}
+ />
+
+
+
+
+ >
+ );
+};
+export default CreateForm;
diff --git a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/index.jsx
index ab64c85..5e27bec 100644
--- a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/index.jsx
+++ b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/index.jsx
@@ -1,121 +1,122 @@
-import { REQUEST_MISSION_WITHOUT_PROCESS } from "@/core/utils/routes";
-import useRequest from "@/lib/hooks/useRequest";
-import { AddCircle, AddCircleOutline, Close } from "@mui/icons-material";
-import { Button, Dialog, IconButton, useMediaQuery, useTheme } from "@mui/material";
-import moment from "jalali-moment";
-import { useState } from "react";
-import CreateForm from "./Form";
-
-const CreateWithoutProcess = ({ mutate }) => {
- const [submitting, setSubmitting] = useState(false);
- const requestServer = useRequest({ notificationSuccess: true });
- const theme = useTheme();
- const isMobile = useMediaQuery(theme.breakpoints.down("sm"));
- const [open, setOpen] = useState(false);
-
- const handleOpen = () => {
- setOpen(true);
- };
-
- const submitForm = async (result) => {
- setSubmitting(true);
- const bound = result.bound.getLatLngs();
- let area =
- result.bound_type == "polygon"
- ? bound.map((ring) => ring.map((latlng) => [latlng.lat, latlng.lng]))[0]
- : bound.map((latlng) => [latlng.lat, latlng.lng]);
-
- await requestServer(REQUEST_MISSION_WITHOUT_PROCESS, "post", {
- data: {
- explanation: result.explanation,
- category_id: result.category_id,
- ...(result.category_id == 3
- ? {
- road_observed_id: result.road_observed_id,
- }
- : {}),
- area: {
- type: result.bound_type,
- coordinates: area,
- },
- ...(result.rahdaran.length != 0 ? { rahdaran: result.rahdaran.map((r) => r.id) } : {}),
- zone: result.region,
- end_point: result.end_point,
- start_date: `${result.start_date} ${moment(result.start_time).format("HH:mm")}`,
- end_date: `${result.end_date} ${moment(result.end_time).format("HH:mm")}`,
- machines: [result.machine.id],
- driver: result.driver.id,
- },
- hasSidebarUpdate: true,
- })
- .then((response) => {
- mutate();
- setOpen(false);
- })
- .catch((error) => {})
- .finally(() => {
- setSubmitting(false);
- });
- };
-
- return (
- <>
- {isMobile ? (
-
-
-
- ) : (
- }
- onClick={handleOpen}
- >
- ثبت ماموریت بدون فرایند
-
- )}
-
- >
- );
-};
-export default CreateWithoutProcess;
+import { REQUEST_MISSION_WITHOUT_PROCESS } from "@/core/utils/routes";
+import useRequest from "@/lib/hooks/useRequest";
+import { AddCircle, AddCircleOutline, Close } from "@mui/icons-material";
+import { Button, Dialog, IconButton, useMediaQuery, useTheme } from "@mui/material";
+import moment from "jalali-moment";
+import { useState } from "react";
+import CreateForm from "./Form";
+
+const CreateWithoutProcess = ({ mutate }) => {
+ const [submitting, setSubmitting] = useState(false);
+ const requestServer = useRequest({ notificationSuccess: true });
+ const theme = useTheme();
+ const isMobile = useMediaQuery(theme.breakpoints.down("sm"));
+ const [open, setOpen] = useState(false);
+
+ const handleOpen = () => {
+ setOpen(true);
+ };
+
+ const submitForm = async (result) => {
+ setSubmitting(true);
+ // const bound = result.bound.getLatLngs();
+ // let area =
+ // result.bound_type === "polygon"
+ // ? bound.map((ring) => ring.map((latlng) => [latlng.lng, latlng.lat]))[0]
+ // : bound.map((latlng) => [latlng.lng, latlng.lat]);
+ //
+ // // بستن polygon
+ // if (result.bound_type === "polygon" && area.length > 0) {
+ // const firstPoint = area[0];
+ // area.push({ ...firstPoint });
+ // }
+
+ await requestServer(REQUEST_MISSION_WITHOUT_PROCESS, "post", {
+ data: {
+ explanation: result.explanation,
+ category_id: result.category_id,
+ ...(result.rahdaran.length != 0 ? { rahdaran: result.rahdaran.map((r) => r.id) } : {}),
+ zone: result.region,
+ end_point: result.end_point,
+ // area: {
+ // type: result.bound_type,
+ // coordinates: area,
+ // },
+ start_date: `${result.start_date} ${moment(result.start_time).format("HH:mm")}`,
+ end_date: `${result.end_date} ${moment(result.end_time).format("HH:mm")}`,
+ driver: result.driver.id,
+ machine_code: result.machine_code,
+ },
+ hasSidebarUpdate: true,
+ })
+ .then((response) => {
+ mutate();
+ setOpen(false);
+ })
+ .catch((error) => {})
+ .finally(() => {
+ setSubmitting(false);
+ });
+ };
+
+ return (
+ <>
+ {isMobile ? (
+
+
+
+ ) : (
+ }
+ onClick={handleOpen}
+ >
+ ثبت ماموریت بدون فرایند
+
+ )}
+
+ >
+ );
+};
+export default CreateWithoutProcess;
diff --git a/src/components/dashboard/roadMissions/operator/Actions/showArea/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/showArea/index.jsx
index be4ee7a..ef25c6b 100644
--- a/src/components/dashboard/roadMissions/operator/Actions/showArea/index.jsx
+++ b/src/components/dashboard/roadMissions/operator/Actions/showArea/index.jsx
@@ -6,10 +6,15 @@ import ShowBound from "../showBound";
import L from "leaflet";
const ShowArea = ({ area }) => {
+ const latLngs = useMemo(() => {
+ return area.coordinates.map(([lng, lat]) => [lat, lng]);
+ }, [area.coordinates]);
+
const bound = useMemo(
- () => (area.type == "polygon" ? L.polygon([...area.coordinates]) : L.polyline([...area.coordinates])),
- [area]
+ () => (area.type === "polygon" ? L.polygon(latLngs) : L.polyline(latLngs)),
+ [area.type, latLngs]
);
+
const [openAreaDialog, setOpenAreaDialog] = useState(false);
return (
diff --git a/src/components/dashboard/roadMissions/operator/OperatorList.jsx b/src/components/dashboard/roadMissions/operator/OperatorList.jsx
index 9625838..c393619 100644
--- a/src/components/dashboard/roadMissions/operator/OperatorList.jsx
+++ b/src/components/dashboard/roadMissions/operator/OperatorList.jsx
@@ -12,6 +12,7 @@ import RowActions from "./RowActions";
import MachinesDialog from "./RowActions/Machines";
import Toolbar from "./Toolbar";
import RahdaranDialog from "./RowActions/Rahdaran";
+import DescriptionDialog from "@/components/dashboard/roadMissions/operator/RowActions/DescriptionDialog";
const OperatorList = () => {
const columns = useMemo(
@@ -219,7 +220,7 @@ const OperatorList = () => {
},
},
},
- Cell: ({ renderedCellValue, row }) => {
+ Cell: ({ row }) => {
return (
@@ -227,6 +228,33 @@ const OperatorList = () => {
);
},
},
+ {
+ header: "دلیل رد درخواست",
+ id: "description",
+ enableColumnFilter: false,
+ enableSorting: false,
+ datatype: "text",
+ filterMode: "contains",
+ columnFilterModeOptions: ["equals", "contains"],
+ grow: false,
+ size: 100,
+ muiTableBodyCellProps: {
+ sx: {
+ borderLeft: "1px solid #e1e1e1",
+ py: 0,
+ "&:first-of-type": {
+ borderLeft: "unset",
+ },
+ },
+ },
+ Cell: ({ row }) => {
+ return (
+
+
+
+ );
+ },
+ },
{
accessorFn: (row) =>
row.start_time ? moment(row.start_time).locale("fa").format("HH:mm | yyyy/MM/DD") : null,
diff --git a/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/Area/MapControlPolygon/DrawBound/index.jsx b/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/Area/MapControlPolygon/DrawBound/index.jsx
index a2134c5..5a253a9 100644
--- a/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/Area/MapControlPolygon/DrawBound/index.jsx
+++ b/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/Area/MapControlPolygon/DrawBound/index.jsx
@@ -1,129 +1,129 @@
-import React, { useCallback, useEffect, useRef, useState } from "react";
-import L from "leaflet";
-import { FeatureGroup, useMap } from "react-leaflet";
-import "leaflet-draw";
-
-const DrawBound = ({ control, controlDispach, bound, setBound }) => {
- const map = useMap();
- const featureRef = useRef(null);
- const [area, setArea] = useState();
- const drawControlRef = useRef(null);
-
- const safeFlyToBounds = (layer) => {
- if (!layer || !map) return;
- try {
- const latLngs = layer.getLatLngs();
- map.flyToBounds(latLngs, {
- paddingTopLeft: [20, 35],
- paddingBottomRight: [20, 55],
- });
- } catch (e) {
- console.warn("flyToBounds failed:", e);
- }
- };
-
- const safeFitBounds = (layer) => {
- if (!layer || !map) return;
- try {
- const latLngs = layer.getLatLngs();
- map.fitBounds(latLngs, {
- paddingTopLeft: [20, 35],
- paddingBottomRight: [20, 55],
- });
- } catch (e) {
- console.warn("fitBounds failed:", e);
- }
- };
-
- const bindEditEvent = (layer) => {
- if (!layer) return;
- layer.on("edit", function (e) {
- const editedLayer = e.target;
- setArea(editedLayer);
- setBound(editedLayer);
- safeFlyToBounds(editedLayer);
- });
- };
-
- const handlerCreatedBound = useCallback((event) => {
- const { layer } = event;
- layer.editing.enable();
- featureRef.current.addLayer(layer); // 🟢 اول اضافه به نقشه
- setArea(layer);
- setBound(layer);
- safeFlyToBounds(layer);
- bindEditEvent(layer);
- controlDispach({ type: "SET_STATUS", status: 2 });
- }, []);
-
- useEffect(() => {
- if (
- control.status === 1 &&
- drawControlRef.current &&
- drawControlRef.current._toolbars?.draw?._modes?.polygon?.handler
- ) {
- drawControlRef.current._toolbars.draw._modes.polygon.handler.enable();
- }
- }, [control.status]);
-
- useEffect(() => {
- if (control.status === 0 && area && featureRef.current) {
- featureRef.current.removeLayer(area);
- setArea(null);
- setBound(null);
- }
- }, [control.status, area]);
-
- useEffect(() => {
- if (control.status === 2 && bound && featureRef.current) {
- setArea(bound);
- featureRef.current.addLayer(bound);
- bound.editing.enable();
- safeFitBounds(bound);
- bindEditEvent(bound);
- }
- }, [control.status, bound]);
-
- useEffect(() => {
- if (!featureRef.current) return;
-
- L.drawLocal.draw.handlers.polygon.tooltip.start = "برای شروع ترسیم محدوده، روی نقشه کلیک کنید";
- L.drawLocal.draw.handlers.polygon.tooltip.cont = "برای ادامه ترسیم، نقاط بعدی را کلیک کنید";
- L.drawLocal.draw.handlers.polygon.tooltip.end = "برای بستن محدوده، روی نقطهی شروع کلیک کنید";
-
- const drawControl = new L.Control.Draw({
- draw: {
- polygon: {
- shapeOptions: {
- color: "#3388ff",
- weight: 3,
- clickable: true,
- },
- },
- polyline: false,
- rectangle: false,
- circle: false,
- marker: false,
- circlemarker: false,
- },
- edit: {
- featureGroup: featureRef.current,
- edit: true,
- remove: false,
- },
- });
-
- drawControlRef.current = drawControl;
- map.addControl(drawControl);
- map.on(L.Draw.Event.CREATED, handlerCreatedBound);
-
- return () => {
- map.off(L.Draw.Event.CREATED, handlerCreatedBound);
- map.removeControl(drawControl);
- };
- }, [map, handlerCreatedBound]);
-
- return ;
-};
-
-export default DrawBound;
+import React, { useCallback, useEffect, useRef, useState } from "react";
+import L from "leaflet";
+import { FeatureGroup, useMap } from "react-leaflet";
+import "leaflet-draw";
+
+const DrawBound = ({ control, controlDispach, bound, setBound }) => {
+ const map = useMap();
+ const featureRef = useRef(null);
+ const [area, setArea] = useState();
+ const drawControlRef = useRef(null);
+
+ const safeFlyToBounds = (layer) => {
+ if (!layer || !map) return;
+ try {
+ const latLngs = layer.getLatLngs();
+ map.flyToBounds(latLngs, {
+ paddingTopLeft: [20, 35],
+ paddingBottomRight: [20, 55],
+ });
+ } catch (e) {
+ console.warn("flyToBounds failed:", e);
+ }
+ };
+
+ const safeFitBounds = (layer) => {
+ if (!layer || !map) return;
+ try {
+ const latLngs = layer.getLatLngs();
+ map.fitBounds(latLngs, {
+ paddingTopLeft: [20, 35],
+ paddingBottomRight: [20, 55],
+ });
+ } catch (e) {
+ console.warn("fitBounds failed:", e);
+ }
+ };
+
+ const bindEditEvent = (layer) => {
+ if (!layer) return;
+ layer.on("edit", function (e) {
+ const editedLayer = e.target;
+ setArea(editedLayer);
+ setBound(editedLayer);
+ safeFlyToBounds(editedLayer);
+ });
+ };
+
+ const handlerCreatedBound = useCallback((event) => {
+ const { layer } = event;
+ layer.editing.enable();
+ featureRef.current.addLayer(layer); // 🟢 اول اضافه به نقشه
+ setArea(layer);
+ setBound(layer);
+ safeFlyToBounds(layer);
+ bindEditEvent(layer);
+ controlDispach({ type: "SET_STATUS", status: 2 });
+ }, []);
+
+ useEffect(() => {
+ if (
+ control.status === 1 &&
+ drawControlRef.current &&
+ drawControlRef.current._toolbars?.draw?._modes?.polygon?.handler
+ ) {
+ drawControlRef.current._toolbars.draw._modes.polygon.handler.enable();
+ }
+ }, [control.status]);
+
+ useEffect(() => {
+ if (control.status === 0 && area && featureRef.current) {
+ featureRef.current.removeLayer(area);
+ setArea(null);
+ setBound(null);
+ }
+ }, [control.status, area]);
+
+ useEffect(() => {
+ if (control.status === 2 && bound && featureRef.current) {
+ setArea(bound);
+ featureRef.current.addLayer(bound);
+ bound.editing.enable();
+ safeFitBounds(bound);
+ bindEditEvent(bound);
+ }
+ }, [control.status, bound]);
+
+ useEffect(() => {
+ if (!featureRef.current) return;
+
+ L.drawLocal.draw.handlers.polygon.tooltip.start = "برای شروع ترسیم محدوده، روی نقشه کلیک کنید";
+ L.drawLocal.draw.handlers.polygon.tooltip.cont = "برای ادامه ترسیم، نقاط بعدی را کلیک کنید";
+ L.drawLocal.draw.handlers.polygon.tooltip.end = "برای بستن محدوده، روی نقطهی شروع کلیک کنید";
+
+ const drawControl = new L.Control.Draw({
+ draw: {
+ polygon: {
+ shapeOptions: {
+ color: "#3388ff",
+ weight: 3,
+ clickable: true,
+ },
+ },
+ polyline: false,
+ rectangle: false,
+ circle: false,
+ marker: false,
+ circlemarker: false,
+ },
+ edit: {
+ featureGroup: featureRef.current,
+ edit: true,
+ remove: false,
+ },
+ });
+
+ drawControlRef.current = drawControl;
+ map.addControl(drawControl);
+ map.on(L.Draw.Event.CREATED, handlerCreatedBound);
+
+ return () => {
+ map.off(L.Draw.Event.CREATED, handlerCreatedBound);
+ map.removeControl(drawControl);
+ };
+ }, [map, handlerCreatedBound]);
+
+ return ;
+};
+
+export default DrawBound;
diff --git a/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/Area/MapControlPolygon/index.jsx b/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/Area/MapControlPolygon/index.jsx
index 186a0b6..718600c 100644
--- a/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/Area/MapControlPolygon/index.jsx
+++ b/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/Area/MapControlPolygon/index.jsx
@@ -1,116 +1,116 @@
-import { Delete, Route } from "@mui/icons-material";
-import { Box, Button, Stack, Typography } from "@mui/material";
-import { useReducer } from "react";
-import DrawBound from "./DrawBound";
-
-const statusType = [
- {
- id: 0,
- message: "برای آغاز ترسیم محدوده، کلیک کنید!",
- buttons: [
- {
- label: "شروع ترسیم محدوده",
- key: "start",
- color: "primary",
- icon: ,
- onclick: (controlDispach) => {
- controlDispach({ type: "SET_STATUS", status: 1 });
- },
- },
- ],
- },
- {
- id: 1,
- message: "محدودهی موردنظر را با کلیک روی نقشه مشخص کنید. برای اتمام، روی نقطهی ابتدایی کلیک کنید!",
- buttons: [],
- },
- {
- id: 2,
- message: "برای اصلاح محدوده، گوشهها را بکشید. برای ترسیم دوباره، آن را حذف کنید",
- buttons: [
- {
- label: "حذف",
- key: "end",
- color: "error",
- icon: ,
- onclick: (controlDispach) => {
- controlDispach({ type: "SET_STATUS", status: 0 });
- },
- },
- ],
- },
-];
-
-const createInitialState = (bound) => {
- if (bound) {
- return { status: 2 };
- }
- return { status: 0 };
-};
-
-const reducer = (state, action) => {
- switch (action.type) {
- case "SET_STATUS":
- return { ...state, status: action.status };
- default:
- return state;
- }
-};
-
-const MapControlPolygon = ({ bound, setBound }) => {
- const [control, controlDispach] = useReducer(reducer, bound, createInitialState);
-
- return (
- <>
-
-
- theme.palette.info.main,
- borderBottomLeftRadius: 8,
- borderBottomRightRadius: 8,
- py: 0.5,
- px: 2,
- }}
- >
-
- {statusType.find((st) => st.id == control.status).message}
-
-
-
-
-
- {statusType
- .find((st) => st.id == control.status)
- .buttons.map((button) => (
-
- ))}
-
-
- >
- );
-};
-export default MapControlPolygon;
+import { Delete, Route } from "@mui/icons-material";
+import { Box, Button, Stack, Typography } from "@mui/material";
+import { useReducer } from "react";
+import DrawBound from "./DrawBound";
+
+const statusType = [
+ {
+ id: 0,
+ message: "برای آغاز ترسیم محدوده، کلیک کنید!",
+ buttons: [
+ {
+ label: "شروع ترسیم محدوده",
+ key: "start",
+ color: "primary",
+ icon: ,
+ onclick: (controlDispach) => {
+ controlDispach({ type: "SET_STATUS", status: 1 });
+ },
+ },
+ ],
+ },
+ {
+ id: 1,
+ message: "محدودهی موردنظر را با کلیک روی نقشه مشخص کنید. برای اتمام، روی نقطهی ابتدایی کلیک کنید!",
+ buttons: [],
+ },
+ {
+ id: 2,
+ message: "برای اصلاح محدوده، گوشهها را بکشید. برای ترسیم دوباره، آن را حذف کنید",
+ buttons: [
+ {
+ label: "حذف",
+ key: "end",
+ color: "error",
+ icon: ,
+ onclick: (controlDispach) => {
+ controlDispach({ type: "SET_STATUS", status: 0 });
+ },
+ },
+ ],
+ },
+];
+
+const createInitialState = (bound) => {
+ if (bound) {
+ return { status: 2 };
+ }
+ return { status: 0 };
+};
+
+const reducer = (state, action) => {
+ switch (action.type) {
+ case "SET_STATUS":
+ return { ...state, status: action.status };
+ default:
+ return state;
+ }
+};
+
+const MapControlPolygon = ({ bound, setBound }) => {
+ const [control, controlDispach] = useReducer(reducer, bound, createInitialState);
+
+ return (
+ <>
+
+
+ theme.palette.info.main,
+ borderBottomLeftRadius: 8,
+ borderBottomRightRadius: 8,
+ py: 0.5,
+ px: 2,
+ }}
+ >
+
+ {statusType.find((st) => st.id == control.status).message}
+
+
+
+
+
+ {statusType
+ .find((st) => st.id == control.status)
+ .buttons.map((button) => (
+
+ ))}
+
+
+ >
+ );
+};
+export default MapControlPolygon;
diff --git a/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/Area/MapControlPolyline/DrawBound/index.jsx b/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/Area/MapControlPolyline/DrawBound/index.jsx
index 682be24..5456d12 100644
--- a/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/Area/MapControlPolyline/DrawBound/index.jsx
+++ b/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/Area/MapControlPolyline/DrawBound/index.jsx
@@ -1,129 +1,129 @@
-import React, { useCallback, useEffect, useRef, useState } from "react";
-import L from "leaflet";
-import { FeatureGroup, useMap } from "react-leaflet";
-import "leaflet-draw";
-
-const DrawBound = ({ control, controlDispach, bound, setBound }) => {
- const map = useMap();
- const featureRef = useRef(null);
- const [area, setArea] = useState();
- const drawControlRef = useRef(null);
-
- const safeFlyToBounds = (layer) => {
- if (!layer || !map) return;
- try {
- const latLngs = layer.getLatLngs();
- map.flyToBounds(latLngs, {
- paddingTopLeft: [20, 35],
- paddingBottomRight: [20, 55],
- });
- } catch (e) {
- console.warn("flyToBounds failed:", e);
- }
- };
-
- const safeFitBounds = (layer) => {
- if (!layer || !map) return;
- try {
- const latLngs = layer.getLatLngs();
- map.fitBounds(latLngs, {
- paddingTopLeft: [20, 35],
- paddingBottomRight: [20, 55],
- });
- } catch (e) {
- console.warn("fitBounds failed:", e);
- }
- };
-
- const bindEditEvent = (layer) => {
- if (!layer) return;
- layer.on("edit", function (e) {
- const editedLayer = e.target;
- setArea(editedLayer);
- setBound(editedLayer);
- safeFlyToBounds(editedLayer);
- });
- };
-
- const handlerCreatedBound = useCallback((event) => {
- const { layer } = event;
- layer.editing.enable();
- featureRef.current.addLayer(layer); // 🟢 اول اضافه به نقشه
- setArea(layer);
- setBound(layer);
- safeFlyToBounds(layer);
- bindEditEvent(layer);
- controlDispach({ type: "SET_STATUS", status: 2 });
- }, []);
-
- useEffect(() => {
- if (
- control.status === 1 &&
- drawControlRef.current &&
- drawControlRef.current._toolbars?.draw?._modes?.polyline?.handler
- ) {
- drawControlRef.current._toolbars.draw._modes.polyline.handler.enable();
- }
- }, [control.status]);
-
- useEffect(() => {
- if (control.status === 0 && area && featureRef.current) {
- featureRef.current.removeLayer(area);
- setArea(null);
- setBound(null);
- }
- }, [control.status, area]);
-
- useEffect(() => {
- if (control.status === 2 && bound && featureRef.current) {
- setArea(bound);
- featureRef.current.addLayer(bound);
- bound.editing.enable();
- safeFitBounds(bound);
- bindEditEvent(bound);
- }
- }, [control.status, bound]);
-
- useEffect(() => {
- if (!featureRef.current) return;
-
- L.drawLocal.draw.handlers.polyline.tooltip.start = "برای شروع ترسیم مسیر، روی نقشه کلیک کنید";
- L.drawLocal.draw.handlers.polyline.tooltip.cont = "برای ادامه ترسیم، نقاط بعدی را کلیک کنید";
- L.drawLocal.draw.handlers.polyline.tooltip.end = "برای بستن مسیر، روی نقطه پایانی کلیک کنید";
-
- const drawControl = new L.Control.Draw({
- draw: {
- polyline: {
- shapeOptions: {
- color: "#3388ff",
- weight: 3,
- clickable: true,
- },
- },
- polygon: false,
- rectangle: false,
- circle: false,
- marker: false,
- circlemarker: false,
- },
- edit: {
- featureGroup: featureRef.current,
- edit: true,
- remove: false,
- },
- });
-
- drawControlRef.current = drawControl;
- map.addControl(drawControl);
- map.on(L.Draw.Event.CREATED, handlerCreatedBound);
-
- return () => {
- map.off(L.Draw.Event.CREATED, handlerCreatedBound);
- map.removeControl(drawControl);
- };
- }, [map, handlerCreatedBound]);
-
- return ;
-};
-
-export default DrawBound;
+import React, { useCallback, useEffect, useRef, useState } from "react";
+import L from "leaflet";
+import { FeatureGroup, useMap } from "react-leaflet";
+import "leaflet-draw";
+
+const DrawBound = ({ control, controlDispach, bound, setBound }) => {
+ const map = useMap();
+ const featureRef = useRef(null);
+ const [area, setArea] = useState();
+ const drawControlRef = useRef(null);
+
+ const safeFlyToBounds = (layer) => {
+ if (!layer || !map) return;
+ try {
+ const latLngs = layer.getLatLngs();
+ map.flyToBounds(latLngs, {
+ paddingTopLeft: [20, 35],
+ paddingBottomRight: [20, 55],
+ });
+ } catch (e) {
+ console.warn("flyToBounds failed:", e);
+ }
+ };
+
+ const safeFitBounds = (layer) => {
+ if (!layer || !map) return;
+ try {
+ const latLngs = layer.getLatLngs();
+ map.fitBounds(latLngs, {
+ paddingTopLeft: [20, 35],
+ paddingBottomRight: [20, 55],
+ });
+ } catch (e) {
+ console.warn("fitBounds failed:", e);
+ }
+ };
+
+ const bindEditEvent = (layer) => {
+ if (!layer) return;
+ layer.on("edit", function (e) {
+ const editedLayer = e.target;
+ setArea(editedLayer);
+ setBound(editedLayer);
+ safeFlyToBounds(editedLayer);
+ });
+ };
+
+ const handlerCreatedBound = useCallback((event) => {
+ const { layer } = event;
+ layer.editing.enable();
+ featureRef.current.addLayer(layer); // 🟢 اول اضافه به نقشه
+ setArea(layer);
+ setBound(layer);
+ safeFlyToBounds(layer);
+ bindEditEvent(layer);
+ controlDispach({ type: "SET_STATUS", status: 2 });
+ }, []);
+
+ useEffect(() => {
+ if (
+ control.status === 1 &&
+ drawControlRef.current &&
+ drawControlRef.current._toolbars?.draw?._modes?.polyline?.handler
+ ) {
+ drawControlRef.current._toolbars.draw._modes.polyline.handler.enable();
+ }
+ }, [control.status]);
+
+ useEffect(() => {
+ if (control.status === 0 && area && featureRef.current) {
+ featureRef.current.removeLayer(area);
+ setArea(null);
+ setBound(null);
+ }
+ }, [control.status, area]);
+
+ useEffect(() => {
+ if (control.status === 2 && bound && featureRef.current) {
+ setArea(bound);
+ featureRef.current.addLayer(bound);
+ bound.editing.enable();
+ safeFitBounds(bound);
+ bindEditEvent(bound);
+ }
+ }, [control.status, bound]);
+
+ useEffect(() => {
+ if (!featureRef.current) return;
+
+ L.drawLocal.draw.handlers.polyline.tooltip.start = "برای شروع ترسیم مسیر، روی نقشه کلیک کنید";
+ L.drawLocal.draw.handlers.polyline.tooltip.cont = "برای ادامه ترسیم، نقاط بعدی را کلیک کنید";
+ L.drawLocal.draw.handlers.polyline.tooltip.end = "برای بستن مسیر، روی نقطه پایانی کلیک کنید";
+
+ const drawControl = new L.Control.Draw({
+ draw: {
+ polyline: {
+ shapeOptions: {
+ color: "#3388ff",
+ weight: 3,
+ clickable: true,
+ },
+ },
+ polygon: false,
+ rectangle: false,
+ circle: false,
+ marker: false,
+ circlemarker: false,
+ },
+ edit: {
+ featureGroup: featureRef.current,
+ edit: true,
+ remove: false,
+ },
+ });
+
+ drawControlRef.current = drawControl;
+ map.addControl(drawControl);
+ map.on(L.Draw.Event.CREATED, handlerCreatedBound);
+
+ return () => {
+ map.off(L.Draw.Event.CREATED, handlerCreatedBound);
+ map.removeControl(drawControl);
+ };
+ }, [map, handlerCreatedBound]);
+
+ return ;
+};
+
+export default DrawBound;
diff --git a/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/Area/MapControlPolyline/index.jsx b/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/Area/MapControlPolyline/index.jsx
index edd6cac..8d9b5d0 100644
--- a/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/Area/MapControlPolyline/index.jsx
+++ b/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/Area/MapControlPolyline/index.jsx
@@ -1,116 +1,116 @@
-import { Delete, Route } from "@mui/icons-material";
-import { Box, Button, Stack, Typography } from "@mui/material";
-import { useReducer } from "react";
-import DrawBound from "./DrawBound";
-
-const statusType = [
- {
- id: 0,
- message: "برای آغاز ترسیم مسیر، کلیک کنید!",
- buttons: [
- {
- label: "شروع ترسیم مسیر",
- key: "start",
- color: "primary",
- icon: ,
- onclick: (controlDispach) => {
- controlDispach({ type: "SET_STATUS", status: 1 });
- },
- },
- ],
- },
- {
- id: 1,
- message: "مسیر موردنظر را با کلیک روی نقشه مشخص کنید. برای اتمام، روی نقطهی پایانی کلیک کنید!",
- buttons: [],
- },
- {
- id: 2,
- message: "برای اصلاح مسیر، گوشهها را بکشید. برای ترسیم دوباره، آن را حذف کنید",
- buttons: [
- {
- label: "حذف",
- key: "end",
- color: "error",
- icon: ,
- onclick: (controlDispach) => {
- controlDispach({ type: "SET_STATUS", status: 0 });
- },
- },
- ],
- },
-];
-
-const createInitialState = (bound) => {
- if (bound) {
- return { status: 2 };
- }
- return { status: 0 };
-};
-
-const reducer = (state, action) => {
- switch (action.type) {
- case "SET_STATUS":
- return { ...state, status: action.status };
- default:
- return state;
- }
-};
-
-const MapControlPolyline = ({ bound, setBound }) => {
- const [control, controlDispach] = useReducer(reducer, bound, createInitialState);
-
- return (
- <>
-
-
- theme.palette.info.main,
- borderBottomLeftRadius: 8,
- borderBottomRightRadius: 8,
- py: 0.5,
- px: 2,
- }}
- >
-
- {statusType.find((st) => st.id == control.status).message}
-
-
-
-
-
- {statusType
- .find((st) => st.id == control.status)
- .buttons.map((button) => (
-
- ))}
-
-
- >
- );
-};
-export default MapControlPolyline;
+import { Delete, Route } from "@mui/icons-material";
+import { Box, Button, Stack, Typography } from "@mui/material";
+import { useReducer } from "react";
+import DrawBound from "./DrawBound";
+
+const statusType = [
+ {
+ id: 0,
+ message: "برای آغاز ترسیم مسیر، کلیک کنید!",
+ buttons: [
+ {
+ label: "شروع ترسیم مسیر",
+ key: "start",
+ color: "primary",
+ icon: ,
+ onclick: (controlDispach) => {
+ controlDispach({ type: "SET_STATUS", status: 1 });
+ },
+ },
+ ],
+ },
+ {
+ id: 1,
+ message: "مسیر موردنظر را با کلیک روی نقشه مشخص کنید. برای اتمام، روی نقطهی پایانی کلیک کنید!",
+ buttons: [],
+ },
+ {
+ id: 2,
+ message: "برای اصلاح مسیر، گوشهها را بکشید. برای ترسیم دوباره، آن را حذف کنید",
+ buttons: [
+ {
+ label: "حذف",
+ key: "end",
+ color: "error",
+ icon: ,
+ onclick: (controlDispach) => {
+ controlDispach({ type: "SET_STATUS", status: 0 });
+ },
+ },
+ ],
+ },
+];
+
+const createInitialState = (bound) => {
+ if (bound) {
+ return { status: 2 };
+ }
+ return { status: 0 };
+};
+
+const reducer = (state, action) => {
+ switch (action.type) {
+ case "SET_STATUS":
+ return { ...state, status: action.status };
+ default:
+ return state;
+ }
+};
+
+const MapControlPolyline = ({ bound, setBound }) => {
+ const [control, controlDispach] = useReducer(reducer, bound, createInitialState);
+
+ return (
+ <>
+
+
+ theme.palette.info.main,
+ borderBottomLeftRadius: 8,
+ borderBottomRightRadius: 8,
+ py: 0.5,
+ px: 2,
+ }}
+ >
+
+ {statusType.find((st) => st.id == control.status).message}
+
+
+
+
+
+ {statusType
+ .find((st) => st.id == control.status)
+ .buttons.map((button) => (
+
+ ))}
+
+
+ >
+ );
+};
+export default MapControlPolyline;
diff --git a/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/Area/OldBoundLayer/index.jsx b/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/Area/OldBoundLayer/index.jsx
index 1f74ad5..835658b 100644
--- a/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/Area/OldBoundLayer/index.jsx
+++ b/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/Area/OldBoundLayer/index.jsx
@@ -1,30 +1,30 @@
-import { useEffect } from "react";
-import { Polygon, Polyline, useMap } from "react-leaflet";
-
-const OldBoundLayer = ({ bound }) => {
- const map = useMap();
-
- const safeFitBounds = (coordinates) => {
- if (!map) return;
- try {
- const latLngs = coordinates;
- map.fitBounds(latLngs, {
- paddingTopLeft: [70, 70],
- paddingBottomRight: [70, 70],
- });
- } catch (e) {
- console.warn("fitBounds failed:", e);
- }
- };
-
- useEffect(() => {
- safeFitBounds(bound.coordinates);
- }, []);
-
- return bound.type == "polygon" ? (
-
- ) : (
-
- );
-};
-export default OldBoundLayer;
+import { useEffect } from "react";
+import { Polygon, Polyline, useMap } from "react-leaflet";
+
+const OldBoundLayer = ({ bound }) => {
+ const map = useMap();
+
+ const safeFitBounds = (coordinates) => {
+ if (!map) return;
+ try {
+ const latLngs = coordinates;
+ map.fitBounds(latLngs, {
+ paddingTopLeft: [70, 70],
+ paddingBottomRight: [70, 70],
+ });
+ } catch (e) {
+ console.warn("fitBounds failed:", e);
+ }
+ };
+
+ useEffect(() => {
+ safeFitBounds(bound.coordinates);
+ }, []);
+
+ return bound.type == "polygon" ? (
+
+ ) : (
+
+ );
+};
+export default OldBoundLayer;
diff --git a/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/Area/SelectBoundType/index.jsx b/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/Area/SelectBoundType/index.jsx
index a69a0ba..ebb3c69 100644
--- a/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/Area/SelectBoundType/index.jsx
+++ b/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/Area/SelectBoundType/index.jsx
@@ -1,25 +1,25 @@
-import SelectBox from "@/core/components/SelectBox";
-
-export const boundTypes = [
- { id: "polygon", name_fa: "محدوده" },
- { id: "polyline", name_fa: "مسیر" },
-];
-
-const SelectBoundType = ({ boundType, setBoundType, setBound, setAllData }) => {
- return (
- <>
- {
- setBound(null);
- setBoundType(newValue);
- setAllData({ bound_type: newValue });
- }}
- />
- >
- );
-};
-export default SelectBoundType;
+import SelectBox from "@/core/components/SelectBox";
+
+export const boundTypes = [
+ { id: "polygon", name_fa: "محدوده" },
+ { id: "polyline", name_fa: "مسیر" },
+];
+
+const SelectBoundType = ({ boundType, setBoundType, setBound, setAllData }) => {
+ return (
+ <>
+ {
+ setBound(null);
+ setBoundType(newValue);
+ setAllData({ bound_type: newValue });
+ }}
+ />
+ >
+ );
+};
+export default SelectBoundType;
diff --git a/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/Area/index.jsx b/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/Area/index.jsx
index fdbd268..c8feef7 100644
--- a/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/Area/index.jsx
+++ b/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/Area/index.jsx
@@ -1,56 +1,55 @@
-import MapLoading from "@/core/components/MapLayer/Loading";
-import { Box, Button, DialogActions, DialogContent, Stack } from "@mui/material";
-import dynamic from "next/dynamic";
-import { useCallback, useState } from "react";
-import MapControlPolygon from "./MapControlPolygon";
-import MapControlPolyline from "./MapControlPolyline";
-import SelectBoundType from "./SelectBoundType";
-import OldBoundLayer from "./OldBoundLayer";
-const MapLayer = dynamic(() => import("@/core/components/MapLayer"), {
- loading: () => ,
- ssr: false,
-});
-
-const Area = ({ allData, setAllData, handlePrev, setTabState, oldBound }) => {
- const [bound, setBound] = useState(allData.bound);
- const [boundType, setBoundType] = useState(allData.bound_type);
-
- const handleNext = useCallback(() => {
- setAllData({ bound: bound });
- setTabState((s) => s + 1);
- }, [bound]);
-
- return (
- <>
-
-
-
-
-
- {boundType == "polygon" ? (
-
- ) : (
-
- )}
-
-
-
-
-
-
-
-
-
- >
- );
-};
-export default Area;
+import MapLoading from "@/core/components/MapLayer/Loading";
+import { Box, Button, DialogActions, DialogContent, Stack } from "@mui/material";
+import dynamic from "next/dynamic";
+import { useCallback, useState } from "react";
+import MapControlPolygon from "./MapControlPolygon";
+import MapControlPolyline from "./MapControlPolyline";
+import SelectBoundType from "./SelectBoundType";
+import OldBoundLayer from "./OldBoundLayer";
+const MapLayer = dynamic(() => import("@/core/components/MapLayer"), {
+ loading: () => ,
+ ssr: false,
+});
+
+const Area = ({ allData, setAllData, handlePrev, setTabState, oldBound }) => {
+ const [bound, setBound] = useState(allData.bound);
+ const [boundType, setBoundType] = useState(allData.bound_type);
+
+ const handleNext = useCallback(() => {
+ setAllData({ bound: bound });
+ setTabState((s) => s + 1);
+ }, [bound]);
+ return (
+ <>
+
+
+
+
+
+ {boundType == "polygon" ? (
+
+ ) : (
+
+ )}
+
+
+
+
+
+
+
+
+
+ >
+ );
+};
+export default Area;
diff --git a/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/GetDateTime/MissionDates/index.jsx b/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/GetDateTime/MissionDates/index.jsx
index 7de1570..b7496d1 100644
--- a/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/GetDateTime/MissionDates/index.jsx
+++ b/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/GetDateTime/MissionDates/index.jsx
@@ -1,60 +1,60 @@
-import MuiDatePicker from "@/core/components/MuiDatePicker";
-import MuiTimePicker from "@/core/components/MuiTimePicker";
-import { Grid } from "@mui/material";
-import { Controller, useWatch } from "react-hook-form";
-
-const MissionDates = ({ control }) => {
- const type = useWatch({ control, name: "type" });
- const now = new Date();
-
- return (
- type && (
- <>
-
- {
- return (
- field.onChange(value || [])}
- helperText={error ? error.message : null}
- />
- );
- }}
- />
-
- {type == 1 && (
-
- {
- return (
- field.onChange(value || null)}
- helperText={error ? error.message : null}
- />
- );
- }}
- />
-
- )}
- >
- )
- );
-};
-export default MissionDates;
+import MuiDatePicker from "@/core/components/MuiDatePicker";
+import MuiTimePicker from "@/core/components/MuiTimePicker";
+import { Grid } from "@mui/material";
+import { Controller, useWatch } from "react-hook-form";
+
+const MissionDates = ({ control }) => {
+ const type = useWatch({ control, name: "type" });
+ const now = new Date();
+
+ return (
+ type && (
+ <>
+
+ {
+ return (
+ field.onChange(value || [])}
+ helperText={error ? error.message : null}
+ />
+ );
+ }}
+ />
+
+ {type == 1 && (
+
+ {
+ return (
+ field.onChange(value || null)}
+ helperText={error ? error.message : null}
+ />
+ );
+ }}
+ />
+
+ )}
+ >
+ )
+ );
+};
+export default MissionDates;
diff --git a/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/GetDateTime/index.jsx b/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/GetDateTime/index.jsx
index 42c977f..4d47405 100644
--- a/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/GetDateTime/index.jsx
+++ b/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/GetDateTime/index.jsx
@@ -1,83 +1,83 @@
-import SelectBox from "@/core/components/SelectBox";
-import StyledForm from "@/core/components/StyledForm";
-import { missionTypes } from "@/core/utils/missionTypes";
-import { yupResolver } from "@hookform/resolvers/yup";
-import { Alert, Box, Button, DialogActions, DialogContent, Grid, Stack } from "@mui/material";
-import moment from "jalali-moment";
-import { Controller, useForm } from "react-hook-form";
-import { object, string } from "yup";
-import MissionDates from "./MissionDates";
-
-const validationSchema = object({
- type: string().required("نوع ماموریت را مشخص کنید!"),
- end_date: string().required("تاریخ پایان ماموریت را مشخص کنید!"),
- end_time: string().when("type", {
- is: "1",
- then: (schema) => schema.required("زمان پایان ماموریت را مشخص کنید!"),
- otherwise: (schema) => schema.notRequired(),
- }),
-});
-
-const GetDateTime = ({ allData, setAllData, handlePrev, setTabState }) => {
- const defaultValues = {
- type: allData.type,
- end_date: allData.end_date,
- end_time: allData.end_time ? moment(allData.end_time).toDate() : null,
- };
-
- const { control, handleSubmit } = useForm({
- defaultValues,
- resolver: yupResolver(validationSchema),
- mode: "all",
- });
-
- const handleNext = (data) => {
- setAllData(data);
- setTabState((s) => s + 1);
- };
-
- return (
-
-
-
-
-
-
- (
-
- )}
- />
-
-
-
- تاریخ شروع مأموریت پس از ثبت مأموریت بهصورت خودکار تعیین میشود.
-
-
-
-
-
-
-
-
-
-
-
-
- );
-};
-export default GetDateTime;
+import SelectBox from "@/core/components/SelectBox";
+import StyledForm from "@/core/components/StyledForm";
+import { missionTypes } from "@/core/utils/missionTypes";
+import { yupResolver } from "@hookform/resolvers/yup";
+import { Alert, Box, Button, DialogActions, DialogContent, Grid, Stack } from "@mui/material";
+import moment from "jalali-moment";
+import { Controller, useForm } from "react-hook-form";
+import { object, string } from "yup";
+import MissionDates from "./MissionDates";
+
+const validationSchema = object({
+ type: string().required("نوع ماموریت را مشخص کنید!"),
+ end_date: string().required("تاریخ پایان ماموریت را مشخص کنید!"),
+ end_time: string().when("type", {
+ is: "1",
+ then: (schema) => schema.required("زمان پایان ماموریت را مشخص کنید!"),
+ otherwise: (schema) => schema.notRequired(),
+ }),
+});
+
+const GetDateTime = ({ allData, setAllData, handlePrev, setTabState }) => {
+ const defaultValues = {
+ type: allData.type,
+ end_date: allData.end_date,
+ end_time: allData.end_time ? moment(allData.end_time).toDate() : null,
+ };
+
+ const { control, handleSubmit } = useForm({
+ defaultValues,
+ resolver: yupResolver(validationSchema),
+ mode: "all",
+ });
+
+ const handleNext = (data) => {
+ setAllData(data);
+ setTabState((s) => s + 1);
+ };
+
+ return (
+
+
+
+
+
+
+ (
+
+ )}
+ />
+
+
+
+ تاریخ شروع مأموریت پس از ثبت مأموریت بهصورت خودکار تعیین میشود.
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+};
+export default GetDateTime;
diff --git a/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/GetItemInfo/FastReactCode/Dialog/List/RowActions/SelectId/index.jsx b/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/GetItemInfo/FastReactCode/Dialog/List/RowActions/SelectId/index.jsx
index 1e7e881..e3e14c0 100644
--- a/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/GetItemInfo/FastReactCode/Dialog/List/RowActions/SelectId/index.jsx
+++ b/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/GetItemInfo/FastReactCode/Dialog/List/RowActions/SelectId/index.jsx
@@ -1,20 +1,20 @@
-import { Done } from "@mui/icons-material";
-import { IconButton, Tooltip } from "@mui/material";
-
-const SelectId = ({ row, onChange, setOpenFastReactDialog }) => {
- const handleClick = () => {
- onChange(row.original.id);
- setOpenFastReactDialog(false);
- };
-
- return (
- <>
-
-
-
-
-
- >
- );
-};
-export default SelectId;
+import { Done } from "@mui/icons-material";
+import { IconButton, Tooltip } from "@mui/material";
+
+const SelectId = ({ row, onChange, setOpenFastReactDialog }) => {
+ const handleClick = () => {
+ onChange(row.original.id);
+ setOpenFastReactDialog(false);
+ };
+
+ return (
+ <>
+
+
+
+
+
+ >
+ );
+};
+export default SelectId;
diff --git a/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/GetItemInfo/FastReactCode/Dialog/List/RowActions/index.jsx b/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/GetItemInfo/FastReactCode/Dialog/List/RowActions/index.jsx
index 3d0b958..646104b 100644
--- a/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/GetItemInfo/FastReactCode/Dialog/List/RowActions/index.jsx
+++ b/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/GetItemInfo/FastReactCode/Dialog/List/RowActions/index.jsx
@@ -1,10 +1,10 @@
-import SelectId from "./SelectId";
-
-const RowActions = ({ row, onChange, setOpenFastReactDialog }) => {
- return (
- <>
-
- >
- );
-};
-export default RowActions;
+import SelectId from "./SelectId";
+
+const RowActions = ({ row, onChange, setOpenFastReactDialog }) => {
+ return (
+ <>
+
+ >
+ );
+};
+export default RowActions;
diff --git a/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/GetItemInfo/FastReactCode/Dialog/List/index.jsx b/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/GetItemInfo/FastReactCode/Dialog/List/index.jsx
index 82a0472..8940335 100644
--- a/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/GetItemInfo/FastReactCode/Dialog/List/index.jsx
+++ b/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/GetItemInfo/FastReactCode/Dialog/List/index.jsx
@@ -1,274 +1,274 @@
-import DataTableWithAuth from "@/core/components/DataTableWithAuth";
-import { GET_FAST_REACT_COMPLAINTS } from "@/core/utils/routes";
-import { Box, Stack, Typography } from "@mui/material";
-import { useMemo } from "react";
-import RowActions from "./RowActions";
-import { usePermissions } from "@/lib/hooks/usePermissions";
-import { useAuth } from "@/lib/contexts/auth";
-import CustomSelectByDependency from "@/core/components/DataTable/filter/fieldsType/CustomSelectByDependency";
-import DescriptionForm from "@/components/dashboard/fastReact/complaintList/RowActions/DescriptionDialog";
-import LocationForm from "@/components/dashboard/fastReact/complaintList/RowActions/LocationDialog";
-import moment from "jalali-moment";
-import useProvinces from "@/lib/hooks/useProvince";
-import useEdaratLists from "@/lib/hooks/useEdaratLists";
-
-const FastReactList = ({ onChange, setOpenFastReactDialog }) => {
- const { data: userPermissions } = usePermissions();
- const hasCountryPermission = userPermissions?.includes("show-fast-react");
- const { user } = useAuth();
- const columns = useMemo(() => {
- const dynamicColumns = {
- header: "استان",
- id: "road_observeds__province_id",
- enableColumnFilter: true,
- datatype: "numeric",
- filterMode: "equals",
- grow: false,
- size: 130,
- ColumnSelectComponent: (props) => {
- const { provinces, errorProvinces, loadingProvinces } = useProvinces();
- const getColumnSelectOptions = useMemo(() => {
- if (loadingProvinces) {
- return [{ value: "loading", label: "در حال بارگذاری..." }];
- }
- if (errorProvinces) {
- return [{ value: "error", label: "خطا در بارگذاری" }];
- }
- return [
- { value: "", label: "کل کشور" },
- ...provinces.map((province) => ({
- value: province.id,
- label: province.name_fa,
- })),
- ];
- }, [provinces, errorProvinces, loadingProvinces]);
- return (
-
- );
- },
- Cell: ({ row }) => <>{row.original.province_fa}>,
- };
- return [
- {
- accessorKey: "id",
- header: "کد یکتا",
- id: "road_observeds__id",
- enableColumnFilter: true,
- datatype: "text",
- filterMode: "equals",
- sortDescFirst: false,
- columnFilterModeOptions: ["equals", "contains"],
- grow: false,
- size: 100,
- },
- ...(hasCountryPermission ? [dynamicColumns] : []),
- {
- header: "اداره",
- id: "road_observeds__edarate_shahri_id",
- enableColumnFilter: true,
- datatype: "numeric",
- filterMode: "equals",
- dependencyId: hasCountryPermission ? "road_observeds__province_id" : null,
- grow: false,
- size: 120,
- ColumnSelectComponent: (props) => {
- const { edaratList, loadingEdaratList, errorEdaratList } = useEdaratLists(
- hasCountryPermission ? props.dependencyFieldValue.value : user.province_id
- );
- const [prevDependency, setPrevDependency] = useState(
- hasCountryPermission ? props.dependencyFieldValue.value : user.province_id
- );
-
- const getColumnSelectOptions = useMemo(() => {
- if (hasCountryPermission && props.dependencyFieldValue.value === "") {
- return [{ value: "empty", label: "ابتدا استان را انتخاب کنید" }];
- }
- if (loadingEdaratList) {
- return [{ value: "loading", label: "در حال بارگذاری..." }];
- }
- if (errorEdaratList) {
- return [{ value: "error", label: "خطا در بارگذاری" }];
- }
- return [
- { value: "", label: "کل ادارات" },
- ...edaratList.map((edare) => ({
- value: edare.id,
- label: edare.name_fa,
- })),
- ];
- }, [edaratList, loadingEdaratList, errorEdaratList]);
- useEffect(() => {
- if (hasCountryPermission) return;
- if (prevDependency === props.dependencyFieldValue?.value) return;
- props.handleChange({ ...props.filterParameters, value: "" });
- setPrevDependency(props.dependencyFieldValue?.value);
- }, [props.dependencyFieldValue?.value, hasCountryPermission]);
- return (
-
- );
- },
- Cell: ({ row }) => <>{row.original.edarate_shahri_name_fa}>,
- },
- {
- header: "اطلاعات ثبت شده در سامانه سوانح",
- id: "fkInfo",
- enableColumnFilter: false,
- enableSorting: false,
- grow: false,
- size: 50,
- columns: [
- {
- accessorKey: "fk_RegisteredEventMessage",
- header: "کد سوانح",
- id: "fk_RegisteredEventMessage",
- enableColumnFilter: true,
- datatype: "text",
- filterMode: "equals",
- sortDescFirst: false,
- columnFilterModeOptions: ["equals", "contains"],
- grow: false,
- size: 100,
- },
- {
- accessorKey: "Title",
- header: "موضوع گزارش",
- id: "Title",
- enableColumnFilter: false,
- datatype: "text",
- filterMode: "equals",
- sortDescFirst: false,
- columnFilterModeOptions: ["equals", "contains"],
- grow: false,
- size: 100,
- },
- {
- accessorKey: "FeatureTypeTitle",
- header: "نوع گزارش",
- id: "FeatureTypeTitle",
- enableColumnFilter: false,
- datatype: "text",
- filterMode: "equals",
- sortDescFirst: false,
- columnFilterModeOptions: ["equals", "contains"],
- grow: false,
- size: 100,
- },
- {
- accessorKey: "Description",
- header: "توضیح گزارش",
- id: "Description",
- enableColumnFilter: false,
- datatype: "text",
- filterMode: "equals",
- sortDescFirst: false,
- columnFilterModeOptions: ["equals", "contains"],
- grow: false,
- size: 100,
- muiTableBodyCellProps: {
- sx: {
- borderLeft: "1px solid #e1e1e1",
- py: 0,
- "&:first-of-type": {
- borderLeft: "unset",
- },
- },
- },
- Cell: ({ renderedCellValue }) => {
- if (renderedCellValue) {
- return (
-
-
-
- );
- }
- return -;
- },
- },
- {
- header: "موقعیت",
- id: "location",
- enableColumnFilter: false,
- enableSorting: false,
- datatype: "array",
- grow: false,
- size: 100,
- muiTableBodyCellProps: {
- sx: {
- borderLeft: "1px solid #e1e1e1",
- py: 0,
- "&:first-of-type": {
- borderLeft: "unset",
- },
- },
- },
- Cell: ({ row }) => {
- return (
-
-
-
- );
- },
- },
- {
- accessorKey: "MobileForSendEventSms",
- header: "شماره تماس گیرنده",
- id: "MobileForSendEventSms",
- enableColumnFilter: false,
- datatype: "text",
- filterMode: "equals",
- sortDescFirst: false,
- columnFilterModeOptions: ["equals", "contains"],
- grow: false,
- size: 100,
- },
- {
- accessorFn: (row) => moment(row.StartTime_DateTime).locale("fa").format("HH:mm | yyyy/MM/DD"),
- header: "تاریخ ثبت",
- id: "StartTime_DateTime",
- enableColumnFilter: true,
- datatype: "date",
- filterMode: "between",
- grow: false,
- size: 100,
- },
- ],
- },
- ];
- }, []);
-
- return (
- <>
-
- (
-
- )}
- />
-
- >
- );
-};
-export default FastReactList;
+import DataTableWithAuth from "@/core/components/DataTableWithAuth";
+import { GET_FAST_REACT_COMPLAINTS } from "@/core/utils/routes";
+import { Box, Stack, Typography } from "@mui/material";
+import { useMemo } from "react";
+import RowActions from "./RowActions";
+import { usePermissions } from "@/lib/hooks/usePermissions";
+import { useAuth } from "@/lib/contexts/auth";
+import CustomSelectByDependency from "@/core/components/DataTable/filter/fieldsType/CustomSelectByDependency";
+import DescriptionForm from "@/components/dashboard/fastReact/complaintList/RowActions/DescriptionDialog";
+import LocationForm from "@/components/dashboard/fastReact/complaintList/RowActions/LocationDialog";
+import moment from "jalali-moment";
+import useProvinces from "@/lib/hooks/useProvince";
+import useEdaratLists from "@/lib/hooks/useEdaratLists";
+
+const FastReactList = ({ onChange, setOpenFastReactDialog }) => {
+ const { data: userPermissions } = usePermissions();
+ const hasCountryPermission = userPermissions?.includes("show-fast-react");
+ const { user } = useAuth();
+ const columns = useMemo(() => {
+ const dynamicColumns = {
+ header: "استان",
+ id: "road_observeds__province_id",
+ enableColumnFilter: true,
+ datatype: "numeric",
+ filterMode: "equals",
+ grow: false,
+ size: 130,
+ ColumnSelectComponent: (props) => {
+ const { provinces, errorProvinces, loadingProvinces } = useProvinces();
+ const getColumnSelectOptions = useMemo(() => {
+ if (loadingProvinces) {
+ return [{ value: "loading", label: "در حال بارگذاری..." }];
+ }
+ if (errorProvinces) {
+ return [{ value: "error", label: "خطا در بارگذاری" }];
+ }
+ return [
+ { value: "", label: "کل کشور" },
+ ...provinces.map((province) => ({
+ value: province.id,
+ label: province.name_fa,
+ })),
+ ];
+ }, [provinces, errorProvinces, loadingProvinces]);
+ return (
+
+ );
+ },
+ Cell: ({ row }) => <>{row.original.province_fa}>,
+ };
+ return [
+ {
+ accessorKey: "id",
+ header: "کد یکتا",
+ id: "road_observeds__id",
+ enableColumnFilter: true,
+ datatype: "text",
+ filterMode: "equals",
+ sortDescFirst: false,
+ columnFilterModeOptions: ["equals", "contains"],
+ grow: false,
+ size: 100,
+ },
+ ...(hasCountryPermission ? [dynamicColumns] : []),
+ {
+ header: "اداره",
+ id: "road_observeds__edarate_shahri_id",
+ enableColumnFilter: true,
+ datatype: "numeric",
+ filterMode: "equals",
+ dependencyId: hasCountryPermission ? "road_observeds__province_id" : null,
+ grow: false,
+ size: 120,
+ ColumnSelectComponent: (props) => {
+ const { edaratList, loadingEdaratList, errorEdaratList } = useEdaratLists(
+ hasCountryPermission ? props.dependencyFieldValue.value : user.province_id
+ );
+ const [prevDependency, setPrevDependency] = useState(
+ hasCountryPermission ? props.dependencyFieldValue.value : user.province_id
+ );
+
+ const getColumnSelectOptions = useMemo(() => {
+ if (hasCountryPermission && props.dependencyFieldValue.value === "") {
+ return [{ value: "empty", label: "ابتدا استان را انتخاب کنید" }];
+ }
+ if (loadingEdaratList) {
+ return [{ value: "loading", label: "در حال بارگذاری..." }];
+ }
+ if (errorEdaratList) {
+ return [{ value: "error", label: "خطا در بارگذاری" }];
+ }
+ return [
+ { value: "", label: "کل ادارات" },
+ ...edaratList.map((edare) => ({
+ value: edare.id,
+ label: edare.name_fa,
+ })),
+ ];
+ }, [edaratList, loadingEdaratList, errorEdaratList]);
+ useEffect(() => {
+ if (hasCountryPermission) return;
+ if (prevDependency === props.dependencyFieldValue?.value) return;
+ props.handleChange({ ...props.filterParameters, value: "" });
+ setPrevDependency(props.dependencyFieldValue?.value);
+ }, [props.dependencyFieldValue?.value, hasCountryPermission]);
+ return (
+
+ );
+ },
+ Cell: ({ row }) => <>{row.original.edarate_shahri_name_fa}>,
+ },
+ {
+ header: "اطلاعات ثبت شده در سامانه سوانح",
+ id: "fkInfo",
+ enableColumnFilter: false,
+ enableSorting: false,
+ grow: false,
+ size: 50,
+ columns: [
+ {
+ accessorKey: "fk_RegisteredEventMessage",
+ header: "کد سوانح",
+ id: "fk_RegisteredEventMessage",
+ enableColumnFilter: true,
+ datatype: "text",
+ filterMode: "equals",
+ sortDescFirst: false,
+ columnFilterModeOptions: ["equals", "contains"],
+ grow: false,
+ size: 100,
+ },
+ {
+ accessorKey: "Title",
+ header: "موضوع گزارش",
+ id: "Title",
+ enableColumnFilter: false,
+ datatype: "text",
+ filterMode: "equals",
+ sortDescFirst: false,
+ columnFilterModeOptions: ["equals", "contains"],
+ grow: false,
+ size: 100,
+ },
+ {
+ accessorKey: "FeatureTypeTitle",
+ header: "نوع گزارش",
+ id: "FeatureTypeTitle",
+ enableColumnFilter: false,
+ datatype: "text",
+ filterMode: "equals",
+ sortDescFirst: false,
+ columnFilterModeOptions: ["equals", "contains"],
+ grow: false,
+ size: 100,
+ },
+ {
+ accessorKey: "Description",
+ header: "توضیح گزارش",
+ id: "Description",
+ enableColumnFilter: false,
+ datatype: "text",
+ filterMode: "equals",
+ sortDescFirst: false,
+ columnFilterModeOptions: ["equals", "contains"],
+ grow: false,
+ size: 100,
+ muiTableBodyCellProps: {
+ sx: {
+ borderLeft: "1px solid #e1e1e1",
+ py: 0,
+ "&:first-of-type": {
+ borderLeft: "unset",
+ },
+ },
+ },
+ Cell: ({ renderedCellValue }) => {
+ if (renderedCellValue) {
+ return (
+
+
+
+ );
+ }
+ return -;
+ },
+ },
+ {
+ header: "موقعیت",
+ id: "location",
+ enableColumnFilter: false,
+ enableSorting: false,
+ datatype: "array",
+ grow: false,
+ size: 100,
+ muiTableBodyCellProps: {
+ sx: {
+ borderLeft: "1px solid #e1e1e1",
+ py: 0,
+ "&:first-of-type": {
+ borderLeft: "unset",
+ },
+ },
+ },
+ Cell: ({ row }) => {
+ return (
+
+
+
+ );
+ },
+ },
+ {
+ accessorKey: "MobileForSendEventSms",
+ header: "شماره تماس گیرنده",
+ id: "MobileForSendEventSms",
+ enableColumnFilter: false,
+ datatype: "text",
+ filterMode: "equals",
+ sortDescFirst: false,
+ columnFilterModeOptions: ["equals", "contains"],
+ grow: false,
+ size: 100,
+ },
+ {
+ accessorFn: (row) => moment(row.StartTime_DateTime).locale("fa").format("HH:mm | yyyy/MM/DD"),
+ header: "تاریخ ثبت",
+ id: "StartTime_DateTime",
+ enableColumnFilter: true,
+ datatype: "date",
+ filterMode: "between",
+ grow: false,
+ size: 100,
+ },
+ ],
+ },
+ ];
+ }, []);
+
+ return (
+ <>
+
+ (
+
+ )}
+ />
+
+ >
+ );
+};
+export default FastReactList;
diff --git a/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/GetItemInfo/FastReactCode/Dialog/index.jsx b/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/GetItemInfo/FastReactCode/Dialog/index.jsx
index 013f73f..d7af56d 100644
--- a/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/GetItemInfo/FastReactCode/Dialog/index.jsx
+++ b/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/GetItemInfo/FastReactCode/Dialog/index.jsx
@@ -1,49 +1,49 @@
-import { Close, Edit } from "@mui/icons-material";
-import { Button, Chip, Dialog, Divider, IconButton } from "@mui/material";
-import FastReactList from "./List";
-import { useState, forwardRef } from "react";
-
-const FastReactDialog = forwardRef(({ onChange, value }, ref) => {
- const [openFastReactDialog, setOpenFastReactDialog] = useState(false);
-
- return (
- <>
-
- {value === "" ? (
-
- ) : (
- }
- onDelete={() => setOpenFastReactDialog(true)}
- />
- )}
-
-
- >
- );
-});
-
-FastReactDialog.displayName = "FastReactDialog";
-
-export default FastReactDialog;
+import { Close, Edit } from "@mui/icons-material";
+import { Button, Chip, Dialog, Divider, IconButton } from "@mui/material";
+import FastReactList from "./List";
+import { useState, forwardRef } from "react";
+
+const FastReactDialog = forwardRef(({ onChange, value }, ref) => {
+ const [openFastReactDialog, setOpenFastReactDialog] = useState(false);
+
+ return (
+ <>
+
+ {value === "" ? (
+
+ ) : (
+ }
+ onDelete={() => setOpenFastReactDialog(true)}
+ />
+ )}
+
+
+ >
+ );
+});
+
+FastReactDialog.displayName = "FastReactDialog";
+
+export default FastReactDialog;
diff --git a/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/GetItemInfo/FastReactCode/index.jsx b/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/GetItemInfo/FastReactCode/index.jsx
index 1545046..1f507c9 100644
--- a/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/GetItemInfo/FastReactCode/index.jsx
+++ b/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/GetItemInfo/FastReactCode/index.jsx
@@ -1,22 +1,22 @@
-import { Divider, Stack } from "@mui/material";
-import { Controller, useWatch } from "react-hook-form";
-import FastReactDialog from "./Dialog";
-
-const FastReactCode = ({ control }) => {
- const category_id = useWatch({ control, name: "category_id" });
-
- if (category_id != 3) return null;
-
- return (
- (
-
-
-
- )}
- />
- );
-};
-export default FastReactCode;
+import { Divider, Stack } from "@mui/material";
+import { Controller, useWatch } from "react-hook-form";
+import FastReactDialog from "./Dialog";
+
+const FastReactCode = ({ control }) => {
+ const category_id = useWatch({ control, name: "category_id" });
+
+ if (category_id != 3) return null;
+
+ return (
+ (
+
+
+
+ )}
+ />
+ );
+};
+export default FastReactCode;
diff --git a/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/GetItemInfo/index.jsx b/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/GetItemInfo/index.jsx
index 3b3b513..6e3afa0 100644
--- a/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/GetItemInfo/index.jsx
+++ b/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/GetItemInfo/index.jsx
@@ -1,153 +1,149 @@
-import PersianTextField from "@/core/components/PersianTextField";
-import SelectBox from "@/core/components/SelectBox";
-import StyledForm from "@/core/components/StyledForm";
-import { missionCategoryTypes } from "@/core/utils/missionCategoryTypes";
-import { missionRegions } from "@/core/utils/missionRegions";
-import { yupResolver } from "@hookform/resolvers/yup";
-import { ExitToApp } from "@mui/icons-material";
-import { Box, Button, DialogActions, DialogContent, Grid, Stack } from "@mui/material";
-import { Controller, useForm } from "react-hook-form";
-import { object, string } from "yup";
-import FastReactCode from "./FastReactCode";
-
-const validationSchema = object({
- explanation: string().required("موضوع را مشخص کنید!"),
- end_point: string().required("مقصد را مشخص کنید!"),
- region: string().required("محور ماموریت را مشخص کنید!"),
- category_id: string().required("نوع ماموریت را مشخص کنید!"),
- road_observed_id: string().when("category_id", {
- is: "3",
- then: (schema) => schema.required("کد یکتا شکایت را مشخص کنید!"),
- otherwise: (schema) => schema.notRequired(),
- }),
-});
-
-const GetItemInfo = ({ allData, setAllData, handlePrev, setTabState }) => {
- const defaultValues = {
- explanation: allData.explanation,
- end_point: allData.end_point,
- region: allData.region,
- category_id: allData.category_id,
- road_observed_id: allData.road_observed_id,
- };
-
- const { control, handleSubmit } = useForm({
- defaultValues,
- resolver: yupResolver(validationSchema),
- mode: "all",
- });
-
- const handleNext = (data) => {
- setAllData(data);
- setTabState((s) => s + 1);
- };
-
- return (
-
-
-
-
-
-
- (
-
- )}
- />
-
-
- (
-
- )}
- />
-
-
- (
-
- )}
- />
-
-
-
-
-
- {
- return (
-
- );
- }}
- />
-
-
-
-
-
-
- }
- >
- {"بستن"}
-
-
-
-
- );
-};
-export default GetItemInfo;
+import PersianTextField from "@/core/components/PersianTextField";
+import SelectBox from "@/core/components/SelectBox";
+import StyledForm from "@/core/components/StyledForm";
+import { missionCategoryTypes } from "@/core/utils/missionCategoryTypes";
+import { missionRegions } from "@/core/utils/missionRegions";
+import { yupResolver } from "@hookform/resolvers/yup";
+import { ExitToApp } from "@mui/icons-material";
+import { Box, Button, DialogActions, DialogContent, Grid, Stack } from "@mui/material";
+import { Controller, useForm } from "react-hook-form";
+import { object, string } from "yup";
+
+const validationSchema = object({
+ explanation: string().required("موضوع را مشخص کنید!"),
+ end_point: string().required("مقصد را مشخص کنید!"),
+ region: string().required("محور ماموریت را مشخص کنید!"),
+ category_id: string().required("نوع ماموریت را مشخص کنید!"),
+ road_observed_id: string().when("category_id", {
+ is: "3",
+ then: (schema) => schema.required("کد یکتا شکایت را مشخص کنید!"),
+ otherwise: (schema) => schema.notRequired(),
+ }),
+});
+
+const GetItemInfo = ({ allData, setAllData, handlePrev, setTabState }) => {
+ const defaultValues = {
+ explanation: allData.explanation,
+ end_point: allData.end_point,
+ region: allData.region,
+ category_id: allData.category_id,
+ road_observed_id: allData.road_observed_id,
+ };
+
+ const { control, handleSubmit } = useForm({
+ defaultValues,
+ resolver: yupResolver(validationSchema),
+ mode: "all",
+ });
+
+ const handleNext = (data) => {
+ setAllData(data);
+ setTabState((s) => s + 1);
+ };
+
+ return (
+
+
+
+
+
+
+ (
+
+ )}
+ />
+
+
+ (
+
+ )}
+ />
+
+
+ (
+
+ )}
+ />
+
+
+ {
+ return (
+
+ );
+ }}
+ />
+
+
+
+
+
+
+ }
+ >
+ {"بستن"}
+
+
+
+
+ );
+};
+export default GetItemInfo;
diff --git a/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/Verify/index.jsx b/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/Verify/index.jsx
index d79251d..bf57f0b 100644
--- a/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/Verify/index.jsx
+++ b/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/Verify/index.jsx
@@ -1,134 +1,134 @@
-import MapLoading from "@/core/components/MapLayer/Loading";
-import { missionCategoryTypes } from "@/core/utils/missionCategoryTypes";
-import { missionRegions } from "@/core/utils/missionRegions";
-import { Box, Button, Chip, DialogActions, DialogContent, Divider, Stack, Typography } from "@mui/material";
-import moment from "jalali-moment";
-import dynamic from "next/dynamic";
-import { useCallback } from "react";
-import ShowBound from "../../../../../../Actions/showBound";
-const MapLayer = dynamic(() => import("@/core/components/MapLayer"), {
- loading: () => ,
- ssr: false,
-});
-
-const Verify = ({ allData, handlePrev, submitForm, submitting }) => {
- const handleNext = useCallback(() => {
- submitForm(allData);
- }, [allData]);
-
- return (
- <>
-
-
-
-
-
-
-
-
-
-
-
-
-
- موضوع ماموریت
-
-
-
-
- محدوده
-
- r.id == allData.region).name_fa} />
-
-
- نوع ماموریت
-
- t.id == allData.category_id).name_fa}
- />
-
- {allData.category_id == 3 && (
-
- کد شکایت
-
-
-
- )}
-
- مقصد
-
-
-
-
- تاریخ شروع ماموریت
-
-
-
-
- تاریخ پایان ماموریت
-
- {allData.type == 1 ? (
-
- ) : (
-
- )}
-
-
-
-
-
-
-
- خودرو
-
-
-
-
- راننده
-
-
-
-
-
-
-
-
- {allData.rahdaran.length != 0 ? (
- allData.rahdaran.map((rahdar) => (
-
- {rahdar.name}
-
-
-
- ))
- ) : (
-
- همراهی ثبت نشده است
-
- )}
-
-
-
-
-
-
-
-
- >
- );
-};
-export default Verify;
+import MapLoading from "@/core/components/MapLayer/Loading";
+import { missionCategoryTypes } from "@/core/utils/missionCategoryTypes";
+import { missionRegions } from "@/core/utils/missionRegions";
+import { Box, Button, Chip, DialogActions, DialogContent, Divider, Stack, Typography } from "@mui/material";
+import moment from "jalali-moment";
+import dynamic from "next/dynamic";
+import { useCallback } from "react";
+import ShowBound from "../../../../../../Actions/showBound";
+const MapLayer = dynamic(() => import("@/core/components/MapLayer"), {
+ loading: () => ,
+ ssr: false,
+});
+
+const Verify = ({ allData, handlePrev, submitForm, submitting }) => {
+ const handleNext = useCallback(() => {
+ submitForm(allData);
+ }, [allData]);
+
+ return (
+ <>
+
+
+
+
+
+
+
+
+
+
+
+
+
+ موضوع ماموریت
+
+
+
+
+ محدوده
+
+ r.id == allData.region).name_fa} />
+
+
+ نوع ماموریت
+
+ t.id == allData.category_id).name_fa}
+ />
+
+ {allData.category_id == 3 && (
+
+ کد شکایت
+
+
+
+ )}
+
+ مقصد
+
+
+
+
+ تاریخ شروع ماموریت
+
+
+
+
+ تاریخ پایان ماموریت
+
+ {allData.type == 1 ? (
+
+ ) : (
+
+ )}
+
+
+
+
+
+
+
+ خودرو
+
+
+
+
+ راننده
+
+
+
+
+
+
+
+
+ {allData.rahdaran.length != 0 ? (
+ allData.rahdaran.map((rahdar) => (
+
+ {rahdar.name}
+
+
+
+ ))
+ ) : (
+
+ همراهی ثبت نشده است
+
+ )}
+
+
+
+
+
+
+
+
+ >
+ );
+};
+export default Verify;
diff --git a/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/index.jsx b/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/index.jsx
index 42f2c36..054e6e6 100644
--- a/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/index.jsx
+++ b/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/index.jsx
@@ -1,102 +1,102 @@
-import { AccessTime, InsertDriveFile, Route, Verified } from "@mui/icons-material";
-import { Box, Tab, Tabs } from "@mui/material";
-import { useReducer, useState } from "react";
-import Area from "./Area";
-import GetDateTime from "./GetDateTime";
-import GetItemInfo from "./GetItemInfo";
-import Verify from "./Verify";
-
-function TabPanel(props) {
- const { children, value, index } = props;
- return (
-
- {value === index && {children}}
-
- );
-}
-
-const reducer = (state, action) => {
- switch (action.type) {
- case "changeData":
- return { ...state, ...action.data };
- default:
- return state;
- }
-};
-
-const CreateForm = ({ defaultValues, submitForm, setOpen, submitting, oldBound }) => {
- const [allData, dispatch] = useReducer(reducer, defaultValues);
- const [tabState, setTabState] = useState(0);
- const handleClose = () => {
- setOpen(false);
- };
- const handleChangeTab = (event, newValue) => {
- setTabState(newValue);
- };
-
- const handlePrev = () => {
- if (tabState === 0) {
- handleClose();
- } else {
- setTabState((t) => t - 1);
- }
- };
-
- return (
- <>
-
- } label="مشخصات" />
- } label="زمانبندی" />
- } label="منطقه عملیاتی" />
- } label="بررسی نهایی" />
-
-
- {
- dispatch({ type: "changeData", data });
- }}
- handlePrev={handlePrev}
- setTabState={setTabState}
- />
-
-
- {
- dispatch({ type: "changeData", data });
- }}
- handlePrev={handlePrev}
- setTabState={setTabState}
- />
-
-
- {
- dispatch({ type: "changeData", data });
- }}
- handlePrev={handlePrev}
- setTabState={setTabState}
- />
-
-
-
-
- >
- );
-};
-export default CreateForm;
+import { AccessTime, InsertDriveFile, Route, Verified } from "@mui/icons-material";
+import { Box, Tab, Tabs } from "@mui/material";
+import { useReducer, useState } from "react";
+import Area from "./Area";
+import GetDateTime from "./GetDateTime";
+import GetItemInfo from "./GetItemInfo";
+import Verify from "./Verify";
+
+function TabPanel(props) {
+ const { children, value, index } = props;
+ return (
+
+ {value === index && {children}}
+
+ );
+}
+
+const reducer = (state, action) => {
+ switch (action.type) {
+ case "changeData":
+ return { ...state, ...action.data };
+ default:
+ return state;
+ }
+};
+
+const CreateForm = ({ defaultValues, submitForm, setOpen, submitting, oldBound }) => {
+ const [allData, dispatch] = useReducer(reducer, defaultValues);
+ const [tabState, setTabState] = useState(0);
+ const handleClose = () => {
+ setOpen(false);
+ };
+ const handleChangeTab = (event, newValue) => {
+ setTabState(newValue);
+ };
+
+ const handlePrev = () => {
+ if (tabState === 0) {
+ handleClose();
+ } else {
+ setTabState((t) => t - 1);
+ }
+ };
+
+ return (
+ <>
+
+ } label="مشخصات" />
+ } label="زمانبندی" />
+ } label="منطقه عملیاتی" />
+ } label="بررسی نهایی" />
+
+
+ {
+ dispatch({ type: "changeData", data });
+ }}
+ handlePrev={handlePrev}
+ setTabState={setTabState}
+ />
+
+
+ {
+ dispatch({ type: "changeData", data });
+ }}
+ handlePrev={handlePrev}
+ setTabState={setTabState}
+ />
+
+
+ {
+ dispatch({ type: "changeData", data });
+ }}
+ handlePrev={handlePrev}
+ setTabState={setTabState}
+ />
+
+
+
+
+ >
+ );
+};
+export default CreateForm;
diff --git a/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/index.jsx b/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/index.jsx
index 440c4e9..3c0f5da 100644
--- a/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/index.jsx
+++ b/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/index.jsx
@@ -1,83 +1,88 @@
-import { REQUEST_MISSION_CONTINUE_MISSION } from "@/core/utils/routes";
-import useRequest from "@/lib/hooks/useRequest";
-import moment from "jalali-moment";
-import { useState } from "react";
-import CreateForm from "./Form";
-
-const DialogAdd = ({ mutate, setOpen, oldBound, rahdaran, machine, row }) => {
- const [submitting, setSubmitting] = useState(false);
- const requestServer = useRequest({ notificationSuccess: true });
-
- const submitForm = async (result) => {
- setSubmitting(true);
- const bound = result.bound.getLatLngs();
- let area =
- result.bound_type == "polygon"
- ? bound.map((ring) => ring.map((latlng) => [latlng.lat, latlng.lng]))[0]
- : bound.map((latlng) => [latlng.lat, latlng.lng]);
-
- await requestServer(`${REQUEST_MISSION_CONTINUE_MISSION}/${row.original.id}`, "post", {
- data: {
- ...(result.rahdaran.length != 0 ? { rahdaran: result.rahdaran.map((r) => r.id) } : {}),
- machines: [result.machine.id],
- driver: result.driver.id,
- zone: result.region,
- type: result.type,
- ...(result.type == 1
- ? {
- end_date: `${result.end_date} ${moment(result.end_time).format("HH:mm")}`,
- }
- : {
- end_date: result.end_date,
- }),
- end_point: result.end_point,
- area: {
- type: result.bound_type,
- coordinates: area,
- },
- category_id: result.category_id,
- explanation: result.explanation,
- ...(result.category_id == 3
- ? {
- road_observed_id: result.road_observed_id,
- }
- : {}),
- },
- hasSidebarUpdate: true,
- })
- .then((response) => {
- mutate();
- setOpen(false);
- })
- .catch((error) => {})
- .finally(() => {
- setSubmitting(false);
- });
- };
-
- return (
- !r.is_driver),
- bound_type: "polygon",
- type: "",
- end_date: "",
- end_time: null,
- end_point: "",
- region: "",
- machine: machine,
- driver: rahdaran.find((r) => r.is_driver),
- }}
- oldBound={oldBound}
- submitForm={submitForm}
- submitting={submitting}
- open={open}
- setOpen={setOpen}
- mutate={mutate}
- />
- );
-};
-export default DialogAdd;
+import { REQUEST_MISSION_CONTINUE_MISSION } from "@/core/utils/routes";
+import useRequest from "@/lib/hooks/useRequest";
+import moment from "jalali-moment";
+import { useState } from "react";
+import CreateForm from "./Form";
+
+const DialogAdd = ({ mutate, setOpen, oldBound, rahdaran, machine, row }) => {
+ const [submitting, setSubmitting] = useState(false);
+ const requestServer = useRequest({ notificationSuccess: true });
+
+ const submitForm = async (result) => {
+ setSubmitting(true);
+ const bound = result.bound.getLatLngs();
+ let area =
+ result.bound_type === "polygon"
+ ? bound.map((ring) => ring.map((latlng) => [latlng.lng, latlng.lat]))[0]
+ : bound.map((latlng) => [latlng.lng, latlng.lat]);
+
+ // بستن polygon
+ if (result.bound_type === "polygon" && area.length > 0) {
+ const firstPoint = area[0];
+ area.push({ ...firstPoint });
+ }
+ await requestServer(`${REQUEST_MISSION_CONTINUE_MISSION}/${row.original.id}`, "post", {
+ data: {
+ ...(result.rahdaran.length != 0 ? { rahdaran: result.rahdaran.map((r) => r.id) } : {}),
+ machine_id: result.machine.id,
+ driver: result.driver.id,
+ zone: result.region,
+ type: result.type,
+ ...(result.type == 1
+ ? {
+ end_date: `${result.end_date} ${moment(result.end_time).format("HH:mm")}`,
+ }
+ : {
+ end_date: result.end_date,
+ }),
+ end_point: result.end_point,
+ area: {
+ type: result.bound_type,
+ coordinates: area,
+ },
+ category_id: result.category_id,
+ explanation: result.explanation,
+ ...(result.category_id == 3
+ ? {
+ road_observed_id: result.road_observed_id,
+ }
+ : {}),
+ },
+ hasSidebarUpdate: true,
+ })
+ .then((response) => {
+ mutate();
+ setOpen(false);
+ })
+ .catch((error) => {})
+ .finally(() => {
+ setSubmitting(false);
+ });
+ };
+
+ return (
+ !r.is_driver),
+ bound_type: "polyline",
+ type: "",
+ end_date: "",
+ end_time: null,
+ end_point: "",
+ region: "",
+ machine: machine,
+ driver: rahdaran.find((r) => r.is_driver),
+ }}
+ oldBound={oldBound}
+ submitForm={submitForm}
+ submitting={submitting}
+ open={open}
+ setOpen={setOpen}
+ mutate={mutate}
+ />
+ );
+};
+export default DialogAdd;
diff --git a/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/index.jsx b/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/index.jsx
index ff5b9c5..a2e6ff0 100644
--- a/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/index.jsx
+++ b/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/index.jsx
@@ -1,52 +1,60 @@
-import DialogLoading from "@/core/components/DialogLoading";
-import { GET_MACHINES_BY_ID, GET_RAHDARAN_BY_ID } from "@/core/utils/routes";
-import useRequest from "@/lib/hooks/useRequest";
-import L from "leaflet";
-import { useEffect, useMemo, useState } from "react";
-import DialogAdd from "./Dialog";
-
-const AddController = ({ row, mutate, setOpenAddDialog }) => {
- const [rahdaran, setRahdaran] = useState(null);
- const [rahdaranLoading, setRahdaranLoading] = useState(true);
- const [machine, setMachine] = useState(null);
- const [machineLoading, setMachineLoading] = useState(true);
- const requestServer = useRequest();
-
- useEffect(() => {
- setRahdaranLoading(true);
- requestServer(`${GET_RAHDARAN_BY_ID}/${row.original.id}`, "get")
- .then((response) => {
- setRahdaran(response.data.data);
- setRahdaranLoading(false);
- })
- .catch((e) => {
- setRahdaranLoading(false);
- });
- }, [row.original.id]);
-
- useEffect(() => {
- setMachineLoading(true);
- requestServer(`${GET_MACHINES_BY_ID}/${row.original.id}`, "get")
- .then((response) => {
- setMachine(response.data.data[0]);
- setMachineLoading(false);
- })
- .catch((e) => {
- setMachineLoading(false);
- });
- }, [row.original.id]);
-
- return rahdaranLoading || machineLoading ? (
-
- ) : (
-
- );
-};
-export default AddController;
+import DialogLoading from "@/core/components/DialogLoading";
+import { GET_MACHINES_BY_ID, GET_RAHDARAN_BY_ID } from "@/core/utils/routes";
+import useRequest from "@/lib/hooks/useRequest";
+import { useEffect, useMemo, useState } from "react";
+import DialogAdd from "./Dialog";
+
+const AddController = ({ row, mutate, setOpenAddDialog }) => {
+ const [rahdaran, setRahdaran] = useState(null);
+ const [rahdaranLoading, setRahdaranLoading] = useState(true);
+ const [machine, setMachine] = useState(null);
+ const [machineLoading, setMachineLoading] = useState(true);
+ const requestServer = useRequest();
+
+ useEffect(() => {
+ setRahdaranLoading(true);
+ requestServer(`${GET_RAHDARAN_BY_ID}/${row.original.id}`, "get")
+ .then((response) => {
+ setRahdaran(response.data.data);
+ setRahdaranLoading(false);
+ })
+ .catch((e) => {
+ setRahdaranLoading(false);
+ });
+ }, [row.original.id]);
+
+ useEffect(() => {
+ setMachineLoading(true);
+ requestServer(`${GET_MACHINES_BY_ID}/${row.original.id}`, "get")
+ .then((response) => {
+ setMachine(response.data.data[0]);
+ setMachineLoading(false);
+ })
+ .catch((e) => {
+ setMachineLoading(false);
+ });
+ }, [row.original.id]);
+
+ const convertedArea = useMemo(() => {
+ if (!row.original.area) return null;
+
+ return {
+ ...row.original.area,
+ coordinates: row.original.area.coordinates.map(([lng, lat]) => [lat, lng]),
+ };
+ }, [row.original.area]);
+
+ return rahdaranLoading || machineLoading ? (
+
+ ) : (
+
+ );
+};
+export default AddController;
diff --git a/src/components/dashboard/roadMissions/operator/RowActions/Add/index.jsx b/src/components/dashboard/roadMissions/operator/RowActions/Add/index.jsx
index 7da989f..a4c8b28 100644
--- a/src/components/dashboard/roadMissions/operator/RowActions/Add/index.jsx
+++ b/src/components/dashboard/roadMissions/operator/RowActions/Add/index.jsx
@@ -1,41 +1,41 @@
-import { Add, Close } from "@mui/icons-material";
-import { Dialog, IconButton, Tooltip } from "@mui/material";
-import { useState } from "react";
-import AddController from "./AddController";
-
-const AddDialog = ({ row, mutate }) => {
- const [openAddDialog, setOpenAddDialog] = useState(false);
-
- return (
- <>
-
- {
- setOpenAddDialog(true);
- }}
- >
-
-
-
-
- >
- );
-};
-export default AddDialog;
+import { Add, Close } from "@mui/icons-material";
+import { Dialog, IconButton, Tooltip } from "@mui/material";
+import { useState } from "react";
+import AddController from "./AddController";
+
+const AddDialog = ({ row, mutate }) => {
+ const [openAddDialog, setOpenAddDialog] = useState(false);
+
+ return (
+ <>
+
+ {
+ setOpenAddDialog(true);
+ }}
+ >
+
+
+
+
+ >
+ );
+};
+export default AddDialog;
diff --git a/src/components/dashboard/roadMissions/operator/RowActions/DescriptionDialog/index.jsx b/src/components/dashboard/roadMissions/operator/RowActions/DescriptionDialog/index.jsx
new file mode 100644
index 0000000..3941b37
--- /dev/null
+++ b/src/components/dashboard/roadMissions/operator/RowActions/DescriptionDialog/index.jsx
@@ -0,0 +1,59 @@
+import {
+ Button,
+ Card,
+ CardContent,
+ Dialog,
+ DialogActions,
+ DialogContent,
+ DialogTitle,
+ IconButton,
+ Tooltip,
+ Typography,
+} from "@mui/material";
+import RemoveRedEyeIcon from "@mui/icons-material/RemoveRedEye";
+import { useState } from "react";
+
+const DescriptionDialog = ({ description }) => {
+ const [openDescriptionDialog, setOpenDescriptionDialog] = useState(false);
+ return (
+ <>
+
+ setOpenDescriptionDialog(true)}>
+
+
+
+
+ >
+ );
+};
+export default DescriptionDialog;
diff --git a/src/components/dashboard/roadMissions/operator/RowActions/Edit/EditController/index.jsx b/src/components/dashboard/roadMissions/operator/RowActions/Edit/EditController/index.jsx
index bfc214a..949fbaa 100644
--- a/src/components/dashboard/roadMissions/operator/RowActions/Edit/EditController/index.jsx
+++ b/src/components/dashboard/roadMissions/operator/RowActions/Edit/EditController/index.jsx
@@ -7,13 +7,15 @@ import L from "leaflet";
import { GET_RAHDARAN_BY_ID, UPDATE_REQUEST_MISSION } from "@/core/utils/routes";
const EditController = ({ row, mutate, openEditDialog, setOpenEditDialog }) => {
+ const latLngs = useMemo(() => {
+ return row.original.area.coordinates.map(([lng, lat]) => [lat, lng]);
+ }, [row.original.area.coordinates]);
+
const bound = useMemo(
- () =>
- row.original.area.type == "polygon"
- ? L.polygon([...row.original.area.coordinates])
- : L.polyline([...row.original.area.coordinates]),
- [row.original.area]
+ () => (row.original.area.type === "polygon" ? L.polygon(latLngs) : L.polyline(latLngs)),
+ [row.original.area.type, latLngs]
);
+
const [submitting, setSubmitting] = useState(false);
const [rahdaran, setRahdaran] = useState(null);
const [rahdaranLoading, setRahdaranLoading] = useState(true);
@@ -35,7 +37,6 @@ const EditController = ({ row, mutate, openEditDialog, setOpenEditDialog }) => {
setSubmitting(true);
const bound = result.bound.getLatLngs();
let area = bound.map((ring) => ring.map((latlng) => [latlng.lat, latlng.lng]));
-
await requestServer(`${UPDATE_REQUEST_MISSION}/${row.original.id}`, "post", {
data: {
explanation: result.explanation,
diff --git a/src/components/dashboard/roadMissions/operator/RowActions/Machines/MachinesContent.jsx b/src/components/dashboard/roadMissions/operator/RowActions/Machines/MachinesContent.jsx
index 3ee5a3c..7465d53 100644
--- a/src/components/dashboard/roadMissions/operator/RowActions/Machines/MachinesContent.jsx
+++ b/src/components/dashboard/roadMissions/operator/RowActions/Machines/MachinesContent.jsx
@@ -1,73 +1,73 @@
-import DialogLoading from "@/core/components/DialogLoading";
-import ShowPlak from "@/core/components/ShowPlak";
-import { GET_MACHINES_BY_ID } from "@/core/utils/routes";
-import useRequest from "@/lib/hooks/useRequest";
-import {
- DialogContent,
- Table,
- TableBody,
- TableCell,
- TableContainer,
- TableHead,
- TableRow,
- Typography,
-} from "@mui/material";
-import { useEffect, useState } from "react";
-
-const MachinesContent = ({ rowId }) => {
- const [loading, setLoading] = useState(true);
- const [data, setData] = useState(null);
- const request = useRequest();
-
- useEffect(() => {
- const fetchData = async () => {
- try {
- setLoading(true);
- const response = await request(`${GET_MACHINES_BY_ID}/${rowId}`);
- setData(response.data.data);
- } catch (error) {
- } finally {
- setLoading(false);
- }
- };
-
- fetchData();
- }, [rowId]);
-
- return (
- <>
-
- {loading ? (
-
- ) : data ? (
-
-
-
-
- کد ماشین
- نام خودرو
-
-
-
- {data.map((machine) => {
- return (
-
- {machine.machine_code}
- {machine.car_name}
-
- );
- })}
-
-
-
- ) : (
- اطلاعات خودرویی در سامانه یافت نشد
- )}
-
- >
- );
-};
-export default MachinesContent;
+import DialogLoading from "@/core/components/DialogLoading";
+import ShowPlak from "@/core/components/ShowPlak";
+import { GET_MACHINES_BY_ID } from "@/core/utils/routes";
+import useRequest from "@/lib/hooks/useRequest";
+import {
+ DialogContent,
+ Table,
+ TableBody,
+ TableCell,
+ TableContainer,
+ TableHead,
+ TableRow,
+ Typography,
+} from "@mui/material";
+import { useEffect, useState } from "react";
+
+const MachinesContent = ({ rowId }) => {
+ const [loading, setLoading] = useState(true);
+ const [data, setData] = useState(null);
+ const request = useRequest();
+
+ useEffect(() => {
+ const fetchData = async () => {
+ try {
+ setLoading(true);
+ const response = await request(`${GET_MACHINES_BY_ID}/${rowId}`);
+ setData(response.data.data);
+ } catch (error) {
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ fetchData();
+ }, [rowId]);
+
+ return (
+ <>
+
+ {loading ? (
+
+ ) : data ? (
+
+
+
+
+ کد ماشین
+ نام خودرو
+
+
+
+ {data.map((machine) => {
+ return (
+
+ {machine.machine_code}
+ {machine.car_name}
+
+ );
+ })}
+
+
+
+ ) : (
+ اطلاعات خودرویی در سامانه یافت نشد
+ )}
+
+ >
+ );
+};
+export default MachinesContent;
diff --git a/src/components/dashboard/roadMissions/operator/RowActions/Machines/index.jsx b/src/components/dashboard/roadMissions/operator/RowActions/Machines/index.jsx
index 395b276..0fa8a07 100644
--- a/src/components/dashboard/roadMissions/operator/RowActions/Machines/index.jsx
+++ b/src/components/dashboard/roadMissions/operator/RowActions/Machines/index.jsx
@@ -1,38 +1,38 @@
-import { Button, Dialog, DialogActions, DialogTitle, IconButton, Tooltip } from "@mui/material";
-import DirectionsCarIcon from "@mui/icons-material/DirectionsCar";
-import { useState } from "react";
-import MachinesContent from "./MachinesContent";
-
-const MachinesDialog = ({ rowId }) => {
- const [openMachinesDialog, setOpenMachinesDialog] = useState(false);
- return (
- <>
-
- setOpenMachinesDialog(true)}>
-
-
-
-
- >
- );
-};
-export default MachinesDialog;
+import { Button, Dialog, DialogActions, DialogTitle, IconButton, Tooltip } from "@mui/material";
+import DirectionsCarIcon from "@mui/icons-material/DirectionsCar";
+import { useState } from "react";
+import MachinesContent from "./MachinesContent";
+
+const MachinesDialog = ({ rowId }) => {
+ const [openMachinesDialog, setOpenMachinesDialog] = useState(false);
+ return (
+ <>
+
+ setOpenMachinesDialog(true)}>
+
+
+
+
+ >
+ );
+};
+export default MachinesDialog;
diff --git a/src/components/dashboard/roadMissions/operator/RowActions/Rahdaran/RahdaranContent.jsx b/src/components/dashboard/roadMissions/operator/RowActions/Rahdaran/RahdaranContent.jsx
index 46001aa..74622a0 100644
--- a/src/components/dashboard/roadMissions/operator/RowActions/Rahdaran/RahdaranContent.jsx
+++ b/src/components/dashboard/roadMissions/operator/RowActions/Rahdaran/RahdaranContent.jsx
@@ -1,74 +1,74 @@
-import DialogLoading from "@/core/components/DialogLoading";
-import { GET_RAHDARAN_BY_ID } from "@/core/utils/routes";
-import useRequest from "@/lib/hooks/useRequest";
-import {
- DialogContent,
- Table,
- TableBody,
- TableCell,
- TableContainer,
- TableHead,
- TableRow,
- Typography,
-} from "@mui/material";
-import { useEffect, useState } from "react";
-
-const RahdaranContent = ({ rowId }) => {
- const [loading, setLoading] = useState(true);
- const [data, setData] = useState(null);
- const request = useRequest();
-
- useEffect(() => {
- const fetchData = async () => {
- try {
- setLoading(true);
- const response = await request(`${GET_RAHDARAN_BY_ID}/${rowId}`);
- setData(response.data.data);
- } catch (error) {
- } finally {
- setLoading(false);
- }
- };
-
- fetchData();
- }, [rowId]);
-
- return (
- <>
-
- {loading ? (
-
- ) : data ? (
-
-
-
-
- کد ملی
- نام
- نقش
-
-
-
- {data.map((rahdar) => {
- return (
-
- {rahdar.code}
- {rahdar.name}
- {rahdar.is_driver ? "راننده" : "همراه"}
-
- );
- })}
-
-
-
- ) : (
- اطلاعات راهداران در سامانه یافت نشد
- )}
-
- >
- );
-};
-export default RahdaranContent;
+import DialogLoading from "@/core/components/DialogLoading";
+import { GET_RAHDARAN_BY_ID } from "@/core/utils/routes";
+import useRequest from "@/lib/hooks/useRequest";
+import {
+ DialogContent,
+ Table,
+ TableBody,
+ TableCell,
+ TableContainer,
+ TableHead,
+ TableRow,
+ Typography,
+} from "@mui/material";
+import { useEffect, useState } from "react";
+
+const RahdaranContent = ({ rowId }) => {
+ const [loading, setLoading] = useState(true);
+ const [data, setData] = useState(null);
+ const request = useRequest();
+
+ useEffect(() => {
+ const fetchData = async () => {
+ try {
+ setLoading(true);
+ const response = await request(`${GET_RAHDARAN_BY_ID}/${rowId}`);
+ setData(response.data.data);
+ } catch (error) {
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ fetchData();
+ }, [rowId]);
+
+ return (
+ <>
+
+ {loading ? (
+
+ ) : data ? (
+
+
+
+
+ کد ملی
+ نام
+ نقش
+
+
+
+ {data.map((rahdar) => {
+ return (
+
+ {rahdar.code}
+ {rahdar.name}
+ {rahdar.is_driver ? "راننده" : "همراه"}
+
+ );
+ })}
+
+
+
+ ) : (
+ اطلاعات راهداران در سامانه یافت نشد
+ )}
+
+ >
+ );
+};
+export default RahdaranContent;
diff --git a/src/components/dashboard/roadMissions/operator/RowActions/Rahdaran/index.jsx b/src/components/dashboard/roadMissions/operator/RowActions/Rahdaran/index.jsx
index b27009d..47a99e9 100644
--- a/src/components/dashboard/roadMissions/operator/RowActions/Rahdaran/index.jsx
+++ b/src/components/dashboard/roadMissions/operator/RowActions/Rahdaran/index.jsx
@@ -1,38 +1,38 @@
-import { Button, Dialog, DialogActions, DialogTitle, IconButton, Tooltip } from "@mui/material";
-import GroupsIcon from "@mui/icons-material/Groups";
-import { useState } from "react";
-import RahdaranContent from "./RahdaranContent";
-
-const RahdaranDialog = ({ rowId }) => {
- const [openRahdaranDialog, setOpenRahdaranDialog] = useState(false);
- return (
- <>
-
- setOpenRahdaranDialog(true)}>
-
-
-
-
- >
- );
-};
-export default RahdaranDialog;
+import { Button, Dialog, DialogActions, DialogTitle, IconButton, Tooltip } from "@mui/material";
+import GroupsIcon from "@mui/icons-material/Groups";
+import { useState } from "react";
+import RahdaranContent from "./RahdaranContent";
+
+const RahdaranDialog = ({ rowId }) => {
+ const [openRahdaranDialog, setOpenRahdaranDialog] = useState(false);
+ return (
+ <>
+
+ setOpenRahdaranDialog(true)}>
+
+
+
+
+ >
+ );
+};
+export default RahdaranDialog;
diff --git a/src/components/dashboard/roadMissions/operator/index.jsx b/src/components/dashboard/roadMissions/operator/index.jsx
index 148167b..20b08f1 100644
--- a/src/components/dashboard/roadMissions/operator/index.jsx
+++ b/src/components/dashboard/roadMissions/operator/index.jsx
@@ -6,7 +6,7 @@ import OperatorList from "./OperatorList";
const OperatorPage = () => {
return (
-
+
);
diff --git a/src/components/dashboard/roadMissions/reports/ExcelPrint/index.jsx b/src/components/dashboard/roadMissions/reports/ExcelPrint/index.jsx
new file mode 100644
index 0000000..5a514fb
--- /dev/null
+++ b/src/components/dashboard/roadMissions/reports/ExcelPrint/index.jsx
@@ -0,0 +1,72 @@
+"use client";
+import { Button, CircularProgress, IconButton, useMediaQuery } from "@mui/material";
+import { useMemo, useState } from "react";
+import moment from "jalali-moment";
+import FileSaver from "file-saver";
+import DescriptionIcon from "@mui/icons-material/Description";
+import useRequest from "@/lib/hooks/useRequest";
+import { useTheme } from "@emotion/react";
+import { EXPORT_COUNTRY_ROAD_PATROL_REPORTS, EXPORT_PROVINCE_ROAD_PATROL_REPORTS } from "@/core/utils/routes";
+
+const PrintExcel = ({ table, filterData }) => {
+ const theme = useTheme();
+ const isMobile = useMediaQuery(theme.breakpoints.down("sm"));
+ const [loading, setLoading] = useState(false);
+ const requestServer = useRequest({ notificationSuccess: true });
+ const activeFilters = Object.entries(filterData).reduce((acc, [key, filter]) => {
+ if (filter.value) {
+ acc.push({ id: filter.id, value: filter.value });
+ }
+ return acc;
+ }, []);
+
+ const filterParams = useMemo(() => {
+ const params = new URLSearchParams();
+ activeFilters.length > 0 &&
+ activeFilters.map((filter, index) => {
+ params.set(`${filter.id}`, filter.value);
+ });
+ return params;
+ }, [activeFilters]);
+
+ const clickHandler = () => {
+ setLoading(true);
+ const CountryOrProvince = activeFilters.find((item) => item.id === "province_id");
+ const requestUrl =
+ CountryOrProvince.value === "-1" ? EXPORT_COUNTRY_ROAD_PATROL_REPORTS : EXPORT_PROVINCE_ROAD_PATROL_REPORTS;
+ requestServer(`${requestUrl}?${filterParams}`, "get", {
+ requestOptions: { responseType: "blob" },
+ })
+ .then((response) => {
+ const filename = `خروجی کارتابل گزارشات گشت راهداری تاریخ_${moment().format("jYYYY_jMM_jDD")}.xlsx`;
+ FileSaver.saveAs(response.data, filename);
+ })
+ .catch(() => {})
+ .finally(() => {
+ setLoading(false);
+ });
+ };
+
+ return (
+ <>
+ {isMobile ? (
+
+
+
+ ) : (
+ : }
+ onClick={clickHandler}
+ >
+ خروجی اکسل
+
+ )}
+ >
+ );
+};
+export default PrintExcel;
diff --git a/src/components/dashboard/roadMissions/reports/ReportLists.jsx b/src/components/dashboard/roadMissions/reports/ReportLists.jsx
new file mode 100644
index 0000000..fd7d606
--- /dev/null
+++ b/src/components/dashboard/roadMissions/reports/ReportLists.jsx
@@ -0,0 +1,84 @@
+"use client";
+import DataTableWithAuth from "@/core/components/DataTableWithAuth";
+import { Box } from "@mui/material";
+import { useMemo } from "react";
+import Toolbar from "./Toolbar";
+
+const ReportLists = ({ data, specialFilter }) => {
+ const columns = useMemo(() => {
+ return [
+ {
+ accessorKey: "province_name",
+ header: "اداره کل",
+ id: "province_name",
+ enableColumnFilter: false,
+ enableSorting: false,
+ datatype: "text",
+ grow: false,
+ size: 50,
+ },
+ {
+ accessorKey: "no_mission_count",
+ header: "تردد بدون ماموریت",
+ id: "no_mission_count",
+ enableColumnFilter: false,
+ enableSorting: false,
+ datatype: "text",
+ grow: false,
+ size: 50,
+ muiTableBodyCellProps: {
+ sx: {
+ textAlign: "center",
+ borderLeft: "1px solid #e1e1e1",
+ py: 0,
+ "&:first-of-type": {
+ borderLeft: "unset",
+ },
+ },
+ },
+ Cell: ({ renderedCellValue }) => {
+ return renderedCellValue;
+ },
+ },
+ {
+ accessorKey: "out_of_area_count",
+ header: "تردد خارج محدوده",
+ id: "out_of_area_count",
+ enableColumnFilter: false,
+ enableSorting: false,
+ datatype: "text",
+ grow: false,
+ size: 50,
+ muiTableBodyCellProps: {
+ sx: {
+ textAlign: "center",
+ borderLeft: "1px solid #e1e1e1",
+ py: 0,
+ "&:first-of-type": {
+ borderLeft: "unset",
+ },
+ },
+ },
+ Cell: ({ renderedCellValue }) => {
+ return renderedCellValue;
+ },
+ },
+ ];
+ }, []);
+
+ return (
+
+
+
+ );
+};
+
+export default ReportLists;
diff --git a/src/components/dashboard/roadMissions/reports/Search/FromDateController.jsx b/src/components/dashboard/roadMissions/reports/Search/FromDateController.jsx
new file mode 100644
index 0000000..45002e1
--- /dev/null
+++ b/src/components/dashboard/roadMissions/reports/Search/FromDateController.jsx
@@ -0,0 +1,28 @@
+import { Controller } from "react-hook-form";
+import MuiDatePicker from "@/core/components/MuiDatePicker";
+import React from "react";
+import moment from "jalali-moment";
+
+const FromDateController = ({ control }) => {
+ return (
+ (
+ {
+ const formattedDate = moment(new Date(newValue)).locale("en").format("YYYY-MM-DD");
+ onChange(formattedDate); // Update the field value in react-hook-form
+ }}
+ helperText={error ? error.message : null}
+ />
+ )}
+ />
+ );
+};
+export default FromDateController;
diff --git a/src/components/dashboard/roadMissions/reports/Search/SearchReportField.jsx b/src/components/dashboard/roadMissions/reports/Search/SearchReportField.jsx
new file mode 100644
index 0000000..5c6aa23
--- /dev/null
+++ b/src/components/dashboard/roadMissions/reports/Search/SearchReportField.jsx
@@ -0,0 +1,45 @@
+import { Button, Grid, LinearProgress, Typography } from "@mui/material";
+import SearchIcon from "@mui/icons-material/Search";
+import React from "react";
+import FromDateController from "./FromDateController";
+import ToDateController from "./ToDateController";
+import SelectProvince from "./SelectProvince";
+import { Controller } from "react-hook-form";
+
+const SearchReportField = ({ control, hasProvincesPermission }) => {
+ return (
+
+
+
+
+
+
+
+ {hasProvincesPermission && (
+
+
+
+ )}
+
+ (
+ }
+ fullWidth
+ >
+ {isSubmitting ? "درحال دریافت اطلاعات" : "جستجو"}
+
+ )}
+ />
+
+
+ );
+};
+
+export default SearchReportField;
diff --git a/src/components/dashboard/roadMissions/reports/Search/SelectProvince.jsx b/src/components/dashboard/roadMissions/reports/Search/SelectProvince.jsx
new file mode 100644
index 0000000..7f738bc
--- /dev/null
+++ b/src/components/dashboard/roadMissions/reports/Search/SelectProvince.jsx
@@ -0,0 +1,47 @@
+import { Controller } from "react-hook-form";
+import MuiDatePicker from "@/core/components/MuiDatePicker";
+import React from "react";
+import { FormControl, FormHelperText, InputLabel, LinearProgress, MenuItem, Select, Typography } from "@mui/material";
+import useProvinces from "@/lib/hooks/useProvince";
+
+const SelectProvince = ({ control }) => {
+ const { provinces, loadingProvinces, errorProvinces } = useProvinces();
+ return (
+ (
+
+ استان
+
+ {error && {error.message}}
+
+ )}
+ />
+ );
+};
+export default SelectProvince;
diff --git a/src/components/dashboard/roadMissions/reports/Search/ToDateController.jsx b/src/components/dashboard/roadMissions/reports/Search/ToDateController.jsx
new file mode 100644
index 0000000..4b5f2a8
--- /dev/null
+++ b/src/components/dashboard/roadMissions/reports/Search/ToDateController.jsx
@@ -0,0 +1,30 @@
+import { Controller, useWatch } from "react-hook-form";
+import MuiDatePicker from "@/core/components/MuiDatePicker";
+import React from "react";
+import moment from "jalali-moment";
+
+const ToDateController = ({ control }) => {
+ const minDate = useWatch({ control, name: "from_date" });
+ return (
+ (
+ {
+ const formattedDate = moment(new Date(newValue)).locale("en").format("YYYY-MM-DD");
+ onChange(formattedDate); // Update the field value in react-hook-form
+ }}
+ helperText={error ? error.message : null}
+ />
+ )}
+ />
+ );
+};
+export default ToDateController;
diff --git a/src/components/dashboard/roadMissions/reports/Search/index.jsx b/src/components/dashboard/roadMissions/reports/Search/index.jsx
new file mode 100644
index 0000000..9d504f2
--- /dev/null
+++ b/src/components/dashboard/roadMissions/reports/Search/index.jsx
@@ -0,0 +1,13 @@
+import StyledForm from "@/core/components/StyledForm";
+import SearchReportField from "./SearchReportField";
+
+const SearchReportList = ({ handleSubmit, onSearchSubmit, control, hasProvincesPermission }) => {
+ return (
+ <>
+
+
+
+ >
+ );
+};
+export default SearchReportList;
diff --git a/src/components/dashboard/roadMissions/reports/Toolbar.jsx b/src/components/dashboard/roadMissions/reports/Toolbar.jsx
new file mode 100644
index 0000000..3e5ab8c
--- /dev/null
+++ b/src/components/dashboard/roadMissions/reports/Toolbar.jsx
@@ -0,0 +1,11 @@
+import PrintExcel from "./ExcelPrint";
+import { Box } from "@mui/material";
+
+const Toolbar = ({ table, filterData, mutate }) => {
+ return (
+
+
+
+ );
+};
+export default Toolbar;
diff --git a/src/components/dashboard/roadMissions/reports/index.jsx b/src/components/dashboard/roadMissions/reports/index.jsx
new file mode 100644
index 0000000..83daf1a
--- /dev/null
+++ b/src/components/dashboard/roadMissions/reports/index.jsx
@@ -0,0 +1,134 @@
+"use client";
+import PageTitle from "@/core/components/PageTitle";
+import { LinearProgress, Stack } from "@mui/material";
+import SearchReportList from "./Search";
+import { useEffect, useState } from "react";
+import ReportLists from "./ReportLists";
+import useRequest from "@/lib/hooks/useRequest";
+import { GET_CITY_ACTIVITY_REPORT, GET_MISSION_CITY_ACTIVITY_REPORT } from "@/core/utils/routes";
+import moment from "jalali-moment";
+import * as yup from "yup";
+import { useForm } from "react-hook-form";
+import { yupResolver } from "@hookform/resolvers/yup";
+import { usePermissions } from "@/lib/hooks/usePermissions";
+import { useAuth } from "@/lib/contexts/auth";
+
+const ReportPage = () => {
+ const [data, setData] = useState(null);
+ const { data: userPermissions } = usePermissions();
+ const { user } = useAuth();
+ const requestServer = useRequest();
+ const hasProvincesPermission = userPermissions?.includes("all"); // TODO : change permission
+
+ const defaultValues = {
+ from_date: moment(new Date()).format("YYYY-MM-DD"),
+ date_to: moment(new Date()).format("YYYY-MM-DD"),
+ province_id: hasProvincesPermission ? "-1" : user.province_id,
+ };
+ const defaultFilter = [
+ { value: `${defaultValues.province_id}`, datatype: "numeric", id: "province_id", fn: "equals" },
+ { value: `${defaultValues.from_date}`, datatype: "date", id: "from_date", fn: "between" },
+ { value: `${defaultValues.date_to}`, datatype: "date", id: "date_to", fn: "between" },
+ ];
+ const [specialFilter, setSpecialFilter] = useState(defaultFilter);
+
+ const onSearchSubmit = async (data) => {
+ const params = new URLSearchParams();
+ params.set("from_date", `${data.from_date}`);
+ params.set("date_to", `${data.date_to}`);
+ setSpecialFilter([
+ { value: `${data.province_id}`, datatype: "numeric", id: "province_id", fn: "equals" },
+ { value: `${data.from_date}`, datatype: "date", id: "from_date", fn: "between" },
+ { value: `${data.date_to}`, datatype: "date", id: "date_to", fn: "between" },
+ ]);
+ // if (data.province_id === "-1") {
+ try {
+ params.set("province_id", `${data.province_id}`);
+ const response = await requestServer(`${GET_CITY_ACTIVITY_REPORT}?${params}`);
+ const result = response.data.data;
+ const nationalReportForItem = result.activities.find((report) => report.province_id === "-1");
+ const nationalReport = {
+ edare_name: "کل کشور",
+ ...nationalReportForItem,
+ };
+
+ setData({
+ data: [
+ nationalReport,
+ ...result.provinces.map((province) => {
+ const filteredReports = result.activities.find((report) => report.province_id == province.id);
+ console.log(filteredReports);
+ return {
+ ...filteredReports,
+ edare_name: province.name_fa,
+ };
+ }),
+ ],
+ filters: data,
+ });
+ } catch (e) {}
+ // } else {
+ // try {
+ // params.set("province_id", `${data.province_id}`);
+ // const response = await requestServer(`${GET_MISSION_CITY_ACTIVITY_REPORT}?${params}`);
+ // const result = response.data.data;
+ // const nationalReportForItem = result.activities.find((report) => report.edare_id === "-1");
+ // const nationalReport = {
+ // ...nationalReportForItem,
+ // edare_name: "کل استان",
+ // };
+ // setData({
+ // data: [
+ // nationalReport,
+ // ...result.edarateShahri.map((edare) => {
+ // const filteredReports = result.activities.find((report) => report.edare_id == edare.id);
+ // return {
+ // edare_name: edare.name_fa,
+ // ...filteredReports,
+ // };
+ // }),
+ // ],
+ // filters: data,
+ // });
+ // } catch (e) {}
+ // }
+ };
+
+ useEffect(() => {
+ if (!userPermissions) return;
+ onSearchSubmit(defaultValues);
+ }, [userPermissions]);
+
+ const validationSchema = yup.object().shape({
+ from_date: yup
+ .string()
+ .required("تاریخ شروع الزامی است!")
+ .matches(/^\d{4}-\d{2}-\d{2}$/, "تاریخ شروع الزامی است!")
+ .test("is-valid-date", "تاریخ شروع معتبر نیست!", (value) => moment(value, "YYYY-MM-DD", true).isValid()),
+ date_to: yup
+ .string()
+ .required("تاریخ پایان الزامی است!")
+ .matches(/^\d{4}-\d{2}-\d{2}$/, "تاریخ پایان الزامی است!")
+ .test("is-valid-date", "تاریخ پایان معتبر نیست!", (value) => moment(value, "YYYY-MM-DD", true).isValid()),
+ province_id: yup.string().nullable(),
+ });
+
+ const { control, handleSubmit } = useForm({
+ defaultValues,
+ resolver: yupResolver(validationSchema),
+ mode: "all",
+ });
+ return (
+
+
+
+ {!data ? : }
+
+ );
+};
+export default ReportPage;
diff --git a/src/components/dashboard/roadMissions/transportation/Actions/showArea/index.jsx b/src/components/dashboard/roadMissions/transportation/Actions/showArea/index.jsx
index be4ee7a..ef25c6b 100644
--- a/src/components/dashboard/roadMissions/transportation/Actions/showArea/index.jsx
+++ b/src/components/dashboard/roadMissions/transportation/Actions/showArea/index.jsx
@@ -6,10 +6,15 @@ import ShowBound from "../showBound";
import L from "leaflet";
const ShowArea = ({ area }) => {
+ const latLngs = useMemo(() => {
+ return area.coordinates.map(([lng, lat]) => [lat, lng]);
+ }, [area.coordinates]);
+
const bound = useMemo(
- () => (area.type == "polygon" ? L.polygon([...area.coordinates]) : L.polyline([...area.coordinates])),
- [area]
+ () => (area.type === "polygon" ? L.polygon(latLngs) : L.polyline(latLngs)),
+ [area.type, latLngs]
);
+
const [openAreaDialog, setOpenAreaDialog] = useState(false);
return (
diff --git a/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/DriversDialog/DriversSearch/Form/index.jsx b/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/DriversDialog/DriversSearch/Form/index.jsx
index 93bb1d6..9dbe4ed 100644
--- a/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/DriversDialog/DriversSearch/Form/index.jsx
+++ b/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/DriversDialog/DriversSearch/Form/index.jsx
@@ -1,61 +1,61 @@
-import RahdarNameOrCode from "@/core/components/RahdarNameOrCode";
-import StyledForm from "@/core/components/StyledForm";
-import { yupResolver } from "@hookform/resolvers/yup";
-import { Done } from "@mui/icons-material";
-import { Button, Stack } from "@mui/material";
-import { Controller, useForm } from "react-hook-form";
-import { object } from "yup";
-
-const schema = object().shape({
- rahdar: object().required("همراه الزامی است."),
-});
-const DriverForm = ({ setDriver, setOpenDriversDialog }) => {
- const defaultValues = {
- rahdar: null,
- };
-
- const {
- control,
- handleSubmit,
- formState: { isSubmitting, isValid },
- } = useForm({ defaultValues, resolver: yupResolver(schema), mode: "all" });
-
- const submit = (data) => {
- setDriver(data.rahdar);
- setOpenDriversDialog(false);
- };
-
- return (
-
-
-
- {
- return (
- field.onChange(value)}
- error={error}
- multiple={false}
- />
- );
- }}
- name={"rahdar"}
- />
-
- }
- >
- انتخاب
-
-
-
- );
-};
-export default DriverForm;
+import RahdarNameOrCode from "@/core/components/RahdarNameOrCode";
+import StyledForm from "@/core/components/StyledForm";
+import { yupResolver } from "@hookform/resolvers/yup";
+import { Done } from "@mui/icons-material";
+import { Button, Stack } from "@mui/material";
+import { Controller, useForm } from "react-hook-form";
+import { object } from "yup";
+
+const schema = object().shape({
+ rahdar: object().required("همراه الزامی است."),
+});
+const DriverForm = ({ setDriver, setOpenDriversDialog }) => {
+ const defaultValues = {
+ rahdar: null,
+ };
+
+ const {
+ control,
+ handleSubmit,
+ formState: { isSubmitting, isValid },
+ } = useForm({ defaultValues, resolver: yupResolver(schema), mode: "all" });
+
+ const submit = (data) => {
+ setDriver(data.rahdar);
+ setOpenDriversDialog(false);
+ };
+
+ return (
+
+
+
+ {
+ return (
+ field.onChange(value)}
+ error={error}
+ multiple={false}
+ />
+ );
+ }}
+ name={"rahdar"}
+ />
+
+ }
+ >
+ انتخاب
+
+
+
+ );
+};
+export default DriverForm;
diff --git a/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/DriversDialog/DriversSearch/index.jsx b/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/DriversDialog/DriversSearch/index.jsx
index b7136c9..2abc9ea 100644
--- a/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/DriversDialog/DriversSearch/index.jsx
+++ b/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/DriversDialog/DriversSearch/index.jsx
@@ -1,11 +1,11 @@
-import { DialogContent } from "@mui/material";
-import DriverForm from "./Form";
-
-const DriversSearch = ({ setDriver, setOpenDriversDialog }) => {
- return (
-
-
-
- );
-};
-export default DriversSearch;
+import { DialogContent } from "@mui/material";
+import DriverForm from "./Form";
+
+const DriversSearch = ({ setDriver, setOpenDriversDialog }) => {
+ return (
+
+
+
+ );
+};
+export default DriversSearch;
diff --git a/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/DriversDialog/index.jsx b/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/DriversDialog/index.jsx
index 3c1d406..0893ccf 100644
--- a/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/DriversDialog/index.jsx
+++ b/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/DriversDialog/index.jsx
@@ -1,41 +1,41 @@
-import { Close, Edit } from "@mui/icons-material";
-import { Button, Dialog, DialogTitle, IconButton } from "@mui/material";
-import { useState } from "react";
-import DriversSearch from "./DriversSearch";
-
-const DriversDialog = ({ setDriver, mode }) => {
- const [openDriversDialog, setOpenDriversDialog] = useState(false);
- return (
- <>
- {mode == "edit" ? (
- setOpenDriversDialog(true)} size="small">
-
-
- ) : (
-
- )}
-
- >
- );
-};
-export default DriversDialog;
+import { Close, Edit } from "@mui/icons-material";
+import { Button, Dialog, DialogTitle, IconButton } from "@mui/material";
+import { useState } from "react";
+import DriversSearch from "./DriversSearch";
+
+const DriversDialog = ({ setDriver, mode }) => {
+ const [openDriversDialog, setOpenDriversDialog] = useState(false);
+ return (
+ <>
+ {mode == "edit" ? (
+ setOpenDriversDialog(true)} size="small">
+
+
+ ) : (
+
+ )}
+
+ >
+ );
+};
+export default DriversDialog;
diff --git a/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/MachinesDialog/MachineList/index.jsx b/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/MachinesDialog/MachineList/index.jsx
index 07e8983..cfd1ed6 100644
--- a/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/MachinesDialog/MachineList/index.jsx
+++ b/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/MachinesDialog/MachineList/index.jsx
@@ -3,8 +3,12 @@ import { Box } from "@mui/material";
import { useMemo } from "react";
import RowActions from "./RowActions";
import { GET_MACHINES_TABLE_LIST } from "@/core/utils/routes";
+import { useAuth } from "@/lib/contexts/auth";
const MachinesList = ({ machineType, setMachine, setOpenMachinesDialog }) => {
+ const {
+ user: { city_id },
+ } = useAuth();
const columns = useMemo(
() => [
{
@@ -40,7 +44,11 @@ const MachinesList = ({ machineType, setMachine, setOpenMachinesDialog }) => {
need_filter={true}
table_title="لیست خودرو ها"
columns={columns}
- specialFilter={[{ value: machineType, datatype: "text", id: "car_type", fn: "equals" }]}
+ specialFilter={[
+ { value: machineType, datatype: "text", id: "car_type", fn: "equals" },
+ { value: 1, datatype: "numeric", id: "status", fn: "equals" },
+ { value: city_id, datatype: "numeric", id: "city_id", fn: "equals" },
+ ]}
sorting={[{ id: "id", desc: true }]}
table_url={GET_MACHINES_TABLE_LIST}
page_name={"roadMissionsTransportation"}
diff --git a/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/index.jsx b/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/index.jsx
index f5d4395..c35018d 100644
--- a/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/index.jsx
+++ b/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/index.jsx
@@ -1,37 +1,45 @@
import MapLayer from "@/core/components/MapLayer";
+import { machineType } from "@/core/utils/machineTypes";
+import { missionRegions } from "@/core/utils/missionRegions";
+import { missionTypes } from "@/core/utils/missionTypes";
import { ALLOCATE_REQUEST_MISSION } from "@/core/utils/routes";
import useRequest from "@/lib/hooks/useRequest";
import { Box, Button, Chip, DialogActions, DialogContent, Divider, Paper, Typography } from "@mui/material";
import { Stack } from "@mui/system";
+import moment from "jalali-moment";
import { useMemo, useState } from "react";
import ShowBound from "../../../Actions/showBound";
-import Reject from "./Reject";
-import { missionRegions } from "@/core/utils/missionRegions";
-import { machineType } from "@/core/utils/machineTypes";
-import { missionTypes } from "@/core/utils/missionTypes";
-import moment from "jalali-moment";
-import MachinesDialog from "./MachinesDialog";
import DriversDialog from "./DriversDialog";
-import LtrTextField from "@/core/components/LtrTextField";
+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]);
+ }, [row.area.coordinates]);
+
const bound = useMemo(
- () =>
- row.area.type == "polygon" ? L.polygon([...row.area.coordinates]) : L.polyline([...row.area.coordinates]),
- [row.area]
+ () => (row.area.type === "polygon" ? L.polygon(latLngs) : L.polyline(latLngs)),
+ [row.area.type, latLngs]
);
const requestServer = useRequest({ notificationSuccess: true });
const [machine, setMachine] = useState();
const [driver, setDriver] = useState();
- const [kilometer, setKilometer] = 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, _kilometer) => {
+ const handleSubmit = async (_machine, _driver) => {
setIsSubmitting(true);
await requestServer(`${ALLOCATE_REQUEST_MISSION}/${row.id}`, "post", {
data: {
- machines: [_machine.id],
+ machine_id: _machine.id,
driver: _driver.id,
- km: kilometer,
},
hasSidebarUpdate: true,
})
@@ -45,6 +53,7 @@ const AllocationForm = ({ row, mutate, setOpenAllocationDialog }) => {
});
};
+ const selectedMachineType = watch("machine_type")?.[0];
return (
<>
@@ -53,12 +62,22 @@ const AllocationForm = ({ row, mutate, setOpenAllocationDialog }) => {
-
- نوع خودرو درخواستی
-
-
- mt.id == row.requested_machines[0]).name_fa}
+ (
+ {
+ field.onChange([newValue]);
+ }}
+ />
+ )}
/>
@@ -76,16 +95,13 @@ const AllocationForm = ({ row, mutate, setOpenAllocationDialog }) => {
/>
>
) : (
-
+
)}
{machine && (
@@ -110,23 +126,6 @@ const AllocationForm = ({ row, mutate, setOpenAllocationDialog }) => {
)}
)}
- {driver && (
-
- {
- if (isNaN(Number(e.target.value))) return;
- setKilometer(e.target.value);
- }}
- size="small"
- fullWidth
- label="کیلومتر خودرو"
- InputLabelProps={{ shrink: true }}
- />
-
- )}
@@ -208,10 +207,10 @@ const AllocationForm = ({ row, mutate, setOpenAllocationDialog }) => {
+
+ مرحله بعد
+
+