(
+
+
+
+ )}
+ />
+ );
+};
+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..7610a5b 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,153 @@
-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";
+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;
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..33e13f7 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,40 @@
-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 { 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;
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..951fd83 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,77 @@
-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 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;
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..039ff75 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,130 @@
-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 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;
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..00c4297 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 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;
diff --git a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/index.jsx
index ab64c85..277a63d 100644
--- a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/index.jsx
+++ b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/index.jsx
@@ -1,121 +1,127 @@
-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.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;
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..d47f840 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,56 @@
-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..7610a5b 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,153 @@
-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";
+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;
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..0b20454 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: "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;
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..2842239 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,52 @@
-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 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;
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/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/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/index.jsx b/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/index.jsx
index 70d8cfb..4c2d1fe 100644
--- a/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/index.jsx
+++ b/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/index.jsx
@@ -28,7 +28,7 @@ const AllocationForm = ({ row, mutate, setOpenAllocationDialog }) => {
setIsSubmitting(true);
await requestServer(`${ALLOCATE_REQUEST_MISSION}/${row.id}`, "post", {
data: {
- machines: _machine.id,
+ machine_id: _machine.id,
driver: _driver.id,
},
hasSidebarUpdate: true,
diff --git a/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/Area/MapControlPolygon/DrawBound/index.jsx b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/Area/MapControlPolygon/DrawBound/index.jsx
index a2134c5..5a253a9 100644
--- a/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/Area/MapControlPolygon/DrawBound/index.jsx
+++ b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/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/violations/Actions/CreateWithoutProcess/Form/Area/MapControlPolygon/index.jsx b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/Area/MapControlPolygon/index.jsx
index 186a0b6..718600c 100644
--- a/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/Area/MapControlPolygon/index.jsx
+++ b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/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/violations/Actions/CreateWithoutProcess/Form/Area/MapControlPolyline/DrawBound/index.jsx b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/Area/MapControlPolyline/DrawBound/index.jsx
index 682be24..5456d12 100644
--- a/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/Area/MapControlPolyline/DrawBound/index.jsx
+++ b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/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/violations/Actions/CreateWithoutProcess/Form/Area/MapControlPolyline/index.jsx b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/Area/MapControlPolyline/index.jsx
index edd6cac..8d9b5d0 100644
--- a/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/Area/MapControlPolyline/index.jsx
+++ b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/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/violations/Actions/CreateWithoutProcess/Form/Area/SelectBoundType/index.jsx b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/Area/SelectBoundType/index.jsx
index a69a0ba..ebb3c69 100644
--- a/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/Area/SelectBoundType/index.jsx
+++ b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/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/violations/Actions/CreateWithoutProcess/Form/Area/index.jsx b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/Area/index.jsx
index 91dd0d3..3d666fd 100644
--- a/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/Area/index.jsx
+++ b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/Area/index.jsx
@@ -1,54 +1,54 @@
-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";
-const MapLayer = dynamic(() => import("@/core/components/MapLayer"), {
- loading: () => ,
- ssr: false,
-});
-
-const Area = ({ allData, setAllData, handlePrev, setTabState }) => {
- 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";
+const MapLayer = dynamic(() => import("@/core/components/MapLayer"), {
+ loading: () => ,
+ ssr: false,
+});
+
+const Area = ({ allData, setAllData, handlePrev, setTabState }) => {
+ 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/violations/Actions/CreateWithoutProcess/Form/GetDateTime/MissionDates/index.jsx b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/GetDateTime/MissionDates/index.jsx
index c002df3..56752de 100644
--- a/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/GetDateTime/MissionDates/index.jsx
+++ b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/GetDateTime/MissionDates/index.jsx
@@ -1,119 +1,119 @@
-import MuiDatePicker from "@/core/components/MuiDatePicker";
-import MuiTimePicker from "@/core/components/MuiTimePicker";
-import { makeDateTime } from "@/core/utils/makeDateTime";
-import { Grid } from "@mui/material";
-import { Controller, useWatch } from "react-hook-form";
-
-const MissionDates = ({ control }) => {
- const start_date = useWatch({ control, name: "start_date" });
- const end_date = useWatch({ control, name: "end_date" });
- const start_time = useWatch({ control, name: "start_time" });
- const end_time = useWatch({ control, name: "end_time" });
-
- const startDateTime = makeDateTime(start_date, start_time);
- const endDateTime = makeDateTime(end_date, end_time);
- const now = new Date();
-
- return (
- <>
-
- (
- field.onChange(value || null)}
- helperText={error ? error.message : null}
- />
- )}
- />
-
-
- {
- return (
- field.onChange(value || null)}
- helperText={error ? error.message : null}
- />
- );
- }}
- />
-
-
- (
- field.onChange(value || null)}
- helperText={error ? error.message : null}
- />
- )}
- />
-
-
- {
- 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 { makeDateTime } from "@/core/utils/makeDateTime";
+import { Grid } from "@mui/material";
+import { Controller, useWatch } from "react-hook-form";
+
+const MissionDates = ({ control }) => {
+ const start_date = useWatch({ control, name: "start_date" });
+ const end_date = useWatch({ control, name: "end_date" });
+ const start_time = useWatch({ control, name: "start_time" });
+ const end_time = useWatch({ control, name: "end_time" });
+
+ const startDateTime = makeDateTime(start_date, start_time);
+ const endDateTime = makeDateTime(end_date, end_time);
+ const now = new Date();
+
+ return (
+ <>
+
+ (
+ field.onChange(value || null)}
+ helperText={error ? error.message : null}
+ />
+ )}
+ />
+
+
+ {
+ return (
+ field.onChange(value || null)}
+ helperText={error ? error.message : null}
+ />
+ );
+ }}
+ />
+
+
+ (
+ field.onChange(value || null)}
+ helperText={error ? error.message : null}
+ />
+ )}
+ />
+
+
+ {
+ return (
+ field.onChange(value || null)}
+ helperText={error ? error.message : null}
+ />
+ );
+ }}
+ />
+
+ >
+ );
+};
+
+export default MissionDates;
diff --git a/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/GetDateTime/index.jsx b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/GetDateTime/index.jsx
index 9e35f41..1b096e9 100644
--- a/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/GetDateTime/index.jsx
+++ b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/GetDateTime/index.jsx
@@ -1,59 +1,59 @@
-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 { 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({
- start_date: string().required("تاریخ شروع ماموریت را مشخص کنید!"),
- start_time: string().required("زمان شروع ماموریت را مشخص کنید!"),
- end_date: string().required("تاریخ پایان ماموریت را مشخص کنید!"),
- end_time: string().required("زمان شروع ماموریت را مشخص کنید!"),
-});
-
-const GetDateTime = ({ allData, setAllData, handlePrev, setTabState }) => {
- const defaultValues = {
- start_date: allData.start_date,
- start_time: allData.start_time ? moment(allData.start_time).toDate() : null,
- 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 { 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({
+ start_date: string().required("تاریخ شروع ماموریت را مشخص کنید!"),
+ start_time: string().required("زمان شروع ماموریت را مشخص کنید!"),
+ end_date: string().required("تاریخ پایان ماموریت را مشخص کنید!"),
+ end_time: string().required("زمان شروع ماموریت را مشخص کنید!"),
+});
+
+const GetDateTime = ({ allData, setAllData, handlePrev, setTabState }) => {
+ const defaultValues = {
+ start_date: allData.start_date,
+ start_time: allData.start_time ? moment(allData.start_time).toDate() : null,
+ 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/violations/Actions/CreateWithoutProcess/Form/GetItemInfo/FastReactCode/Dialog/List/RowActions/SelectId/index.jsx b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/GetItemInfo/FastReactCode/Dialog/List/RowActions/SelectId/index.jsx
index 1e7e881..e3e14c0 100644
--- a/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/GetItemInfo/FastReactCode/Dialog/List/RowActions/SelectId/index.jsx
+++ b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/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/violations/Actions/CreateWithoutProcess/Form/GetItemInfo/FastReactCode/Dialog/List/RowActions/index.jsx b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/GetItemInfo/FastReactCode/Dialog/List/RowActions/index.jsx
index 3d0b958..646104b 100644
--- a/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/GetItemInfo/FastReactCode/Dialog/List/RowActions/index.jsx
+++ b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/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/violations/Actions/CreateWithoutProcess/Form/GetItemInfo/FastReactCode/Dialog/List/index.jsx b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/GetItemInfo/FastReactCode/Dialog/List/index.jsx
index 82a0472..8940335 100644
--- a/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/GetItemInfo/FastReactCode/Dialog/List/index.jsx
+++ b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/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/violations/Actions/CreateWithoutProcess/Form/GetItemInfo/FastReactCode/Dialog/index.jsx b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/GetItemInfo/FastReactCode/Dialog/index.jsx
index 013f73f..d7af56d 100644
--- a/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/GetItemInfo/FastReactCode/Dialog/index.jsx
+++ b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/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/violations/Actions/CreateWithoutProcess/Form/GetItemInfo/FastReactCode/index.jsx b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/GetItemInfo/FastReactCode/index.jsx
index 1545046..1f507c9 100644
--- a/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/GetItemInfo/FastReactCode/index.jsx
+++ b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/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/violations/Actions/CreateWithoutProcess/Form/GetItemInfo/index.jsx b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/GetItemInfo/index.jsx
index 3b3b513..7610a5b 100644
--- a/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/GetItemInfo/index.jsx
+++ b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/GetItemInfo/index.jsx
@@ -1,153 +1,153 @@
-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";
+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;
diff --git a/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/MachineAndDriver/DriversDialog/DriversSearch/Form/index.jsx b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/MachineAndDriver/DriversDialog/DriversSearch/Form/index.jsx
index 93bb1d6..9dbe4ed 100644
--- a/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/MachineAndDriver/DriversDialog/DriversSearch/Form/index.jsx
+++ b/src/components/dashboard/roadMissions/violations/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/violations/Actions/CreateWithoutProcess/Form/MachineAndDriver/DriversDialog/DriversSearch/index.jsx b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/MachineAndDriver/DriversDialog/DriversSearch/index.jsx
index b7136c9..2abc9ea 100644
--- a/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/MachineAndDriver/DriversDialog/DriversSearch/index.jsx
+++ b/src/components/dashboard/roadMissions/violations/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/violations/Actions/CreateWithoutProcess/Form/MachineAndDriver/DriversDialog/index.jsx b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/MachineAndDriver/DriversDialog/index.jsx
index 3c1d406..0893ccf 100644
--- a/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/MachineAndDriver/DriversDialog/index.jsx
+++ b/src/components/dashboard/roadMissions/violations/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/violations/Actions/CreateWithoutProcess/Form/MachineAndDriver/MachinesDialog/MachineList/RowActions/Allocate/index.jsx b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/MachineAndDriver/MachinesDialog/MachineList/RowActions/Allocate/index.jsx
index f03579a..9718815 100644
--- a/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/MachineAndDriver/MachinesDialog/MachineList/RowActions/Allocate/index.jsx
+++ b/src/components/dashboard/roadMissions/violations/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/violations/Actions/CreateWithoutProcess/Form/MachineAndDriver/MachinesDialog/MachineList/RowActions/index.jsx b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/MachineAndDriver/MachinesDialog/MachineList/RowActions/index.jsx
index bcfcc03..ba0a20d 100644
--- a/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/MachineAndDriver/MachinesDialog/MachineList/RowActions/index.jsx
+++ b/src/components/dashboard/roadMissions/violations/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/violations/Actions/CreateWithoutProcess/Form/MachineAndDriver/MachinesDialog/MachineList/index.jsx b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/MachineAndDriver/MachinesDialog/MachineList/index.jsx
index e070b01..fae083c 100644
--- a/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/MachineAndDriver/MachinesDialog/MachineList/index.jsx
+++ b/src/components/dashboard/roadMissions/violations/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/violations/Actions/CreateWithoutProcess/Form/MachineAndDriver/MachinesDialog/index.jsx b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/MachineAndDriver/MachinesDialog/index.jsx
index 8750142..33e13f7 100644
--- a/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/MachineAndDriver/MachinesDialog/index.jsx
+++ b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/MachineAndDriver/MachinesDialog/index.jsx
@@ -1,40 +1,40 @@
-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 { 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;
diff --git a/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/MachineAndDriver/index.jsx b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/MachineAndDriver/index.jsx
index 24bfb15..951fd83 100644
--- a/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/MachineAndDriver/index.jsx
+++ b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/MachineAndDriver/index.jsx
@@ -1,77 +1,77 @@
-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 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;
diff --git a/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/Rahdaran/Form/index.jsx b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/Rahdaran/Form/index.jsx
index a4449fe..390974d 100644
--- a/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/Rahdaran/Form/index.jsx
+++ b/src/components/dashboard/roadMissions/violations/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/violations/Actions/CreateWithoutProcess/Form/Rahdaran/List/index.jsx b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/Rahdaran/List/index.jsx
index ebc4edc..be31897 100644
--- a/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/Rahdaran/List/index.jsx
+++ b/src/components/dashboard/roadMissions/violations/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/violations/Actions/CreateWithoutProcess/Form/Rahdaran/index.jsx b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/Rahdaran/index.jsx
index af01fe6..b530af4 100644
--- a/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/Rahdaran/index.jsx
+++ b/src/components/dashboard/roadMissions/violations/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/violations/Actions/CreateWithoutProcess/Form/Verify/index.jsx b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/Verify/index.jsx
index 0393018..039ff75 100644
--- a/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/Verify/index.jsx
+++ b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/Verify/index.jsx
@@ -1,130 +1,130 @@
-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 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;
diff --git a/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/index.jsx b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/index.jsx
index 00f9ef1..00c4297 100644
--- a/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/index.jsx
+++ b/src/components/dashboard/roadMissions/violations/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 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;
diff --git a/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/index.jsx b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/index.jsx
index 2e3cb75..4159027 100644
--- a/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/index.jsx
+++ b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/index.jsx
@@ -1,119 +1,119 @@
-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.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;
diff --git a/src/components/dashboard/roadMissions/violations/RowActions/index.jsx b/src/components/dashboard/roadMissions/violations/RowActions/index.jsx
index 192bfe1..0687f1d 100644
--- a/src/components/dashboard/roadMissions/violations/RowActions/index.jsx
+++ b/src/components/dashboard/roadMissions/violations/RowActions/index.jsx
@@ -1,4 +1,4 @@
-const RowActions = ({ row, mutate }) => {
- return <>>;
-};
-export default RowActions;
+const RowActions = ({ row, mutate }) => {
+ return <>>;
+};
+export default RowActions;
diff --git a/src/components/dashboard/roadMissions/violations/ViolationsList.jsx b/src/components/dashboard/roadMissions/violations/ViolationsList.jsx
index 49223c2..f7a3719 100644
--- a/src/components/dashboard/roadMissions/violations/ViolationsList.jsx
+++ b/src/components/dashboard/roadMissions/violations/ViolationsList.jsx
@@ -1,83 +1,83 @@
-"use client";
-import DataTableWithAuth from "@/core/components/DataTableWithAuth";
-import { GET_ROAD_MISSIONS_VIOLATIONS_LIST } from "@/core/utils/routes";
-import { Box } from "@mui/material";
-import moment from "jalali-moment";
-import { useMemo } from "react";
-import RowActions from "./RowActions";
-
-const ViolationsList = () => {
- const columns = useMemo(
- () => [
- {
- accessorKey: "id",
- header: "کد یکتا",
- id: "id",
- enableColumnFilter: true,
- datatype: "text",
- filterMode: "equals",
- columnFilterModeOptions: ["equals", "contains"],
- grow: false,
- },
- {
- accessorKey: "type",
- header: "نوع تخلف",
- id: "type",
- enableColumnFilter: true,
- datatype: "numeric",
- filterMode: "equals",
- sortDescFirst: true,
- grow: false,
- Cell: ({ row }) => (row.original.type === 1 ? "خروج بدون مجوز" : "عدم تحرک"),
- },
- {
- accessorKey: "machine_code",
- header: "خودرو",
- id: "machine_code",
- datatype: "text",
- columnFilterModeOptions: ["equals", "contains"],
- grow: false,
- },
- {
- accessorKey: "mission_id",
- header: "کد ماموریت",
- id: "mission_id",
- enableColumnFilter: false,
- datatype: "numeric",
- filterMode: "equals",
- grow: false,
- Cell: ({ row }) => row.original.mission_id || "-",
- },
- {
- accessorKey: "request_date",
- header: "تاریخ تخلف",
- id: "request_date",
- enableColumnFilter: true,
- datatype: "date",
- filterMode: "between",
- grow: false,
- Cell: ({ row }) => moment(row.original.request_date).locale("fa").format("YYYY/MM/DD"),
- },
- ],
- []
- );
-
- return (
- <>
-
-
-
- >
- );
-};
-export default ViolationsList;
+"use client";
+import DataTableWithAuth from "@/core/components/DataTableWithAuth";
+import { GET_ROAD_MISSIONS_VIOLATIONS_LIST } from "@/core/utils/routes";
+import { Box } from "@mui/material";
+import moment from "jalali-moment";
+import { useMemo } from "react";
+import RowActions from "./RowActions";
+
+const ViolationsList = () => {
+ const columns = useMemo(
+ () => [
+ {
+ accessorKey: "id",
+ header: "کد یکتا",
+ id: "id",
+ enableColumnFilter: true,
+ datatype: "text",
+ filterMode: "equals",
+ columnFilterModeOptions: ["equals", "contains"],
+ grow: false,
+ },
+ {
+ accessorKey: "type",
+ header: "نوع تخلف",
+ id: "type",
+ enableColumnFilter: true,
+ datatype: "numeric",
+ filterMode: "equals",
+ sortDescFirst: true,
+ grow: false,
+ Cell: ({ row }) => (row.original.type === 1 ? "خروج بدون مجوز" : "عدم تحرک"),
+ },
+ {
+ accessorKey: "machine_code",
+ header: "خودرو",
+ id: "machine_code",
+ datatype: "text",
+ columnFilterModeOptions: ["equals", "contains"],
+ grow: false,
+ },
+ {
+ accessorKey: "mission_id",
+ header: "کد ماموریت",
+ id: "mission_id",
+ enableColumnFilter: false,
+ datatype: "numeric",
+ filterMode: "equals",
+ grow: false,
+ Cell: ({ row }) => row.original.mission_id || "-",
+ },
+ {
+ accessorKey: "request_date",
+ header: "تاریخ تخلف",
+ id: "request_date",
+ enableColumnFilter: true,
+ datatype: "date",
+ filterMode: "between",
+ grow: false,
+ Cell: ({ row }) => moment(row.original.request_date).locale("fa").format("YYYY/MM/DD"),
+ },
+ ],
+ []
+ );
+
+ return (
+ <>
+
+
+
+ >
+ );
+};
+export default ViolationsList;
diff --git a/src/components/dashboard/roadMissions/violations/index.jsx b/src/components/dashboard/roadMissions/violations/index.jsx
index ace0981..5bd4a2f 100644
--- a/src/components/dashboard/roadMissions/violations/index.jsx
+++ b/src/components/dashboard/roadMissions/violations/index.jsx
@@ -1,14 +1,14 @@
-"use client";
-import PageTitle from "@/core/components/PageTitle";
-import { Stack } from "@mui/material";
-import ViolationsList from "./ViolationsList";
-
-const ViolationsPage = () => {
- return (
-
-
-
-
- );
-};
-export default ViolationsPage;
+"use client";
+import PageTitle from "@/core/components/PageTitle";
+import { Stack } from "@mui/material";
+import ViolationsList from "./ViolationsList";
+
+const ViolationsPage = () => {
+ return (
+
+
+
+
+ );
+};
+export default ViolationsPage;
diff --git a/src/components/dashboard/roadSafety/operator/RowActions/ActionPictureDialog/List.jsx b/src/components/dashboard/roadSafety/operator/RowActions/ActionPictureDialog/List.jsx
index 8f3bfb2..be3c840 100644
--- a/src/components/dashboard/roadSafety/operator/RowActions/ActionPictureDialog/List.jsx
+++ b/src/components/dashboard/roadSafety/operator/RowActions/ActionPictureDialog/List.jsx
@@ -1,13 +1,13 @@
-import { Stack } from "@mui/material";
-import ActionPictureContent from "./ActionPictureContent";
-
-const List = ({ image1, image2, image3 }) => {
- return (
-
-
-
-
-
- );
-};
-export default List;
+import { Stack } from "@mui/material";
+import ActionPictureContent from "./ActionPictureContent";
+
+const List = ({ image1, image2, image3 }) => {
+ return (
+
+
+
+
+
+ );
+};
+export default List;
diff --git a/src/components/dashboard/roadSafety/operator/RowActions/RecognizePictureDialog/List.jsx b/src/components/dashboard/roadSafety/operator/RowActions/RecognizePictureDialog/List.jsx
index 6456faf..b6b20a1 100644
--- a/src/components/dashboard/roadSafety/operator/RowActions/RecognizePictureDialog/List.jsx
+++ b/src/components/dashboard/roadSafety/operator/RowActions/RecognizePictureDialog/List.jsx
@@ -1,12 +1,12 @@
-import { Stack } from "@mui/material";
-import RecognizePictureContent from "./RecognizePictureContent";
-
-const List = ({ image1, image2 }) => {
- return (
-
-
-
-
- );
-};
-export default List;
+import { Stack } from "@mui/material";
+import RecognizePictureContent from "./RecognizePictureContent";
+
+const List = ({ image1, image2 }) => {
+ return (
+
+
+
+
+ );
+};
+export default List;
diff --git a/src/components/dashboard/roadSafety/reports/accessRoad/ExcelPrint/index.jsx b/src/components/dashboard/roadSafety/reports/accessRoad/ExcelPrint/index.jsx
index c0a33cd..0dc22f5 100644
--- a/src/components/dashboard/roadSafety/reports/accessRoad/ExcelPrint/index.jsx
+++ b/src/components/dashboard/roadSafety/reports/accessRoad/ExcelPrint/index.jsx
@@ -1,72 +1,72 @@
-"use client";
-import DataTableFilterDataStructure from "@/core/utils/DataTableFilterDataStructure";
-import isArrayEmpty from "@/core/utils/isArrayEmpty";
-import {
- EXPORT_COUNTRY_ROAD_SAFETY_REPORT,
- EXPORT_PROVINCE_ROAD_SAFETY_REPORT,
- EXPORT_ROAD_SAFETY_CITY_ACTIVITY_ACCESS_ROAD_REPORT,
- EXPORT_ROAD_SAFETY_PROVINCE_ACTIVITY_ACCESS_ROAD_REPORTT,
-} from "@/core/utils/routes";
-import useRequest from "@/lib/hooks/useRequest";
-import { useTheme } from "@emotion/react";
-import DescriptionIcon from "@mui/icons-material/Description";
-import { Button, CircularProgress, IconButton, useMediaQuery } from "@mui/material";
-import FileSaver from "file-saver";
-import moment from "jalali-moment";
-import { useState } from "react";
-
-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 clickHandler = () => {
- setLoading(true);
- const filters = DataTableFilterDataStructure(filterData, isArrayEmpty);
- const filterParams = new URLSearchParams();
- let requestUrl;
- filterParams.set("filters", JSON.stringify(filters || []));
- if (filterData.province_id.value === "") {
- requestUrl = EXPORT_ROAD_SAFETY_PROVINCE_ACTIVITY_ACCESS_ROAD_REPORTT;
- } else {
- filterParams.set("province_id", filterData.province_id.value);
- requestUrl = EXPORT_ROAD_SAFETY_CITY_ACTIVITY_ACCESS_ROAD_REPORT;
- }
-
- 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;
+"use client";
+import DataTableFilterDataStructure from "@/core/utils/DataTableFilterDataStructure";
+import isArrayEmpty from "@/core/utils/isArrayEmpty";
+import {
+ EXPORT_COUNTRY_ROAD_SAFETY_REPORT,
+ EXPORT_PROVINCE_ROAD_SAFETY_REPORT,
+ EXPORT_ROAD_SAFETY_CITY_ACTIVITY_ACCESS_ROAD_REPORT,
+ EXPORT_ROAD_SAFETY_PROVINCE_ACTIVITY_ACCESS_ROAD_REPORTT,
+} from "@/core/utils/routes";
+import useRequest from "@/lib/hooks/useRequest";
+import { useTheme } from "@emotion/react";
+import DescriptionIcon from "@mui/icons-material/Description";
+import { Button, CircularProgress, IconButton, useMediaQuery } from "@mui/material";
+import FileSaver from "file-saver";
+import moment from "jalali-moment";
+import { useState } from "react";
+
+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 clickHandler = () => {
+ setLoading(true);
+ const filters = DataTableFilterDataStructure(filterData, isArrayEmpty);
+ const filterParams = new URLSearchParams();
+ let requestUrl;
+ filterParams.set("filters", JSON.stringify(filters || []));
+ if (filterData.province_id.value === "") {
+ requestUrl = EXPORT_ROAD_SAFETY_PROVINCE_ACTIVITY_ACCESS_ROAD_REPORTT;
+ } else {
+ filterParams.set("province_id", filterData.province_id.value);
+ requestUrl = EXPORT_ROAD_SAFETY_CITY_ACTIVITY_ACCESS_ROAD_REPORT;
+ }
+
+ 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/roadSafety/reports/accessRoad/ReportLists.jsx b/src/components/dashboard/roadSafety/reports/accessRoad/ReportLists.jsx
index c5de8fd..14c972c 100644
--- a/src/components/dashboard/roadSafety/reports/accessRoad/ReportLists.jsx
+++ b/src/components/dashboard/roadSafety/reports/accessRoad/ReportLists.jsx
@@ -1,463 +1,463 @@
-"use client";
-import DataTableWithAuth from "@/core/components/DataTableWithAuth";
-import { Box } from "@mui/material";
-import { useMemo } from "react";
-import Toolbar from "./Toolbar";
-
-const ReportLists = ({ data, filterData, setFilterData, isLoading }) => {
- const columns = useMemo(() => {
- return [
- {
- accessorKey: "edare_name",
- header: "اداره کل",
- id: "edare_name",
- enableColumnFilter: false,
- enableSorting: false,
- datatype: "text",
- grow: false,
- size: 50,
- },
- {
- accessorFn: (row) => (row["1"] ? row["1"].total_sum : 0),
- header: "تعداد کل",
- id: "sum",
- 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 / 1).toLocaleString();
- },
- },
- {
- header: "آزادراه",
- enableColumnFilter: false,
- enableSorting: false,
- datatype: "text",
- id: "id_1",
- grow: false,
- size: 50,
- columns: [
- {
- accessorFn: (row) => (row["1"] ? row["1"].s1 : 0),
- header: "گام اول",
- id: "id_1.1",
- 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 / 1).toLocaleString();
- },
- },
- {
- accessorFn: (row) => (row["1"] ? row["1"].s2 : 0),
- header: "گام دوم",
- id: "id_1.2",
- 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 / 1).toLocaleString();
- },
- },
- {
- accessorFn: (row) => (row["1"] ? row["1"].s3 : 0),
- header: "گام سوم",
- id: "id_1.3",
- 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 / 1).toLocaleString();
- },
- },
- ],
- },
- {
- header: "بزرگراه",
- enableColumnFilter: false,
- enableSorting: false,
- datatype: "text",
- id: "id_2",
- grow: false,
- size: 50,
- columns: [
- {
- accessorFn: (row) => (row["2"] ? row["2"].s1 : 0),
- header: "گام اول",
- id: "id_2.1",
- 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 / 1).toLocaleString();
- },
- },
- {
- accessorFn: (row) => (row["2"] ? row["2"].s2 : 0),
- header: "گام دوم",
- id: "id_2.2",
- 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 / 1).toLocaleString();
- },
- },
- {
- accessorFn: (row) => (row["2"] ? row["2"].s3 : 0),
- header: "گام سوم",
- id: "id_2.3",
- 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 / 1).toLocaleString();
- },
- },
- ],
- },
- {
- header: "اصلی",
- enableColumnFilter: false,
- enableSorting: false,
- datatype: "text",
- id: "id_3",
- grow: false,
- size: 50,
- columns: [
- {
- accessorFn: (row) => (row["3"] ? row["3"].s1 : 0),
- header: "گام اول",
- id: "id_3.1",
- 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 / 1).toLocaleString();
- },
- },
- {
- accessorFn: (row) => (row["3"] ? row["3"].s2 : 0),
- header: "گام دوم",
- id: "id_3.2",
- 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 / 1).toLocaleString();
- },
- },
- {
- accessorFn: (row) => (row["3"] ? row["3"].s3 : 0),
- header: "گام سوم",
- id: "id_3.3",
- 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 / 1).toLocaleString();
- },
- },
- ],
- },
- {
- header: "فرعی",
- enableColumnFilter: false,
- enableSorting: false,
- datatype: "text",
- id: "id_4",
- grow: false,
- size: 50,
- columns: [
- {
- accessorFn: (row) => (row["4"] ? row["4"].s1 : 0),
- header: "گام اول",
- id: "id_4.1",
- 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 / 1).toLocaleString();
- },
- },
- {
- accessorFn: (row) => (row["4"] ? row["4"].s2 : 0),
- header: "گام دوم",
- id: "id_4.2",
- 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 / 1).toLocaleString();
- },
- },
- {
- accessorFn: (row) => (row["4"] ? row["4"].s3 : 0),
- header: "گام سوم",
- id: "id_4.3",
- 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 / 1).toLocaleString();
- },
- },
- ],
- },
- {
- header: "روستایی",
- enableColumnFilter: false,
- enableSorting: false,
- datatype: "text",
- id: "id_5",
- grow: false,
- size: 50,
- columns: [
- {
- accessorFn: (row) => (row["5"] ? row["5"].s1 : 0),
- header: "گام اول",
- id: "id_5.1",
- 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 / 1).toLocaleString();
- },
- },
- {
- accessorFn: (row) => (row["5"] ? row["5"].s2 : 0),
- header: "گام دوم",
- id: "id_5.2",
- 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 / 1).toLocaleString();
- },
- },
- {
- accessorFn: (row) => (row["5"] ? row["5"].s3 : 0),
- header: "گام سوم",
- id: "id_5.3",
- 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 / 1).toLocaleString();
- },
- },
- ],
- },
- ];
- }, []);
-
- return (
-
-
-
- );
-};
-
-export default ReportLists;
+"use client";
+import DataTableWithAuth from "@/core/components/DataTableWithAuth";
+import { Box } from "@mui/material";
+import { useMemo } from "react";
+import Toolbar from "./Toolbar";
+
+const ReportLists = ({ data, filterData, setFilterData, isLoading }) => {
+ const columns = useMemo(() => {
+ return [
+ {
+ accessorKey: "edare_name",
+ header: "اداره کل",
+ id: "edare_name",
+ enableColumnFilter: false,
+ enableSorting: false,
+ datatype: "text",
+ grow: false,
+ size: 50,
+ },
+ {
+ accessorFn: (row) => (row["1"] ? row["1"].total_sum : 0),
+ header: "تعداد کل",
+ id: "sum",
+ 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 / 1).toLocaleString();
+ },
+ },
+ {
+ header: "آزادراه",
+ enableColumnFilter: false,
+ enableSorting: false,
+ datatype: "text",
+ id: "id_1",
+ grow: false,
+ size: 50,
+ columns: [
+ {
+ accessorFn: (row) => (row["1"] ? row["1"].s1 : 0),
+ header: "گام اول",
+ id: "id_1.1",
+ 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 / 1).toLocaleString();
+ },
+ },
+ {
+ accessorFn: (row) => (row["1"] ? row["1"].s2 : 0),
+ header: "گام دوم",
+ id: "id_1.2",
+ 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 / 1).toLocaleString();
+ },
+ },
+ {
+ accessorFn: (row) => (row["1"] ? row["1"].s3 : 0),
+ header: "گام سوم",
+ id: "id_1.3",
+ 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 / 1).toLocaleString();
+ },
+ },
+ ],
+ },
+ {
+ header: "بزرگراه",
+ enableColumnFilter: false,
+ enableSorting: false,
+ datatype: "text",
+ id: "id_2",
+ grow: false,
+ size: 50,
+ columns: [
+ {
+ accessorFn: (row) => (row["2"] ? row["2"].s1 : 0),
+ header: "گام اول",
+ id: "id_2.1",
+ 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 / 1).toLocaleString();
+ },
+ },
+ {
+ accessorFn: (row) => (row["2"] ? row["2"].s2 : 0),
+ header: "گام دوم",
+ id: "id_2.2",
+ 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 / 1).toLocaleString();
+ },
+ },
+ {
+ accessorFn: (row) => (row["2"] ? row["2"].s3 : 0),
+ header: "گام سوم",
+ id: "id_2.3",
+ 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 / 1).toLocaleString();
+ },
+ },
+ ],
+ },
+ {
+ header: "اصلی",
+ enableColumnFilter: false,
+ enableSorting: false,
+ datatype: "text",
+ id: "id_3",
+ grow: false,
+ size: 50,
+ columns: [
+ {
+ accessorFn: (row) => (row["3"] ? row["3"].s1 : 0),
+ header: "گام اول",
+ id: "id_3.1",
+ 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 / 1).toLocaleString();
+ },
+ },
+ {
+ accessorFn: (row) => (row["3"] ? row["3"].s2 : 0),
+ header: "گام دوم",
+ id: "id_3.2",
+ 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 / 1).toLocaleString();
+ },
+ },
+ {
+ accessorFn: (row) => (row["3"] ? row["3"].s3 : 0),
+ header: "گام سوم",
+ id: "id_3.3",
+ 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 / 1).toLocaleString();
+ },
+ },
+ ],
+ },
+ {
+ header: "فرعی",
+ enableColumnFilter: false,
+ enableSorting: false,
+ datatype: "text",
+ id: "id_4",
+ grow: false,
+ size: 50,
+ columns: [
+ {
+ accessorFn: (row) => (row["4"] ? row["4"].s1 : 0),
+ header: "گام اول",
+ id: "id_4.1",
+ 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 / 1).toLocaleString();
+ },
+ },
+ {
+ accessorFn: (row) => (row["4"] ? row["4"].s2 : 0),
+ header: "گام دوم",
+ id: "id_4.2",
+ 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 / 1).toLocaleString();
+ },
+ },
+ {
+ accessorFn: (row) => (row["4"] ? row["4"].s3 : 0),
+ header: "گام سوم",
+ id: "id_4.3",
+ 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 / 1).toLocaleString();
+ },
+ },
+ ],
+ },
+ {
+ header: "روستایی",
+ enableColumnFilter: false,
+ enableSorting: false,
+ datatype: "text",
+ id: "id_5",
+ grow: false,
+ size: 50,
+ columns: [
+ {
+ accessorFn: (row) => (row["5"] ? row["5"].s1 : 0),
+ header: "گام اول",
+ id: "id_5.1",
+ 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 / 1).toLocaleString();
+ },
+ },
+ {
+ accessorFn: (row) => (row["5"] ? row["5"].s2 : 0),
+ header: "گام دوم",
+ id: "id_5.2",
+ 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 / 1).toLocaleString();
+ },
+ },
+ {
+ accessorFn: (row) => (row["5"] ? row["5"].s3 : 0),
+ header: "گام سوم",
+ id: "id_5.3",
+ 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 / 1).toLocaleString();
+ },
+ },
+ ],
+ },
+ ];
+ }, []);
+
+ return (
+
+
+
+ );
+};
+
+export default ReportLists;
diff --git a/src/components/dashboard/roadSafety/reports/accessRoad/Toolbar.jsx b/src/components/dashboard/roadSafety/reports/accessRoad/Toolbar.jsx
index 7dd930f..3e5ab8c 100644
--- a/src/components/dashboard/roadSafety/reports/accessRoad/Toolbar.jsx
+++ b/src/components/dashboard/roadSafety/reports/accessRoad/Toolbar.jsx
@@ -1,11 +1,11 @@
-import PrintExcel from "./ExcelPrint";
-import { Box } from "@mui/material";
-
-const Toolbar = ({ table, filterData, mutate }) => {
- return (
-
-
-
- );
-};
-export default Toolbar;
+import PrintExcel from "./ExcelPrint";
+import { Box } from "@mui/material";
+
+const Toolbar = ({ table, filterData, mutate }) => {
+ return (
+
+
+
+ );
+};
+export default Toolbar;
diff --git a/src/components/dashboard/roadSafety/reports/accessRoad/index.jsx b/src/components/dashboard/roadSafety/reports/accessRoad/index.jsx
index 4fa2fa5..dd260c9 100644
--- a/src/components/dashboard/roadSafety/reports/accessRoad/index.jsx
+++ b/src/components/dashboard/roadSafety/reports/accessRoad/index.jsx
@@ -1,205 +1,205 @@
-"use client";
-import CustomSelectByDependency from "@/core/components/FilterDrawer/fieldsType/CustomSelectByDependency";
-import PageTitle from "@/core/components/PageTitle";
-import DataTableFilterDataStructure from "@/core/utils/DataTableFilterDataStructure";
-import isArrayEmpty from "@/core/utils/isArrayEmpty";
-import {
- GET_ROAD_SAFETY_CITY_ACTIVITY_ACCESS_ROAD_REPORT,
- GET_ROAD_SAFETY_PROVINCE_ACTIVITY_ACCESS_ROAD_REPORT,
-} from "@/core/utils/routes";
-import { useAuth } from "@/lib/contexts/auth";
-import { usePermissions } from "@/lib/hooks/usePermissions";
-import useProvinces from "@/lib/hooks/useProvince";
-import useRequest from "@/lib/hooks/useRequest";
-import { LinearProgress, Stack } from "@mui/material";
-import { useEffect, useMemo, useState } from "react";
-import ReportLists from "./ReportLists";
-import groupByProvinceAxisStep from "@/core/utils/groupByProvinceAxisStep";
-import groupByEdareAxisStep from "@/core/utils/groupByEdareAxisStep";
-
-const ReportAccessRoadPage = () => {
- const { data: userPermissions } = usePermissions();
- const hasProvincesPermission = userPermissions.includes("show-safety-and-privacy-operator-cartable");
- const { user } = useAuth();
- const requestServer = useRequest();
- const [data, setData] = useState(null);
- const [isLoading, setLoading] = useState(true);
-
- const defaultValues = useMemo(
- () => [
- {
- header: "استان",
- id: "province_id",
- filterMode: "equals",
- datatype: "numeric",
- value: hasProvincesPermission ? "" : user.province_id,
- enable: hasProvincesPermission,
- SelectComponent: (props) => {
- const { provinces, errorProvinces, loadingProvinces } = useProvinces();
- const getSelectOptions = 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 (
-
- );
- },
- },
- {
- header: "مورد",
- id: "info_id",
- filterMode: "equals",
- datatype: "numeric",
- value: "90",
- enable: false,
- },
- {
- header: "تاریخ ثبت",
- id: "created_at",
- filterMode: "between",
- datatype: "date",
- value: ["", ""],
- enable: true,
- },
- {
- header: "تاریخ بازدید",
- id: "activity_date_time",
- filterMode: "between",
- datatype: "date",
- value: ["", ""],
- enable: true,
- },
- {
- header: "تاریخ بارگذاری مستندات",
- id: "judiciary_document_upload_date",
- filterMode: "between",
- datatype: "date",
- value: ["", ""],
- enable: true,
- },
- {
- header: "تاریخ اقدام",
- id: "action_date",
- filterMode: "between",
- datatype: "date",
- value: ["", ""],
- enable: true,
- },
- ],
- [hasProvincesPermission, user.province_id]
- );
-
- const [filterData, setFilterData] = useState(
- defaultValues.reduce((acc, item) => {
- acc[item.id] = item;
- return acc;
- }, {})
- );
-
- useEffect(() => {
- const fetchData = async () => {
- try {
- setLoading(true);
- const filters = DataTableFilterDataStructure(filterData, isArrayEmpty);
- const params = new URLSearchParams();
- params.set("filters", JSON.stringify(filters || []));
- if (filterData.province_id.value === "") {
- try {
- const response = await requestServer(
- `${GET_ROAD_SAFETY_PROVINCE_ACTIVITY_ACCESS_ROAD_REPORT}?${params.toString()}`
- );
-
- const result = response.data.data;
- const grouped = groupByProvinceAxisStep(result.activities);
-
- const nationalReportForItem = grouped[-1];
- const nationalReport = {
- edare_name: "کل کشور",
- ...nationalReportForItem,
- };
-
- setData([
- nationalReport,
- ...result.provinces.map((province) => {
- const filteredReports = grouped[province.id];
- return {
- ...filteredReports,
- edare_name: province.name_fa,
- };
- }),
- ]);
- } catch (e) {
- console.log(e);
- }
- } else {
- params.set("province_id", filterData.province_id.value);
- try {
- const response = await requestServer(
- `${GET_ROAD_SAFETY_CITY_ACTIVITY_ACCESS_ROAD_REPORT}?${params.toString()}`
- );
- const result = response.data.data;
- const grouped = groupByEdareAxisStep(result.activities);
-
- const nationalReportForItem = grouped[-1];
- const nationalReport = {
- ...nationalReportForItem,
- edare_name: "کل استان",
- };
- setData([
- nationalReport,
- ...result.edarateShahri.map((edare) => {
- const filteredReports = grouped[edare.id];
- return {
- edare_name: edare.name_fa,
- ...filteredReports,
- };
- }),
- ]);
- } catch (e) {
- console.log(e);
- }
- }
- } catch (error) {
- console.log(error);
- } finally {
- setLoading(false);
- }
- };
-
- fetchData();
- }, [filterData]);
-
- return (
-
-
- {!data ? (
-
- ) : (
- <>
-
- >
- )}
-
- );
-};
-export default ReportAccessRoadPage;
+"use client";
+import CustomSelectByDependency from "@/core/components/FilterDrawer/fieldsType/CustomSelectByDependency";
+import PageTitle from "@/core/components/PageTitle";
+import DataTableFilterDataStructure from "@/core/utils/DataTableFilterDataStructure";
+import isArrayEmpty from "@/core/utils/isArrayEmpty";
+import {
+ GET_ROAD_SAFETY_CITY_ACTIVITY_ACCESS_ROAD_REPORT,
+ GET_ROAD_SAFETY_PROVINCE_ACTIVITY_ACCESS_ROAD_REPORT,
+} from "@/core/utils/routes";
+import { useAuth } from "@/lib/contexts/auth";
+import { usePermissions } from "@/lib/hooks/usePermissions";
+import useProvinces from "@/lib/hooks/useProvince";
+import useRequest from "@/lib/hooks/useRequest";
+import { LinearProgress, Stack } from "@mui/material";
+import { useEffect, useMemo, useState } from "react";
+import ReportLists from "./ReportLists";
+import groupByProvinceAxisStep from "@/core/utils/groupByProvinceAxisStep";
+import groupByEdareAxisStep from "@/core/utils/groupByEdareAxisStep";
+
+const ReportAccessRoadPage = () => {
+ const { data: userPermissions } = usePermissions();
+ const hasProvincesPermission = userPermissions.includes("show-safety-and-privacy-operator-cartable");
+ const { user } = useAuth();
+ const requestServer = useRequest();
+ const [data, setData] = useState(null);
+ const [isLoading, setLoading] = useState(true);
+
+ const defaultValues = useMemo(
+ () => [
+ {
+ header: "استان",
+ id: "province_id",
+ filterMode: "equals",
+ datatype: "numeric",
+ value: hasProvincesPermission ? "" : user.province_id,
+ enable: hasProvincesPermission,
+ SelectComponent: (props) => {
+ const { provinces, errorProvinces, loadingProvinces } = useProvinces();
+ const getSelectOptions = 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 (
+
+ );
+ },
+ },
+ {
+ header: "مورد",
+ id: "info_id",
+ filterMode: "equals",
+ datatype: "numeric",
+ value: "90",
+ enable: false,
+ },
+ {
+ header: "تاریخ ثبت",
+ id: "created_at",
+ filterMode: "between",
+ datatype: "date",
+ value: ["", ""],
+ enable: true,
+ },
+ {
+ header: "تاریخ بازدید",
+ id: "activity_date_time",
+ filterMode: "between",
+ datatype: "date",
+ value: ["", ""],
+ enable: true,
+ },
+ {
+ header: "تاریخ بارگذاری مستندات",
+ id: "judiciary_document_upload_date",
+ filterMode: "between",
+ datatype: "date",
+ value: ["", ""],
+ enable: true,
+ },
+ {
+ header: "تاریخ اقدام",
+ id: "action_date",
+ filterMode: "between",
+ datatype: "date",
+ value: ["", ""],
+ enable: true,
+ },
+ ],
+ [hasProvincesPermission, user.province_id]
+ );
+
+ const [filterData, setFilterData] = useState(
+ defaultValues.reduce((acc, item) => {
+ acc[item.id] = item;
+ return acc;
+ }, {})
+ );
+
+ useEffect(() => {
+ const fetchData = async () => {
+ try {
+ setLoading(true);
+ const filters = DataTableFilterDataStructure(filterData, isArrayEmpty);
+ const params = new URLSearchParams();
+ params.set("filters", JSON.stringify(filters || []));
+ if (filterData.province_id.value === "") {
+ try {
+ const response = await requestServer(
+ `${GET_ROAD_SAFETY_PROVINCE_ACTIVITY_ACCESS_ROAD_REPORT}?${params.toString()}`
+ );
+
+ const result = response.data.data;
+ const grouped = groupByProvinceAxisStep(result.activities);
+
+ const nationalReportForItem = grouped[-1];
+ const nationalReport = {
+ edare_name: "کل کشور",
+ ...nationalReportForItem,
+ };
+
+ setData([
+ nationalReport,
+ ...result.provinces.map((province) => {
+ const filteredReports = grouped[province.id];
+ return {
+ ...filteredReports,
+ edare_name: province.name_fa,
+ };
+ }),
+ ]);
+ } catch (e) {
+ console.log(e);
+ }
+ } else {
+ params.set("province_id", filterData.province_id.value);
+ try {
+ const response = await requestServer(
+ `${GET_ROAD_SAFETY_CITY_ACTIVITY_ACCESS_ROAD_REPORT}?${params.toString()}`
+ );
+ const result = response.data.data;
+ const grouped = groupByEdareAxisStep(result.activities);
+
+ const nationalReportForItem = grouped[-1];
+ const nationalReport = {
+ ...nationalReportForItem,
+ edare_name: "کل استان",
+ };
+ setData([
+ nationalReport,
+ ...result.edarateShahri.map((edare) => {
+ const filteredReports = grouped[edare.id];
+ return {
+ edare_name: edare.name_fa,
+ ...filteredReports,
+ };
+ }),
+ ]);
+ } catch (e) {
+ console.log(e);
+ }
+ }
+ } catch (error) {
+ console.log(error);
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ fetchData();
+ }, [filterData]);
+
+ return (
+
+
+ {!data ? (
+
+ ) : (
+ <>
+
+ >
+ )}
+
+ );
+};
+export default ReportAccessRoadPage;
diff --git a/src/components/dashboard/roadSafety/reports/constructionActivity/ExcelPrint/index.jsx b/src/components/dashboard/roadSafety/reports/constructionActivity/ExcelPrint/index.jsx
index 39f801a..59dfc8c 100644
--- a/src/components/dashboard/roadSafety/reports/constructionActivity/ExcelPrint/index.jsx
+++ b/src/components/dashboard/roadSafety/reports/constructionActivity/ExcelPrint/index.jsx
@@ -1,70 +1,70 @@
-"use client";
-import DataTableFilterDataStructure from "@/core/utils/DataTableFilterDataStructure";
-import isArrayEmpty from "@/core/utils/isArrayEmpty";
-import {
- EXPORT_ROAD_SAFETY_CITY_ACTIVITY_CONSTRUCTION_ACTIVITY_REPORT,
- EXPORT_ROAD_SAFETY_PROVINCE_ACTIVITY_CONSTRUCTION_ACTIVITY_REPORTT,
-} from "@/core/utils/routes";
-import useRequest from "@/lib/hooks/useRequest";
-import { useTheme } from "@emotion/react";
-import DescriptionIcon from "@mui/icons-material/Description";
-import { Button, CircularProgress, IconButton, useMediaQuery } from "@mui/material";
-import FileSaver from "file-saver";
-import moment from "jalali-moment";
-import { useState } from "react";
-
-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 clickHandler = () => {
- setLoading(true);
- const filters = DataTableFilterDataStructure(filterData, isArrayEmpty);
- const filterParams = new URLSearchParams();
- let requestUrl;
- filterParams.set("filters", JSON.stringify(filters || []));
- if (filterData.province_id.value === "") {
- requestUrl = EXPORT_ROAD_SAFETY_PROVINCE_ACTIVITY_CONSTRUCTION_ACTIVITY_REPORTT;
- } else {
- filterParams.set("province_id", filterData.province_id.value);
- requestUrl = EXPORT_ROAD_SAFETY_CITY_ACTIVITY_CONSTRUCTION_ACTIVITY_REPORT;
- }
-
- 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;
+"use client";
+import DataTableFilterDataStructure from "@/core/utils/DataTableFilterDataStructure";
+import isArrayEmpty from "@/core/utils/isArrayEmpty";
+import {
+ EXPORT_ROAD_SAFETY_CITY_ACTIVITY_CONSTRUCTION_ACTIVITY_REPORT,
+ EXPORT_ROAD_SAFETY_PROVINCE_ACTIVITY_CONSTRUCTION_ACTIVITY_REPORTT,
+} from "@/core/utils/routes";
+import useRequest from "@/lib/hooks/useRequest";
+import { useTheme } from "@emotion/react";
+import DescriptionIcon from "@mui/icons-material/Description";
+import { Button, CircularProgress, IconButton, useMediaQuery } from "@mui/material";
+import FileSaver from "file-saver";
+import moment from "jalali-moment";
+import { useState } from "react";
+
+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 clickHandler = () => {
+ setLoading(true);
+ const filters = DataTableFilterDataStructure(filterData, isArrayEmpty);
+ const filterParams = new URLSearchParams();
+ let requestUrl;
+ filterParams.set("filters", JSON.stringify(filters || []));
+ if (filterData.province_id.value === "") {
+ requestUrl = EXPORT_ROAD_SAFETY_PROVINCE_ACTIVITY_CONSTRUCTION_ACTIVITY_REPORTT;
+ } else {
+ filterParams.set("province_id", filterData.province_id.value);
+ requestUrl = EXPORT_ROAD_SAFETY_CITY_ACTIVITY_CONSTRUCTION_ACTIVITY_REPORT;
+ }
+
+ 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/roadSafety/reports/constructionActivity/ReportLists.jsx b/src/components/dashboard/roadSafety/reports/constructionActivity/ReportLists.jsx
index 37fa24a..919388a 100644
--- a/src/components/dashboard/roadSafety/reports/constructionActivity/ReportLists.jsx
+++ b/src/components/dashboard/roadSafety/reports/constructionActivity/ReportLists.jsx
@@ -1,463 +1,463 @@
-"use client";
-import DataTableWithAuth from "@/core/components/DataTableWithAuth";
-import { Box } from "@mui/material";
-import { useMemo } from "react";
-import Toolbar from "./Toolbar";
-
-const ReportLists = ({ data, filterData, setFilterData, isLoading }) => {
- const columns = useMemo(() => {
- return [
- {
- accessorKey: "edare_name",
- header: "اداره کل",
- id: "edare_name",
- enableColumnFilter: false,
- enableSorting: false,
- datatype: "text",
- grow: false,
- size: 50,
- },
- {
- accessorFn: (row) => (row["1"] ? row["1"].total_sum : 0),
- header: "تعداد کل",
- id: "sum",
- 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 / 1).toLocaleString();
- },
- },
- {
- header: "آزادراه",
- enableColumnFilter: false,
- enableSorting: false,
- datatype: "text",
- id: "id_1",
- grow: false,
- size: 50,
- columns: [
- {
- accessorFn: (row) => (row["1"] ? row["1"].s1 : 0),
- header: "گام اول",
- id: "id_1.1",
- 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 / 1).toLocaleString();
- },
- },
- {
- accessorFn: (row) => (row["1"] ? row["1"].s2 : 0),
- header: "گام دوم",
- id: "id_1.2",
- 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 / 1).toLocaleString();
- },
- },
- {
- accessorFn: (row) => (row["1"] ? row["1"].s3 : 0),
- header: "گام سوم",
- id: "id_1.3",
- 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 / 1).toLocaleString();
- },
- },
- ],
- },
- {
- header: "بزرگراه",
- enableColumnFilter: false,
- enableSorting: false,
- datatype: "text",
- id: "id_2",
- grow: false,
- size: 50,
- columns: [
- {
- accessorFn: (row) => (row["2"] ? row["2"].s1 : 0),
- header: "گام اول",
- id: "id_2.1",
- 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 / 1).toLocaleString();
- },
- },
- {
- accessorFn: (row) => (row["2"] ? row["2"].s2 : 0),
- header: "گام دوم",
- id: "id_2.2",
- 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 / 1).toLocaleString();
- },
- },
- {
- accessorFn: (row) => (row["2"] ? row["2"].s3 : 0),
- header: "گام سوم",
- id: "id_2.3",
- 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 / 1).toLocaleString();
- },
- },
- ],
- },
- {
- header: "اصلی",
- enableColumnFilter: false,
- enableSorting: false,
- datatype: "text",
- id: "id_3",
- grow: false,
- size: 50,
- columns: [
- {
- accessorFn: (row) => (row["3"] ? row["3"].s1 : 0),
- header: "گام اول",
- id: "id_3.1",
- 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 / 1).toLocaleString();
- },
- },
- {
- accessorFn: (row) => (row["3"] ? row["3"].s2 : 0),
- header: "گام دوم",
- id: "id_3.2",
- 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 / 1).toLocaleString();
- },
- },
- {
- accessorFn: (row) => (row["3"] ? row["3"].s3 : 0),
- header: "گام سوم",
- id: "id_3.3",
- 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 / 1).toLocaleString();
- },
- },
- ],
- },
- {
- header: "فرعی",
- enableColumnFilter: false,
- enableSorting: false,
- datatype: "text",
- id: "id_4",
- grow: false,
- size: 50,
- columns: [
- {
- accessorFn: (row) => (row["4"] ? row["4"].s1 : 0),
- header: "گام اول",
- id: "id_4.1",
- 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 / 1).toLocaleString();
- },
- },
- {
- accessorFn: (row) => (row["4"] ? row["4"].s2 : 0),
- header: "گام دوم",
- id: "id_4.2",
- 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 / 1).toLocaleString();
- },
- },
- {
- accessorFn: (row) => (row["4"] ? row["4"].s3 : 0),
- header: "گام سوم",
- id: "id_4.3",
- 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 / 1).toLocaleString();
- },
- },
- ],
- },
- {
- header: "روستایی",
- enableColumnFilter: false,
- enableSorting: false,
- datatype: "text",
- id: "id_5",
- grow: false,
- size: 50,
- columns: [
- {
- accessorFn: (row) => (row["5"] ? row["5"].s1 : 0),
- header: "گام اول",
- id: "id_5.1",
- 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 / 1).toLocaleString();
- },
- },
- {
- accessorFn: (row) => (row["5"] ? row["5"].s2 : 0),
- header: "گام دوم",
- id: "id_5.2",
- 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 / 1).toLocaleString();
- },
- },
- {
- accessorFn: (row) => (row["5"] ? row["5"].s3 : 0),
- header: "گام سوم",
- id: "id_5.3",
- 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 / 1).toLocaleString();
- },
- },
- ],
- },
- ];
- }, []);
-
- return (
-
-
-
- );
-};
-
-export default ReportLists;
+"use client";
+import DataTableWithAuth from "@/core/components/DataTableWithAuth";
+import { Box } from "@mui/material";
+import { useMemo } from "react";
+import Toolbar from "./Toolbar";
+
+const ReportLists = ({ data, filterData, setFilterData, isLoading }) => {
+ const columns = useMemo(() => {
+ return [
+ {
+ accessorKey: "edare_name",
+ header: "اداره کل",
+ id: "edare_name",
+ enableColumnFilter: false,
+ enableSorting: false,
+ datatype: "text",
+ grow: false,
+ size: 50,
+ },
+ {
+ accessorFn: (row) => (row["1"] ? row["1"].total_sum : 0),
+ header: "تعداد کل",
+ id: "sum",
+ 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 / 1).toLocaleString();
+ },
+ },
+ {
+ header: "آزادراه",
+ enableColumnFilter: false,
+ enableSorting: false,
+ datatype: "text",
+ id: "id_1",
+ grow: false,
+ size: 50,
+ columns: [
+ {
+ accessorFn: (row) => (row["1"] ? row["1"].s1 : 0),
+ header: "گام اول",
+ id: "id_1.1",
+ 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 / 1).toLocaleString();
+ },
+ },
+ {
+ accessorFn: (row) => (row["1"] ? row["1"].s2 : 0),
+ header: "گام دوم",
+ id: "id_1.2",
+ 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 / 1).toLocaleString();
+ },
+ },
+ {
+ accessorFn: (row) => (row["1"] ? row["1"].s3 : 0),
+ header: "گام سوم",
+ id: "id_1.3",
+ 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 / 1).toLocaleString();
+ },
+ },
+ ],
+ },
+ {
+ header: "بزرگراه",
+ enableColumnFilter: false,
+ enableSorting: false,
+ datatype: "text",
+ id: "id_2",
+ grow: false,
+ size: 50,
+ columns: [
+ {
+ accessorFn: (row) => (row["2"] ? row["2"].s1 : 0),
+ header: "گام اول",
+ id: "id_2.1",
+ 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 / 1).toLocaleString();
+ },
+ },
+ {
+ accessorFn: (row) => (row["2"] ? row["2"].s2 : 0),
+ header: "گام دوم",
+ id: "id_2.2",
+ 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 / 1).toLocaleString();
+ },
+ },
+ {
+ accessorFn: (row) => (row["2"] ? row["2"].s3 : 0),
+ header: "گام سوم",
+ id: "id_2.3",
+ 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 / 1).toLocaleString();
+ },
+ },
+ ],
+ },
+ {
+ header: "اصلی",
+ enableColumnFilter: false,
+ enableSorting: false,
+ datatype: "text",
+ id: "id_3",
+ grow: false,
+ size: 50,
+ columns: [
+ {
+ accessorFn: (row) => (row["3"] ? row["3"].s1 : 0),
+ header: "گام اول",
+ id: "id_3.1",
+ 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 / 1).toLocaleString();
+ },
+ },
+ {
+ accessorFn: (row) => (row["3"] ? row["3"].s2 : 0),
+ header: "گام دوم",
+ id: "id_3.2",
+ 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 / 1).toLocaleString();
+ },
+ },
+ {
+ accessorFn: (row) => (row["3"] ? row["3"].s3 : 0),
+ header: "گام سوم",
+ id: "id_3.3",
+ 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 / 1).toLocaleString();
+ },
+ },
+ ],
+ },
+ {
+ header: "فرعی",
+ enableColumnFilter: false,
+ enableSorting: false,
+ datatype: "text",
+ id: "id_4",
+ grow: false,
+ size: 50,
+ columns: [
+ {
+ accessorFn: (row) => (row["4"] ? row["4"].s1 : 0),
+ header: "گام اول",
+ id: "id_4.1",
+ 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 / 1).toLocaleString();
+ },
+ },
+ {
+ accessorFn: (row) => (row["4"] ? row["4"].s2 : 0),
+ header: "گام دوم",
+ id: "id_4.2",
+ 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 / 1).toLocaleString();
+ },
+ },
+ {
+ accessorFn: (row) => (row["4"] ? row["4"].s3 : 0),
+ header: "گام سوم",
+ id: "id_4.3",
+ 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 / 1).toLocaleString();
+ },
+ },
+ ],
+ },
+ {
+ header: "روستایی",
+ enableColumnFilter: false,
+ enableSorting: false,
+ datatype: "text",
+ id: "id_5",
+ grow: false,
+ size: 50,
+ columns: [
+ {
+ accessorFn: (row) => (row["5"] ? row["5"].s1 : 0),
+ header: "گام اول",
+ id: "id_5.1",
+ 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 / 1).toLocaleString();
+ },
+ },
+ {
+ accessorFn: (row) => (row["5"] ? row["5"].s2 : 0),
+ header: "گام دوم",
+ id: "id_5.2",
+ 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 / 1).toLocaleString();
+ },
+ },
+ {
+ accessorFn: (row) => (row["5"] ? row["5"].s3 : 0),
+ header: "گام سوم",
+ id: "id_5.3",
+ 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 / 1).toLocaleString();
+ },
+ },
+ ],
+ },
+ ];
+ }, []);
+
+ return (
+
+
+
+ );
+};
+
+export default ReportLists;
diff --git a/src/components/dashboard/roadSafety/reports/constructionActivity/Toolbar.jsx b/src/components/dashboard/roadSafety/reports/constructionActivity/Toolbar.jsx
index 7dd930f..3e5ab8c 100644
--- a/src/components/dashboard/roadSafety/reports/constructionActivity/Toolbar.jsx
+++ b/src/components/dashboard/roadSafety/reports/constructionActivity/Toolbar.jsx
@@ -1,11 +1,11 @@
-import PrintExcel from "./ExcelPrint";
-import { Box } from "@mui/material";
-
-const Toolbar = ({ table, filterData, mutate }) => {
- return (
-
-
-
- );
-};
-export default Toolbar;
+import PrintExcel from "./ExcelPrint";
+import { Box } from "@mui/material";
+
+const Toolbar = ({ table, filterData, mutate }) => {
+ return (
+
+
+
+ );
+};
+export default Toolbar;
diff --git a/src/components/dashboard/roadSafety/reports/constructionActivity/index.jsx b/src/components/dashboard/roadSafety/reports/constructionActivity/index.jsx
index d3c784b..4548dc7 100644
--- a/src/components/dashboard/roadSafety/reports/constructionActivity/index.jsx
+++ b/src/components/dashboard/roadSafety/reports/constructionActivity/index.jsx
@@ -1,205 +1,205 @@
-"use client";
-import CustomSelectByDependency from "@/core/components/FilterDrawer/fieldsType/CustomSelectByDependency";
-import PageTitle from "@/core/components/PageTitle";
-import DataTableFilterDataStructure from "@/core/utils/DataTableFilterDataStructure";
-import groupByEdareAxisStep from "@/core/utils/groupByEdareAxisStep";
-import groupByProvinceAxisStep from "@/core/utils/groupByProvinceAxisStep";
-import isArrayEmpty from "@/core/utils/isArrayEmpty";
-import {
- GET_ROAD_SAFETY_CITY_ACTIVITY_CONSTRUCTION_ACTIVITY_REPORT,
- GET_ROAD_SAFETY_PROVINCE_ACTIVITY_CONSTRUCTION_ACTIVITY_REPORT,
-} from "@/core/utils/routes";
-import { useAuth } from "@/lib/contexts/auth";
-import { usePermissions } from "@/lib/hooks/usePermissions";
-import useProvinces from "@/lib/hooks/useProvince";
-import useRequest from "@/lib/hooks/useRequest";
-import { LinearProgress, Stack } from "@mui/material";
-import { useEffect, useMemo, useState } from "react";
-import ReportLists from "./ReportLists";
-
-const ReportConstructionActivityPage = () => {
- const { data: userPermissions } = usePermissions();
- const hasProvincesPermission = userPermissions.includes("show-safety-and-privacy-operator-cartable");
- const { user } = useAuth();
- const requestServer = useRequest();
- const [data, setData] = useState(null);
- const [isLoading, setLoading] = useState(true);
-
- const defaultValues = useMemo(
- () => [
- {
- header: "استان",
- id: "province_id",
- filterMode: "equals",
- datatype: "numeric",
- value: hasProvincesPermission ? "" : user.province_id,
- enable: hasProvincesPermission,
- SelectComponent: (props) => {
- const { provinces, errorProvinces, loadingProvinces } = useProvinces();
- const getSelectOptions = 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 (
-
- );
- },
- },
- {
- header: "مورد",
- id: "info_id",
- filterMode: "equals",
- datatype: "numeric",
- value: "89",
- enable: false,
- },
- {
- header: "تاریخ ثبت",
- id: "created_at",
- filterMode: "between",
- datatype: "date",
- value: ["", ""],
- enable: true,
- },
- {
- header: "تاریخ بازدید",
- id: "activity_date_time",
- filterMode: "between",
- datatype: "date",
- value: ["", ""],
- enable: true,
- },
- {
- header: "تاریخ بارگذاری مستندات",
- id: "judiciary_document_upload_date",
- filterMode: "between",
- datatype: "date",
- value: ["", ""],
- enable: true,
- },
- {
- header: "تاریخ اقدام",
- id: "action_date",
- filterMode: "between",
- datatype: "date",
- value: ["", ""],
- enable: true,
- },
- ],
- [hasProvincesPermission, user.province_id]
- );
-
- const [filterData, setFilterData] = useState(
- defaultValues.reduce((acc, item) => {
- acc[item.id] = item;
- return acc;
- }, {})
- );
-
- useEffect(() => {
- const fetchData = async () => {
- try {
- setLoading(true);
- const filters = DataTableFilterDataStructure(filterData, isArrayEmpty);
- const params = new URLSearchParams();
- params.set("filters", JSON.stringify(filters || []));
- if (filterData.province_id.value === "") {
- try {
- const response = await requestServer(
- `${GET_ROAD_SAFETY_PROVINCE_ACTIVITY_CONSTRUCTION_ACTIVITY_REPORT}?${params.toString()}`
- );
-
- const result = response.data.data;
- const grouped = groupByProvinceAxisStep(result.activities);
-
- const nationalReportForItem = grouped[-1];
- const nationalReport = {
- edare_name: "کل کشور",
- ...nationalReportForItem,
- };
-
- setData([
- nationalReport,
- ...result.provinces.map((province) => {
- const filteredReports = grouped[province.id];
- return {
- ...filteredReports,
- edare_name: province.name_fa,
- };
- }),
- ]);
- } catch (e) {
- console.log(e);
- }
- } else {
- params.set("province_id", filterData.province_id.value);
- try {
- const response = await requestServer(
- `${GET_ROAD_SAFETY_CITY_ACTIVITY_CONSTRUCTION_ACTIVITY_REPORT}?${params.toString()}`
- );
- const result = response.data.data;
- const grouped = groupByEdareAxisStep(result.activities);
-
- const nationalReportForItem = grouped[-1];
- const nationalReport = {
- ...nationalReportForItem,
- edare_name: "کل استان",
- };
- setData([
- nationalReport,
- ...result.edarateShahri.map((edare) => {
- const filteredReports = grouped[edare.id];
- return {
- edare_name: edare.name_fa,
- ...filteredReports,
- };
- }),
- ]);
- } catch (e) {
- console.log(e);
- }
- }
- } catch (error) {
- console.log(error);
- } finally {
- setLoading(false);
- }
- };
-
- fetchData();
- }, [filterData]);
-
- return (
-
-
- {!data ? (
-
- ) : (
- <>
-
- >
- )}
-
- );
-};
-export default ReportConstructionActivityPage;
+"use client";
+import CustomSelectByDependency from "@/core/components/FilterDrawer/fieldsType/CustomSelectByDependency";
+import PageTitle from "@/core/components/PageTitle";
+import DataTableFilterDataStructure from "@/core/utils/DataTableFilterDataStructure";
+import groupByEdareAxisStep from "@/core/utils/groupByEdareAxisStep";
+import groupByProvinceAxisStep from "@/core/utils/groupByProvinceAxisStep";
+import isArrayEmpty from "@/core/utils/isArrayEmpty";
+import {
+ GET_ROAD_SAFETY_CITY_ACTIVITY_CONSTRUCTION_ACTIVITY_REPORT,
+ GET_ROAD_SAFETY_PROVINCE_ACTIVITY_CONSTRUCTION_ACTIVITY_REPORT,
+} from "@/core/utils/routes";
+import { useAuth } from "@/lib/contexts/auth";
+import { usePermissions } from "@/lib/hooks/usePermissions";
+import useProvinces from "@/lib/hooks/useProvince";
+import useRequest from "@/lib/hooks/useRequest";
+import { LinearProgress, Stack } from "@mui/material";
+import { useEffect, useMemo, useState } from "react";
+import ReportLists from "./ReportLists";
+
+const ReportConstructionActivityPage = () => {
+ const { data: userPermissions } = usePermissions();
+ const hasProvincesPermission = userPermissions.includes("show-safety-and-privacy-operator-cartable");
+ const { user } = useAuth();
+ const requestServer = useRequest();
+ const [data, setData] = useState(null);
+ const [isLoading, setLoading] = useState(true);
+
+ const defaultValues = useMemo(
+ () => [
+ {
+ header: "استان",
+ id: "province_id",
+ filterMode: "equals",
+ datatype: "numeric",
+ value: hasProvincesPermission ? "" : user.province_id,
+ enable: hasProvincesPermission,
+ SelectComponent: (props) => {
+ const { provinces, errorProvinces, loadingProvinces } = useProvinces();
+ const getSelectOptions = 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 (
+
+ );
+ },
+ },
+ {
+ header: "مورد",
+ id: "info_id",
+ filterMode: "equals",
+ datatype: "numeric",
+ value: "89",
+ enable: false,
+ },
+ {
+ header: "تاریخ ثبت",
+ id: "created_at",
+ filterMode: "between",
+ datatype: "date",
+ value: ["", ""],
+ enable: true,
+ },
+ {
+ header: "تاریخ بازدید",
+ id: "activity_date_time",
+ filterMode: "between",
+ datatype: "date",
+ value: ["", ""],
+ enable: true,
+ },
+ {
+ header: "تاریخ بارگذاری مستندات",
+ id: "judiciary_document_upload_date",
+ filterMode: "between",
+ datatype: "date",
+ value: ["", ""],
+ enable: true,
+ },
+ {
+ header: "تاریخ اقدام",
+ id: "action_date",
+ filterMode: "between",
+ datatype: "date",
+ value: ["", ""],
+ enable: true,
+ },
+ ],
+ [hasProvincesPermission, user.province_id]
+ );
+
+ const [filterData, setFilterData] = useState(
+ defaultValues.reduce((acc, item) => {
+ acc[item.id] = item;
+ return acc;
+ }, {})
+ );
+
+ useEffect(() => {
+ const fetchData = async () => {
+ try {
+ setLoading(true);
+ const filters = DataTableFilterDataStructure(filterData, isArrayEmpty);
+ const params = new URLSearchParams();
+ params.set("filters", JSON.stringify(filters || []));
+ if (filterData.province_id.value === "") {
+ try {
+ const response = await requestServer(
+ `${GET_ROAD_SAFETY_PROVINCE_ACTIVITY_CONSTRUCTION_ACTIVITY_REPORT}?${params.toString()}`
+ );
+
+ const result = response.data.data;
+ const grouped = groupByProvinceAxisStep(result.activities);
+
+ const nationalReportForItem = grouped[-1];
+ const nationalReport = {
+ edare_name: "کل کشور",
+ ...nationalReportForItem,
+ };
+
+ setData([
+ nationalReport,
+ ...result.provinces.map((province) => {
+ const filteredReports = grouped[province.id];
+ return {
+ ...filteredReports,
+ edare_name: province.name_fa,
+ };
+ }),
+ ]);
+ } catch (e) {
+ console.log(e);
+ }
+ } else {
+ params.set("province_id", filterData.province_id.value);
+ try {
+ const response = await requestServer(
+ `${GET_ROAD_SAFETY_CITY_ACTIVITY_CONSTRUCTION_ACTIVITY_REPORT}?${params.toString()}`
+ );
+ const result = response.data.data;
+ const grouped = groupByEdareAxisStep(result.activities);
+
+ const nationalReportForItem = grouped[-1];
+ const nationalReport = {
+ ...nationalReportForItem,
+ edare_name: "کل استان",
+ };
+ setData([
+ nationalReport,
+ ...result.edarateShahri.map((edare) => {
+ const filteredReports = grouped[edare.id];
+ return {
+ edare_name: edare.name_fa,
+ ...filteredReports,
+ };
+ }),
+ ]);
+ } catch (e) {
+ console.log(e);
+ }
+ }
+ } catch (error) {
+ console.log(error);
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ fetchData();
+ }, [filterData]);
+
+ return (
+
+
+ {!data ? (
+
+ ) : (
+ <>
+
+ >
+ )}
+
+ );
+};
+export default ReportConstructionActivityPage;
diff --git a/src/components/dashboard/roadSafety/reports/utilityPassingActivity/ExcelPrint/index.jsx b/src/components/dashboard/roadSafety/reports/utilityPassingActivity/ExcelPrint/index.jsx
index 69fd75e..406d8e1 100644
--- a/src/components/dashboard/roadSafety/reports/utilityPassingActivity/ExcelPrint/index.jsx
+++ b/src/components/dashboard/roadSafety/reports/utilityPassingActivity/ExcelPrint/index.jsx
@@ -1,70 +1,70 @@
-"use client";
-import DataTableFilterDataStructure from "@/core/utils/DataTableFilterDataStructure";
-import isArrayEmpty from "@/core/utils/isArrayEmpty";
-import {
- EXPORT_ROAD_SAFETY_CITY_ACTIVITY_UTILITY_PASSING_ACTIVITY_REPORT,
- EXPORT_ROAD_SAFETY_PROVINCE_ACTIVITY_UTILITY_PASSING_ACTIVITY_REPORTT,
-} from "@/core/utils/routes";
-import useRequest from "@/lib/hooks/useRequest";
-import { useTheme } from "@emotion/react";
-import DescriptionIcon from "@mui/icons-material/Description";
-import { Button, CircularProgress, IconButton, useMediaQuery } from "@mui/material";
-import FileSaver from "file-saver";
-import moment from "jalali-moment";
-import { useState } from "react";
-
-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 clickHandler = () => {
- setLoading(true);
- const filters = DataTableFilterDataStructure(filterData, isArrayEmpty);
- const filterParams = new URLSearchParams();
- let requestUrl;
- filterParams.set("filters", JSON.stringify(filters || []));
- if (filterData.province_id.value === "") {
- requestUrl = EXPORT_ROAD_SAFETY_PROVINCE_ACTIVITY_UTILITY_PASSING_ACTIVITY_REPORTT;
- } else {
- filterParams.set("province_id", filterData.province_id.value);
- requestUrl = EXPORT_ROAD_SAFETY_CITY_ACTIVITY_UTILITY_PASSING_ACTIVITY_REPORT;
- }
-
- 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;
+"use client";
+import DataTableFilterDataStructure from "@/core/utils/DataTableFilterDataStructure";
+import isArrayEmpty from "@/core/utils/isArrayEmpty";
+import {
+ EXPORT_ROAD_SAFETY_CITY_ACTIVITY_UTILITY_PASSING_ACTIVITY_REPORT,
+ EXPORT_ROAD_SAFETY_PROVINCE_ACTIVITY_UTILITY_PASSING_ACTIVITY_REPORTT,
+} from "@/core/utils/routes";
+import useRequest from "@/lib/hooks/useRequest";
+import { useTheme } from "@emotion/react";
+import DescriptionIcon from "@mui/icons-material/Description";
+import { Button, CircularProgress, IconButton, useMediaQuery } from "@mui/material";
+import FileSaver from "file-saver";
+import moment from "jalali-moment";
+import { useState } from "react";
+
+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 clickHandler = () => {
+ setLoading(true);
+ const filters = DataTableFilterDataStructure(filterData, isArrayEmpty);
+ const filterParams = new URLSearchParams();
+ let requestUrl;
+ filterParams.set("filters", JSON.stringify(filters || []));
+ if (filterData.province_id.value === "") {
+ requestUrl = EXPORT_ROAD_SAFETY_PROVINCE_ACTIVITY_UTILITY_PASSING_ACTIVITY_REPORTT;
+ } else {
+ filterParams.set("province_id", filterData.province_id.value);
+ requestUrl = EXPORT_ROAD_SAFETY_CITY_ACTIVITY_UTILITY_PASSING_ACTIVITY_REPORT;
+ }
+
+ 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/roadSafety/reports/utilityPassingActivity/ReportLists.jsx b/src/components/dashboard/roadSafety/reports/utilityPassingActivity/ReportLists.jsx
index 7d46eaf..6558738 100644
--- a/src/components/dashboard/roadSafety/reports/utilityPassingActivity/ReportLists.jsx
+++ b/src/components/dashboard/roadSafety/reports/utilityPassingActivity/ReportLists.jsx
@@ -1,463 +1,463 @@
-"use client";
-import DataTableWithAuth from "@/core/components/DataTableWithAuth";
-import { Box } from "@mui/material";
-import { useMemo } from "react";
-import Toolbar from "./Toolbar";
-
-const ReportLists = ({ data, filterData, setFilterData, isLoading }) => {
- const columns = useMemo(() => {
- return [
- {
- accessorKey: "edare_name",
- header: "اداره کل",
- id: "edare_name",
- enableColumnFilter: false,
- enableSorting: false,
- datatype: "text",
- grow: false,
- size: 50,
- },
- {
- accessorFn: (row) => (row["1"] ? row["1"].total_sum : 0),
- header: "تعداد کل",
- id: "sum",
- 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 / 1).toLocaleString();
- },
- },
- {
- header: "آزادراه",
- enableColumnFilter: false,
- enableSorting: false,
- datatype: "text",
- id: "id_1",
- grow: false,
- size: 50,
- columns: [
- {
- accessorFn: (row) => (row["1"] ? row["1"].s1 : 0),
- header: "گام اول",
- id: "id_1.1",
- 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 / 1).toLocaleString();
- },
- },
- {
- accessorFn: (row) => (row["1"] ? row["1"].s2 : 0),
- header: "گام دوم",
- id: "id_1.2",
- 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 / 1).toLocaleString();
- },
- },
- {
- accessorFn: (row) => (row["1"] ? row["1"].s3 : 0),
- header: "گام سوم",
- id: "id_1.3",
- 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 / 1).toLocaleString();
- },
- },
- ],
- },
- {
- header: "بزرگراه",
- enableColumnFilter: false,
- enableSorting: false,
- datatype: "text",
- id: "id_2",
- grow: false,
- size: 50,
- columns: [
- {
- accessorFn: (row) => (row["2"] ? row["2"].s1 : 0),
- header: "گام اول",
- id: "id_2.1",
- 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 / 1).toLocaleString();
- },
- },
- {
- accessorFn: (row) => (row["2"] ? row["2"].s2 : 0),
- header: "گام دوم",
- id: "id_2.2",
- 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 / 1).toLocaleString();
- },
- },
- {
- accessorFn: (row) => (row["2"] ? row["2"].s3 : 0),
- header: "گام سوم",
- id: "id_2.3",
- 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 / 1).toLocaleString();
- },
- },
- ],
- },
- {
- header: "اصلی",
- enableColumnFilter: false,
- enableSorting: false,
- datatype: "text",
- id: "id_3",
- grow: false,
- size: 50,
- columns: [
- {
- accessorFn: (row) => (row["3"] ? row["3"].s1 : 0),
- header: "گام اول",
- id: "id_3.1",
- 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 / 1).toLocaleString();
- },
- },
- {
- accessorFn: (row) => (row["3"] ? row["3"].s2 : 0),
- header: "گام دوم",
- id: "id_3.2",
- 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 / 1).toLocaleString();
- },
- },
- {
- accessorFn: (row) => (row["3"] ? row["3"].s3 : 0),
- header: "گام سوم",
- id: "id_3.3",
- 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 / 1).toLocaleString();
- },
- },
- ],
- },
- {
- header: "فرعی",
- enableColumnFilter: false,
- enableSorting: false,
- datatype: "text",
- id: "id_4",
- grow: false,
- size: 50,
- columns: [
- {
- accessorFn: (row) => (row["4"] ? row["4"].s1 : 0),
- header: "گام اول",
- id: "id_4.1",
- 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 / 1).toLocaleString();
- },
- },
- {
- accessorFn: (row) => (row["4"] ? row["4"].s2 : 0),
- header: "گام دوم",
- id: "id_4.2",
- 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 / 1).toLocaleString();
- },
- },
- {
- accessorFn: (row) => (row["4"] ? row["4"].s3 : 0),
- header: "گام سوم",
- id: "id_4.3",
- 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 / 1).toLocaleString();
- },
- },
- ],
- },
- {
- header: "روستایی",
- enableColumnFilter: false,
- enableSorting: false,
- datatype: "text",
- id: "id_5",
- grow: false,
- size: 50,
- columns: [
- {
- accessorFn: (row) => (row["5"] ? row["5"].s1 : 0),
- header: "گام اول",
- id: "id_5.1",
- 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 / 1).toLocaleString();
- },
- },
- {
- accessorFn: (row) => (row["5"] ? row["5"].s2 : 0),
- header: "گام دوم",
- id: "id_5.2",
- 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 / 1).toLocaleString();
- },
- },
- {
- accessorFn: (row) => (row["5"] ? row["5"].s3 : 0),
- header: "گام سوم",
- id: "id_5.3",
- 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 / 1).toLocaleString();
- },
- },
- ],
- },
- ];
- }, []);
-
- return (
-
-
-
- );
-};
-
-export default ReportLists;
+"use client";
+import DataTableWithAuth from "@/core/components/DataTableWithAuth";
+import { Box } from "@mui/material";
+import { useMemo } from "react";
+import Toolbar from "./Toolbar";
+
+const ReportLists = ({ data, filterData, setFilterData, isLoading }) => {
+ const columns = useMemo(() => {
+ return [
+ {
+ accessorKey: "edare_name",
+ header: "اداره کل",
+ id: "edare_name",
+ enableColumnFilter: false,
+ enableSorting: false,
+ datatype: "text",
+ grow: false,
+ size: 50,
+ },
+ {
+ accessorFn: (row) => (row["1"] ? row["1"].total_sum : 0),
+ header: "تعداد کل",
+ id: "sum",
+ 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 / 1).toLocaleString();
+ },
+ },
+ {
+ header: "آزادراه",
+ enableColumnFilter: false,
+ enableSorting: false,
+ datatype: "text",
+ id: "id_1",
+ grow: false,
+ size: 50,
+ columns: [
+ {
+ accessorFn: (row) => (row["1"] ? row["1"].s1 : 0),
+ header: "گام اول",
+ id: "id_1.1",
+ 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 / 1).toLocaleString();
+ },
+ },
+ {
+ accessorFn: (row) => (row["1"] ? row["1"].s2 : 0),
+ header: "گام دوم",
+ id: "id_1.2",
+ 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 / 1).toLocaleString();
+ },
+ },
+ {
+ accessorFn: (row) => (row["1"] ? row["1"].s3 : 0),
+ header: "گام سوم",
+ id: "id_1.3",
+ 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 / 1).toLocaleString();
+ },
+ },
+ ],
+ },
+ {
+ header: "بزرگراه",
+ enableColumnFilter: false,
+ enableSorting: false,
+ datatype: "text",
+ id: "id_2",
+ grow: false,
+ size: 50,
+ columns: [
+ {
+ accessorFn: (row) => (row["2"] ? row["2"].s1 : 0),
+ header: "گام اول",
+ id: "id_2.1",
+ 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 / 1).toLocaleString();
+ },
+ },
+ {
+ accessorFn: (row) => (row["2"] ? row["2"].s2 : 0),
+ header: "گام دوم",
+ id: "id_2.2",
+ 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 / 1).toLocaleString();
+ },
+ },
+ {
+ accessorFn: (row) => (row["2"] ? row["2"].s3 : 0),
+ header: "گام سوم",
+ id: "id_2.3",
+ 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 / 1).toLocaleString();
+ },
+ },
+ ],
+ },
+ {
+ header: "اصلی",
+ enableColumnFilter: false,
+ enableSorting: false,
+ datatype: "text",
+ id: "id_3",
+ grow: false,
+ size: 50,
+ columns: [
+ {
+ accessorFn: (row) => (row["3"] ? row["3"].s1 : 0),
+ header: "گام اول",
+ id: "id_3.1",
+ 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 / 1).toLocaleString();
+ },
+ },
+ {
+ accessorFn: (row) => (row["3"] ? row["3"].s2 : 0),
+ header: "گام دوم",
+ id: "id_3.2",
+ 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 / 1).toLocaleString();
+ },
+ },
+ {
+ accessorFn: (row) => (row["3"] ? row["3"].s3 : 0),
+ header: "گام سوم",
+ id: "id_3.3",
+ 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 / 1).toLocaleString();
+ },
+ },
+ ],
+ },
+ {
+ header: "فرعی",
+ enableColumnFilter: false,
+ enableSorting: false,
+ datatype: "text",
+ id: "id_4",
+ grow: false,
+ size: 50,
+ columns: [
+ {
+ accessorFn: (row) => (row["4"] ? row["4"].s1 : 0),
+ header: "گام اول",
+ id: "id_4.1",
+ 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 / 1).toLocaleString();
+ },
+ },
+ {
+ accessorFn: (row) => (row["4"] ? row["4"].s2 : 0),
+ header: "گام دوم",
+ id: "id_4.2",
+ 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 / 1).toLocaleString();
+ },
+ },
+ {
+ accessorFn: (row) => (row["4"] ? row["4"].s3 : 0),
+ header: "گام سوم",
+ id: "id_4.3",
+ 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 / 1).toLocaleString();
+ },
+ },
+ ],
+ },
+ {
+ header: "روستایی",
+ enableColumnFilter: false,
+ enableSorting: false,
+ datatype: "text",
+ id: "id_5",
+ grow: false,
+ size: 50,
+ columns: [
+ {
+ accessorFn: (row) => (row["5"] ? row["5"].s1 : 0),
+ header: "گام اول",
+ id: "id_5.1",
+ 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 / 1).toLocaleString();
+ },
+ },
+ {
+ accessorFn: (row) => (row["5"] ? row["5"].s2 : 0),
+ header: "گام دوم",
+ id: "id_5.2",
+ 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 / 1).toLocaleString();
+ },
+ },
+ {
+ accessorFn: (row) => (row["5"] ? row["5"].s3 : 0),
+ header: "گام سوم",
+ id: "id_5.3",
+ 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 / 1).toLocaleString();
+ },
+ },
+ ],
+ },
+ ];
+ }, []);
+
+ return (
+
+
+
+ );
+};
+
+export default ReportLists;
diff --git a/src/components/dashboard/roadSafety/reports/utilityPassingActivity/Toolbar.jsx b/src/components/dashboard/roadSafety/reports/utilityPassingActivity/Toolbar.jsx
index 7dd930f..3e5ab8c 100644
--- a/src/components/dashboard/roadSafety/reports/utilityPassingActivity/Toolbar.jsx
+++ b/src/components/dashboard/roadSafety/reports/utilityPassingActivity/Toolbar.jsx
@@ -1,11 +1,11 @@
-import PrintExcel from "./ExcelPrint";
-import { Box } from "@mui/material";
-
-const Toolbar = ({ table, filterData, mutate }) => {
- return (
-
-
-
- );
-};
-export default Toolbar;
+import PrintExcel from "./ExcelPrint";
+import { Box } from "@mui/material";
+
+const Toolbar = ({ table, filterData, mutate }) => {
+ return (
+
+
+
+ );
+};
+export default Toolbar;
diff --git a/src/components/dashboard/roadSafety/reports/utilityPassingActivity/index.jsx b/src/components/dashboard/roadSafety/reports/utilityPassingActivity/index.jsx
index 5621b3a..49371d8 100644
--- a/src/components/dashboard/roadSafety/reports/utilityPassingActivity/index.jsx
+++ b/src/components/dashboard/roadSafety/reports/utilityPassingActivity/index.jsx
@@ -1,205 +1,205 @@
-"use client";
-import CustomSelectByDependency from "@/core/components/FilterDrawer/fieldsType/CustomSelectByDependency";
-import PageTitle from "@/core/components/PageTitle";
-import DataTableFilterDataStructure from "@/core/utils/DataTableFilterDataStructure";
-import groupByEdareAxisStep from "@/core/utils/groupByEdareAxisStep";
-import groupByProvinceAxisStep from "@/core/utils/groupByProvinceAxisStep";
-import isArrayEmpty from "@/core/utils/isArrayEmpty";
-import {
- GET_ROAD_SAFETY_CITY_ACTIVITY_UTILITY_PASSING_ACTIVITY_REPORT,
- GET_ROAD_SAFETY_PROVINCE_ACTIVITY_UTILITY_PASSING_ACTIVITY_REPORT,
-} from "@/core/utils/routes";
-import { useAuth } from "@/lib/contexts/auth";
-import { usePermissions } from "@/lib/hooks/usePermissions";
-import useProvinces from "@/lib/hooks/useProvince";
-import useRequest from "@/lib/hooks/useRequest";
-import { LinearProgress, Stack } from "@mui/material";
-import { useEffect, useMemo, useState } from "react";
-import ReportLists from "./ReportLists";
-
-const ReportUtilityPassingActivityPage = () => {
- const { data: userPermissions } = usePermissions();
- const hasProvincesPermission = userPermissions.includes("show-safety-and-privacy-operator-cartable");
- const { user } = useAuth();
- const requestServer = useRequest();
- const [data, setData] = useState(null);
- const [isLoading, setLoading] = useState(true);
-
- const defaultValues = useMemo(
- () => [
- {
- header: "استان",
- id: "province_id",
- filterMode: "equals",
- datatype: "numeric",
- value: hasProvincesPermission ? "" : user.province_id,
- enable: hasProvincesPermission,
- SelectComponent: (props) => {
- const { provinces, errorProvinces, loadingProvinces } = useProvinces();
- const getSelectOptions = 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 (
-
- );
- },
- },
- {
- header: "مورد",
- id: "info_id",
- filterMode: "equals",
- datatype: "numeric",
- value: "91",
- enable: false,
- },
- {
- header: "تاریخ ثبت",
- id: "created_at",
- filterMode: "between",
- datatype: "date",
- value: ["", ""],
- enable: true,
- },
- {
- header: "تاریخ بازدید",
- id: "activity_date_time",
- filterMode: "between",
- datatype: "date",
- value: ["", ""],
- enable: true,
- },
- {
- header: "تاریخ بارگذاری مستندات",
- id: "judiciary_document_upload_date",
- filterMode: "between",
- datatype: "date",
- value: ["", ""],
- enable: true,
- },
- {
- header: "تاریخ اقدام",
- id: "action_date",
- filterMode: "between",
- datatype: "date",
- value: ["", ""],
- enable: true,
- },
- ],
- [hasProvincesPermission, user.province_id]
- );
-
- const [filterData, setFilterData] = useState(
- defaultValues.reduce((acc, item) => {
- acc[item.id] = item;
- return acc;
- }, {})
- );
-
- useEffect(() => {
- const fetchData = async () => {
- try {
- setLoading(true);
- const filters = DataTableFilterDataStructure(filterData, isArrayEmpty);
- const params = new URLSearchParams();
- params.set("filters", JSON.stringify(filters || []));
- if (filterData.province_id.value === "") {
- try {
- const response = await requestServer(
- `${GET_ROAD_SAFETY_PROVINCE_ACTIVITY_UTILITY_PASSING_ACTIVITY_REPORT}?${params.toString()}`
- );
-
- const result = response.data.data;
- const grouped = groupByProvinceAxisStep(result.activities);
-
- const nationalReportForItem = grouped[-1];
- const nationalReport = {
- edare_name: "کل کشور",
- ...nationalReportForItem,
- };
-
- setData([
- nationalReport,
- ...result.provinces.map((province) => {
- const filteredReports = grouped[province.id];
- return {
- ...filteredReports,
- edare_name: province.name_fa,
- };
- }),
- ]);
- } catch (e) {
- console.log(e);
- }
- } else {
- params.set("province_id", filterData.province_id.value);
- try {
- const response = await requestServer(
- `${GET_ROAD_SAFETY_CITY_ACTIVITY_UTILITY_PASSING_ACTIVITY_REPORT}?${params.toString()}`
- );
- const result = response.data.data;
- const grouped = groupByEdareAxisStep(result.activities);
-
- const nationalReportForItem = grouped[-1];
- const nationalReport = {
- ...nationalReportForItem,
- edare_name: "کل استان",
- };
- setData([
- nationalReport,
- ...result.edarateShahri.map((edare) => {
- const filteredReports = grouped[edare.id];
- return {
- edare_name: edare.name_fa,
- ...filteredReports,
- };
- }),
- ]);
- } catch (e) {
- console.log(e);
- }
- }
- } catch (error) {
- console.log(error);
- } finally {
- setLoading(false);
- }
- };
-
- fetchData();
- }, [filterData]);
-
- return (
-
-
- {!data ? (
-
- ) : (
- <>
-
- >
- )}
-
- );
-};
-export default ReportUtilityPassingActivityPage;
+"use client";
+import CustomSelectByDependency from "@/core/components/FilterDrawer/fieldsType/CustomSelectByDependency";
+import PageTitle from "@/core/components/PageTitle";
+import DataTableFilterDataStructure from "@/core/utils/DataTableFilterDataStructure";
+import groupByEdareAxisStep from "@/core/utils/groupByEdareAxisStep";
+import groupByProvinceAxisStep from "@/core/utils/groupByProvinceAxisStep";
+import isArrayEmpty from "@/core/utils/isArrayEmpty";
+import {
+ GET_ROAD_SAFETY_CITY_ACTIVITY_UTILITY_PASSING_ACTIVITY_REPORT,
+ GET_ROAD_SAFETY_PROVINCE_ACTIVITY_UTILITY_PASSING_ACTIVITY_REPORT,
+} from "@/core/utils/routes";
+import { useAuth } from "@/lib/contexts/auth";
+import { usePermissions } from "@/lib/hooks/usePermissions";
+import useProvinces from "@/lib/hooks/useProvince";
+import useRequest from "@/lib/hooks/useRequest";
+import { LinearProgress, Stack } from "@mui/material";
+import { useEffect, useMemo, useState } from "react";
+import ReportLists from "./ReportLists";
+
+const ReportUtilityPassingActivityPage = () => {
+ const { data: userPermissions } = usePermissions();
+ const hasProvincesPermission = userPermissions.includes("show-safety-and-privacy-operator-cartable");
+ const { user } = useAuth();
+ const requestServer = useRequest();
+ const [data, setData] = useState(null);
+ const [isLoading, setLoading] = useState(true);
+
+ const defaultValues = useMemo(
+ () => [
+ {
+ header: "استان",
+ id: "province_id",
+ filterMode: "equals",
+ datatype: "numeric",
+ value: hasProvincesPermission ? "" : user.province_id,
+ enable: hasProvincesPermission,
+ SelectComponent: (props) => {
+ const { provinces, errorProvinces, loadingProvinces } = useProvinces();
+ const getSelectOptions = 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 (
+
+ );
+ },
+ },
+ {
+ header: "مورد",
+ id: "info_id",
+ filterMode: "equals",
+ datatype: "numeric",
+ value: "91",
+ enable: false,
+ },
+ {
+ header: "تاریخ ثبت",
+ id: "created_at",
+ filterMode: "between",
+ datatype: "date",
+ value: ["", ""],
+ enable: true,
+ },
+ {
+ header: "تاریخ بازدید",
+ id: "activity_date_time",
+ filterMode: "between",
+ datatype: "date",
+ value: ["", ""],
+ enable: true,
+ },
+ {
+ header: "تاریخ بارگذاری مستندات",
+ id: "judiciary_document_upload_date",
+ filterMode: "between",
+ datatype: "date",
+ value: ["", ""],
+ enable: true,
+ },
+ {
+ header: "تاریخ اقدام",
+ id: "action_date",
+ filterMode: "between",
+ datatype: "date",
+ value: ["", ""],
+ enable: true,
+ },
+ ],
+ [hasProvincesPermission, user.province_id]
+ );
+
+ const [filterData, setFilterData] = useState(
+ defaultValues.reduce((acc, item) => {
+ acc[item.id] = item;
+ return acc;
+ }, {})
+ );
+
+ useEffect(() => {
+ const fetchData = async () => {
+ try {
+ setLoading(true);
+ const filters = DataTableFilterDataStructure(filterData, isArrayEmpty);
+ const params = new URLSearchParams();
+ params.set("filters", JSON.stringify(filters || []));
+ if (filterData.province_id.value === "") {
+ try {
+ const response = await requestServer(
+ `${GET_ROAD_SAFETY_PROVINCE_ACTIVITY_UTILITY_PASSING_ACTIVITY_REPORT}?${params.toString()}`
+ );
+
+ const result = response.data.data;
+ const grouped = groupByProvinceAxisStep(result.activities);
+
+ const nationalReportForItem = grouped[-1];
+ const nationalReport = {
+ edare_name: "کل کشور",
+ ...nationalReportForItem,
+ };
+
+ setData([
+ nationalReport,
+ ...result.provinces.map((province) => {
+ const filteredReports = grouped[province.id];
+ return {
+ ...filteredReports,
+ edare_name: province.name_fa,
+ };
+ }),
+ ]);
+ } catch (e) {
+ console.log(e);
+ }
+ } else {
+ params.set("province_id", filterData.province_id.value);
+ try {
+ const response = await requestServer(
+ `${GET_ROAD_SAFETY_CITY_ACTIVITY_UTILITY_PASSING_ACTIVITY_REPORT}?${params.toString()}`
+ );
+ const result = response.data.data;
+ const grouped = groupByEdareAxisStep(result.activities);
+
+ const nationalReportForItem = grouped[-1];
+ const nationalReport = {
+ ...nationalReportForItem,
+ edare_name: "کل استان",
+ };
+ setData([
+ nationalReport,
+ ...result.edarateShahri.map((edare) => {
+ const filteredReports = grouped[edare.id];
+ return {
+ edare_name: edare.name_fa,
+ ...filteredReports,
+ };
+ }),
+ ]);
+ } catch (e) {
+ console.log(e);
+ }
+ }
+ } catch (error) {
+ console.log(error);
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ fetchData();
+ }, [filterData]);
+
+ return (
+
+
+ {!data ? (
+
+ ) : (
+ <>
+
+ >
+ )}
+
+ );
+};
+export default ReportUtilityPassingActivityPage;
diff --git a/src/components/dashboard/roadSafety/supervisor/RowActions/ActionPictureDialog/List.jsx b/src/components/dashboard/roadSafety/supervisor/RowActions/ActionPictureDialog/List.jsx
index 8f3bfb2..be3c840 100644
--- a/src/components/dashboard/roadSafety/supervisor/RowActions/ActionPictureDialog/List.jsx
+++ b/src/components/dashboard/roadSafety/supervisor/RowActions/ActionPictureDialog/List.jsx
@@ -1,13 +1,13 @@
-import { Stack } from "@mui/material";
-import ActionPictureContent from "./ActionPictureContent";
-
-const List = ({ image1, image2, image3 }) => {
- return (
-
-
-
-
-
- );
-};
-export default List;
+import { Stack } from "@mui/material";
+import ActionPictureContent from "./ActionPictureContent";
+
+const List = ({ image1, image2, image3 }) => {
+ return (
+
+
+
+
+
+ );
+};
+export default List;
diff --git a/src/components/dashboard/roadSafety/supervisor/RowActions/RecognizePictureDialog/List.jsx b/src/components/dashboard/roadSafety/supervisor/RowActions/RecognizePictureDialog/List.jsx
index 6456faf..b6b20a1 100644
--- a/src/components/dashboard/roadSafety/supervisor/RowActions/RecognizePictureDialog/List.jsx
+++ b/src/components/dashboard/roadSafety/supervisor/RowActions/RecognizePictureDialog/List.jsx
@@ -1,12 +1,12 @@
-import { Stack } from "@mui/material";
-import RecognizePictureContent from "./RecognizePictureContent";
-
-const List = ({ image1, image2 }) => {
- return (
-
-
-
-
- );
-};
-export default List;
+import { Stack } from "@mui/material";
+import RecognizePictureContent from "./RecognizePictureContent";
+
+const List = ({ image1, image2 }) => {
+ return (
+
+
+
+
+ );
+};
+export default List;
diff --git a/src/components/infrastructure/tollHouse/Form/CreateTollHouse/TollHouseArea.jsx b/src/components/infrastructure/tollHouse/Form/CreateTollHouse/TollHouseArea.jsx
index 9ae0f66..15b8804 100644
--- a/src/components/infrastructure/tollHouse/Form/CreateTollHouse/TollHouseArea.jsx
+++ b/src/components/infrastructure/tollHouse/Form/CreateTollHouse/TollHouseArea.jsx
@@ -1,80 +1,80 @@
-import LtrTextField from "@/core/components/LtrTextField";
-import { Add, Close } from "@mui/icons-material";
-import { Button, Collapse, Divider, IconButton, Stack, Typography } from "@mui/material";
-import { TransitionGroup } from "react-transition-group";
-
-const TollHouseArea = ({ value, onChange, error = [] }) => {
- const handleChange = (index, field, newValue) => {
- const newPoints = [...value];
- newPoints[index] = { ...newPoints[index], [field]: newValue };
- onChange(newPoints);
- };
-
- const handleAdd = () => {
- onChange([...value, { lat: "", lon: "" }]);
- };
-
- const handleRemove = (index) => {
- if (value.length > 4) {
- const newPoints = value.filter((_, i) => i !== index);
- onChange(newPoints);
- }
- };
-
- return (
-
- {value.map((point, index) => (
-
-
- #{index + 1}
- {index >= 4 && (
- handleRemove(index)}>
-
-
- )}
-
-
- handleChange(index, "lat", e.target.value)}
- error={Boolean(error[index]?.lat)}
- helperText={error[index]?.lat?.message}
- />
- handleChange(index, "lon", e.target.value)}
- error={Boolean(error[index]?.lon)}
- helperText={error[index]?.lon?.message}
- />
-
-
-
- ))}
-
-
-
- }
- onClick={handleAdd}
- sx={{ alignSelf: "flex-start" }}
- >
- افزودن نقطه
-
-
-
-
-
- );
-};
-export default TollHouseArea;
+import LtrTextField from "@/core/components/LtrTextField";
+import { Add, Close } from "@mui/icons-material";
+import { Button, Collapse, Divider, IconButton, Stack, Typography } from "@mui/material";
+import { TransitionGroup } from "react-transition-group";
+
+const TollHouseArea = ({ value, onChange, error = [] }) => {
+ const handleChange = (index, field, newValue) => {
+ const newPoints = [...value];
+ newPoints[index] = { ...newPoints[index], [field]: newValue };
+ onChange(newPoints);
+ };
+
+ const handleAdd = () => {
+ onChange([...value, { lat: "", lon: "" }]);
+ };
+
+ const handleRemove = (index) => {
+ if (value.length > 4) {
+ const newPoints = value.filter((_, i) => i !== index);
+ onChange(newPoints);
+ }
+ };
+
+ return (
+
+ {value.map((point, index) => (
+
+
+ #{index + 1}
+ {index >= 4 && (
+ handleRemove(index)}>
+
+
+ )}
+
+
+ handleChange(index, "lat", e.target.value)}
+ error={Boolean(error[index]?.lat)}
+ helperText={error[index]?.lat?.message}
+ />
+ handleChange(index, "lon", e.target.value)}
+ error={Boolean(error[index]?.lon)}
+ helperText={error[index]?.lon?.message}
+ />
+
+
+
+ ))}
+
+
+
+ }
+ onClick={handleAdd}
+ sx={{ alignSelf: "flex-start" }}
+ >
+ افزودن نقطه
+
+
+
+
+
+ );
+};
+export default TollHouseArea;
diff --git a/src/components/infrastructure/tollHouse/Form/CreateTollHouse/index.jsx b/src/components/infrastructure/tollHouse/Form/CreateTollHouse/index.jsx
index a9cb7cf..5a6ffe1 100644
--- a/src/components/infrastructure/tollHouse/Form/CreateTollHouse/index.jsx
+++ b/src/components/infrastructure/tollHouse/Form/CreateTollHouse/index.jsx
@@ -53,10 +53,12 @@ const CreateTollHouse = ({ mutate }) => {
formData.append("lng", result.start_point.lng);
formData.append("area[type]", "polygon");
result.area.map((point, pointIndex) => {
- formData.append(`area[coordinates][${pointIndex}][0]`, point.lat);
- formData.append(`area[coordinates][${pointIndex}][1]`, point.lon);
+ formData.append(`area[coordinates][${pointIndex}][0]`, point.lon);
+ formData.append(`area[coordinates][${pointIndex}][1]`, point.lat);
});
-
+ const repeat_first = result.area.length;
+ formData.append(`area[coordinates][${repeat_first}][0]`, result.area[0].lon);
+ formData.append(`area[coordinates][${repeat_first}][1]`, result.area[0].lat);
await requestServer(`${CREATE_TOLL_HOUSE}`, "post", {
data: formData,
})
diff --git a/src/components/infrastructure/tollHouse/ShowProjectArea/ShowBound.jsx b/src/components/infrastructure/tollHouse/ShowProjectArea/ShowBound.jsx
index 24db476..43dd0b8 100644
--- a/src/components/infrastructure/tollHouse/ShowProjectArea/ShowBound.jsx
+++ b/src/components/infrastructure/tollHouse/ShowProjectArea/ShowBound.jsx
@@ -1,29 +1,29 @@
-import { useEffect, useRef } from "react";
-import { FeatureGroup, useMap } from "react-leaflet";
-
-const ShowBound = ({ bound }) => {
- const map = useMap();
- const featureRef = useRef(null);
-
- const safeFitBounds = (layer) => {
- if (!layer || !map) return;
- try {
- const latLngs = layer.getLatLngs();
- map.fitBounds(latLngs, {
- paddingTopLeft: [20, 20],
- paddingBottomRight: [20, 20],
- });
- } catch (e) {
- console.warn("fitBounds failed:", e);
- }
- };
-
- useEffect(() => {
- bound?.editing?.disable();
- featureRef.current.addLayer(bound);
- safeFitBounds(bound);
- }, []);
-
- return ;
-};
-export default ShowBound;
+import { useEffect, useRef } from "react";
+import { FeatureGroup, useMap } from "react-leaflet";
+
+const ShowBound = ({ bound }) => {
+ const map = useMap();
+ const featureRef = useRef(null);
+
+ const safeFitBounds = (layer) => {
+ if (!layer || !map) return;
+ try {
+ const latLngs = layer.getLatLngs();
+ map.fitBounds(latLngs, {
+ paddingTopLeft: [20, 20],
+ paddingBottomRight: [20, 20],
+ });
+ } catch (e) {
+ console.warn("fitBounds failed:", e);
+ }
+ };
+
+ useEffect(() => {
+ bound?.editing?.disable();
+ featureRef.current.addLayer(bound);
+ safeFitBounds(bound);
+ }, []);
+
+ return ;
+};
+export default ShowBound;
diff --git a/src/components/infrastructure/tollHouse/ShowProjectArea/index.jsx b/src/components/infrastructure/tollHouse/ShowProjectArea/index.jsx
index 250cd52..29f2697 100644
--- a/src/components/infrastructure/tollHouse/ShowProjectArea/index.jsx
+++ b/src/components/infrastructure/tollHouse/ShowProjectArea/index.jsx
@@ -1,65 +1,65 @@
-const { IconButton, Tooltip, Box, Dialog, DialogTitle, Typography, DialogContent } = require("@mui/material");
-import MapLayer from "@/core/components/MapLayer";
-import CloseIcon from "@mui/icons-material/Close";
-import LayersIcon from "@mui/icons-material/Layers";
-import L from "leaflet";
-import { useMemo, useState } from "react";
-import ShowBound from "./ShowBound";
-
-const ShowProjectArea = ({ primaryArea }) => {
- const [openShowAreaDialog, setOpenShowAreaDialog] = useState(false);
- const bound = useMemo(() => {
- const coordinates = Object.values(primaryArea.coordinates);
-
- const latLngCoords = coordinates.map(([lat, lng]) => [parseFloat(lng), parseFloat(lat)]);
-
- return primaryArea.type === "polygon"
- ? L.polygon(latLngCoords, { color: "#ff5555" })
- : L.polyline(latLngCoords);
- }, [primaryArea]);
-
- return (
-
-
- setOpenShowAreaDialog(true)}>
-
-
-
-
-
- );
-};
-
-export default ShowProjectArea;
+const { IconButton, Tooltip, Box, Dialog, DialogTitle, Typography, DialogContent } = require("@mui/material");
+import MapLayer from "@/core/components/MapLayer";
+import CloseIcon from "@mui/icons-material/Close";
+import LayersIcon from "@mui/icons-material/Layers";
+import L from "leaflet";
+import { useMemo, useState } from "react";
+import ShowBound from "./ShowBound";
+
+const ShowProjectArea = ({ primaryArea }) => {
+ const [openShowAreaDialog, setOpenShowAreaDialog] = useState(false);
+ const bound = useMemo(() => {
+ const coordinates = Object.values(primaryArea.coordinates);
+
+ const latLngCoords = coordinates.map(([lat, lng]) => [parseFloat(lng), parseFloat(lat)]);
+
+ return primaryArea.type === "polygon"
+ ? L.polygon(latLngCoords, { color: "#ff5555" })
+ : L.polyline(latLngCoords);
+ }, [primaryArea]);
+
+ return (
+
+
+ setOpenShowAreaDialog(true)}>
+
+
+
+
+
+ );
+};
+
+export default ShowProjectArea;
diff --git a/src/components/infrastructure/tollHouseMap/ClusterSwitch/index.jsx b/src/components/infrastructure/tollHouseMap/ClusterSwitch/index.jsx
index e8fac87..29312eb 100644
--- a/src/components/infrastructure/tollHouseMap/ClusterSwitch/index.jsx
+++ b/src/components/infrastructure/tollHouseMap/ClusterSwitch/index.jsx
@@ -1,25 +1,25 @@
-import DoneIcon from "@mui/icons-material/Done";
-import { Chip, Tooltip, Zoom } from "@mui/material";
-
-const ClusterSwitch = ({ isCluster, setCluster, disabled, max }) => {
- return (
-
-
- setCluster((c) => !c)}
- sx={{ borderRadius: 1 }}
- icon={
-
-
-
- }
- />
-
-
- );
-};
-export default ClusterSwitch;
+import DoneIcon from "@mui/icons-material/Done";
+import { Chip, Tooltip, Zoom } from "@mui/material";
+
+const ClusterSwitch = ({ isCluster, setCluster, disabled, max }) => {
+ return (
+
+
+ setCluster((c) => !c)}
+ sx={{ borderRadius: 1 }}
+ icon={
+
+
+
+ }
+ />
+
+
+ );
+};
+export default ClusterSwitch;
diff --git a/src/components/infrastructure/tollHouseMap/Filter/index.jsx b/src/components/infrastructure/tollHouseMap/Filter/index.jsx
index 3cbbe5d..7fdcacb 100644
--- a/src/components/infrastructure/tollHouseMap/Filter/index.jsx
+++ b/src/components/infrastructure/tollHouseMap/Filter/index.jsx
@@ -1,44 +1,44 @@
-"use client";
-import { Box, Button, Drawer } from "@mui/material";
-import FilterListIcon from "@mui/icons-material/FilterList";
-import { useCallback, useState } from "react";
-import FilterDrawer from "@/core/components/FilterDrawer";
-
-const drawerSx = {
- overflowY: "hidden",
- display: "flex",
- flexDirection: "column",
- height: "100%",
- zIndex: "1300",
-};
-
-const boxSx = {
- width: { xs: 300, sm: 450 },
-};
-
-const Filter = ({ filterData, setFilterData }) => {
- const [open, setOpen] = useState(false);
-
- const openDrawer = useCallback(() => setOpen(true), []);
- const closeDrawer = useCallback(() => setOpen(false), []);
-
- return (
- <>
- }>
- فیلتر
-
-
-
- {open && (
-
- )}
-
-
- >
- );
-};
-export default Filter;
+"use client";
+import { Box, Button, Drawer } from "@mui/material";
+import FilterListIcon from "@mui/icons-material/FilterList";
+import { useCallback, useState } from "react";
+import FilterDrawer from "@/core/components/FilterDrawer";
+
+const drawerSx = {
+ overflowY: "hidden",
+ display: "flex",
+ flexDirection: "column",
+ height: "100%",
+ zIndex: "1300",
+};
+
+const boxSx = {
+ width: { xs: 300, sm: 450 },
+};
+
+const Filter = ({ filterData, setFilterData }) => {
+ const [open, setOpen] = useState(false);
+
+ const openDrawer = useCallback(() => setOpen(true), []);
+ const closeDrawer = useCallback(() => setOpen(false), []);
+
+ return (
+ <>
+ }>
+ فیلتر
+
+
+
+ {open && (
+
+ )}
+
+
+ >
+ );
+};
+export default Filter;
diff --git a/src/components/infrastructure/tollHouseMap/Legend/index.jsx b/src/components/infrastructure/tollHouseMap/Legend/index.jsx
index b6f5936..90de5d4 100644
--- a/src/components/infrastructure/tollHouseMap/Legend/index.jsx
+++ b/src/components/infrastructure/tollHouseMap/Legend/index.jsx
@@ -1,35 +1,35 @@
-import { Box, Stack, Typography } from "@mui/material";
-
-const Legend = () => {
- return (
-
-
- theme.palette.success.main,
- background: (theme) => theme.palette.success.light,
- }}
- />
- فعال
-
-
- theme.palette.error.main,
- background: (theme) => theme.palette.error.light,
- }}
- />
- غیرفعال
-
-
- );
-};
-export default Legend;
+import { Box, Stack, Typography } from "@mui/material";
+
+const Legend = () => {
+ return (
+
+
+ theme.palette.success.main,
+ background: (theme) => theme.palette.success.light,
+ }}
+ />
+ فعال
+
+
+ theme.palette.error.main,
+ background: (theme) => theme.palette.error.light,
+ }}
+ />
+ غیرفعال
+
+
+ );
+};
+export default Legend;
diff --git a/src/components/infrastructure/tollHouseMap/PointsOnMap/DialogInfoItem/ContentInfoItem.jsx b/src/components/infrastructure/tollHouseMap/PointsOnMap/DialogInfoItem/ContentInfoItem.jsx
index 5061fe9..36ce07a 100644
--- a/src/components/infrastructure/tollHouseMap/PointsOnMap/DialogInfoItem/ContentInfoItem.jsx
+++ b/src/components/infrastructure/tollHouseMap/PointsOnMap/DialogInfoItem/ContentInfoItem.jsx
@@ -1,71 +1,71 @@
-import { Box, Chip, Divider, Stack, Typography } from "@mui/material";
-import moment from "jalali-moment";
-import Image from "next/image";
-
-const ContentInfoItem = ({ data }) => {
- return (
-
-
-
-
- {data.id !== "" && data.id}
-
-
-
-
-
- {data.province_name !== "" && data.province_name}
-
-
-
-
-
-
- {data.type_fa !== "" && data.type_fa}
-
-
-
-
-
-
- {data.status === "1" ? "فعال" : "غیرفعال"}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- );
-};
-export default ContentInfoItem;
+import { Box, Chip, Divider, Stack, Typography } from "@mui/material";
+import moment from "jalali-moment";
+import Image from "next/image";
+
+const ContentInfoItem = ({ data }) => {
+ return (
+
+
+
+
+ {data.id !== "" && data.id}
+
+
+
+
+
+ {data.province_name !== "" && data.province_name}
+
+
+
+
+
+
+ {data.type_fa !== "" && data.type_fa}
+
+
+
+
+
+
+ {data.status === "1" ? "فعال" : "غیرفعال"}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+};
+export default ContentInfoItem;
diff --git a/src/components/infrastructure/tollHouseMap/PointsOnMap/DialogInfoItem/index.jsx b/src/components/infrastructure/tollHouseMap/PointsOnMap/DialogInfoItem/index.jsx
index 232c2a4..6403083 100644
--- a/src/components/infrastructure/tollHouseMap/PointsOnMap/DialogInfoItem/index.jsx
+++ b/src/components/infrastructure/tollHouseMap/PointsOnMap/DialogInfoItem/index.jsx
@@ -1,51 +1,51 @@
-import DialogLoading from "@/core/components/DialogLoading";
-import { GET_TOLL_HOUSE_DETAILS } from "@/core/utils/routes";
-import useRequest from "@/lib/hooks/useRequest";
-import { Button, DialogActions, DialogContent, DialogTitle } from "@mui/material";
-import { useEffect, useState } from "react";
-import ContentInfoItem from "./ContentInfoItem";
-
-const DialogInfoItem = ({ selectedId, closeDialog }) => {
- const request = useRequest();
- const [loading, setLoading] = useState(true);
- const [data, setData] = useState(null);
-
- useEffect(() => {
- const controller = new AbortController();
-
- const fetchItem = async () => {
- setLoading(true);
- setData(null);
- try {
- const response = await request(`${GET_TOLL_HOUSE_DETAILS}/${selectedId}`, "get", {
- signal: controller.signal,
- });
- setData(response.data.data);
- } catch (error) {
- } finally {
- setLoading(false);
- }
- };
-
- fetchItem();
-
- return () => {
- controller.abort();
- };
- }, [selectedId]);
-
- return (
- <>
- جزئیات فعالیت
-
- {loading ? : data && }
-
-
-
-
- >
- );
-};
-export default DialogInfoItem;
+import DialogLoading from "@/core/components/DialogLoading";
+import { GET_TOLL_HOUSE_DETAILS } from "@/core/utils/routes";
+import useRequest from "@/lib/hooks/useRequest";
+import { Button, DialogActions, DialogContent, DialogTitle } from "@mui/material";
+import { useEffect, useState } from "react";
+import ContentInfoItem from "./ContentInfoItem";
+
+const DialogInfoItem = ({ selectedId, closeDialog }) => {
+ const request = useRequest();
+ const [loading, setLoading] = useState(true);
+ const [data, setData] = useState(null);
+
+ useEffect(() => {
+ const controller = new AbortController();
+
+ const fetchItem = async () => {
+ setLoading(true);
+ setData(null);
+ try {
+ const response = await request(`${GET_TOLL_HOUSE_DETAILS}/${selectedId}`, "get", {
+ signal: controller.signal,
+ });
+ setData(response.data.data);
+ } catch (error) {
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ fetchItem();
+
+ return () => {
+ controller.abort();
+ };
+ }, [selectedId]);
+
+ return (
+ <>
+ جزئیات فعالیت
+
+ {loading ? : data && }
+
+
+
+
+ >
+ );
+};
+export default DialogInfoItem;
diff --git a/src/components/infrastructure/tollHouseMap/PointsOnMap/index.jsx b/src/components/infrastructure/tollHouseMap/PointsOnMap/index.jsx
index 8283bbf..eb17037 100644
--- a/src/components/infrastructure/tollHouseMap/PointsOnMap/index.jsx
+++ b/src/components/infrastructure/tollHouseMap/PointsOnMap/index.jsx
@@ -1,97 +1,97 @@
-import { Dialog, useTheme } from "@mui/material";
-import { useCallback, useEffect, useMemo, useState } from "react";
-import { CircleMarker, useMap } from "react-leaflet";
-import MarkerClusterGroup from "react-leaflet-markercluster";
-import DialogInfoItem from "./DialogInfoItem";
-
-const PointsOnMap = ({ data, isCluster }) => {
- const map = useMap();
- const theme = useTheme();
- const [selectedId, setSelectedId] = useState(null);
- const [open, setOpen] = useState(false);
-
- const openDialog = useCallback(() => setOpen(true), []);
- const closeDialog = useCallback(() => setOpen(false), []);
-
- const getMarkerColor = (status) => {
- if (status === 1) return theme.palette.warning.main;
- if (status === 2) return theme.palette.error.main;
- return theme.palette.success.main;
- };
-
- const markers = useMemo(() => {
- return data.map(({ id, lat, lng, step }) => {
- if (!lat && !lng) return;
- return (
- {
- openDialog();
- setSelectedId(id);
- },
- }}
- color={getMarkerColor(Number(status))}
- />
- );
- });
- }, [data, theme]);
-
- useEffect(() => {
- if (data.length === 0) {
- // fly to Iran
- map.flyTo([32.4279, 53.688], 6, { duration: 0.7 });
- return;
- }
-
- // ساختن bounds با حذف مواردی که lat/lng ندارند
- const validPoints = data
- .filter(({ lat, lng }) => lat && lng)
- .map(({ lat, lng }) => L.latLng(Number(lat), Number(lng)));
-
- if (validPoints.length === 0) {
- // اگر هیچ مختصات معتبری نبود → ایران
- map.flyTo([32.4279, 53.688], 6, { duration: 0.7 });
- return;
- }
-
- const bounds = L.latLngBounds(validPoints);
-
- if (!bounds.isValid()) {
- // اگر bounds معتبر نبود → fallback روی ایران
- map.flyTo([32.4279, 53.688], 6, { duration: 0.7 });
- return;
- }
-
- map.flyToBounds(bounds, { duration: 0.7 });
- }, [data]);
-
- const createClusterCustomIcon = (cluster) => {
- const count = cluster.getChildCount();
- return L.divIcon({
- html: `${count}
`,
- className: "custom-marker-cluster",
- iconSize: L.point(40, 40, true),
- });
- };
-
- if (data.length === 0) return null;
-
- return (
- <>
- {isCluster ? (
-
- {markers}
-
- ) : (
- markers
- )}
-
- >
- );
-};
-export default PointsOnMap;
+import { Dialog, useTheme } from "@mui/material";
+import { useCallback, useEffect, useMemo, useState } from "react";
+import { CircleMarker, useMap } from "react-leaflet";
+import MarkerClusterGroup from "react-leaflet-markercluster";
+import DialogInfoItem from "./DialogInfoItem";
+
+const PointsOnMap = ({ data, isCluster }) => {
+ const map = useMap();
+ const theme = useTheme();
+ const [selectedId, setSelectedId] = useState(null);
+ const [open, setOpen] = useState(false);
+
+ const openDialog = useCallback(() => setOpen(true), []);
+ const closeDialog = useCallback(() => setOpen(false), []);
+
+ const getMarkerColor = (status) => {
+ if (status === 1) return theme.palette.warning.main;
+ if (status === 2) return theme.palette.error.main;
+ return theme.palette.success.main;
+ };
+
+ const markers = useMemo(() => {
+ return data.map(({ id, lat, lng, step }) => {
+ if (!lat && !lng) return;
+ return (
+ {
+ openDialog();
+ setSelectedId(id);
+ },
+ }}
+ color={getMarkerColor(Number(status))}
+ />
+ );
+ });
+ }, [data, theme]);
+
+ useEffect(() => {
+ if (data.length === 0) {
+ // fly to Iran
+ map.flyTo([32.4279, 53.688], 6, { duration: 0.7 });
+ return;
+ }
+
+ // ساختن bounds با حذف مواردی که lat/lng ندارند
+ const validPoints = data
+ .filter(({ lat, lng }) => lat && lng)
+ .map(({ lat, lng }) => L.latLng(Number(lat), Number(lng)));
+
+ if (validPoints.length === 0) {
+ // اگر هیچ مختصات معتبری نبود → ایران
+ map.flyTo([32.4279, 53.688], 6, { duration: 0.7 });
+ return;
+ }
+
+ const bounds = L.latLngBounds(validPoints);
+
+ if (!bounds.isValid()) {
+ // اگر bounds معتبر نبود → fallback روی ایران
+ map.flyTo([32.4279, 53.688], 6, { duration: 0.7 });
+ return;
+ }
+
+ map.flyToBounds(bounds, { duration: 0.7 });
+ }, [data]);
+
+ const createClusterCustomIcon = (cluster) => {
+ const count = cluster.getChildCount();
+ return L.divIcon({
+ html: `${count}
`,
+ className: "custom-marker-cluster",
+ iconSize: L.point(40, 40, true),
+ });
+ };
+
+ if (data.length === 0) return null;
+
+ return (
+ <>
+ {isCluster ? (
+
+ {markers}
+
+ ) : (
+ markers
+ )}
+
+ >
+ );
+};
+export default PointsOnMap;
diff --git a/src/components/infrastructure/tollHouseMap/index.jsx b/src/components/infrastructure/tollHouseMap/index.jsx
index f7b5a86..4fa4ace 100644
--- a/src/components/infrastructure/tollHouseMap/index.jsx
+++ b/src/components/infrastructure/tollHouseMap/index.jsx
@@ -1,231 +1,231 @@
-"use client";
-import LoadingHardPage from "@/core/components/LoadingHardPage";
-import MapLoading from "@/core/components/MapLayer/Loading";
-import isArrayEmpty from "@/core/utils/isArrayEmpty";
-import { GET_TOLL_HOUSE_MAP } from "@/core/utils/routes";
-import useRequest from "@/lib/hooks/useRequest";
-import { Box, Stack } from "@mui/material";
-import dynamic from "next/dynamic";
-import { useCallback, useEffect, useMemo, useState } from "react";
-import ClusterSwitch from "./ClusterSwitch";
-import Filter from "./Filter";
-import Legend from "./Legend";
-import PointsOnMap from "./PointsOnMap";
-import DataTableFilterDataStructure from "@/core/utils/DataTableFilterDataStructure";
-import useProvinces from "@/lib/hooks/useProvince";
-import CustomSelectByDependency from "@/core/components/FilterDrawer/fieldsType/CustomSelectByDependency";
-import useEdaratLists from "@/lib/hooks/useEdaratLists";
-const MapLayer = dynamic(() => import("@/core/components/MapLayer"), {
- loading: () => ,
- ssr: false,
-});
-const typeOptions = [
- { value: "", label: "همه نوع ها" },
- { value: 0, label: "فصلی" },
- { value: 1, label: "دائمی" },
- { value: 2, label: "موقت" },
-];
-
-const MAX_POINTS = 1000;
-
-const containerStyles = {
- width: "100%",
- height: "100%",
- p: 1,
- border: "1px dashed",
- borderColor: "divider",
- borderRadius: 1,
-};
-
-const controlBarStyles = {
- p: 1,
- background: "#fff",
-};
-
-const RoadSafetyReportMap = () => {
- const defaultValues = useMemo(
- () => [
- {
- header: "استان",
- id: "province_id",
- filterMode: "equals",
- datatype: "numeric",
- value: "",
- enable: true,
- SelectComponent: (props) => {
- const { provinces, errorProvinces, loadingProvinces } = useProvinces();
- const getSelectOptions = 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 (
-
- );
- },
- },
- {
- eader: "اداره",
- id: "edare_shahri_id",
- filterMode: "equals",
- datatype: "numeric",
- dependencyId: "province_id",
- value: "",
- enable: true,
- SelectComponent: (props) => {
- const { edaratList, loadingEdaratList, errorEdaratList } = useEdaratLists(
- props.dependencyFieldValue.value
- );
- const [prevDependency, setPrevDependency] = useState(props.dependencyFieldValue.value);
-
- const getSelectOptions = useMemo(() => {
- if (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 (prevDependency === props.dependencyFieldValue?.value) return;
- props.handleChange({ ...props.filterParameters, value: "" });
- setPrevDependency(props.dependencyFieldValue?.value);
- }, [props.dependencyFieldValue?.value]);
- return (
-
- );
- },
- },
- {
- header: "نوع",
- id: "type",
- filterMode: "equals",
- datatype: "numeric",
- value: "",
- enable: true,
- selectOption: () => {
- return typeOptions.map((status) => ({
- value: status.value,
- label: status.label,
- }));
- },
- },
- ],
- []
- );
- const requestServer = useRequest();
- const [filterData, setFilterData] = useState(
- defaultValues.reduce((acc, item) => {
- acc[item.id] = item;
- return acc;
- }, {})
- );
- const [isCluster, setCluster] = useState(false);
- const [data, setData] = useState([]);
- const [isLoading, setLoading] = useState(true);
-
- const buildQueryParams = useCallback(() => {
- const params = new URLSearchParams();
- const filters = DataTableFilterDataStructure(filterData, isArrayEmpty);
- params.set("filters", JSON.stringify(filters || []));
- return params.toString();
- }, [filterData]);
-
- useEffect(() => {
- const fetchData = async () => {
- try {
- setLoading(true);
- const params = new URLSearchParams();
- const filters = DataTableFilterDataStructure(filterData, isArrayEmpty);
- params.set("filters", JSON.stringify(filters || []));
- const query = params.toString();
- const response = await requestServer(`${GET_TOLL_HOUSE_MAP}?${query}`);
- const fetchedData = response?.data?.data || [];
-
- if (fetchedData.length > MAX_POINTS) {
- setCluster(true);
- }
- setData(fetchedData);
- } catch (error) {
- console.log(error);
- } finally {
- setLoading(false);
- }
- };
-
- fetchData();
- }, [filterData, buildQueryParams]);
-
- return (
-
-
-
-
- MAX_POINTS}
- max={MAX_POINTS}
- />
-
-
-
-
-
-
-
-
-
-
- {isLoading && (
-
-
-
- )}
-
-
-
-
- );
-};
-export default RoadSafetyReportMap;
+"use client";
+import LoadingHardPage from "@/core/components/LoadingHardPage";
+import MapLoading from "@/core/components/MapLayer/Loading";
+import isArrayEmpty from "@/core/utils/isArrayEmpty";
+import { GET_TOLL_HOUSE_MAP } from "@/core/utils/routes";
+import useRequest from "@/lib/hooks/useRequest";
+import { Box, Stack } from "@mui/material";
+import dynamic from "next/dynamic";
+import { useCallback, useEffect, useMemo, useState } from "react";
+import ClusterSwitch from "./ClusterSwitch";
+import Filter from "./Filter";
+import Legend from "./Legend";
+import PointsOnMap from "./PointsOnMap";
+import DataTableFilterDataStructure from "@/core/utils/DataTableFilterDataStructure";
+import useProvinces from "@/lib/hooks/useProvince";
+import CustomSelectByDependency from "@/core/components/FilterDrawer/fieldsType/CustomSelectByDependency";
+import useEdaratLists from "@/lib/hooks/useEdaratLists";
+const MapLayer = dynamic(() => import("@/core/components/MapLayer"), {
+ loading: () => ,
+ ssr: false,
+});
+const typeOptions = [
+ { value: "", label: "همه نوع ها" },
+ { value: 0, label: "فصلی" },
+ { value: 1, label: "دائمی" },
+ { value: 2, label: "موقت" },
+];
+
+const MAX_POINTS = 1000;
+
+const containerStyles = {
+ width: "100%",
+ height: "100%",
+ p: 1,
+ border: "1px dashed",
+ borderColor: "divider",
+ borderRadius: 1,
+};
+
+const controlBarStyles = {
+ p: 1,
+ background: "#fff",
+};
+
+const RoadSafetyReportMap = () => {
+ const defaultValues = useMemo(
+ () => [
+ {
+ header: "استان",
+ id: "province_id",
+ filterMode: "equals",
+ datatype: "numeric",
+ value: "",
+ enable: true,
+ SelectComponent: (props) => {
+ const { provinces, errorProvinces, loadingProvinces } = useProvinces();
+ const getSelectOptions = 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 (
+
+ );
+ },
+ },
+ {
+ eader: "اداره",
+ id: "edare_shahri_id",
+ filterMode: "equals",
+ datatype: "numeric",
+ dependencyId: "province_id",
+ value: "",
+ enable: true,
+ SelectComponent: (props) => {
+ const { edaratList, loadingEdaratList, errorEdaratList } = useEdaratLists(
+ props.dependencyFieldValue.value
+ );
+ const [prevDependency, setPrevDependency] = useState(props.dependencyFieldValue.value);
+
+ const getSelectOptions = useMemo(() => {
+ if (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 (prevDependency === props.dependencyFieldValue?.value) return;
+ props.handleChange({ ...props.filterParameters, value: "" });
+ setPrevDependency(props.dependencyFieldValue?.value);
+ }, [props.dependencyFieldValue?.value]);
+ return (
+
+ );
+ },
+ },
+ {
+ header: "نوع",
+ id: "type",
+ filterMode: "equals",
+ datatype: "numeric",
+ value: "",
+ enable: true,
+ selectOption: () => {
+ return typeOptions.map((status) => ({
+ value: status.value,
+ label: status.label,
+ }));
+ },
+ },
+ ],
+ []
+ );
+ const requestServer = useRequest();
+ const [filterData, setFilterData] = useState(
+ defaultValues.reduce((acc, item) => {
+ acc[item.id] = item;
+ return acc;
+ }, {})
+ );
+ const [isCluster, setCluster] = useState(false);
+ const [data, setData] = useState([]);
+ const [isLoading, setLoading] = useState(true);
+
+ const buildQueryParams = useCallback(() => {
+ const params = new URLSearchParams();
+ const filters = DataTableFilterDataStructure(filterData, isArrayEmpty);
+ params.set("filters", JSON.stringify(filters || []));
+ return params.toString();
+ }, [filterData]);
+
+ useEffect(() => {
+ const fetchData = async () => {
+ try {
+ setLoading(true);
+ const params = new URLSearchParams();
+ const filters = DataTableFilterDataStructure(filterData, isArrayEmpty);
+ params.set("filters", JSON.stringify(filters || []));
+ const query = params.toString();
+ const response = await requestServer(`${GET_TOLL_HOUSE_MAP}?${query}`);
+ const fetchedData = response?.data?.data || [];
+
+ if (fetchedData.length > MAX_POINTS) {
+ setCluster(true);
+ }
+ setData(fetchedData);
+ } catch (error) {
+ console.log(error);
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ fetchData();
+ }, [filterData, buildQueryParams]);
+
+ return (
+
+
+
+
+ MAX_POINTS}
+ max={MAX_POINTS}
+ />
+
+
+
+
+
+
+
+
+
+
+ {isLoading && (
+
+
+
+ )}
+
+
+
+
+ );
+};
+export default RoadSafetyReportMap;
diff --git a/src/core/components/RahdarNameOrCode.jsx b/src/core/components/RahdarNameOrCode.jsx
index 9f51949..b3799c7 100644
--- a/src/core/components/RahdarNameOrCode.jsx
+++ b/src/core/components/RahdarNameOrCode.jsx
@@ -1,93 +1,93 @@
-"use client";
-import { GET_RAHDARANS_LIST_SEARCH } from "@/core/utils/routes";
-import useRequest from "@/lib/hooks/useRequest";
-import { Autocomplete, CircularProgress, TextField } from "@mui/material";
-import { useEffect, useState } from "react";
-
-const RahdarNameOrCode = ({ title = "راهدار", rahdarsName, setRahdarsName, error, multiple = true }) => {
- const [inputValue, setInputValue] = useState(""); // مدیریت مقدار تایپشده
- const [options, setOptions] = useState([]);
- const [loading, setLoading] = useState(false);
- const requestServer = useRequest();
-
- useEffect(() => {
- const fetchRahdarNames = (inputValue, controller) => {
- if ((inputValue || "").length < 3) {
- setOptions([]);
- return;
- }
- setLoading(true);
- requestServer(`${GET_RAHDARANS_LIST_SEARCH}?search=${inputValue}`, "get", {
- requestOptions: { signal: controller.signal },
- })
- .then((response) => {
- const combinedArray = rahdarsName
- ? [...rahdarsName, ...response.data.data]
- : [...response.data.data];
- const uniqueArray = Array.from(new Map(combinedArray.map((item) => [item.id, item])).values());
- setOptions(uniqueArray || []);
- })
- .catch(() => {
- setOptions([]);
- })
- .finally(() => {
- setLoading(false);
- });
- };
-
- const controller = new AbortController();
- fetchRahdarNames(inputValue, controller);
- return () => controller.abort();
- }, [inputValue]);
-
- return (
- {
- setRahdarsName(multiple ? newValue || [] : newValue || null); // مدیریت حالت چندگانه و تکگانه
- }}
- inputValue={inputValue} // مقدار تایپشده
- onInputChange={(event, newInputValue) => {
- setInputValue(newInputValue || ""); // بهروزرسانی مقدار تایپشده
- }}
- options={options} // گزینههای موجود
- getOptionLabel={(option) => (typeof option === "string" ? option : `${option.code} - ${option.name}`)}
- isOptionEqualToValue={(option, value) => {
- if (!value) return false;
- if (value === "") return option.code === "";
- return option.code === (value?.code || value);
- }}
- loading={loading}
- loadingText={`درحال جستجوی ${title}`}
- noOptionsText={(inputValue || "").length < 3 ? `حداقل سه کاراکتر وارد کنید` : `${title}ی یافت نشد`}
- fullWidth
- renderInput={(params) => (
-
- {loading ? : null}
- {params.InputProps.endAdornment}
- >
- ),
- }}
- />
- )}
- />
- );
-};
-export default RahdarNameOrCode;
+"use client";
+import { GET_RAHDARANS_LIST_SEARCH } from "@/core/utils/routes";
+import useRequest from "@/lib/hooks/useRequest";
+import { Autocomplete, CircularProgress, TextField } from "@mui/material";
+import { useEffect, useState } from "react";
+
+const RahdarNameOrCode = ({ title = "راهدار", rahdarsName, setRahdarsName, error, multiple = true }) => {
+ const [inputValue, setInputValue] = useState(""); // مدیریت مقدار تایپشده
+ const [options, setOptions] = useState([]);
+ const [loading, setLoading] = useState(false);
+ const requestServer = useRequest();
+
+ useEffect(() => {
+ const fetchRahdarNames = (inputValue, controller) => {
+ if ((inputValue || "").length < 3) {
+ setOptions([]);
+ return;
+ }
+ setLoading(true);
+ requestServer(`${GET_RAHDARANS_LIST_SEARCH}?search=${inputValue}`, "get", {
+ requestOptions: { signal: controller.signal },
+ })
+ .then((response) => {
+ const combinedArray = rahdarsName
+ ? [...rahdarsName, ...response.data.data]
+ : [...response.data.data];
+ const uniqueArray = Array.from(new Map(combinedArray.map((item) => [item.id, item])).values());
+ setOptions(uniqueArray || []);
+ })
+ .catch(() => {
+ setOptions([]);
+ })
+ .finally(() => {
+ setLoading(false);
+ });
+ };
+
+ const controller = new AbortController();
+ fetchRahdarNames(inputValue, controller);
+ return () => controller.abort();
+ }, [inputValue]);
+
+ return (
+ {
+ setRahdarsName(multiple ? newValue || [] : newValue || null); // مدیریت حالت چندگانه و تکگانه
+ }}
+ inputValue={inputValue} // مقدار تایپشده
+ onInputChange={(event, newInputValue) => {
+ setInputValue(newInputValue || ""); // بهروزرسانی مقدار تایپشده
+ }}
+ options={options} // گزینههای موجود
+ getOptionLabel={(option) => (typeof option === "string" ? option : `${option.code} - ${option.name}`)}
+ isOptionEqualToValue={(option, value) => {
+ if (!value) return false;
+ if (value === "") return option.code === "";
+ return option.code === (value?.code || value);
+ }}
+ loading={loading}
+ loadingText={`درحال جستجوی ${title}`}
+ noOptionsText={(inputValue || "").length < 3 ? `حداقل سه کاراکتر وارد کنید` : `${title}ی یافت نشد`}
+ fullWidth
+ renderInput={(params) => (
+
+ {loading ? : null}
+ {params.InputProps.endAdornment}
+ >
+ ),
+ }}
+ />
+ )}
+ />
+ );
+};
+export default RahdarNameOrCode;
diff --git a/src/core/components/TabPanel.jsx b/src/core/components/TabPanel.jsx
index 529fad0..8228d2a 100644
--- a/src/core/components/TabPanel.jsx
+++ b/src/core/components/TabPanel.jsx
@@ -1,11 +1,11 @@
-import { Box } from "@mui/material";
-
-const TabPanel = (props) => {
- const { children, value, index } = props;
- return (
-
- {value === index && {children}}
-
- );
-};
-export default TabPanel;
+import { Box } from "@mui/material";
+
+const TabPanel = (props) => {
+ const { children, value, index } = props;
+ return (
+
+ {value === index && {children}}
+
+ );
+};
+export default TabPanel;
diff --git a/src/core/utils/geoCalculations.js b/src/core/utils/geoCalculations.js
index ebf8a96..e8f543e 100644
--- a/src/core/utils/geoCalculations.js
+++ b/src/core/utils/geoCalculations.js
@@ -1,35 +1,35 @@
-import * as turf from "@turf/turf";
-
-export const calculatePolygonMetrics = (coordinates, isLatLngOrder = true) => {
- if (!coordinates || coordinates.length < 3) {
- return { area: 0, sides: [], coordinates: [] };
- }
-
- const geoCoords = isLatLngOrder
- ? coordinates.map(([lat, lng]) => [lng, lat])
- : coordinates.map(([lng, lat]) => [lng, lat]);
-
- if (
- geoCoords[0][0] !== geoCoords[geoCoords.length - 1][0] ||
- geoCoords[0][1] !== geoCoords[geoCoords.length - 1][1]
- ) {
- geoCoords.push(geoCoords[0]);
- }
-
- const polygon = turf.polygon([geoCoords]);
-
- const area = turf.area(polygon);
-
- const sides = [];
- for (let i = 0; i < geoCoords.length - 1; i++) {
- const line = turf.lineString([geoCoords[i], geoCoords[i + 1]]);
- const length = turf.length(line, { units: "meters" });
- sides.push(length);
- }
-
- return {
- area,
- sides,
- coordinates: geoCoords,
- };
-};
+import * as turf from "@turf/turf";
+
+export const calculatePolygonMetrics = (coordinates, isLatLngOrder = true) => {
+ if (!coordinates || coordinates.length < 3) {
+ return { area: 0, sides: [], coordinates: [] };
+ }
+
+ const geoCoords = isLatLngOrder
+ ? coordinates.map(([lat, lng]) => [lng, lat])
+ : coordinates.map(([lng, lat]) => [lng, lat]);
+
+ if (
+ geoCoords[0][0] !== geoCoords[geoCoords.length - 1][0] ||
+ geoCoords[0][1] !== geoCoords[geoCoords.length - 1][1]
+ ) {
+ geoCoords.push(geoCoords[0]);
+ }
+
+ const polygon = turf.polygon([geoCoords]);
+
+ const area = turf.area(polygon);
+
+ const sides = [];
+ for (let i = 0; i < geoCoords.length - 1; i++) {
+ const line = turf.lineString([geoCoords[i], geoCoords[i + 1]]);
+ const length = turf.length(line, { units: "meters" });
+ sides.push(length);
+ }
+
+ return {
+ area,
+ sides,
+ coordinates: geoCoords,
+ };
+};
diff --git a/src/core/utils/groupByEdareAxisStep.js b/src/core/utils/groupByEdareAxisStep.js
index 90ffc73..729c3e4 100644
--- a/src/core/utils/groupByEdareAxisStep.js
+++ b/src/core/utils/groupByEdareAxisStep.js
@@ -1,12 +1,12 @@
-export default function groupByEdareAxisStep(data) {
- return data.reduce((acc, item) => {
- const { edare_id, axis_type_id } = item;
-
- if (!acc[edare_id]) acc[edare_id] = {};
- if (!acc[edare_id][axis_type_id]) acc[edare_id][axis_type_id] = {};
-
- acc[edare_id][axis_type_id] = { ...item };
-
- return acc;
- }, {});
-}
+export default function groupByEdareAxisStep(data) {
+ return data.reduce((acc, item) => {
+ const { edare_id, axis_type_id } = item;
+
+ if (!acc[edare_id]) acc[edare_id] = {};
+ if (!acc[edare_id][axis_type_id]) acc[edare_id][axis_type_id] = {};
+
+ acc[edare_id][axis_type_id] = { ...item };
+
+ return acc;
+ }, {});
+}
diff --git a/src/core/utils/groupByProvinceAxisStep.js b/src/core/utils/groupByProvinceAxisStep.js
index cd192f0..a9d9978 100644
--- a/src/core/utils/groupByProvinceAxisStep.js
+++ b/src/core/utils/groupByProvinceAxisStep.js
@@ -1,12 +1,12 @@
-export default function groupByProvinceAxisStep(data) {
- return data.reduce((acc, item) => {
- const { province_id, axis_type_id } = item;
-
- if (!acc[province_id]) acc[province_id] = {};
- if (!acc[province_id][axis_type_id]) acc[province_id][axis_type_id] = {};
-
- acc[province_id][axis_type_id] = { ...item };
-
- return acc;
- }, {});
-}
+export default function groupByProvinceAxisStep(data) {
+ return data.reduce((acc, item) => {
+ const { province_id, axis_type_id } = item;
+
+ if (!acc[province_id]) acc[province_id] = {};
+ if (!acc[province_id][axis_type_id]) acc[province_id][axis_type_id] = {};
+
+ acc[province_id][axis_type_id] = { ...item };
+
+ return acc;
+ }, {});
+}
diff --git a/src/core/utils/makeDateTime.js b/src/core/utils/makeDateTime.js
index 645a93c..6ee93b9 100644
--- a/src/core/utils/makeDateTime.js
+++ b/src/core/utils/makeDateTime.js
@@ -1,9 +1,9 @@
-export const makeDateTime = (date, time) => {
- if (!date) return null;
- const d = new Date(date);
- if (time) {
- const t = new Date(time);
- d.setHours(t.getHours(), t.getMinutes(), 0, 0);
- }
- return d;
-};
+export const makeDateTime = (date, time) => {
+ if (!date) return null;
+ const d = new Date(date);
+ if (time) {
+ const t = new Date(time);
+ d.setHours(t.getHours(), t.getMinutes(), 0, 0);
+ }
+ return d;
+};
diff --git a/src/core/utils/missionCategoryTypes.js b/src/core/utils/missionCategoryTypes.js
index 10ee11b..b9d912f 100644
--- a/src/core/utils/missionCategoryTypes.js
+++ b/src/core/utils/missionCategoryTypes.js
@@ -1,5 +1,5 @@
-export const missionCategoryTypes = [
- { id: 1, name_fa: "فعالیت روزانه" },
- { id: 2, name_fa: "گشت راهداری" },
- // { id: 3, name_fa: "واکنش سریع" },
-];
+export const missionCategoryTypes = [
+ { id: 1, name_fa: "فعالیت روزانه" },
+ { id: 2, name_fa: "گشت راهداری" },
+ // { id: 3, name_fa: "واکنش سریع" },
+];
diff --git a/src/core/utils/missionRegions.js b/src/core/utils/missionRegions.js
index 48896ca..7c42cb4 100644
--- a/src/core/utils/missionRegions.js
+++ b/src/core/utils/missionRegions.js
@@ -1,5 +1,5 @@
-export const missionRegions = [
- { id: 1, name_fa: "داخل شهر" },
- { id: 2, name_fa: "بیرون شهر - داخل محدوده" },
- { id: 3, name_fa: "بیرون شهر - خارج محدوده" },
-];
+export const missionRegions = [
+ { id: 1, name_fa: "داخل شهر" },
+ { id: 2, name_fa: "بیرون شهر - داخل محدوده" },
+ { id: 3, name_fa: "بیرون شهر - خارج محدوده" },
+];
diff --git a/src/core/utils/missionTypes.js b/src/core/utils/missionTypes.js
index 3b41b88..0e0d3fe 100644
--- a/src/core/utils/missionTypes.js
+++ b/src/core/utils/missionTypes.js
@@ -1,4 +1,4 @@
-export const missionTypes = [
- { id: 1, name_fa: "ساعتی" },
- { id: 2, name_fa: "روزانه" },
-];
+export const missionTypes = [
+ { id: 1, name_fa: "ساعتی" },
+ { id: 2, name_fa: "روزانه" },
+];
diff --git a/src/lib/hooks/useHistory.js b/src/lib/hooks/useHistory.js
index df1836c..f223eb2 100644
--- a/src/lib/hooks/useHistory.js
+++ b/src/lib/hooks/useHistory.js
@@ -1,30 +1,30 @@
-import { useState, useEffect } from "react";
-import useRequest from "@/lib/hooks/useRequest";
-import { GET_HISTORY_LIST } from "@/core/utils/routes";
-
-export const useHistory = (rowId) => {
- const requestServer = useRequest();
- const [historyData, setHistoryData] = useState([]);
- const [loading, setLoading] = useState(true);
- const [error, setError] = useState(null);
-
- useEffect(() => {
- if (!rowId) return;
-
- const fetchHistory = async () => {
- try {
- setLoading(true);
- const response = await requestServer(`${GET_HISTORY_LIST}/${rowId}`);
- setHistoryData(response.data.data);
- } catch (err) {
- setError(err.message);
- } finally {
- setLoading(false);
- }
- };
-
- fetchHistory();
- }, [rowId]);
-
- return { historyData, loading, error };
-};
+import { useState, useEffect } from "react";
+import useRequest from "@/lib/hooks/useRequest";
+import { GET_HISTORY_LIST } from "@/core/utils/routes";
+
+export const useHistory = (rowId) => {
+ const requestServer = useRequest();
+ const [historyData, setHistoryData] = useState([]);
+ const [loading, setLoading] = useState(true);
+ const [error, setError] = useState(null);
+
+ useEffect(() => {
+ if (!rowId) return;
+
+ const fetchHistory = async () => {
+ try {
+ setLoading(true);
+ const response = await requestServer(`${GET_HISTORY_LIST}/${rowId}`);
+ setHistoryData(response.data.data);
+ } catch (err) {
+ setError(err.message);
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ fetchHistory();
+ }, [rowId]);
+
+ return { historyData, loading, error };
+};
diff --git a/src/lib/hooks/useInquiryPrivacyState.js b/src/lib/hooks/useInquiryPrivacyState.js
index a66d83f..3a52989 100644
--- a/src/lib/hooks/useInquiryPrivacyState.js
+++ b/src/lib/hooks/useInquiryPrivacyState.js
@@ -1,30 +1,30 @@
-import { GET_INQUIRY_PRIVACY_STATE_LIST } from "@/core/utils/routes";
-import useRequest from "@/lib/hooks/useRequest";
-import { useEffect, useState } from "react";
-
-const useInquiryPrivacyState = () => {
- const requestServer = useRequest();
- const [itemsList, setItemsList] = useState([]);
- const [loadingItemsList, setLoadingItemsList] = useState(true);
- const [errorItemsList, setErrorItemsList] = useState(null);
-
- useEffect(() => {
- const fetchItems = async () => {
- try {
- const response = await requestServer(`${GET_INQUIRY_PRIVACY_STATE_LIST}`);
- setItemsList(response.data.data);
- setLoadingItemsList(false);
- setErrorItemsList(false);
- } catch (e) {
- setErrorItemsList(e);
- setLoadingItemsList(false);
- }
- };
-
- fetchItems();
- }, []);
-
- return { itemsList, loadingItemsList, errorItemsList };
-};
-
-export default useInquiryPrivacyState;
+import { GET_INQUIRY_PRIVACY_STATE_LIST } from "@/core/utils/routes";
+import useRequest from "@/lib/hooks/useRequest";
+import { useEffect, useState } from "react";
+
+const useInquiryPrivacyState = () => {
+ const requestServer = useRequest();
+ const [itemsList, setItemsList] = useState([]);
+ const [loadingItemsList, setLoadingItemsList] = useState(true);
+ const [errorItemsList, setErrorItemsList] = useState(null);
+
+ useEffect(() => {
+ const fetchItems = async () => {
+ try {
+ const response = await requestServer(`${GET_INQUIRY_PRIVACY_STATE_LIST}`);
+ setItemsList(response.data.data);
+ setLoadingItemsList(false);
+ setErrorItemsList(false);
+ } catch (e) {
+ setErrorItemsList(e);
+ setLoadingItemsList(false);
+ }
+ };
+
+ fetchItems();
+ }, []);
+
+ return { itemsList, loadingItemsList, errorItemsList };
+};
+
+export default useInquiryPrivacyState;