From ab3c80a0d310fa7d90d16f0fa43e48eddf43b82f Mon Sep 17 00:00:00 2001 From: mhmjalali Date: Sat, 18 Oct 2025 16:57:01 +0330 Subject: [PATCH 01/61] folder structure for estelam harim and start cartable for city admin --- .../inquiry-privacy/assistant/page.js | 13 ++ .../assistant/zamin-gov/page.js | 12 -- .../inquiry-privacy/city-admin/page.js | 14 ++ .../city-admin/zamin-gov/page.js | 12 -- .../inquiry-privacy/general-manager/page.js | 13 ++ .../general-manager/zamin-gov/page.js | 12 -- .../inquiry-privacy/privacy-office/page.js | 13 ++ .../province-admin/zamin-gov/page.js | 12 -- .../RoadSafetyForm/DescriptionForm.jsx | 29 ---- .../ManagerOrAssistantSubmit.jsx | 15 -- .../RoadSafetyForm/PrevCartableOpinion.jsx | 25 --- .../RoadSafetyForm/QuestionSafetyForm.jsx | 33 ---- .../RoadSafetyForm/RoadSafetyFormContext.jsx | 82 ---------- .../RowActions/RoadSafetyForm/index.jsx | 52 ------- .../RowActions/TaskDetail/DetailDialog.jsx | 75 --------- .../zaminGov/RowActions/TaskDetail/index.jsx | 26 ---- .../assistant/zaminGov/RowActions/index.jsx | 13 -- .../assistant/zaminGov/TaskList.jsx | 145 ------------------ .../assistant/zaminGov/index.jsx | 15 -- .../city-admin/CityAdminList.jsx | 57 +++++++ .../RowActions/ConfirmAction/index.jsx | 17 ++ .../RowActions/RejectAction/index.jsx | 17 ++ .../city-admin/RowActions/index.jsx | 14 ++ .../inquiryPrivacy/city-admin/index.jsx | 14 ++ .../RowActions/Refer/ReferFormContext.jsx | 138 ----------------- .../zaminGov/RowActions/Refer/index.jsx | 41 ----- .../RowActions/TaskDetail/DetailDialog.jsx | 109 ------------- .../zaminGov/RowActions/TaskDetail/index.jsx | 26 ---- .../cityAdmin/zaminGov/RowActions/index.jsx | 15 -- .../cityAdmin/zaminGov/TaskList.jsx | 145 ------------------ .../cityAdmin/zaminGov/index.jsx | 14 -- .../RoadSafetyForm/DescriptionForm.jsx | 29 ---- .../ManagerOrAssistantSubmit.jsx | 15 -- .../RoadSafetyForm/PrevCartableOpinion.jsx | 26 ---- .../RoadSafetyForm/QuestionSafetyForm.jsx | 33 ---- .../RoadSafetyForm/RoadSafetyFormContext.jsx | 82 ---------- .../RowActions/RoadSafetyForm/index.jsx | 52 ------- .../RowActions/TaskDetail/DetailDialog.jsx | 75 --------- .../zaminGov/RowActions/TaskDetail/index.jsx | 26 ---- .../zaminGov/RowActions/index.jsx | 13 -- .../generalManager/zaminGov/TaskList.jsx | 145 ------------------ .../generalManager/zaminGov/index.jsx | 15 -- .../RowActions/MapModify/MapActionButtons.jsx | 100 ------------ .../RowActions/MapModify/MapModifyDialog.jsx | 96 ------------ .../RowActions/MapModify/PolygonForDesign.jsx | 115 -------------- .../zaminGov/RowActions/MapModify/index.jsx | 29 ---- .../RowActions/Refer/ReferFormContext.jsx | 139 ----------------- .../zaminGov/RowActions/Refer/index.jsx | 41 ----- .../RoadSafetyForm/DescriptionForm.jsx | 29 ---- .../RoadSafetyForm/PrevCartableOpinion.jsx | 27 ---- .../RoadSafetyForm/QuestionSafetyForm.jsx | 57 ------- .../RoadSafetyForm/RoadSaftyFormContext.jsx | 80 ---------- .../RoadSafetyForm/SubmitButtonsAdmin.jsx | 21 --- .../RowActions/RoadSafetyForm/index.jsx | 52 ------- .../RowActions/TaskDetail/DetailDialog.jsx | 75 --------- .../zaminGov/RowActions/TaskDetail/index.jsx | 26 ---- .../zaminGov/RowActions/index.jsx | 17 -- .../provinceAdmin/zaminGov/TaskList.jsx | 145 ------------------ .../provinceAdmin/zaminGov/index.jsx | 15 -- src/core/utils/pageMenuDev.js | 32 ++-- src/core/utils/routes.js | 3 + 61 files changed, 191 insertions(+), 2637 deletions(-) create mode 100644 src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/assistant/page.js delete mode 100644 src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/assistant/zamin-gov/page.js create mode 100644 src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/city-admin/page.js delete mode 100644 src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/city-admin/zamin-gov/page.js create mode 100644 src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/general-manager/page.js delete mode 100644 src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/general-manager/zamin-gov/page.js create mode 100644 src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/privacy-office/page.js delete mode 100644 src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/province-admin/zamin-gov/page.js delete mode 100644 src/components/dashboard/inquiryPrivacy/assistant/zaminGov/RowActions/RoadSafetyForm/DescriptionForm.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/assistant/zaminGov/RowActions/RoadSafetyForm/ManagerOrAssistantSubmit.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/assistant/zaminGov/RowActions/RoadSafetyForm/PrevCartableOpinion.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/assistant/zaminGov/RowActions/RoadSafetyForm/QuestionSafetyForm.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/assistant/zaminGov/RowActions/RoadSafetyForm/RoadSafetyFormContext.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/assistant/zaminGov/RowActions/RoadSafetyForm/index.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/assistant/zaminGov/RowActions/TaskDetail/DetailDialog.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/assistant/zaminGov/RowActions/TaskDetail/index.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/assistant/zaminGov/RowActions/index.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/assistant/zaminGov/TaskList.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/assistant/zaminGov/index.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/city-admin/CityAdminList.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/city-admin/RowActions/ConfirmAction/index.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/city-admin/RowActions/RejectAction/index.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/city-admin/RowActions/index.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/city-admin/index.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/cityAdmin/zaminGov/RowActions/Refer/ReferFormContext.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/cityAdmin/zaminGov/RowActions/Refer/index.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/cityAdmin/zaminGov/RowActions/TaskDetail/DetailDialog.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/cityAdmin/zaminGov/RowActions/TaskDetail/index.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/cityAdmin/zaminGov/RowActions/index.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/cityAdmin/zaminGov/TaskList.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/cityAdmin/zaminGov/index.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/generalManager/zaminGov/RowActions/RoadSafetyForm/DescriptionForm.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/generalManager/zaminGov/RowActions/RoadSafetyForm/ManagerOrAssistantSubmit.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/generalManager/zaminGov/RowActions/RoadSafetyForm/PrevCartableOpinion.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/generalManager/zaminGov/RowActions/RoadSafetyForm/QuestionSafetyForm.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/generalManager/zaminGov/RowActions/RoadSafetyForm/RoadSafetyFormContext.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/generalManager/zaminGov/RowActions/RoadSafetyForm/index.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/generalManager/zaminGov/RowActions/TaskDetail/DetailDialog.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/generalManager/zaminGov/RowActions/TaskDetail/index.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/generalManager/zaminGov/RowActions/index.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/generalManager/zaminGov/TaskList.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/generalManager/zaminGov/index.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/MapModify/MapActionButtons.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/MapModify/MapModifyDialog.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/MapModify/PolygonForDesign.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/MapModify/index.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/Refer/ReferFormContext.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/Refer/index.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/RoadSafetyForm/DescriptionForm.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/RoadSafetyForm/PrevCartableOpinion.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/RoadSafetyForm/QuestionSafetyForm.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/RoadSafetyForm/RoadSaftyFormContext.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/RoadSafetyForm/SubmitButtonsAdmin.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/RoadSafetyForm/index.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/TaskDetail/DetailDialog.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/TaskDetail/index.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/index.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/TaskList.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/index.jsx diff --git a/src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/assistant/page.js b/src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/assistant/page.js new file mode 100644 index 0000000..c13a78d --- /dev/null +++ b/src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/assistant/page.js @@ -0,0 +1,13 @@ +import WithPermission from "@/core/middlewares/withPermission"; +export const metadata = { + title: "کارتابل معاون", +}; +const Page = () => { + return ( + +

کارتابل معاون

+
+ ); +}; + +export default Page; diff --git a/src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/assistant/zamin-gov/page.js b/src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/assistant/zamin-gov/page.js deleted file mode 100644 index d82631a..0000000 --- a/src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/assistant/zamin-gov/page.js +++ /dev/null @@ -1,12 +0,0 @@ -import AssistantZaminGovComponent from "@/components/dashboard/inquiryPrivacy/assistant/zaminGov"; -import WithPermission from "@/core/middlewares/withPermission"; - -const Page = () => { - return ( - - - - ); -}; - -export default Page; diff --git a/src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/city-admin/page.js b/src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/city-admin/page.js new file mode 100644 index 0000000..3fd1888 --- /dev/null +++ b/src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/city-admin/page.js @@ -0,0 +1,14 @@ +import CityAdminPage from "@/components/dashboard/inquiryPrivacy/city-admin"; +import WithPermission from "@/core/middlewares/withPermission"; +export const metadata = { + title: "کارتابل شهرستان", +}; +const Page = () => { + return ( + + + + ); +}; + +export default Page; diff --git a/src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/city-admin/zamin-gov/page.js b/src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/city-admin/zamin-gov/page.js deleted file mode 100644 index d7631c9..0000000 --- a/src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/city-admin/zamin-gov/page.js +++ /dev/null @@ -1,12 +0,0 @@ -import CityAdminZaminGovComponent from "@/components/dashboard/inquiryPrivacy/cityAdmin/zaminGov"; -import WithPermission from "@/core/middlewares/withPermission"; - -const Page = () => { - return ( - - - - ); -}; - -export default Page; diff --git a/src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/general-manager/page.js b/src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/general-manager/page.js new file mode 100644 index 0000000..e24a103 --- /dev/null +++ b/src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/general-manager/page.js @@ -0,0 +1,13 @@ +import WithPermission from "@/core/middlewares/withPermission"; +export const metadata = { + title: "کارتابل مدیر", +}; +const Page = () => { + return ( + +

کارتابل مدیر

+
+ ); +}; + +export default Page; diff --git a/src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/general-manager/zamin-gov/page.js b/src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/general-manager/zamin-gov/page.js deleted file mode 100644 index 9b9d446..0000000 --- a/src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/general-manager/zamin-gov/page.js +++ /dev/null @@ -1,12 +0,0 @@ -import GeneralManagerZaminGovComponent from "@/components/dashboard/inquiryPrivacy/generalManager/zaminGov"; -import WithPermission from "@/core/middlewares/withPermission"; - -const Page = () => { - return ( - - - - ); -}; - -export default Page; diff --git a/src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/privacy-office/page.js b/src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/privacy-office/page.js new file mode 100644 index 0000000..ed381eb --- /dev/null +++ b/src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/privacy-office/page.js @@ -0,0 +1,13 @@ +import WithPermission from "@/core/middlewares/withPermission"; +export const metadata = { + title: "کارتابل اداره حریم", +}; +const Page = () => { + return ( + +

کارتابل اداره حریم

+
+ ); +}; + +export default Page; diff --git a/src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/province-admin/zamin-gov/page.js b/src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/province-admin/zamin-gov/page.js deleted file mode 100644 index 0c51a47..0000000 --- a/src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/province-admin/zamin-gov/page.js +++ /dev/null @@ -1,12 +0,0 @@ -import ProvinceAdminZaminGovComponent from "@/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov"; -import WithPermission from "@/core/middlewares/withPermission"; - -const Page = () => { - return ( - - - - ); -}; - -export default Page; diff --git a/src/components/dashboard/inquiryPrivacy/assistant/zaminGov/RowActions/RoadSafetyForm/DescriptionForm.jsx b/src/components/dashboard/inquiryPrivacy/assistant/zaminGov/RowActions/RoadSafetyForm/DescriptionForm.jsx deleted file mode 100644 index ba2cdeb..0000000 --- a/src/components/dashboard/inquiryPrivacy/assistant/zaminGov/RowActions/RoadSafetyForm/DescriptionForm.jsx +++ /dev/null @@ -1,29 +0,0 @@ -import { FormControl, FormHelperText, InputLabel, OutlinedInput, Stack } from "@mui/material"; - -const DescriptionForm = ({ errors, register }) => { - return ( - - - - توضیحات - - - - {errors.description ? errors.description.message : null} - - - - ); -}; -export default DescriptionForm; diff --git a/src/components/dashboard/inquiryPrivacy/assistant/zaminGov/RowActions/RoadSafetyForm/ManagerOrAssistantSubmit.jsx b/src/components/dashboard/inquiryPrivacy/assistant/zaminGov/RowActions/RoadSafetyForm/ManagerOrAssistantSubmit.jsx deleted file mode 100644 index d755b7c..0000000 --- a/src/components/dashboard/inquiryPrivacy/assistant/zaminGov/RowActions/RoadSafetyForm/ManagerOrAssistantSubmit.jsx +++ /dev/null @@ -1,15 +0,0 @@ -import { Button } from "@mui/material"; - -const ManagerOrAssistantSubmit = ({ isSubmitting }) => { - return ( - <> - - - - ); -}; -export default ManagerOrAssistantSubmit; diff --git a/src/components/dashboard/inquiryPrivacy/assistant/zaminGov/RowActions/RoadSafetyForm/PrevCartableOpinion.jsx b/src/components/dashboard/inquiryPrivacy/assistant/zaminGov/RowActions/RoadSafetyForm/PrevCartableOpinion.jsx deleted file mode 100644 index d6df4b1..0000000 --- a/src/components/dashboard/inquiryPrivacy/assistant/zaminGov/RowActions/RoadSafetyForm/PrevCartableOpinion.jsx +++ /dev/null @@ -1,25 +0,0 @@ -import { Card, CardContent, CardHeader, CircularProgress, Divider, Stack, Typography } from "@mui/material"; - -const PrevCartableOpinion = ({ message, loadingMessage, errorMessage }) => { - return ( - - - - - {errorMessage ? ( - خطا در دریافت اطلاعات !!! - ) : loadingMessage ? ( - - - درحال دریافت اطلاعات - - ) : ( - {message} - )} - - - - - ); -}; -export default PrevCartableOpinion; diff --git a/src/components/dashboard/inquiryPrivacy/assistant/zaminGov/RowActions/RoadSafetyForm/QuestionSafetyForm.jsx b/src/components/dashboard/inquiryPrivacy/assistant/zaminGov/RowActions/RoadSafetyForm/QuestionSafetyForm.jsx deleted file mode 100644 index 5410d66..0000000 --- a/src/components/dashboard/inquiryPrivacy/assistant/zaminGov/RowActions/RoadSafetyForm/QuestionSafetyForm.jsx +++ /dev/null @@ -1,33 +0,0 @@ -import { Card, CardContent, FormControl, FormLabel, Stack, Typography } from "@mui/material"; - -const QuestionSafetyForm = () => { - return ( - - - - - - - آیا ایمنی راه این طرح مورد تایید است ؟ - - - - دفتر حریم راه : - - بله - - - - - - - ); -}; -export default QuestionSafetyForm; diff --git a/src/components/dashboard/inquiryPrivacy/assistant/zaminGov/RowActions/RoadSafetyForm/RoadSafetyFormContext.jsx b/src/components/dashboard/inquiryPrivacy/assistant/zaminGov/RowActions/RoadSafetyForm/RoadSafetyFormContext.jsx deleted file mode 100644 index 75a279c..0000000 --- a/src/components/dashboard/inquiryPrivacy/assistant/zaminGov/RowActions/RoadSafetyForm/RoadSafetyFormContext.jsx +++ /dev/null @@ -1,82 +0,0 @@ -import { DialogActions, DialogContent, Stack } from "@mui/material"; -import StyledForm from "@/core/components/StyledForm"; -import useRequest from "@/lib/hooks/useRequest"; -import { useForm } from "react-hook-form"; -import { yupResolver } from "@hookform/resolvers/yup"; -import { object, string } from "yup"; -import { SUBMIT_ROAD_SAFETY_FORM } from "@/core/utils/routes"; -import usePrevStateOpinion from "@/lib/hooks/usePrevStateopinion"; -import QuestionSafetyForm from "./QuestionSafetyForm"; -import PrevCartableOpinion from "./PrevCartableOpinion"; -import DescriptionForm from "./DescriptionForm"; -import ManagerOrAssistantSubmit from "./ManagerOrAssistantSubmit"; -import ApplicantRequestDetail from "@/core/components/ApplicantRequestDetail"; -const fakeData = { - id: 1, - shomareh_darkhast: "2124", - ostan: "ostan", - shahr: "shahr", - shahrestan: "shahrestan", - bakhsh: "bakhsh", - roosta: "roosta", - tarikh_darkhast: "tarikh_darkhast", - sazman: "sazman", - masahat_zamin: "masahat_zamin", - masahat_tarh: "masahat_tarh", - gorooh_tarh: "gorooh_tarh", - onvane_tarh: "onvane_tarh", - address: "کرج - فلان جا - جنب پاساژ - نزدیک اونجا - اونور خیابون - زیر رو گذر - روی زیر گذر", - file_mosavab: "file", - polygon: [ - [51.515, -0.09], - [51.52, -0.1], - [51.52, -0.12], - ], -}; -const validationSchema = object({ - description: string().required("وارد کردن توضیحات الزامیست!"), -}); -const RoadSafetyFormContext = ({ rowId, mutate, setOpenRoadSafetyForm }) => { - const defaultValues = { - description: "", - }; - const requestServer = useRequest({ notificationSuccess: true }); - const { message, loadingMessage, errorMessage } = usePrevStateOpinion(); - const { - register, - handleSubmit, - formState: { isSubmitting, errors }, - } = useForm({ defaultValues, resolver: yupResolver(validationSchema), mode: "all" }); - const onSubmit = async (data) => { - const formData = new FormData(); - formData.append("description", data.description); - requestServer(`${SUBMIT_ROAD_SAFETY_FORM}/${rowId}`, "post", { - data: formData, - }) - .then(() => { - setOpenRoadSafetyForm(false); - mutate(); - }) - .catch(() => {}); - }; - return ( - - - - - - - - - - - - - - ); -}; -export default RoadSafetyFormContext; diff --git a/src/components/dashboard/inquiryPrivacy/assistant/zaminGov/RowActions/RoadSafetyForm/index.jsx b/src/components/dashboard/inquiryPrivacy/assistant/zaminGov/RowActions/RoadSafetyForm/index.jsx deleted file mode 100644 index a4de0d7..0000000 --- a/src/components/dashboard/inquiryPrivacy/assistant/zaminGov/RowActions/RoadSafetyForm/index.jsx +++ /dev/null @@ -1,52 +0,0 @@ -import { Dialog, IconButton, Stack, Tooltip } from "@mui/material"; -import EngineeringIcon from "@mui/icons-material/Engineering"; -import DialogTransition from "@/core/components/DialogTransition"; -import { useState } from "react"; -import { Close } from "@mui/icons-material"; -import RoadSafetyFormContext from "./RoadSafetyFormContext"; - -const RoadSafetyForm = ({ rowId, mutate }) => { - const [openRoadSafetyForm, setOpenRoadSafetyForm] = useState(false); - return ( - - - { - setOpenRoadSafetyForm(true); - }} - > - - - - - setOpenRoadSafetyForm(false)} - sx={{ - position: "absolute", - right: 8, - top: 8, - zIndex: 10, - color: (theme) => theme.palette.grey[500], - }} - > - - - - - - ); -}; -export default RoadSafetyForm; diff --git a/src/components/dashboard/inquiryPrivacy/assistant/zaminGov/RowActions/TaskDetail/DetailDialog.jsx b/src/components/dashboard/inquiryPrivacy/assistant/zaminGov/RowActions/TaskDetail/DetailDialog.jsx deleted file mode 100644 index 777eecf..0000000 --- a/src/components/dashboard/inquiryPrivacy/assistant/zaminGov/RowActions/TaskDetail/DetailDialog.jsx +++ /dev/null @@ -1,75 +0,0 @@ -"use client"; - -import { Dialog, DialogContent } from "@mui/material"; -import { object, string } from "yup"; -import useRequest from "@/lib/hooks/useRequest"; -import { useForm } from "react-hook-form"; -import { yupResolver } from "@hookform/resolvers/yup"; -import StyledForm from "@/core/components/StyledForm"; -import ApplicantRequestDetail from "@/core/components/ApplicantRequestDetail"; - -const fakeData = { - id: 1, - shomareh_darkhast: "2124", - ostan: "ostan", - shahr: "shahr", - shahrestan: "shahrestan", - bakhsh: "bakhsh", - roosta: "roosta", - tarikh_darkhast: "tarikh_darkhast", - sazman: "sazman", - masahat_zamin: "masahat_zamin", - masahat_tarh: "masahat_tarh", - gorooh_tarh: "gorooh_tarh", - onvane_tarh: "onvane_tarh", - address: "کرج - فلان جا - جنب پاساژ - نزدیک اونجا - اونور خیابون - زیر رو گذر - روی زیر گذر", - file_mosavab: "file", - polygon: [ - [51.515, -0.09], - [51.52, -0.1], - [51.52, -0.12], - ], -}; - -const validationSchema = object({ - description: string().required("وارد کردن توضیحات الزامیست!"), -}); - -const DetailDialog = ({ taskModal, setTaskModal, rowId, mutate }) => { - const requestServer = useRequest({ auth: true }); - const defaultValues = { - description: "", - }; - const handleClose = () => { - setTaskModal(false); - }; - - const { - register, - handleSubmit, - formState: { isSubmitting, errors, touchedFields }, - } = useForm({ defaultValues, resolver: yupResolver(validationSchema), mode: "all" }); - - const onSubmit = async (data) => { - const formData = new FormData(); - formData.append("description", data.description); - requestServer(`api-for-send-to-harim/${rowId}`, "post", { - data: formData, - }) - .then(() => { - handleClose(); - mutate(); - }) - .catch(() => {}); - }; - return ( - - - - - - - - ); -}; -export default DetailDialog; diff --git a/src/components/dashboard/inquiryPrivacy/assistant/zaminGov/RowActions/TaskDetail/index.jsx b/src/components/dashboard/inquiryPrivacy/assistant/zaminGov/RowActions/TaskDetail/index.jsx deleted file mode 100644 index 1641840..0000000 --- a/src/components/dashboard/inquiryPrivacy/assistant/zaminGov/RowActions/TaskDetail/index.jsx +++ /dev/null @@ -1,26 +0,0 @@ -"use client"; - -import { IconButton, Tooltip } from "@mui/material"; -import AssignmentIcon from "@mui/icons-material/Assignment"; -import DetailDialog from "./DetailDialog"; -import { useState } from "react"; - -const TaskDetail = ({ rowId, mutate }) => { - const [taskModal, setTaskModal] = useState(false); - - const openDetailDialog = () => { - setTaskModal(true); - }; - - return ( - <> - - - - - - - - ); -}; -export default TaskDetail; diff --git a/src/components/dashboard/inquiryPrivacy/assistant/zaminGov/RowActions/index.jsx b/src/components/dashboard/inquiryPrivacy/assistant/zaminGov/RowActions/index.jsx deleted file mode 100644 index ae4213c..0000000 --- a/src/components/dashboard/inquiryPrivacy/assistant/zaminGov/RowActions/index.jsx +++ /dev/null @@ -1,13 +0,0 @@ -import TaskDetail from "./TaskDetail"; -import { Box } from "@mui/material"; -import RoadSafetyForm from "./RoadSafetyForm"; - -const RowActions = ({ row, mutate }) => { - return ( - - - - - ); -}; -export default RowActions; diff --git a/src/components/dashboard/inquiryPrivacy/assistant/zaminGov/TaskList.jsx b/src/components/dashboard/inquiryPrivacy/assistant/zaminGov/TaskList.jsx deleted file mode 100644 index 31452f6..0000000 --- a/src/components/dashboard/inquiryPrivacy/assistant/zaminGov/TaskList.jsx +++ /dev/null @@ -1,145 +0,0 @@ -"use client"; - -import { useMemo } from "react"; -import { Box } from "@mui/material"; -import DataTableWithAuth from "@/core/components/DataTableWithAuth"; -import RowActions from "./RowActions"; - -const TaskList = () => { - const columns = useMemo( - () => [ - { - accessorKey: "id", - header: "کد یکتا", - id: "id", - enableColumnFilter: false, - datatype: "text", - filterMode: "notEquals", - }, - { - accessorKey: "aplication_number", - header: "شماره درخواست", - id: "aplication_number", - enableColumnFilter: false, - datatype: "text", - filterMode: "notEquals", - }, - { - accessorKey: "application_date", - header: "تاریخ درخواست", - id: "application_date", - enableColumnFilter: false, - datatype: "text", - filterMode: "equals", - }, - { - accessorKey: "province", - header: "استان", - id: "province", - enableColumnFilter: false, - datatype: "text", - filterMode: "equals", - }, - { - accessorKey: "township", - header: "شهرستان", - id: "township", - enableColumnFilter: false, - datatype: "text", - filterMode: "equals", - }, - { - accessorKey: "city", - header: "شهر", - id: "city", - enableColumnFilter: false, - datatype: "text", - filterMode: "equals", - }, - { - accessorKey: "county", - header: "بخش", - id: "county", - enableColumnFilter: false, - datatype: "text", - filterMode: "equals", - }, - { - accessorKey: "village", - header: "روستا", - id: "village", - enableColumnFilter: false, - datatype: "text", - filterMode: "equals", - }, - { - accessorKey: "land_area", - header: "مساحت زمین", - id: "land_area", - enableColumnFilter: false, - datatype: "text", - filterMode: "equals", - }, - { - accessorKey: "design_area", - header: "مساحت طرح", - id: "design_area", - enableColumnFilter: false, - datatype: "text", - filterMode: "equals", - }, - { - accessorKey: "organization", - header: "سازمان", - id: "organization", - enableColumnFilter: false, - datatype: "text", - filterMode: "equals", - }, - { - accessorKey: "design_group", - header: "گروه طرح", - id: "design_group", - enableColumnFilter: false, - datatype: "text", - filterMode: "equals", - }, - { - accessorKey: "design_title", - header: "عنوان طرح", - id: "design_title", - enableColumnFilter: false, - datatype: "text", - filterMode: "equals", - }, - { - accessorKey: "state", - header: "وضعیت درخواست", - id: "state", - enableColumnFilter: false, - datatype: "text", - filterMode: "equals", - }, - ], - [] - ); - - return ( - <> - - - - - ); -}; -export default TaskList; diff --git a/src/components/dashboard/inquiryPrivacy/assistant/zaminGov/index.jsx b/src/components/dashboard/inquiryPrivacy/assistant/zaminGov/index.jsx deleted file mode 100644 index a6a53cf..0000000 --- a/src/components/dashboard/inquiryPrivacy/assistant/zaminGov/index.jsx +++ /dev/null @@ -1,15 +0,0 @@ -"use client"; - -import PageTitle from "@/core/components/PageTitle"; -import { Stack } from "@mui/material"; -import TaskList from "./TaskList"; - -const AssistantZaminGovComponent = () => { - return ( - - - - - ); -}; -export default AssistantZaminGovComponent; diff --git a/src/components/dashboard/inquiryPrivacy/city-admin/CityAdminList.jsx b/src/components/dashboard/inquiryPrivacy/city-admin/CityAdminList.jsx new file mode 100644 index 0000000..be14803 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/city-admin/CityAdminList.jsx @@ -0,0 +1,57 @@ +import DataTableWithAuth from '@/core/components/DataTableWithAuth'; +import { GET_CITY_ADMIN_LIST } from '@/core/utils/routes'; +import { Box } from '@mui/material'; +import { useMemo } from 'react'; +import RowActions from './RowActions'; + +const CityAdminList = () => { + const columns = useMemo(() => { + return [ + { + accessorKey: "id", + header: "کد یکتا", + id: "panjare_vahed_id", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ row }) => <>{row.original.panjare_vahed_id}, + }, + { + accessorKey: "national_id", + header: "کد ملی", + id: "national_id", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ row }) => <>{row.original.national_id}, + }, + ]; + }, []); + + return ( + <> + + + + + ) +} + +export default CityAdminList \ No newline at end of file diff --git a/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/ConfirmAction/index.jsx b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/ConfirmAction/index.jsx new file mode 100644 index 0000000..6eb22a6 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/ConfirmAction/index.jsx @@ -0,0 +1,17 @@ +import ThumbUpIcon from '@mui/icons-material/ThumbUp'; +import { IconButton, Tooltip } from "@mui/material"; +import { useState } from "react"; + +const ConfirmAction = ({ rowId, mutate }) => { + const [openConfirmDialog, setOpenConfirmDialog] = useState(false); + return ( + <> + + setOpenConfirmDialog(true)}> + + + + + ); +}; +export default ConfirmAction; diff --git a/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/RejectAction/index.jsx b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/RejectAction/index.jsx new file mode 100644 index 0000000..ccdffaf --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/RejectAction/index.jsx @@ -0,0 +1,17 @@ +import ThumbDownIcon from '@mui/icons-material/ThumbDown'; +import { IconButton, Tooltip } from "@mui/material"; +import { useState } from "react"; + +const RejectAction = ({ rowId, mutate }) => { + const [openRejectDialog, setOpenRejectDialog] = useState(false); + return ( + <> + + setOpenRejectDialog(true)}> + + + + + ); +}; +export default RejectAction; diff --git a/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/index.jsx b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/index.jsx new file mode 100644 index 0000000..c8906f2 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/index.jsx @@ -0,0 +1,14 @@ +import { Box } from "@mui/material"; +import ConfirmAction from "./ConfirmAction"; +import RejectAction from "./RejectAction"; + +const RowActions = ({ row, mutate }) => { + + return ( + + + + + ); +}; +export default RowActions; diff --git a/src/components/dashboard/inquiryPrivacy/city-admin/index.jsx b/src/components/dashboard/inquiryPrivacy/city-admin/index.jsx new file mode 100644 index 0000000..b8d7433 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/city-admin/index.jsx @@ -0,0 +1,14 @@ +"use client"; +import PageTitle from "@/core/components/PageTitle"; +import { Stack } from "@mui/material"; +import CityAdminList from "./CityAdminList"; + +const CityAdminPage = () => { + return ( + + + + + ); +}; +export default CityAdminPage; diff --git a/src/components/dashboard/inquiryPrivacy/cityAdmin/zaminGov/RowActions/Refer/ReferFormContext.jsx b/src/components/dashboard/inquiryPrivacy/cityAdmin/zaminGov/RowActions/Refer/ReferFormContext.jsx deleted file mode 100644 index 604e141..0000000 --- a/src/components/dashboard/inquiryPrivacy/cityAdmin/zaminGov/RowActions/Refer/ReferFormContext.jsx +++ /dev/null @@ -1,138 +0,0 @@ -import { - Autocomplete, - Button, - CircularProgress, - DialogActions, - DialogContent, - FormControl, - FormHelperText, - InputLabel, - OutlinedInput, - Stack, - TextField, - Typography, -} from "@mui/material"; -import { Controller, useForm } from "react-hook-form"; -import { yupResolver } from "@hookform/resolvers/yup"; -import { object, string } from "yup"; -import StyledForm from "@/core/components/StyledForm"; -import useCities from "@/lib/hooks/useCities"; -import useRequest from "@/lib/hooks/useRequest"; -import { REFER_ADMIN_CITY } from "@/core/utils/routes"; - -const validationSchema = object({ - description: string().required("وارد کردن توضیحات الزامیست!"), - city: string().required("وارد کردن شهرستان الزامیست!"), -}); - -const ReferFormContext = ({ setOpenReferDialog, rowId, mutate }) => { - const defaultValues = { - description: "", - city: "", - }; - const { cities, loadingCities, errorCities } = useCities(); - const requestServer = useRequest({ notificationSuccess: true }); - const { - control, - register, - handleSubmit, - formState: { isSubmitting, errors, touchedFields }, - } = useForm({ defaultValues, resolver: yupResolver(validationSchema), mode: "all" }); - - const onSubmit = async (data) => { - const formData = new FormData(); - formData.append("description", data.description); - formData.append("cityId", data.city); - requestServer(`${REFER_ADMIN_CITY}/${rowId}`, "post", { - data: formData, - }) - .then(() => { - setOpenReferDialog(false); - mutate(); - }) - .catch(() => {}); - }; - return ( - - - - - - - توضیحات - - - - {errors.description ? errors.description.message : null} - - - - - ( - - - {errorCities ? ( - خطایی در دریافت شهرستان ها رخ داده است! - ) : loadingCities ? ( - - - درحال دریافت لیست شهرستان ها - - ) : ( - city.id === value) || null} - disablePortal - options={cities} - getOptionLabel={(city) => city.name} - isOptionEqualToValue={(option, value) => option.id === value.id} - onChange={(event, newValue) => { - onChange(newValue ? newValue.id : ""); - }} - renderInput={(params) => ( - - )} - /> - )} - - {errors.city ? errors.city.message : null} - - - )} - /> - - - - - - - - - ); -}; -export default ReferFormContext; diff --git a/src/components/dashboard/inquiryPrivacy/cityAdmin/zaminGov/RowActions/Refer/index.jsx b/src/components/dashboard/inquiryPrivacy/cityAdmin/zaminGov/RowActions/Refer/index.jsx deleted file mode 100644 index a8ebdc2..0000000 --- a/src/components/dashboard/inquiryPrivacy/cityAdmin/zaminGov/RowActions/Refer/index.jsx +++ /dev/null @@ -1,41 +0,0 @@ -import { Dialog, DialogTitle, IconButton, Stack, Tooltip } from "@mui/material"; -import ReplyIcon from "@mui/icons-material/Reply"; -import DialogTransition from "@/core/components/DialogTransition"; -import ReferFormContext from "./ReferFormContext"; -import { useState } from "react"; - -const ReferForm = ({ rowId, mutate }) => { - const [openReferDialog, setOpenReferDialog] = useState(false); - return ( - - - { - setOpenReferDialog(true); - }} - > - - - - - - ارجاع به شهرستان دیگر - - - - - ); -}; -export default ReferForm; diff --git a/src/components/dashboard/inquiryPrivacy/cityAdmin/zaminGov/RowActions/TaskDetail/DetailDialog.jsx b/src/components/dashboard/inquiryPrivacy/cityAdmin/zaminGov/RowActions/TaskDetail/DetailDialog.jsx deleted file mode 100644 index 3c25592..0000000 --- a/src/components/dashboard/inquiryPrivacy/cityAdmin/zaminGov/RowActions/TaskDetail/DetailDialog.jsx +++ /dev/null @@ -1,109 +0,0 @@ -"use client"; - -import { - Button, - Dialog, - DialogActions, - DialogContent, - FormControl, - FormHelperText, - InputLabel, - OutlinedInput, -} from "@mui/material"; -import { object, string } from "yup"; -import useRequest from "@/lib/hooks/useRequest"; -import { useForm } from "react-hook-form"; -import { yupResolver } from "@hookform/resolvers/yup"; -import StyledForm from "@/core/components/StyledForm"; -import ApplicantRequestDetail from "@/core/components/ApplicantRequestDetail"; - -const fakeData = { - id: 1, - shomareh_darkhast: "2124", - ostan: "ostan", - shahr: "shahr", - shahrestan: "shahrestan", - bakhsh: "bakhsh", - roosta: "roosta", - tarikh_darkhast: "tarikh_darkhast", - sazman: "sazman", - masahat_zamin: "masahat_zamin", - masahat_tarh: "masahat_tarh", - gorooh_tarh: "gorooh_tarh", - onvane_tarh: "onvane_tarh", - address: "کرج - فلان جا - جنب پاساژ - نزدیک اونجا - اونور خیابون - زیر رو گذر - روی زیر گذر", - file_mosavab: "file", - polygon: [ - [51.515, -0.09], - [51.52, -0.1], - [51.52, -0.12], - ], -}; - -const validationSchema = object({ - description: string().required("وارد کردن توضیحات الزامیست!"), -}); - -const DetailDialog = ({ taskModal, setTaskModal, rowId, mutate }) => { - const requestServer = useRequest({ auth: true }); - const defaultValues = { - description: "", - }; - const handleClose = () => { - setTaskModal(false); - }; - - const { - register, - handleSubmit, - formState: { isSubmitting, errors, touchedFields }, - } = useForm({ defaultValues, resolver: yupResolver(validationSchema), mode: "all" }); - - const onSubmit = async (data) => { - const formData = new FormData(); - formData.append("description", data.description); - requestServer(`api-for-send-to-harim/${rowId}`, "post", { - data: formData, - }) - .then(() => { - handleClose(); - mutate(); - }) - .catch(() => {}); - }; - return ( - - - - - - - توضیحات - - - - {errors.description ? errors.description.message : null} - - - - - - - - - ); -}; -export default DetailDialog; diff --git a/src/components/dashboard/inquiryPrivacy/cityAdmin/zaminGov/RowActions/TaskDetail/index.jsx b/src/components/dashboard/inquiryPrivacy/cityAdmin/zaminGov/RowActions/TaskDetail/index.jsx deleted file mode 100644 index 1641840..0000000 --- a/src/components/dashboard/inquiryPrivacy/cityAdmin/zaminGov/RowActions/TaskDetail/index.jsx +++ /dev/null @@ -1,26 +0,0 @@ -"use client"; - -import { IconButton, Tooltip } from "@mui/material"; -import AssignmentIcon from "@mui/icons-material/Assignment"; -import DetailDialog from "./DetailDialog"; -import { useState } from "react"; - -const TaskDetail = ({ rowId, mutate }) => { - const [taskModal, setTaskModal] = useState(false); - - const openDetailDialog = () => { - setTaskModal(true); - }; - - return ( - <> - - - - - - - - ); -}; -export default TaskDetail; diff --git a/src/components/dashboard/inquiryPrivacy/cityAdmin/zaminGov/RowActions/index.jsx b/src/components/dashboard/inquiryPrivacy/cityAdmin/zaminGov/RowActions/index.jsx deleted file mode 100644 index 2ed70e0..0000000 --- a/src/components/dashboard/inquiryPrivacy/cityAdmin/zaminGov/RowActions/index.jsx +++ /dev/null @@ -1,15 +0,0 @@ -"use client"; - -import ReferForm from "./Refer"; -import TaskDetail from "./TaskDetail"; -import { Box } from "@mui/material"; - -const RowActions = ({ row, mutate }) => { - return ( - - - - - ); -}; -export default RowActions; diff --git a/src/components/dashboard/inquiryPrivacy/cityAdmin/zaminGov/TaskList.jsx b/src/components/dashboard/inquiryPrivacy/cityAdmin/zaminGov/TaskList.jsx deleted file mode 100644 index 14a0e35..0000000 --- a/src/components/dashboard/inquiryPrivacy/cityAdmin/zaminGov/TaskList.jsx +++ /dev/null @@ -1,145 +0,0 @@ -"use client"; - -import { useMemo } from "react"; -import { Box } from "@mui/material"; -import DataTableWithAuth from "@/core/components/DataTableWithAuth"; -import RowActions from "./RowActions"; - -const TaskList = () => { - const columns = useMemo( - () => [ - { - accessorKey: "id", - header: "کد یکتا", - id: "id", - enableColumnFilter: false, - datatype: "text", - filterMode: "notEquals", - }, - { - accessorKey: "aplication_number", - header: "شماره درخواست", - id: "aplication_number", - enableColumnFilter: false, - datatype: "text", - filterMode: "notEquals", - }, - { - accessorKey: "application_date", - header: "تاریخ درخواست", - id: "application_date", - enableColumnFilter: false, - datatype: "text", - filterMode: "equals", - }, - { - accessorKey: "province", - header: "استان", - id: "province", - enableColumnFilter: false, - datatype: "text", - filterMode: "equals", - }, - { - accessorKey: "township", - header: "شهرستان", - id: "township", - enableColumnFilter: false, - datatype: "text", - filterMode: "equals", - }, - { - accessorKey: "city", - header: "شهر", - id: "city", - enableColumnFilter: false, - datatype: "text", - filterMode: "equals", - }, - { - accessorKey: "county", - header: "بخش", - id: "county", - enableColumnFilter: false, - datatype: "text", - filterMode: "equals", - }, - { - accessorKey: "village", - header: "روستا", - id: "village", - enableColumnFilter: false, - datatype: "text", - filterMode: "equals", - }, - { - accessorKey: "land_area", - header: "مساحت زمین", - id: "land_area", - enableColumnFilter: false, - datatype: "text", - filterMode: "equals", - }, - { - accessorKey: "design_area", - header: "مساحت طرح", - id: "design_area", - enableColumnFilter: false, - datatype: "text", - filterMode: "equals", - }, - { - accessorKey: "organization", - header: "سازمان", - id: "organization", - enableColumnFilter: false, - datatype: "text", - filterMode: "equals", - }, - { - accessorKey: "design_group", - header: "گروه طرح", - id: "design_group", - enableColumnFilter: false, - datatype: "text", - filterMode: "equals", - }, - { - accessorKey: "design_title", - header: "عنوان طرح", - id: "design_title", - enableColumnFilter: false, - datatype: "text", - filterMode: "equals", - }, - { - accessorKey: "state", - header: "وضعیت درخواست", - id: "state", - enableColumnFilter: false, - datatype: "text", - filterMode: "equals", - }, - ], - [] - ); - - return ( - <> - - - - - ); -}; -export default TaskList; diff --git a/src/components/dashboard/inquiryPrivacy/cityAdmin/zaminGov/index.jsx b/src/components/dashboard/inquiryPrivacy/cityAdmin/zaminGov/index.jsx deleted file mode 100644 index 4af891c..0000000 --- a/src/components/dashboard/inquiryPrivacy/cityAdmin/zaminGov/index.jsx +++ /dev/null @@ -1,14 +0,0 @@ -"use client"; -import PageTitle from "@/core/components/PageTitle"; -import { Stack } from "@mui/material"; -import TaskList from "./TaskList"; - -const CityAdminZaminGovComponent = () => { - return ( - - - - - ); -}; -export default CityAdminZaminGovComponent; diff --git a/src/components/dashboard/inquiryPrivacy/generalManager/zaminGov/RowActions/RoadSafetyForm/DescriptionForm.jsx b/src/components/dashboard/inquiryPrivacy/generalManager/zaminGov/RowActions/RoadSafetyForm/DescriptionForm.jsx deleted file mode 100644 index ba2cdeb..0000000 --- a/src/components/dashboard/inquiryPrivacy/generalManager/zaminGov/RowActions/RoadSafetyForm/DescriptionForm.jsx +++ /dev/null @@ -1,29 +0,0 @@ -import { FormControl, FormHelperText, InputLabel, OutlinedInput, Stack } from "@mui/material"; - -const DescriptionForm = ({ errors, register }) => { - return ( - - - - توضیحات - - - - {errors.description ? errors.description.message : null} - - - - ); -}; -export default DescriptionForm; diff --git a/src/components/dashboard/inquiryPrivacy/generalManager/zaminGov/RowActions/RoadSafetyForm/ManagerOrAssistantSubmit.jsx b/src/components/dashboard/inquiryPrivacy/generalManager/zaminGov/RowActions/RoadSafetyForm/ManagerOrAssistantSubmit.jsx deleted file mode 100644 index d755b7c..0000000 --- a/src/components/dashboard/inquiryPrivacy/generalManager/zaminGov/RowActions/RoadSafetyForm/ManagerOrAssistantSubmit.jsx +++ /dev/null @@ -1,15 +0,0 @@ -import { Button } from "@mui/material"; - -const ManagerOrAssistantSubmit = ({ isSubmitting }) => { - return ( - <> - - - - ); -}; -export default ManagerOrAssistantSubmit; diff --git a/src/components/dashboard/inquiryPrivacy/generalManager/zaminGov/RowActions/RoadSafetyForm/PrevCartableOpinion.jsx b/src/components/dashboard/inquiryPrivacy/generalManager/zaminGov/RowActions/RoadSafetyForm/PrevCartableOpinion.jsx deleted file mode 100644 index 365c1b4..0000000 --- a/src/components/dashboard/inquiryPrivacy/generalManager/zaminGov/RowActions/RoadSafetyForm/PrevCartableOpinion.jsx +++ /dev/null @@ -1,26 +0,0 @@ -import { Card, CardContent, CardHeader, CircularProgress, Divider, Stack, Typography } from "@mui/material"; -import usePrevStateOpinion from "@/lib/hooks/usePrevStateopinion"; - -const PrevCartableOpinion = ({ message, loadingMessage, errorMessage }) => { - return ( - - - - - {errorMessage ? ( - خطا در دریافت اطلاعات !!! - ) : loadingMessage ? ( - - - درحال دریافت اطلاعات - - ) : ( - {message} - )} - - - - - ); -}; -export default PrevCartableOpinion; diff --git a/src/components/dashboard/inquiryPrivacy/generalManager/zaminGov/RowActions/RoadSafetyForm/QuestionSafetyForm.jsx b/src/components/dashboard/inquiryPrivacy/generalManager/zaminGov/RowActions/RoadSafetyForm/QuestionSafetyForm.jsx deleted file mode 100644 index 5410d66..0000000 --- a/src/components/dashboard/inquiryPrivacy/generalManager/zaminGov/RowActions/RoadSafetyForm/QuestionSafetyForm.jsx +++ /dev/null @@ -1,33 +0,0 @@ -import { Card, CardContent, FormControl, FormLabel, Stack, Typography } from "@mui/material"; - -const QuestionSafetyForm = () => { - return ( - - - - - - - آیا ایمنی راه این طرح مورد تایید است ؟ - - - - دفتر حریم راه : - - بله - - - - - - - ); -}; -export default QuestionSafetyForm; diff --git a/src/components/dashboard/inquiryPrivacy/generalManager/zaminGov/RowActions/RoadSafetyForm/RoadSafetyFormContext.jsx b/src/components/dashboard/inquiryPrivacy/generalManager/zaminGov/RowActions/RoadSafetyForm/RoadSafetyFormContext.jsx deleted file mode 100644 index 68ffecf..0000000 --- a/src/components/dashboard/inquiryPrivacy/generalManager/zaminGov/RowActions/RoadSafetyForm/RoadSafetyFormContext.jsx +++ /dev/null @@ -1,82 +0,0 @@ -import { DialogActions, DialogContent, Stack } from "@mui/material"; -import StyledForm from "@/core/components/StyledForm"; -import useRequest from "@/lib/hooks/useRequest"; -import { useForm } from "react-hook-form"; -import { yupResolver } from "@hookform/resolvers/yup"; -import { object, string } from "yup"; -import { SUBMIT_ROAD_SAFETY_FORM } from "@/core/utils/routes"; -import QuestionSafetyForm from "./QuestionSafetyForm"; -import PrevCartableOpinion from "./PrevCartableOpinion"; -import DescriptionForm from "./DescriptionForm"; -import ManagerOrAssistantSubmit from "./ManagerOrAssistantSubmit"; -import usePrevStateOpinion from "@/lib/hooks/usePrevStateopinion"; -import ApplicantRequestDetail from "@/core/components/ApplicantRequestDetail"; -const fakeData = { - id: 1, - shomareh_darkhast: "2124", - ostan: "ostan", - shahr: "shahr", - shahrestan: "shahrestan", - bakhsh: "bakhsh", - roosta: "roosta", - tarikh_darkhast: "tarikh_darkhast", - sazman: "sazman", - masahat_zamin: "masahat_zamin", - masahat_tarh: "masahat_tarh", - gorooh_tarh: "gorooh_tarh", - onvane_tarh: "onvane_tarh", - address: "کرج - فلان جا - جنب پاساژ - نزدیک اونجا - اونور خیابون - زیر رو گذر - روی زیر گذر", - file_mosavab: "file", - polygon: [ - [51.515, -0.09], - [51.52, -0.1], - [51.52, -0.12], - ], -}; -const validationSchema = object({ - description: string().required("وارد کردن توضیحات الزامیست!"), -}); -const RoadSafetyFormContext = ({ rowId, mutate, setOpenRoadSafetyForm }) => { - const defaultValues = { - description: "", - }; - const requestServer = useRequest({ notificationSuccess: true }); - const { message, loadingMessage, errorMessage } = usePrevStateOpinion(); - const { - register, - handleSubmit, - formState: { isSubmitting, errors }, - } = useForm({ defaultValues, resolver: yupResolver(validationSchema), mode: "all" }); - const onSubmit = async (data) => { - const formData = new FormData(); - formData.append("description", data.description); - requestServer(`${SUBMIT_ROAD_SAFETY_FORM}/${rowId}`, "post", { - data: formData, - }) - .then(() => { - setOpenRoadSafetyForm(false); - mutate(); - }) - .catch(() => {}); - }; - return ( - - - - - - - - - - - - - - ); -}; -export default RoadSafetyFormContext; diff --git a/src/components/dashboard/inquiryPrivacy/generalManager/zaminGov/RowActions/RoadSafetyForm/index.jsx b/src/components/dashboard/inquiryPrivacy/generalManager/zaminGov/RowActions/RoadSafetyForm/index.jsx deleted file mode 100644 index a4de0d7..0000000 --- a/src/components/dashboard/inquiryPrivacy/generalManager/zaminGov/RowActions/RoadSafetyForm/index.jsx +++ /dev/null @@ -1,52 +0,0 @@ -import { Dialog, IconButton, Stack, Tooltip } from "@mui/material"; -import EngineeringIcon from "@mui/icons-material/Engineering"; -import DialogTransition from "@/core/components/DialogTransition"; -import { useState } from "react"; -import { Close } from "@mui/icons-material"; -import RoadSafetyFormContext from "./RoadSafetyFormContext"; - -const RoadSafetyForm = ({ rowId, mutate }) => { - const [openRoadSafetyForm, setOpenRoadSafetyForm] = useState(false); - return ( - - - { - setOpenRoadSafetyForm(true); - }} - > - - - - - setOpenRoadSafetyForm(false)} - sx={{ - position: "absolute", - right: 8, - top: 8, - zIndex: 10, - color: (theme) => theme.palette.grey[500], - }} - > - - - - - - ); -}; -export default RoadSafetyForm; diff --git a/src/components/dashboard/inquiryPrivacy/generalManager/zaminGov/RowActions/TaskDetail/DetailDialog.jsx b/src/components/dashboard/inquiryPrivacy/generalManager/zaminGov/RowActions/TaskDetail/DetailDialog.jsx deleted file mode 100644 index 777eecf..0000000 --- a/src/components/dashboard/inquiryPrivacy/generalManager/zaminGov/RowActions/TaskDetail/DetailDialog.jsx +++ /dev/null @@ -1,75 +0,0 @@ -"use client"; - -import { Dialog, DialogContent } from "@mui/material"; -import { object, string } from "yup"; -import useRequest from "@/lib/hooks/useRequest"; -import { useForm } from "react-hook-form"; -import { yupResolver } from "@hookform/resolvers/yup"; -import StyledForm from "@/core/components/StyledForm"; -import ApplicantRequestDetail from "@/core/components/ApplicantRequestDetail"; - -const fakeData = { - id: 1, - shomareh_darkhast: "2124", - ostan: "ostan", - shahr: "shahr", - shahrestan: "shahrestan", - bakhsh: "bakhsh", - roosta: "roosta", - tarikh_darkhast: "tarikh_darkhast", - sazman: "sazman", - masahat_zamin: "masahat_zamin", - masahat_tarh: "masahat_tarh", - gorooh_tarh: "gorooh_tarh", - onvane_tarh: "onvane_tarh", - address: "کرج - فلان جا - جنب پاساژ - نزدیک اونجا - اونور خیابون - زیر رو گذر - روی زیر گذر", - file_mosavab: "file", - polygon: [ - [51.515, -0.09], - [51.52, -0.1], - [51.52, -0.12], - ], -}; - -const validationSchema = object({ - description: string().required("وارد کردن توضیحات الزامیست!"), -}); - -const DetailDialog = ({ taskModal, setTaskModal, rowId, mutate }) => { - const requestServer = useRequest({ auth: true }); - const defaultValues = { - description: "", - }; - const handleClose = () => { - setTaskModal(false); - }; - - const { - register, - handleSubmit, - formState: { isSubmitting, errors, touchedFields }, - } = useForm({ defaultValues, resolver: yupResolver(validationSchema), mode: "all" }); - - const onSubmit = async (data) => { - const formData = new FormData(); - formData.append("description", data.description); - requestServer(`api-for-send-to-harim/${rowId}`, "post", { - data: formData, - }) - .then(() => { - handleClose(); - mutate(); - }) - .catch(() => {}); - }; - return ( - - - - - - - - ); -}; -export default DetailDialog; diff --git a/src/components/dashboard/inquiryPrivacy/generalManager/zaminGov/RowActions/TaskDetail/index.jsx b/src/components/dashboard/inquiryPrivacy/generalManager/zaminGov/RowActions/TaskDetail/index.jsx deleted file mode 100644 index 1641840..0000000 --- a/src/components/dashboard/inquiryPrivacy/generalManager/zaminGov/RowActions/TaskDetail/index.jsx +++ /dev/null @@ -1,26 +0,0 @@ -"use client"; - -import { IconButton, Tooltip } from "@mui/material"; -import AssignmentIcon from "@mui/icons-material/Assignment"; -import DetailDialog from "./DetailDialog"; -import { useState } from "react"; - -const TaskDetail = ({ rowId, mutate }) => { - const [taskModal, setTaskModal] = useState(false); - - const openDetailDialog = () => { - setTaskModal(true); - }; - - return ( - <> - - - - - - - - ); -}; -export default TaskDetail; diff --git a/src/components/dashboard/inquiryPrivacy/generalManager/zaminGov/RowActions/index.jsx b/src/components/dashboard/inquiryPrivacy/generalManager/zaminGov/RowActions/index.jsx deleted file mode 100644 index ae4213c..0000000 --- a/src/components/dashboard/inquiryPrivacy/generalManager/zaminGov/RowActions/index.jsx +++ /dev/null @@ -1,13 +0,0 @@ -import TaskDetail from "./TaskDetail"; -import { Box } from "@mui/material"; -import RoadSafetyForm from "./RoadSafetyForm"; - -const RowActions = ({ row, mutate }) => { - return ( - - - - - ); -}; -export default RowActions; diff --git a/src/components/dashboard/inquiryPrivacy/generalManager/zaminGov/TaskList.jsx b/src/components/dashboard/inquiryPrivacy/generalManager/zaminGov/TaskList.jsx deleted file mode 100644 index cb0bd3d..0000000 --- a/src/components/dashboard/inquiryPrivacy/generalManager/zaminGov/TaskList.jsx +++ /dev/null @@ -1,145 +0,0 @@ -"use client"; - -import { useMemo } from "react"; -import { Box } from "@mui/material"; -import DataTableWithAuth from "@/core/components/DataTableWithAuth"; -import RowActions from "./RowActions"; - -const TaskList = () => { - const columns = useMemo( - () => [ - { - accessorKey: "id", - header: "کد یکتا", - id: "id", - enableColumnFilter: false, - datatype: "text", - filterMode: "notEquals", - }, - { - accessorKey: "aplication_number", - header: "شماره درخواست", - id: "aplication_number", - enableColumnFilter: false, - datatype: "text", - filterMode: "notEquals", - }, - { - accessorKey: "application_date", - header: "تاریخ درخواست", - id: "application_date", - enableColumnFilter: false, - datatype: "text", - filterMode: "equals", - }, - { - accessorKey: "province", - header: "استان", - id: "province", - enableColumnFilter: false, - datatype: "text", - filterMode: "equals", - }, - { - accessorKey: "township", - header: "شهرستان", - id: "township", - enableColumnFilter: false, - datatype: "text", - filterMode: "equals", - }, - { - accessorKey: "city", - header: "شهر", - id: "city", - enableColumnFilter: false, - datatype: "text", - filterMode: "equals", - }, - { - accessorKey: "county", - header: "بخش", - id: "county", - enableColumnFilter: false, - datatype: "text", - filterMode: "equals", - }, - { - accessorKey: "village", - header: "روستا", - id: "village", - enableColumnFilter: false, - datatype: "text", - filterMode: "equals", - }, - { - accessorKey: "land_area", - header: "مساحت زمین", - id: "land_area", - enableColumnFilter: false, - datatype: "text", - filterMode: "equals", - }, - { - accessorKey: "design_area", - header: "مساحت طرح", - id: "design_area", - enableColumnFilter: false, - datatype: "text", - filterMode: "equals", - }, - { - accessorKey: "organization", - header: "سازمان", - id: "organization", - enableColumnFilter: false, - datatype: "text", - filterMode: "equals", - }, - { - accessorKey: "design_group", - header: "گروه طرح", - id: "design_group", - enableColumnFilter: false, - datatype: "text", - filterMode: "equals", - }, - { - accessorKey: "design_title", - header: "عنوان طرح", - id: "design_title", - enableColumnFilter: false, - datatype: "text", - filterMode: "equals", - }, - { - accessorKey: "state", - header: "وضعیت درخواست", - id: "state", - enableColumnFilter: false, - datatype: "text", - filterMode: "equals", - }, - ], - [] - ); - - return ( - <> - - - - - ); -}; -export default TaskList; diff --git a/src/components/dashboard/inquiryPrivacy/generalManager/zaminGov/index.jsx b/src/components/dashboard/inquiryPrivacy/generalManager/zaminGov/index.jsx deleted file mode 100644 index ef66f17..0000000 --- a/src/components/dashboard/inquiryPrivacy/generalManager/zaminGov/index.jsx +++ /dev/null @@ -1,15 +0,0 @@ -"use client"; - -import PageTitle from "@/core/components/PageTitle"; -import { Stack } from "@mui/material"; -import TaskList from "./TaskList"; - -const GeneralManagerZaminGovComponent = () => { - return ( - - - - - ); -}; -export default GeneralManagerZaminGovComponent; diff --git a/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/MapModify/MapActionButtons.jsx b/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/MapModify/MapActionButtons.jsx deleted file mode 100644 index 600372d..0000000 --- a/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/MapModify/MapActionButtons.jsx +++ /dev/null @@ -1,100 +0,0 @@ -import { Box, Button, ButtonGroup } from "@mui/material"; -import AutoModeIcon from "@mui/icons-material/AutoMode"; -import DeleteIcon from "@mui/icons-material/Delete"; -import EditLocationAltIcon from "@mui/icons-material/EditLocationAlt"; -import SaveIcon from "@mui/icons-material/Save"; -import CancelIcon from "@mui/icons-material/Cancel"; - -const MapActionButtons = ({ - disableToCreate, - disableToEditAndDelete, - disableToSaveAndCancel, - onDraw, - onEdit, - onRemove, - onSave, - onCancel, -}) => ( - <> - - - - - - - - - - - - - -); - -export default MapActionButtons; diff --git a/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/MapModify/MapModifyDialog.jsx b/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/MapModify/MapModifyDialog.jsx deleted file mode 100644 index 218cce5..0000000 --- a/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/MapModify/MapModifyDialog.jsx +++ /dev/null @@ -1,96 +0,0 @@ -"use client"; - -import { - Box, - Button, - Chip, - Dialog, - DialogActions, - DialogContent, - Divider, - FormControl, - FormControlLabel, - FormLabel, - Radio, - RadioGroup, - Typography, -} from "@mui/material"; -import dynamic from "next/dynamic"; -import MapLoading from "@/core/components/MapLayer/Loading"; -import "leaflet-draw/dist/leaflet.draw.css"; -import GppMaybeIcon from "@mui/icons-material/GppMaybe"; -import PolygonForDesign from "./PolygonForDesign"; - -const MapLayer = dynamic(() => import("@/core/components/MapLayer"), { - loading: () => , - ssr: false, -}); - -const MapModifyDialog = ({ mapModifyModal, setMapModifyModal }) => { - const handleClose = () => { - setMapModifyModal(false); - }; - - return ( - - - - - - - - - - - - - - نکته: اصلاح ننمودن طرح به منزله تایید طرح میباشد. - - - - - - آیا طرح نیاز به ایجاد راه دسترسی دارد؟ - - - } label="بله" /> - } label="خیر" /> - - - - - - - - - - ); -}; - -export default MapModifyDialog; diff --git a/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/MapModify/PolygonForDesign.jsx b/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/MapModify/PolygonForDesign.jsx deleted file mode 100644 index f765e41..0000000 --- a/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/MapModify/PolygonForDesign.jsx +++ /dev/null @@ -1,115 +0,0 @@ -"use client"; - -import { FeatureGroup, useMap } from "react-leaflet"; -import { EditControl } from "react-leaflet-draw"; -import { useEffect, useRef, useState } from "react"; -import MapActionButtons from "./MapActionButtons"; - -const PolygonForDesign = () => { - const map = useMap(); - const editableFG = useRef(null); - const [polygonLayer, setPolygonLayer] = useState(null); - const [disableToCreate, setDisableToCreate] = useState(false); - const [disableToEditAndDelete, setDisableToEditAndDelete] = useState(true); - const [disableToSaveAndCancel, setDisableToSaveAndCancel] = useState(true); - const [editToolbar, setEditToolbar] = useState(null); - - useEffect(() => { - const { L } = window; - L.drawLocal.draw.handlers.polygon.tooltip = { - start: "برای شروع کشیدن پلیگان، کلیک کنید.", - cont: "گوشه های دیگر پلیگان را نیز انتخاب کنید.", - end: "برای اتمام رسم پلیگان، نقطه آخر را به اول متصل نمایید.", - }; - L.drawLocal.edit.handlers.edit.tooltip = { - text: "برای ذخیر یا لغو تغییرات، از دکمه های بالا سمت چپ استفاده نمایید.", - subtext: "نقاط مشخص شده را گرفته و برای ویرایش جابجا نمایید.", - }; - }, []); - - const handleDrawPolygon = () => { - const { L } = window; - const drawControl = new L.Draw.Polygon(map); - drawControl.enable(); - setDisableToCreate(true); - }; - - const handleEditPolygon = () => { - const { L } = window; - if (editableFG.current && polygonLayer) { - const editControlInstance = new L.EditToolbar.Edit(map, { - featureGroup: editableFG.current, - }); - editControlInstance.enable(); - setEditToolbar(editControlInstance); - setDisableToEditAndDelete(true); - setDisableToSaveAndCancel(false); - } - }; - - const handleRemovePolygon = () => { - if (polygonLayer && editableFG.current) { - editableFG.current.removeLayer(polygonLayer); - setPolygonLayer(null); - setDisableToEditAndDelete(true); - setDisableToCreate(false); - } - }; - - const handleSavePolygon = () => { - if (editToolbar) { - editToolbar.save(); - editToolbar.disable(); - setDisableToEditAndDelete(false); - setDisableToSaveAndCancel(true); - } - }; - - const handleCancelEdit = () => { - if (editToolbar) { - editToolbar.revertLayers(); - editToolbar.disable(); - setDisableToEditAndDelete(false); - setDisableToSaveAndCancel(true); - } - }; - - const handlePolygonCreate = (e) => { - const layer = e.layer; - setPolygonLayer(layer); - editableFG.current.addLayer(layer); - setDisableToEditAndDelete(false); - }; - - return ( - <> - - - - - - ); -}; - -export default PolygonForDesign; diff --git a/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/MapModify/index.jsx b/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/MapModify/index.jsx deleted file mode 100644 index 970f93c..0000000 --- a/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/MapModify/index.jsx +++ /dev/null @@ -1,29 +0,0 @@ -import { IconButton, Tooltip } from "@mui/material"; -import MapIcon from "@mui/icons-material/Map"; -import { useState } from "react"; -import MapModifyDialog from "./MapModifyDialog"; - -const MapModify = ({ rowId, mutate }) => { - const [mapModifyModal, setMapModifyModal] = useState(false); - - const openMapModifyDialog = () => { - setMapModifyModal(true); - }; - - return ( - <> - - - - - - - - ); -}; -export default MapModify; diff --git a/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/Refer/ReferFormContext.jsx b/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/Refer/ReferFormContext.jsx deleted file mode 100644 index 221e411..0000000 --- a/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/Refer/ReferFormContext.jsx +++ /dev/null @@ -1,139 +0,0 @@ -import { - Autocomplete, - Button, - CircularProgress, - DialogActions, - DialogContent, - FormControl, - FormHelperText, - InputLabel, - OutlinedInput, - Stack, - TextField, - Typography, -} from "@mui/material"; -import { Controller, useForm } from "react-hook-form"; -import { yupResolver } from "@hookform/resolvers/yup"; -import { object, string } from "yup"; -import StyledForm from "@/core/components/StyledForm"; -import useProvinces from "@/lib/hooks/useProvince"; -import useRequest from "@/lib/hooks/useRequest"; -import { REFER_ADMIN_PROVINCE } from "@/core/utils/routes"; - -const validationSchema = object({ - description: string().required("وارد کردن توضیحات الزامیست!"), - province: string().required("وارد کردن استان الزامیست!"), -}); - -const ReferFormContext = ({ setOpenReferDialog, rowId, mutate }) => { - const defaultValues = { - description: "", - province: "", - }; - const { provinces, loadingProvinces, errorProvinces } = useProvinces(); - const requestServer = useRequest({ notificationSuccess: true }); - const { - control, - register, - handleSubmit, - formState: { isSubmitting, errors, touchedFields }, - } = useForm({ defaultValues, resolver: yupResolver(validationSchema), mode: "all" }); - - const onSubmit = async (data) => { - const formData = new FormData(); - formData.append("description", data.description); - formData.append("provinceId", data.province); - - requestServer(`${REFER_ADMIN_PROVINCE}/${rowId}`, "post", { - data: formData, - }) - .then(() => { - setOpenReferDialog(false); - mutate(); - }) - .catch(() => {}); - }; - return ( - - - - - - - توضیحات - - - - {errors.description ? errors.description.message : null} - - - - - ( - - - {errorProvinces ? ( - خطایی در دریافت استان ها رخ داده است! - ) : loadingProvinces ? ( - - - درحال دریافت لیست استان ها - - ) : ( - province.id === value) || null} - disablePortal - options={provinces} - getOptionLabel={(province) => province.name_fa} - isOptionEqualToValue={(option, value) => option.id === value.id} - onChange={(event, newValue) => { - onChange(newValue ? newValue.id : ""); - }} - renderInput={(params) => ( - - )} - /> - )} - - {errors.province ? errors.province.message : null} - - - )} - /> - - - - - - - - - ); -}; -export default ReferFormContext; diff --git a/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/Refer/index.jsx b/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/Refer/index.jsx deleted file mode 100644 index ee76b95..0000000 --- a/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/Refer/index.jsx +++ /dev/null @@ -1,41 +0,0 @@ -import { Dialog, DialogTitle, IconButton, Stack, Tooltip } from "@mui/material"; -import ReplyIcon from "@mui/icons-material/Reply"; -import DialogTransition from "@/core/components/DialogTransition"; -import { useState } from "react"; -import ReferFormContext from "./ReferFormContext"; - -const ReferForm = ({ rowId, mutate }) => { - const [openReferDialog, setOpenReferDialog] = useState(false); - return ( - - - { - setOpenReferDialog(true); - }} - > - - - - - - ارجاع به استان دیگر - - - - - ); -}; -export default ReferForm; diff --git a/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/RoadSafetyForm/DescriptionForm.jsx b/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/RoadSafetyForm/DescriptionForm.jsx deleted file mode 100644 index ba2cdeb..0000000 --- a/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/RoadSafetyForm/DescriptionForm.jsx +++ /dev/null @@ -1,29 +0,0 @@ -import { FormControl, FormHelperText, InputLabel, OutlinedInput, Stack } from "@mui/material"; - -const DescriptionForm = ({ errors, register }) => { - return ( - - - - توضیحات - - - - {errors.description ? errors.description.message : null} - - - - ); -}; -export default DescriptionForm; diff --git a/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/RoadSafetyForm/PrevCartableOpinion.jsx b/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/RoadSafetyForm/PrevCartableOpinion.jsx deleted file mode 100644 index 74f9b45..0000000 --- a/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/RoadSafetyForm/PrevCartableOpinion.jsx +++ /dev/null @@ -1,27 +0,0 @@ -import { Card, CardContent, CardHeader, CircularProgress, Divider, Stack, Typography } from "@mui/material"; -import usePrevStateOpinion from "@/lib/hooks/usePrevStateopinion"; - -const PrevCartableOpinion = () => { - const { message, loadingMessage, errorMessage } = usePrevStateOpinion(); - return ( - - - - - {errorMessage ? ( - خطا در دریافت اطلاعات !!! - ) : loadingMessage ? ( - - - درحال دریافت اطلاعات - - ) : ( - {message} - )} - - - - - ); -}; -export default PrevCartableOpinion; diff --git a/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/RoadSafetyForm/QuestionSafetyForm.jsx b/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/RoadSafetyForm/QuestionSafetyForm.jsx deleted file mode 100644 index ef005b8..0000000 --- a/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/RoadSafetyForm/QuestionSafetyForm.jsx +++ /dev/null @@ -1,57 +0,0 @@ -import { - Card, - CardContent, - FormControl, - FormControlLabel, - FormLabel, - RadioGroup, - Stack, - Typography, -} from "@mui/material"; -import Radio from "@mui/material/Radio"; - -const QuestionSafetyForm = ({ register, errors }) => { - return ( - - - - - - - آیا ایمنی راه این طرح مورد تایید است ؟ - - - - - } - label="بله" - {...register("RadioGroup")} - /> - } - label="خیر" - {...register("RadioGroup")} - /> - - - {errors.RadioGroup && ( - - {errors.RadioGroup.message} - - )} - - - - - ); -}; -export default QuestionSafetyForm; diff --git a/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/RoadSafetyForm/RoadSaftyFormContext.jsx b/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/RoadSafetyForm/RoadSaftyFormContext.jsx deleted file mode 100644 index 8be0c6c..0000000 --- a/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/RoadSafetyForm/RoadSaftyFormContext.jsx +++ /dev/null @@ -1,80 +0,0 @@ -import { DialogActions, DialogContent, Stack } from "@mui/material"; -import StyledForm from "@/core/components/StyledForm"; -import useRequest from "@/lib/hooks/useRequest"; -import { useForm } from "react-hook-form"; -import { yupResolver } from "@hookform/resolvers/yup"; -import { object, string } from "yup"; -import QuestionSafetyForm from "./QuestionSafetyForm"; -import PrevCartableOpinion from "./PrevCartableOpinion"; -import DescriptionForm from "./DescriptionForm"; -import SubmitButtonsAdmin from "./SubmitButtonsAdmin"; -import { SUBMIT_ROAD_SAFETY_FORM } from "@/core/utils/routes"; -import ApplicantRequestDetail from "@/core/components/ApplicantRequestDetail"; -const fakeData = { - id: 1, - shomareh_darkhast: "2124", - ostan: "ostan", - shahr: "shahr", - shahrestan: "shahrestan", - bakhsh: "bakhsh", - roosta: "roosta", - tarikh_darkhast: "tarikh_darkhast", - sazman: "sazman", - masahat_zamin: "masahat_zamin", - masahat_tarh: "masahat_tarh", - gorooh_tarh: "gorooh_tarh", - onvane_tarh: "onvane_tarh", - address: "کرج - فلان جا - جنب پاساژ - نزدیک اونجا - اونور خیابون - زیر رو گذر - روی زیر گذر", - file_mosavab: "file", - polygon: [ - [51.515, -0.09], - [51.52, -0.1], - [51.52, -0.12], - ], -}; -const validationSchema = object({ - description: string().required("وارد کردن توضیحات الزامیست!"), - RadioGroup: string().required("تاییدیه ایمنی راه ضروریست!"), -}); -const RoadSafetyFormContext = ({ rowId, mutate, setOpenRoadSafetyForm }) => { - const defaultValues = { - description: "", - RadioGroup: "", - }; - const requestServer = useRequest({ notificationSuccess: true }); - const { - register, - handleSubmit, - formState: { isSubmitting, errors }, - } = useForm({ defaultValues, resolver: yupResolver(validationSchema), mode: "all" }); - const onSubmit = async (data) => { - const formData = new FormData(); - formData.append("description", data.description); - formData.append("provinceId", data.RadioGroup); - - requestServer(`${SUBMIT_ROAD_SAFETY_FORM}/${rowId}`, "post", { - data: formData, - }) - .then(() => { - setOpenRoadSafetyForm(false); - mutate(); - }) - .catch(() => {}); - }; - return ( - - - - - - - - - - - - - - ); -}; -export default RoadSafetyFormContext; diff --git a/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/RoadSafetyForm/SubmitButtonsAdmin.jsx b/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/RoadSafetyForm/SubmitButtonsAdmin.jsx deleted file mode 100644 index 611457f..0000000 --- a/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/RoadSafetyForm/SubmitButtonsAdmin.jsx +++ /dev/null @@ -1,21 +0,0 @@ -import { Button } from "@mui/material"; - -const SubmitButtonsAdmin = ({ setOpenRoadSafetyForm, isSubmitting }) => { - return ( - <> - - - - ); -}; -export default SubmitButtonsAdmin; diff --git a/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/RoadSafetyForm/index.jsx b/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/RoadSafetyForm/index.jsx deleted file mode 100644 index 9787ef5..0000000 --- a/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/RoadSafetyForm/index.jsx +++ /dev/null @@ -1,52 +0,0 @@ -import { Dialog, IconButton, Stack, Tooltip } from "@mui/material"; -import EngineeringIcon from "@mui/icons-material/Engineering"; -import DialogTransition from "@/core/components/DialogTransition"; -import { useState } from "react"; -import RoadSafetyFormContext from "./RoadSaftyFormContext"; -import { Close } from "@mui/icons-material"; - -const RoadSafetyForm = ({ rowId, mutate }) => { - const [openRoadSafetyForm, setOpenRoadSafetyForm] = useState(false); - return ( - - - { - setOpenRoadSafetyForm(true); - }} - > - - - - - setOpenRoadSafetyForm(false)} - sx={{ - position: "absolute", - right: 8, - top: 8, - zIndex: 10, - color: (theme) => theme.palette.grey[500], - }} - > - - - - - - ); -}; -export default RoadSafetyForm; diff --git a/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/TaskDetail/DetailDialog.jsx b/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/TaskDetail/DetailDialog.jsx deleted file mode 100644 index 777eecf..0000000 --- a/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/TaskDetail/DetailDialog.jsx +++ /dev/null @@ -1,75 +0,0 @@ -"use client"; - -import { Dialog, DialogContent } from "@mui/material"; -import { object, string } from "yup"; -import useRequest from "@/lib/hooks/useRequest"; -import { useForm } from "react-hook-form"; -import { yupResolver } from "@hookform/resolvers/yup"; -import StyledForm from "@/core/components/StyledForm"; -import ApplicantRequestDetail from "@/core/components/ApplicantRequestDetail"; - -const fakeData = { - id: 1, - shomareh_darkhast: "2124", - ostan: "ostan", - shahr: "shahr", - shahrestan: "shahrestan", - bakhsh: "bakhsh", - roosta: "roosta", - tarikh_darkhast: "tarikh_darkhast", - sazman: "sazman", - masahat_zamin: "masahat_zamin", - masahat_tarh: "masahat_tarh", - gorooh_tarh: "gorooh_tarh", - onvane_tarh: "onvane_tarh", - address: "کرج - فلان جا - جنب پاساژ - نزدیک اونجا - اونور خیابون - زیر رو گذر - روی زیر گذر", - file_mosavab: "file", - polygon: [ - [51.515, -0.09], - [51.52, -0.1], - [51.52, -0.12], - ], -}; - -const validationSchema = object({ - description: string().required("وارد کردن توضیحات الزامیست!"), -}); - -const DetailDialog = ({ taskModal, setTaskModal, rowId, mutate }) => { - const requestServer = useRequest({ auth: true }); - const defaultValues = { - description: "", - }; - const handleClose = () => { - setTaskModal(false); - }; - - const { - register, - handleSubmit, - formState: { isSubmitting, errors, touchedFields }, - } = useForm({ defaultValues, resolver: yupResolver(validationSchema), mode: "all" }); - - const onSubmit = async (data) => { - const formData = new FormData(); - formData.append("description", data.description); - requestServer(`api-for-send-to-harim/${rowId}`, "post", { - data: formData, - }) - .then(() => { - handleClose(); - mutate(); - }) - .catch(() => {}); - }; - return ( - - - - - - - - ); -}; -export default DetailDialog; diff --git a/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/TaskDetail/index.jsx b/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/TaskDetail/index.jsx deleted file mode 100644 index 1641840..0000000 --- a/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/TaskDetail/index.jsx +++ /dev/null @@ -1,26 +0,0 @@ -"use client"; - -import { IconButton, Tooltip } from "@mui/material"; -import AssignmentIcon from "@mui/icons-material/Assignment"; -import DetailDialog from "./DetailDialog"; -import { useState } from "react"; - -const TaskDetail = ({ rowId, mutate }) => { - const [taskModal, setTaskModal] = useState(false); - - const openDetailDialog = () => { - setTaskModal(true); - }; - - return ( - <> - - - - - - - - ); -}; -export default TaskDetail; diff --git a/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/index.jsx b/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/index.jsx deleted file mode 100644 index 2d324bc..0000000 --- a/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/index.jsx +++ /dev/null @@ -1,17 +0,0 @@ -import ReferForm from "./Refer"; -import TaskDetail from "./TaskDetail"; -import { Box } from "@mui/material"; -import RoadSafetyForm from "./RoadSafetyForm"; -import MapModify from "./MapModify"; - -const RowActions = ({ row, mutate }) => { - return ( - - - - - - - ); -}; -export default RowActions; diff --git a/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/TaskList.jsx b/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/TaskList.jsx deleted file mode 100644 index 188c1d6..0000000 --- a/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/TaskList.jsx +++ /dev/null @@ -1,145 +0,0 @@ -"use client"; - -import { useMemo } from "react"; -import { Box } from "@mui/material"; -import DataTableWithAuth from "@/core/components/DataTableWithAuth"; -import RowActions from "./RowActions"; - -const TaskList = () => { - const columns = useMemo( - () => [ - { - accessorKey: "id", - header: "کد یکتا", - id: "id", - enableColumnFilter: false, - datatype: "text", - filterMode: "notEquals", - }, - { - accessorKey: "aplication_number", - header: "شماره درخواست", - id: "aplication_number", - enableColumnFilter: false, - datatype: "text", - filterMode: "notEquals", - }, - { - accessorKey: "application_date", - header: "تاریخ درخواست", - id: "application_date", - enableColumnFilter: false, - datatype: "text", - filterMode: "equals", - }, - { - accessorKey: "province", - header: "استان", - id: "province", - enableColumnFilter: false, - datatype: "text", - filterMode: "equals", - }, - { - accessorKey: "township", - header: "شهرستان", - id: "township", - enableColumnFilter: false, - datatype: "text", - filterMode: "equals", - }, - { - accessorKey: "city", - header: "شهر", - id: "city", - enableColumnFilter: false, - datatype: "text", - filterMode: "equals", - }, - { - accessorKey: "county", - header: "بخش", - id: "county", - enableColumnFilter: false, - datatype: "text", - filterMode: "equals", - }, - { - accessorKey: "village", - header: "روستا", - id: "village", - enableColumnFilter: false, - datatype: "text", - filterMode: "equals", - }, - { - accessorKey: "land_area", - header: "مساحت زمین", - id: "land_area", - enableColumnFilter: false, - datatype: "text", - filterMode: "equals", - }, - { - accessorKey: "design_area", - header: "مساحت طرح", - id: "design_area", - enableColumnFilter: false, - datatype: "text", - filterMode: "equals", - }, - { - accessorKey: "organization", - header: "سازمان", - id: "organization", - enableColumnFilter: false, - datatype: "text", - filterMode: "equals", - }, - { - accessorKey: "design_group", - header: "گروه طرح", - id: "design_group", - enableColumnFilter: false, - datatype: "text", - filterMode: "equals", - }, - { - accessorKey: "design_title", - header: "عنوان طرح", - id: "design_title", - enableColumnFilter: false, - datatype: "text", - filterMode: "equals", - }, - { - accessorKey: "state", - header: "وضعیت درخواست", - id: "state", - enableColumnFilter: false, - datatype: "text", - filterMode: "equals", - }, - ], - [] - ); - - return ( - <> - - - - - ); -}; -export default TaskList; diff --git a/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/index.jsx b/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/index.jsx deleted file mode 100644 index 936d610..0000000 --- a/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/index.jsx +++ /dev/null @@ -1,15 +0,0 @@ -"use client"; - -import PageTitle from "@/core/components/PageTitle"; -import { Stack } from "@mui/material"; -import TaskList from "./TaskList"; - -const ProvinceAdminZaminGovComponent = () => { - return ( - - - - - ); -}; -export default ProvinceAdminZaminGovComponent; diff --git a/src/core/utils/pageMenuDev.js b/src/core/utils/pageMenuDev.js index 5fda757..68c6537 100644 --- a/src/core/utils/pageMenuDev.js +++ b/src/core/utils/pageMenuDev.js @@ -295,32 +295,32 @@ export const pageMenuDev = [ hasSubitems: true, Subitems: [ { - id: "cityAdminZaminGov", - label: "استعلام حرائم پنجره واحد", + id: "cityAdmin", + label: "کارتابل شهرستان", type: "page", - route: "/dashboard/inquiry-privacy/city-admin/zamin-gov", - permissions: [], + route: "/dashboard/inquiry-privacy/city-admin", + permissions: ["all"], }, { - id: "provinceAdminZaminGov", - label: "استعلام حرائم پنجره واحد", + id: "privacyOffice", + label: "کارتابل اداره حریم", type: "page", - route: "/dashboard/inquiry-privacy/province-admin/zamin-gov", - permissions: [], + route: "/dashboard/inquiry-privacy/privacy-office", + permissions: ["all"], }, { - id: "assistantZaminGov", - label: "استعلام حرائم پنجره واحد", + id: "assistant", + label: "کارتابل معاون", type: "page", - route: "/dashboard/inquiry-privacy/assistant/zamin-gov", - permissions: [], + route: "/dashboard/inquiry-privacy/assistant", + permissions: ["all"], }, { - id: "generalManagerZaminGov", - label: "استعلام حرائم پنجره واحد", + id: "generalManager", + label: "کارتابل مدیر", type: "page", - route: "/dashboard/inquiry-privacy/general-manager/zamin-gov", - permissions: [], + route: "/dashboard/inquiry-privacy/general-manager", + permissions: ["all"], }, ], }, diff --git a/src/core/utils/routes.js b/src/core/utils/routes.js index 1ddf8dc..780cd12 100644 --- a/src/core/utils/routes.js +++ b/src/core/utils/routes.js @@ -234,3 +234,6 @@ export const GET_RAHDARAN_TABLE_LIST = api + "/api/v3/rahdaran"; export const DELETE_RAHDARAN_ITEM = api + "/api/v3/rahdaran"; export const UPDATE_RAHDARAN_ITEM = api + "/api/v3/rahdaran"; export const CREATE_RAHDARAN_ITEM = api + "/api/v3/rahdaran"; + +// estelam harim +export const GET_CITY_ADMIN_LIST = api + "/api/v3/harim/province_office"; \ No newline at end of file From 7f1122233058271ba9c09b64c8da7c002255bea4 Mon Sep 17 00:00:00 2001 From: mhmjalali Date: Sun, 2 Nov 2025 10:33:35 +0330 Subject: [PATCH 02/61] solve bug of two polygon editable --- src/assets/scss/leaflet-measure.scss | 170 ++++++++++++++++ .../city-admin/CityAdminList.jsx | 188 +++++++++++++++++- .../MapDrawPolygon/DrawBound.jsx | 114 +++++++++++ .../FeedbackAction/MapDrawPolygon/index.jsx | 116 +++++++++++ .../RowActions/FeedbackAction/index.jsx | 135 +++++++++++++ .../city-admin/RowActions/index.jsx | 9 +- .../city-admin/ShowPrimaryArea/ShowBound.jsx | 29 +++ .../city-admin/ShowPrimaryArea/index.jsx | 61 ++++++ .../RowActions/ConfirmAction/index.jsx | 0 .../RowActions/RejectAction/index.jsx | 0 .../privacy-office/RowActions/index.jsx | 14 ++ .../inquiryPrivacy/privacy-office/index.jsx | 0 src/core/utils/pageMenuDev.js | 8 + src/core/utils/routes.js | 4 +- src/lib/hooks/useInquiryPrivacyState.js | 30 +++ 15 files changed, 868 insertions(+), 10 deletions(-) create mode 100644 src/assets/scss/leaflet-measure.scss create mode 100644 src/components/dashboard/inquiryPrivacy/city-admin/RowActions/FeedbackAction/MapDrawPolygon/DrawBound.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/city-admin/RowActions/FeedbackAction/MapDrawPolygon/index.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/city-admin/RowActions/FeedbackAction/index.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/city-admin/ShowPrimaryArea/ShowBound.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/city-admin/ShowPrimaryArea/index.jsx rename src/components/dashboard/inquiryPrivacy/{city-admin => privacy-office}/RowActions/ConfirmAction/index.jsx (100%) rename src/components/dashboard/inquiryPrivacy/{city-admin => privacy-office}/RowActions/RejectAction/index.jsx (100%) create mode 100644 src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/index.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/privacy-office/index.jsx create mode 100644 src/lib/hooks/useInquiryPrivacyState.js diff --git a/src/assets/scss/leaflet-measure.scss b/src/assets/scss/leaflet-measure.scss new file mode 100644 index 0000000..97e3bc1 --- /dev/null +++ b/src/assets/scss/leaflet-measure.scss @@ -0,0 +1,170 @@ +// leaflet-measure.scss + +$color-divider: #ddd; +$color-button: #5e66cc; +$color-lightertext: #999; + +$spacing-external: 12px; +$spacing-internal: 10px; + +$max-width: 280px; + +$button-icon-size: 12px; +$button-icon-spacing: 4px; + +@mixin hoverbutton { + color: $color-button; + text-decoration: none; + &:hover { + opacity: 0.5; + text-decoration: none; + } +} + +@mixin button ($icon) { + display: inline; + width: auto; + height: auto; + padding-left: 20px; + margin-right: $button-icon-spacing; + line-height: 1em; + border: 0; + text-align: left; + color: $color-button; + &, + &:hover { + background-color: transparent; + } + background: { + image: url('assets/#{ $icon }.png'); + repeat: no-repeat; + position: 0% 50%; + size: $button-icon-size $button-icon-size; + } + .leaflet-retina & { + background-image: url('assets/#{ $icon }_@2X.png'); + } + + @include hoverbutton; +} + +.leaflet-control-measure, +.leaflet-measure-resultpopup { + h3 { + margin: 0 0 $spacing-external 0; + padding-bottom: $spacing-internal; + border-bottom: solid 1px $color-divider; + } + p { + margin: $spacing-internal 0 0 0; + line-height: 1.5em; + &:first-child { + margin-top: 0; + } + } + .tasks { + margin: $spacing-external 0 0 0; + padding: $spacing-internal 0 0 0; + border-top: solid 1px $color-divider; + text-align: right; + + list-style: none; + list-style-image: none; + + li { + display: inline; + margin: 0 $spacing-internal 0 0; + &:last-child { + margin-right: 0; + } + } + } + + .coorddivider { + color: $color-lightertext; + } +} + +.leaflet-control-measure { + max-width: $max-width; + background: #fff; + + .leaflet-control-measure-toggle, + .leaflet-control-measure-toggle:hover { + background: { + size: 14px 14px; + image: url(assets/rulers.png); + } + border: 0; + border-radius: 4px; + .leaflet-touch & { + border-radius: 2px; + } + + // Hide text + text-indent: 100%; + white-space: nowrap; + overflow: hidden; + + .leaflet-retina & { + background-image: url(assets/rulers_@2X.png); + } + + .leaflet-touch & { + background-size: 16px 16px; + } + } + + // Special styling because start prompt has no content, just header and tasks + .startprompt { + h3 { + margin-bottom: $spacing-internal; + } + .tasks { + margin-top: 0; + padding-top: 0; + border-top: 0; + text-align: left; + } + } + + .leaflet-control-measure-interaction { + padding: $spacing-internal $spacing-external; + } + + .results { + .group { + margin-top: $spacing-internal; + padding-top: $spacing-internal; + border-top: dotted 1px lighten($color-divider, 5); + &:first-child { + margin-top: 0; + padding-top: 0; + border-top: 0; + } + } + .heading { + margin-right: $spacing-internal * 0.5; + color: $color-lightertext; + } + } + + a.start { + @include button(start); + } + a.cancel { + @include button(cancel); + } + a.finish { + @include button(check); + } +} + +.leaflet-measure-resultpopup { + a.zoomto { + @include button(focus); + } + a.deletemarkup { + @include button(trash); + } +} \ No newline at end of file diff --git a/src/components/dashboard/inquiryPrivacy/city-admin/CityAdminList.jsx b/src/components/dashboard/inquiryPrivacy/city-admin/CityAdminList.jsx index be14803..14b18ec 100644 --- a/src/components/dashboard/inquiryPrivacy/city-admin/CityAdminList.jsx +++ b/src/components/dashboard/inquiryPrivacy/city-admin/CityAdminList.jsx @@ -1,15 +1,37 @@ +import CustomSelectByDependency from '@/core/components/DataTable/filter/fieldsType/CustomSelectByDependency'; import DataTableWithAuth from '@/core/components/DataTableWithAuth'; import { GET_CITY_ADMIN_LIST } from '@/core/utils/routes'; -import { Box } from '@mui/material'; +import useInquiryPrivacyState from '@/lib/hooks/useInquiryPrivacyState'; +import { Box, Stack } from '@mui/material'; +import moment from 'jalali-moment'; import { useMemo } from 'react'; +import MapsHomeWorkIcon from '@mui/icons-material/MapsHomeWork'; +import SecurityIcon from '@mui/icons-material/Security'; +import ManageAccountsIcon from '@mui/icons-material/ManageAccounts'; +import PsychologyAltIcon from '@mui/icons-material/PsychologyAlt'; +import ReceiptLongIcon from '@mui/icons-material/ReceiptLong'; +import WindowIcon from '@mui/icons-material/Window'; +import DangerousIcon from '@mui/icons-material/Dangerous'; +import AutorenewIcon from '@mui/icons-material/Autorenew'; import RowActions from './RowActions'; +import ShowPrimaryArea from './ShowPrimaryArea'; const CityAdminList = () => { + const stateIcon = (state_id) => { + if (state_id === 1) return ; + if (state_id === 2 || state_id === 5 || state_id === 13) return ; + if (state_id === 3 || state_id === 6 || state_id === 14) return ; + if (state_id === 4 || state_id === 7 || state_id === 15) return ; + if (state_id === 8) return ; + if (state_id === 9 || state_id === 11) return ; + if (state_id === 10) return ; + if (state_id === 12) return ; + }; const columns = useMemo(() => { return [ { - accessorKey: "id", - header: "کد یکتا", + accessorKey: "panjare_vahed_id", + header: "کدرهگیری درخواست", id: "panjare_vahed_id", enableColumnFilter: true, datatype: "text", @@ -33,6 +55,166 @@ const CityAdminList = () => { size: 100, Cell: ({ row }) => <>{row.original.national_id}, }, + { + accessorKey: "state_id", + header: "وضعیت", + id: "state_id", + enableColumnFilter: true, + datatype: "numeric", + filterMode: "equals", + sortDescFirst: false, + grow: false, + size: 100, + ColumnSelectComponent: (props) => { + const { itemsList, loadingItemsList, errorItemsList } = useInquiryPrivacyState(); + + const getColumnSelectOptions = useMemo(() => { + if (loadingItemsList) { + return [{ value: "loading", label: "در حال بارگذاری..." }]; + } + if (errorItemsList) { + return [{ value: "error", label: "خطا در بارگذاری" }]; + } + return [ + { value: "", label: "همه موارد" }, + ...itemsList.map((item) => ({ + value: item.id, + label: item.name, + })), + ]; + }, [itemsList, loadingItemsList, errorItemsList]); + + return ( + + ); + }, + Cell: ({ row }) => ( + + {stateIcon(row.original.state_id)} + + {row.original.state_name} + + + ), + }, + { + accessorKey: "plan_title", + header: "عنوان طرح", + id: "plan_title", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ row }) => <>{row.original.plan_title}, + }, + { + accessorKey: "plan_group", + header: "گروه طرح", + id: "plan_group", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ row }) => <>{row.original.plan_group}, + }, + { + accessorKey: "requested_organization", + header: "دستگاه صادر کننده", + id: "requested_organization", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ row }) => <>{row.original.requested_organization}, + }, + { + accessorKey: "worksheet_id", + header: "شناسه کاربرگ", + id: "worksheet_id", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ row }) => <>{row.original.worksheet_id}, + }, + { + accessorKey: "primary_area", + header: "نمایش محدوده طرح", + id: "primary_area", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ row }) => row.original.primary_area ? ( + + + + ) : ("-"), + }, + { + accessorKey: "province_id", + header: "استان", + id: "province_id", + enableColumnFilter: false, + datatype: "numeric", + sortDescFirst: false, + grow: false, + size: 100, + Cell: ({ row }) => <>{row.original.province_name}, + }, + { + accessorKey: "city_id", + header: "شهر", + id: "city_id", + enableColumnFilter: false, + datatype: "numeric", + sortDescFirst: false, + grow: false, + size: 100, + Cell: ({ row }) => <>{row.original.city_name}, + }, + { + accessorKey: "isic", + header: "کد آیسیک", + id: "isic", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ row }) => <>{row.original.isic}, + }, + { + accessorFn: (row) => moment(row.request_date).locale("fa").format("YYYY/MM/DD"), + header: "تاریخ درخواست", + id: "request_date", + enableColumnFilter: true, + datatype: "date", + filterMode: "between", + grow: false, + size: 100, + }, ]; }, []); diff --git a/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/FeedbackAction/MapDrawPolygon/DrawBound.jsx b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/FeedbackAction/MapDrawPolygon/DrawBound.jsx new file mode 100644 index 0000000..e715f3e --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/FeedbackAction/MapDrawPolygon/DrawBound.jsx @@ -0,0 +1,114 @@ +import React, { useCallback, useEffect, useRef, useState } from "react"; +import L from "leaflet"; +import { FeatureGroup, useMap } from "react-leaflet"; +import "leaflet-draw"; + +const DrawPolygon = ({ control, controlDispach, drawBound, setDrawBound }) => { + const map = useMap(); + const featureRef = useRef(null); + const [area, setArea] = useState(); + const drawControlRef = useRef(null); + + 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); + setDrawBound(editedLayer); + }); + }; + + const handlerCreatedBound = useCallback((event) => { + const { layer } = event; + layer.editing.enable(); + featureRef.current.addLayer(layer); + setArea(layer); + setDrawBound(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); + setDrawBound(null); + } + }, [control.status, area]); + + useEffect(() => { + if (control.status === 2 && drawBound && featureRef.current) { + setArea(drawBound); + featureRef.current.addLayer(drawBound); + drawBound.editing.enable(); + safeFitBounds(drawBound); + bindEditEvent(drawBound); + } + }, [control.status, drawBound]); + + 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: "red", + 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 DrawPolygon; diff --git a/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/FeedbackAction/MapDrawPolygon/index.jsx b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/FeedbackAction/MapDrawPolygon/index.jsx new file mode 100644 index 0000000..bef1529 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/FeedbackAction/MapDrawPolygon/index.jsx @@ -0,0 +1,116 @@ +import { Delete, Route } from "@mui/icons-material"; +import { Box, Button, Stack, Typography } from "@mui/material"; +import { useReducer } from "react"; +import DrawPolygon from "./DrawBound"; + +const statusType = [ + { + id: 0, + message: "برای آغاز ترسیم محدوده، کلیک کنید!", + buttons: [ + { + label: "شروع ترسیم محدوده", + key: "start", + color: "warning", + 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 = (drawBound) => { + if (drawBound) { + 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 MapDrawPolygon = ({ drawBound, setDrawBound }) => { + const [control, controlDispach] = useReducer(reducer, drawBound, createInitialState); + + return ( + <> + + + theme.palette.secondary.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 MapDrawPolygon; diff --git a/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/FeedbackAction/index.jsx b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/FeedbackAction/index.jsx new file mode 100644 index 0000000..e954aeb --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/FeedbackAction/index.jsx @@ -0,0 +1,135 @@ +import MapLayer from "@/core/components/MapLayer"; +import { CITY_ADMIN_FEEDBACK } from "@/core/utils/routes"; +import useRequest from "@/lib/hooks/useRequest"; +import { yupResolver } from "@hookform/resolvers/yup"; +import CloseIcon from "@mui/icons-material/Close"; +import ForumIcon from '@mui/icons-material/Forum'; +import { Box, Button, Dialog, DialogActions, DialogContent, DialogTitle, IconButton, TextField, Tooltip, Typography } from '@mui/material'; +import { useEffect, useMemo, useState } from 'react'; +import { useForm } from "react-hook-form"; +import { object, string } from 'yup'; +import ShowBound from "../../ShowPrimaryArea/ShowBound"; +import MapDrawPolygon from "./MapDrawPolygon"; + +const validationSchema = object({ + expert_description: string().required("توضیحات ناظر اجباری است!"), +}); + +const FeedbackAction = ({rowId, mutate, rowPrimaryArea}) => { + const requestServer = useRequest({ notificationSuccess: true }); + const [openFeedbackDialog, setOpenFeedbackDialog] = useState(false); + const [drawBound, setDrawBound] = useState(null); + const bound = useMemo(() => { + const latLngCoords = rowPrimaryArea.coordinates.map(coord => [coord[1], coord[0]]); + return rowPrimaryArea.type === "polygon" + ? L.polygon(latLngCoords) + : L.polyline(latLngCoords); + }, [rowPrimaryArea]); + + + useEffect(() => { + console.log("drawBound", drawBound); + + }, [drawBound]) + + + const { + control, + register, + handleSubmit, + setValue, + formState: { isSubmitting, errors }, + } = useForm({ + defaultValues: {expert_description: "", forbidden_area: ""}, + resolver: yupResolver(validationSchema), + mode: "all" + }); + + + const onSubmit = async (data) => { + const formData = new FormData(); + formData.append("expert_description", data.expert_description); + + try { + await requestServer(`${CITY_ADMIN_FEEDBACK}/${rowId}`, "post", { + data: formData, + }); + mutate(); + setOpenFeedbackDialog(false); + } catch (error) {} + }; + + + return ( + <> + + + setOpenFeedbackDialog(true)}> + + + + setOpenFeedbackDialog(false)} + PaperProps={{ + sx: { + transition: "all .3s", + boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px", + borderRadius: 2, + }, + }} + maxWidth="sm" + fullWidth + dir="rtl" + > + + + توضیحات ناظر + + setOpenFeedbackDialog(false)} size="small"> + + + + + منطقه ممنوعه (در صورت وجود انتخاب کنید) + + + + + + + + + + + + + + + + ) +} + +export default FeedbackAction \ No newline at end of file diff --git a/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/index.jsx b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/index.jsx index c8906f2..a823158 100644 --- a/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/index.jsx @@ -1,13 +1,10 @@ import { Box } from "@mui/material"; -import ConfirmAction from "./ConfirmAction"; -import RejectAction from "./RejectAction"; +import FeedbackAction from "./FeedbackAction"; const RowActions = ({ row, mutate }) => { - return ( - - - + + ); }; diff --git a/src/components/dashboard/inquiryPrivacy/city-admin/ShowPrimaryArea/ShowBound.jsx b/src/components/dashboard/inquiryPrivacy/city-admin/ShowPrimaryArea/ShowBound.jsx new file mode 100644 index 0000000..24db476 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/city-admin/ShowPrimaryArea/ShowBound.jsx @@ -0,0 +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; diff --git a/src/components/dashboard/inquiryPrivacy/city-admin/ShowPrimaryArea/index.jsx b/src/components/dashboard/inquiryPrivacy/city-admin/ShowPrimaryArea/index.jsx new file mode 100644 index 0000000..7300a1f --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/city-admin/ShowPrimaryArea/index.jsx @@ -0,0 +1,61 @@ +const { Button, IconButton, Tooltip, Box, Dialog, DialogTitle, Typography, DialogContent, DialogActions } = require("@mui/material"); +import LayersIcon from '@mui/icons-material/Layers'; +import CloseIcon from "@mui/icons-material/Close"; +import { useMemo, useState } from 'react'; +import MapLayer from '@/core/components/MapLayer'; +import ShowBound from './ShowBound'; + +const ShowPrimaryArea = ({primaryArea}) => { + const [openShowAreaDialog, setOpenShowAreaDialog] = useState(false); + const bound = useMemo(() => { + const latLngCoords = primaryArea.coordinates.map(coord => [coord[1], coord[0]]); + return primaryArea.type === "polygon" + ? L.polygon(latLngCoords) + : L.polyline(latLngCoords); + }, [primaryArea]); + + return ( + + + setOpenShowAreaDialog(true)}> + + + + setOpenShowAreaDialog(false)} + PaperProps={{ + sx: { + transition: "all .3s", + boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px", + borderRadius: 2, + padding: 1, + }, + }} + maxWidth="sm" + fullWidth + dir="rtl" + > + + + محدوده طرح + + setOpenShowAreaDialog(false)} size="small"> + + + + + + + + + + + + + + + ) +} + +export default ShowPrimaryArea \ No newline at end of file diff --git a/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/ConfirmAction/index.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ConfirmAction/index.jsx similarity index 100% rename from src/components/dashboard/inquiryPrivacy/city-admin/RowActions/ConfirmAction/index.jsx rename to src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ConfirmAction/index.jsx diff --git a/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/RejectAction/index.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RejectAction/index.jsx similarity index 100% rename from src/components/dashboard/inquiryPrivacy/city-admin/RowActions/RejectAction/index.jsx rename to src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RejectAction/index.jsx diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/index.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/index.jsx new file mode 100644 index 0000000..45e1693 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/index.jsx @@ -0,0 +1,14 @@ +import { Box } from "@mui/material"; +import ConfirmAction from "./ConfirmAction"; +import RejectAction from "./RejectAction"; + +const RowActions = ({ row, mutate }) => { + + return ( + + + + + ); +}; +export default RowActions; diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/index.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/index.jsx new file mode 100644 index 0000000..e69de29 diff --git a/src/core/utils/pageMenuDev.js b/src/core/utils/pageMenuDev.js index 68c6537..67b05dc 100644 --- a/src/core/utils/pageMenuDev.js +++ b/src/core/utils/pageMenuDev.js @@ -24,6 +24,10 @@ import RouteIcon from "@mui/icons-material/Route"; import ScienceIcon from "@mui/icons-material/Science"; import SpaceDashboardIcon from "@mui/icons-material/SpaceDashboard"; import SpeedIcon from "@mui/icons-material/Speed"; +import PsychologyAltIcon from '@mui/icons-material/PsychologyAlt'; +import MapsHomeWorkIcon from '@mui/icons-material/MapsHomeWork'; +import SecurityIcon from '@mui/icons-material/Security'; +import ManageAccountsIcon from '@mui/icons-material/ManageAccounts'; export const pageMenuDev = [ { @@ -299,6 +303,7 @@ export const pageMenuDev = [ label: "کارتابل شهرستان", type: "page", route: "/dashboard/inquiry-privacy/city-admin", + icon: , permissions: ["all"], }, { @@ -306,6 +311,7 @@ export const pageMenuDev = [ label: "کارتابل اداره حریم", type: "page", route: "/dashboard/inquiry-privacy/privacy-office", + icon: , permissions: ["all"], }, { @@ -313,6 +319,7 @@ export const pageMenuDev = [ label: "کارتابل معاون", type: "page", route: "/dashboard/inquiry-privacy/assistant", + icon: , permissions: ["all"], }, { @@ -320,6 +327,7 @@ export const pageMenuDev = [ label: "کارتابل مدیر", type: "page", route: "/dashboard/inquiry-privacy/general-manager", + icon: , permissions: ["all"], }, ], diff --git a/src/core/utils/routes.js b/src/core/utils/routes.js index 780cd12..0a3ee79 100644 --- a/src/core/utils/routes.js +++ b/src/core/utils/routes.js @@ -236,4 +236,6 @@ export const UPDATE_RAHDARAN_ITEM = api + "/api/v3/rahdaran"; export const CREATE_RAHDARAN_ITEM = api + "/api/v3/rahdaran"; // estelam harim -export const GET_CITY_ADMIN_LIST = api + "/api/v3/harim/province_office"; \ No newline at end of file +export const GET_CITY_ADMIN_LIST = api + "/api/v3/harim/province_office"; +export const GET_INQUIRY_PRIVACY_STATE_LIST = api + "/api/v3/harim/detail/states"; +export const CITY_ADMIN_FEEDBACK = api + "/api/v3/harim/province_office/feedback"; \ No newline at end of file diff --git a/src/lib/hooks/useInquiryPrivacyState.js b/src/lib/hooks/useInquiryPrivacyState.js new file mode 100644 index 0000000..a66d83f --- /dev/null +++ b/src/lib/hooks/useInquiryPrivacyState.js @@ -0,0 +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; From 26924102f742e1e0047b20b9359a5529d7efb8cb Mon Sep 17 00:00:00 2001 From: mhmjalali Date: Tue, 4 Nov 2025 09:06:04 +0330 Subject: [PATCH 03/61] work on privacy_office --- package.json | 1 + .../inquiry-privacy/privacy-office/page.js | 3 +- .../MapDrawPolygon/DrawBound.jsx | 242 ++++++++++-------- .../FeedbackAction/MapDrawPolygon/index.jsx | 10 +- .../RowActions/FeedbackAction/index.jsx | 37 +-- .../city-admin/RowActions/index.jsx | 2 +- .../privacy-office/PrivacyOfficeList.jsx | 239 +++++++++++++++++ .../RowActions/RejectAction/index.jsx | 2 +- .../ShowPrimaryArea/ShowBound.jsx | 29 +++ .../privacy-office/ShowPrimaryArea/index.jsx | 61 +++++ .../inquiryPrivacy/privacy-office/index.jsx | 14 + src/core/utils/geoCalculations.js | 35 +++ src/core/utils/routes.js | 3 +- 13 files changed, 550 insertions(+), 128 deletions(-) create mode 100644 src/components/dashboard/inquiryPrivacy/privacy-office/PrivacyOfficeList.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/privacy-office/ShowPrimaryArea/ShowBound.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/privacy-office/ShowPrimaryArea/index.jsx create mode 100644 src/core/utils/geoCalculations.js diff --git a/package.json b/package.json index a4532cb..8a2e759 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "@mui/material-nextjs": "^5.16.6", "@mui/x-date-pickers": "^6.19.5", "@mui/x-tree-view": "^7.11.0", + "@turf/turf": "^7.2.0", "axios": "^1.7.2", "date-fns": "^3.3.1", "date-fns-jalali": "^2.13.0-0", diff --git a/src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/privacy-office/page.js b/src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/privacy-office/page.js index ed381eb..c0de9c5 100644 --- a/src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/privacy-office/page.js +++ b/src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/privacy-office/page.js @@ -1,3 +1,4 @@ +import PrivacyOfficePage from "@/components/dashboard/inquiryPrivacy/privacy-office"; import WithPermission from "@/core/middlewares/withPermission"; export const metadata = { title: "کارتابل اداره حریم", @@ -5,7 +6,7 @@ export const metadata = { const Page = () => { return ( -

کارتابل اداره حریم

+
); }; diff --git a/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/FeedbackAction/MapDrawPolygon/DrawBound.jsx b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/FeedbackAction/MapDrawPolygon/DrawBound.jsx index e715f3e..31b9706 100644 --- a/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/FeedbackAction/MapDrawPolygon/DrawBound.jsx +++ b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/FeedbackAction/MapDrawPolygon/DrawBound.jsx @@ -2,113 +2,151 @@ import React, { useCallback, useEffect, useRef, useState } from "react"; import L from "leaflet"; import { FeatureGroup, useMap } from "react-leaflet"; import "leaflet-draw"; +import { calculatePolygonMetrics } from "@/core/utils/geoCalculations"; const DrawPolygon = ({ control, controlDispach, drawBound, setDrawBound }) => { - const map = useMap(); - const featureRef = useRef(null); - const [area, setArea] = useState(); - const drawControlRef = useRef(null); + const map = useMap(); + const featureRef = useRef(null); + const drawControlRef = useRef(null); - 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 [area, setArea] = useState(0); + const [sideLengths, setSideLengths] = useState([]); + + const calculatePolygonMetricsForLayer = useCallback( + (layer) => { + if (!layer) return; + + const latlngs = layer.getLatLngs()[0]; + if (!latlngs || latlngs.length < 3) return; + + const coordinates = latlngs.map((p) => [p.lat, p.lng]); + + const metrics = calculatePolygonMetrics(coordinates, true); + + setArea(metrics.area); + setSideLengths(metrics.sides); + + setDrawBound({ + layer, + metrics, + }); + }, + [setDrawBound] + ); + + 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 = useCallback( + (layer) => { + if (!layer) return; + layer.on("edit", function (e) { + const editedLayer = e.target; + calculatePolygonMetricsForLayer(editedLayer); + }); + }, + [calculatePolygonMetricsForLayer] + ); + + const handlerCreatedBound = useCallback( + (event) => { + const { layer } = event; + layer.editing.enable(); + featureRef.current.addLayer(layer); + + calculatePolygonMetricsForLayer(layer); + bindEditEvent(layer); + + controlDispach({ type: "SET_STATUS", status: 2 }); + }, + [calculatePolygonMetricsForLayer, bindEditEvent, controlDispach] + ); + + 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 && featureRef.current) { + featureRef.current.clearLayers(); + setArea(0); + setSideLengths([]); + setDrawBound(null); + } + }, [control.status, setDrawBound]); + + useEffect(() => { + if (control.status === 2 && drawBound && featureRef.current) { + const { layer, metrics } = drawBound; + featureRef.current.addLayer(layer); + layer.editing.enable(); + safeFitBounds(layer); + bindEditEvent(layer); + + setArea(metrics?.area || 0); + setSideLengths(metrics?.sides || []); + } + }, [control.status, drawBound, bindEditEvent]); + + 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: "red", + weight: 3, + clickable: true, + }, + }, + polyline: false, + rectangle: false, + circle: false, + marker: false, + circlemarker: false, + }, + edit: { + featureGroup: featureRef.current, + edit: true, + remove: true, + }, + }); + + 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]); - const bindEditEvent = (layer) => { - if (!layer) return; - layer.on("edit", function (e) { - const editedLayer = e.target; - setArea(editedLayer); - setDrawBound(editedLayer); - }); - }; - - const handlerCreatedBound = useCallback((event) => { - const { layer } = event; - layer.editing.enable(); - featureRef.current.addLayer(layer); - setArea(layer); - setDrawBound(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); - setDrawBound(null); - } - }, [control.status, area]); - - useEffect(() => { - if (control.status === 2 && drawBound && featureRef.current) { - setArea(drawBound); - featureRef.current.addLayer(drawBound); - drawBound.editing.enable(); - safeFitBounds(drawBound); - bindEditEvent(drawBound); - } - }, [control.status, drawBound]); - - 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: "red", - 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 ; + return ; }; export default DrawPolygon; diff --git a/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/FeedbackAction/MapDrawPolygon/index.jsx b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/FeedbackAction/MapDrawPolygon/index.jsx index bef1529..41ebf0f 100644 --- a/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/FeedbackAction/MapDrawPolygon/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/FeedbackAction/MapDrawPolygon/index.jsx @@ -63,10 +63,10 @@ const MapDrawPolygon = ({ drawBound, setDrawBound }) => { return ( <> - { {statusType.find((st) => st.id == control.status).message} - +
{ background: "linear-gradient(to top, rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0))", }} > - + {statusType .find((st) => st.id == control.status) .buttons.map((button) => ( @@ -108,7 +108,7 @@ const MapDrawPolygon = ({ drawBound, setDrawBound }) => { {button.label} ))} - + ); diff --git a/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/FeedbackAction/index.jsx b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/FeedbackAction/index.jsx index e954aeb..d20160a 100644 --- a/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/FeedbackAction/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/FeedbackAction/index.jsx @@ -5,7 +5,7 @@ import { yupResolver } from "@hookform/resolvers/yup"; import CloseIcon from "@mui/icons-material/Close"; import ForumIcon from '@mui/icons-material/Forum'; import { Box, Button, Dialog, DialogActions, DialogContent, DialogTitle, IconButton, TextField, Tooltip, Typography } from '@mui/material'; -import { useEffect, useMemo, useState } from 'react'; +import { useMemo, useState } from 'react'; import { useForm } from "react-hook-form"; import { object, string } from 'yup'; import ShowBound from "../../ShowPrimaryArea/ShowBound"; @@ -25,38 +25,41 @@ const FeedbackAction = ({rowId, mutate, rowPrimaryArea}) => { ? L.polygon(latLngCoords) : L.polyline(latLngCoords); }, [rowPrimaryArea]); - - - useEffect(() => { - console.log("drawBound", drawBound); - - }, [drawBound]) const { - control, register, handleSubmit, - setValue, formState: { isSubmitting, errors }, } = useForm({ - defaultValues: {expert_description: "", forbidden_area: ""}, + defaultValues: {expert_description: "", forbidden_area: "", forbidden_area_space: ""}, resolver: yupResolver(validationSchema), mode: "all" }); - const onSubmit = async (data) => { - const formData = new FormData(); - formData.append("expert_description", data.expert_description); - try { + const payload = { + expert_description: data.expert_description, + }; + + if (drawBound && drawBound.metrics) { + const { metrics } = drawBound; + payload.forbidden_area = { + type: "polygon", + coordinates: metrics.coordinates, + }; + payload.forbidden_area_space = metrics.area.toFixed(2); + } await requestServer(`${CITY_ADMIN_FEEDBACK}/${rowId}`, "post", { - data: formData, + data: payload, }); + mutate(); setOpenFeedbackDialog(false); - } catch (error) {} + } catch (error) { + console.error("❌ Error submitting feedback:", error); + } }; @@ -64,7 +67,7 @@ const FeedbackAction = ({rowId, mutate, rowPrimaryArea}) => { <> - setOpenFeedbackDialog(true)}> + setOpenFeedbackDialog(true)}> diff --git a/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/index.jsx b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/index.jsx index a823158..69d588a 100644 --- a/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/index.jsx @@ -4,7 +4,7 @@ import FeedbackAction from "./FeedbackAction"; const RowActions = ({ row, mutate }) => { return ( - + {row.original.state_id === 1 ? : "-"} ); }; diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/PrivacyOfficeList.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/PrivacyOfficeList.jsx new file mode 100644 index 0000000..20fe52d --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/PrivacyOfficeList.jsx @@ -0,0 +1,239 @@ +import CustomSelectByDependency from '@/core/components/DataTable/filter/fieldsType/CustomSelectByDependency'; +import DataTableWithAuth from '@/core/components/DataTableWithAuth'; +import useInquiryPrivacyState from '@/lib/hooks/useInquiryPrivacyState'; +import AutorenewIcon from '@mui/icons-material/Autorenew'; +import DangerousIcon from '@mui/icons-material/Dangerous'; +import ManageAccountsIcon from '@mui/icons-material/ManageAccounts'; +import MapsHomeWorkIcon from '@mui/icons-material/MapsHomeWork'; +import PsychologyAltIcon from '@mui/icons-material/PsychologyAlt'; +import ReceiptLongIcon from '@mui/icons-material/ReceiptLong'; +import SecurityIcon from '@mui/icons-material/Security'; +import WindowIcon from '@mui/icons-material/Window'; +import { Box, Stack } from '@mui/material'; +import moment from 'jalali-moment'; +import { useMemo } from 'react'; +import RowActions from './RowActions'; +import { GET_PRIVACY_ADMIN_LIST } from '@/core/utils/routes'; +import ShowPrimaryArea from './ShowPrimaryArea'; + +const PrivacyOfficeList = () => { + const stateIcon = (state_id) => { + if (state_id === 1) return ; + if (state_id === 2 || state_id === 5 || state_id === 13) return ; + if (state_id === 3 || state_id === 6 || state_id === 14) return ; + if (state_id === 4 || state_id === 7 || state_id === 15) return ; + if (state_id === 8) return ; + if (state_id === 9 || state_id === 11) return ; + if (state_id === 10) return ; + if (state_id === 12) return ; + }; + const columns = useMemo(() => { + return [ + { + accessorKey: "panjare_vahed_id", + header: "کدرهگیری درخواست", + id: "panjare_vahed_id", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ row }) => <>{row.original.panjare_vahed_id}, + }, + { + accessorKey: "national_id", + header: "کد ملی", + id: "national_id", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ row }) => <>{row.original.national_id}, + }, + { + accessorKey: "state_id", + header: "وضعیت", + id: "state_id", + enableColumnFilter: true, + datatype: "numeric", + filterMode: "equals", + sortDescFirst: false, + grow: false, + size: 100, + ColumnSelectComponent: (props) => { + const { itemsList, loadingItemsList, errorItemsList } = useInquiryPrivacyState(); + + const getColumnSelectOptions = useMemo(() => { + if (loadingItemsList) { + return [{ value: "loading", label: "در حال بارگذاری..." }]; + } + if (errorItemsList) { + return [{ value: "error", label: "خطا در بارگذاری" }]; + } + return [ + { value: "", label: "همه موارد" }, + ...itemsList.map((item) => ({ + value: item.id, + label: item.name, + })), + ]; + }, [itemsList, loadingItemsList, errorItemsList]); + + return ( + + ); + }, + Cell: ({ row }) => ( + + {stateIcon(row.original.state_id)} + + {row.original.state_name} + + + ), + }, + { + accessorKey: "plan_title", + header: "عنوان طرح", + id: "plan_title", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ row }) => <>{row.original.plan_title}, + }, + { + accessorKey: "plan_group", + header: "گروه طرح", + id: "plan_group", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ row }) => <>{row.original.plan_group}, + }, + { + accessorKey: "requested_organization", + header: "دستگاه صادر کننده", + id: "requested_organization", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ row }) => <>{row.original.requested_organization}, + }, + { + accessorKey: "worksheet_id", + header: "شناسه کاربرگ", + id: "worksheet_id", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ row }) => <>{row.original.worksheet_id}, + }, + { + accessorKey: "primary_area", + header: "نمایش محدوده طرح", + id: "primary_area", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ row }) => row.original.primary_area ? ( + + + + ) : ("-"), + }, + { + accessorKey: "province_id", + header: "استان", + id: "province_id", + enableColumnFilter: false, + datatype: "numeric", + sortDescFirst: false, + grow: false, + size: 100, + Cell: ({ row }) => <>{row.original.province_name}, + }, + { + accessorKey: "city_id", + header: "شهر", + id: "city_id", + enableColumnFilter: false, + datatype: "numeric", + sortDescFirst: false, + grow: false, + size: 100, + Cell: ({ row }) => <>{row.original.city_name}, + }, + { + accessorKey: "isic", + header: "کد آیسیک", + id: "isic", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ row }) => <>{row.original.isic}, + }, + { + accessorFn: (row) => moment(row.request_date).locale("fa").format("YYYY/MM/DD"), + header: "تاریخ درخواست", + id: "request_date", + enableColumnFilter: true, + datatype: "date", + filterMode: "between", + grow: false, + size: 100, + }, + ]; + }, []); + + return ( + <> + + + + + ) +} + +export default PrivacyOfficeList \ No newline at end of file diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RejectAction/index.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RejectAction/index.jsx index ccdffaf..c8a7e96 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RejectAction/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RejectAction/index.jsx @@ -6,7 +6,7 @@ const RejectAction = ({ rowId, mutate }) => { const [openRejectDialog, setOpenRejectDialog] = useState(false); return ( <> - + setOpenRejectDialog(true)}> diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/ShowPrimaryArea/ShowBound.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/ShowPrimaryArea/ShowBound.jsx new file mode 100644 index 0000000..24db476 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/ShowPrimaryArea/ShowBound.jsx @@ -0,0 +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; diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/ShowPrimaryArea/index.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/ShowPrimaryArea/index.jsx new file mode 100644 index 0000000..7300a1f --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/ShowPrimaryArea/index.jsx @@ -0,0 +1,61 @@ +const { Button, IconButton, Tooltip, Box, Dialog, DialogTitle, Typography, DialogContent, DialogActions } = require("@mui/material"); +import LayersIcon from '@mui/icons-material/Layers'; +import CloseIcon from "@mui/icons-material/Close"; +import { useMemo, useState } from 'react'; +import MapLayer from '@/core/components/MapLayer'; +import ShowBound from './ShowBound'; + +const ShowPrimaryArea = ({primaryArea}) => { + const [openShowAreaDialog, setOpenShowAreaDialog] = useState(false); + const bound = useMemo(() => { + const latLngCoords = primaryArea.coordinates.map(coord => [coord[1], coord[0]]); + return primaryArea.type === "polygon" + ? L.polygon(latLngCoords) + : L.polyline(latLngCoords); + }, [primaryArea]); + + return ( + + + setOpenShowAreaDialog(true)}> + + + + setOpenShowAreaDialog(false)} + PaperProps={{ + sx: { + transition: "all .3s", + boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px", + borderRadius: 2, + padding: 1, + }, + }} + maxWidth="sm" + fullWidth + dir="rtl" + > + + + محدوده طرح + + setOpenShowAreaDialog(false)} size="small"> + + + + + + + + + + + + + + + ) +} + +export default ShowPrimaryArea \ No newline at end of file diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/index.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/index.jsx index e69de29..ce52276 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/index.jsx @@ -0,0 +1,14 @@ +"use client"; +import PageTitle from "@/core/components/PageTitle"; +import { Stack } from "@mui/material"; +import PrivacyOfficeList from "./PrivacyOfficeList"; + +const PrivacyOfficePage = () => { + return ( + + + + + ); +}; +export default PrivacyOfficePage; diff --git a/src/core/utils/geoCalculations.js b/src/core/utils/geoCalculations.js new file mode 100644 index 0000000..f0f9f03 --- /dev/null +++ b/src/core/utils/geoCalculations.js @@ -0,0 +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, + }; +}; \ No newline at end of file diff --git a/src/core/utils/routes.js b/src/core/utils/routes.js index 0a3ee79..d51af49 100644 --- a/src/core/utils/routes.js +++ b/src/core/utils/routes.js @@ -238,4 +238,5 @@ export const CREATE_RAHDARAN_ITEM = api + "/api/v3/rahdaran"; // estelam harim export const GET_CITY_ADMIN_LIST = api + "/api/v3/harim/province_office"; export const GET_INQUIRY_PRIVACY_STATE_LIST = api + "/api/v3/harim/detail/states"; -export const CITY_ADMIN_FEEDBACK = api + "/api/v3/harim/province_office/feedback"; \ No newline at end of file +export const CITY_ADMIN_FEEDBACK = api + "/api/v3/harim/province_office/feedback"; +export const GET_PRIVACY_ADMIN_LIST = api + "/api/v3/harim/harim_office" \ No newline at end of file From 5b61380550a8ef5c2e3e47618169cb2735221902 Mon Sep 17 00:00:00 2001 From: mhmjalali Date: Tue, 4 Nov 2025 09:08:32 +0330 Subject: [PATCH 04/61] formatting --- src/assets/scss/leaflet-measure.scss | 254 ++++++++--------- .../city-admin/CityAdminList.jsx | 72 ++--- .../MapDrawPolygon/DrawBound.jsx | 259 +++++++++--------- .../FeedbackAction/MapDrawPolygon/index.jsx | 9 +- .../RowActions/FeedbackAction/index.jsx | 72 +++-- .../city-admin/RowActions/index.jsx | 6 +- .../city-admin/ShowPrimaryArea/index.jsx | 104 +++---- .../privacy-office/PrivacyOfficeList.jsx | 72 ++--- .../RowActions/ConfirmAction/index.jsx | 2 +- .../RowActions/RejectAction/index.jsx | 2 +- .../privacy-office/RowActions/index.jsx | 1 - .../privacy-office/ShowPrimaryArea/index.jsx | 104 +++---- src/core/utils/geoCalculations.js | 52 ++-- src/core/utils/pageMenuDev.js | 8 +- src/core/utils/routes.js | 2 +- 15 files changed, 533 insertions(+), 486 deletions(-) diff --git a/src/assets/scss/leaflet-measure.scss b/src/assets/scss/leaflet-measure.scss index 97e3bc1..6cc4efa 100644 --- a/src/assets/scss/leaflet-measure.scss +++ b/src/assets/scss/leaflet-measure.scss @@ -13,158 +13,158 @@ $button-icon-size: 12px; $button-icon-spacing: 4px; @mixin hoverbutton { - color: $color-button; - text-decoration: none; - &:hover { - opacity: 0.5; + color: $color-button; text-decoration: none; - } + &:hover { + opacity: 0.5; + text-decoration: none; + } } -@mixin button ($icon) { - display: inline; - width: auto; - height: auto; - padding-left: 20px; - margin-right: $button-icon-spacing; - line-height: 1em; - border: 0; - text-align: left; - color: $color-button; - &, - &:hover { - background-color: transparent; - } - background: { - image: url('assets/#{ $icon }.png'); - repeat: no-repeat; - position: 0% 50%; - size: $button-icon-size $button-icon-size; - } - .leaflet-retina & { - background-image: url('assets/#{ $icon }_@2X.png'); - } +@mixin button($icon) { + display: inline; + width: auto; + height: auto; + padding-left: 20px; + margin-right: $button-icon-spacing; + line-height: 1em; + border: 0; + text-align: left; + color: $color-button; + &, + &:hover { + background-color: transparent; + } + background: { + image: url("assets/#{ $icon }.png"); + repeat: no-repeat; + position: 0% 50%; + size: $button-icon-size $button-icon-size; + } + .leaflet-retina & { + background-image: url("assets/#{ $icon }_@2X.png"); + } - @include hoverbutton; + @include hoverbutton; } .leaflet-control-measure, .leaflet-measure-resultpopup { - h3 { - margin: 0 0 $spacing-external 0; - padding-bottom: $spacing-internal; - border-bottom: solid 1px $color-divider; - } - p { - margin: $spacing-internal 0 0 0; - line-height: 1.5em; - &:first-child { - margin-top: 0; + h3 { + margin: 0 0 $spacing-external 0; + padding-bottom: $spacing-internal; + border-bottom: solid 1px $color-divider; } - } - .tasks { - margin: $spacing-external 0 0 0; - padding: $spacing-internal 0 0 0; - border-top: solid 1px $color-divider; - text-align: right; - - list-style: none; - list-style-image: none; - - li { - display: inline; - margin: 0 $spacing-internal 0 0; - &:last-child { - margin-right: 0; - } + p { + margin: $spacing-internal 0 0 0; + line-height: 1.5em; + &:first-child { + margin-top: 0; + } } - } + .tasks { + margin: $spacing-external 0 0 0; + padding: $spacing-internal 0 0 0; + border-top: solid 1px $color-divider; + text-align: right; - .coorddivider { - color: $color-lightertext; - } + list-style: none; + list-style-image: none; + + li { + display: inline; + margin: 0 $spacing-internal 0 0; + &:last-child { + margin-right: 0; + } + } + } + + .coorddivider { + color: $color-lightertext; + } } .leaflet-control-measure { - max-width: $max-width; - background: #fff; + max-width: $max-width; + background: #fff; - .leaflet-control-measure-toggle, - .leaflet-control-measure-toggle:hover { - background: { - size: 14px 14px; - image: url(assets/rulers.png); - } - border: 0; - border-radius: 4px; - .leaflet-touch & { - border-radius: 2px; + .leaflet-control-measure-toggle, + .leaflet-control-measure-toggle:hover { + background: { + size: 14px 14px; + image: url(assets/rulers.png); + } + border: 0; + border-radius: 4px; + .leaflet-touch & { + border-radius: 2px; + } + + // Hide text + text-indent: 100%; + white-space: nowrap; + overflow: hidden; + + .leaflet-retina & { + background-image: url(assets/rulers_@2X.png); + } + + .leaflet-touch & { + background-size: 16px 16px; + } } - // Hide text - text-indent: 100%; - white-space: nowrap; - overflow: hidden; - - .leaflet-retina & { - background-image: url(assets/rulers_@2X.png); + // Special styling because start prompt has no content, just header and tasks + .startprompt { + h3 { + margin-bottom: $spacing-internal; + } + .tasks { + margin-top: 0; + padding-top: 0; + border-top: 0; + text-align: left; + } } - .leaflet-touch & { - background-size: 16px 16px; + .leaflet-control-measure-interaction { + padding: $spacing-internal $spacing-external; } - } - // Special styling because start prompt has no content, just header and tasks - .startprompt { - h3 { - margin-bottom: $spacing-internal; + .results { + .group { + margin-top: $spacing-internal; + padding-top: $spacing-internal; + border-top: dotted 1px lighten($color-divider, 5); + &:first-child { + margin-top: 0; + padding-top: 0; + border-top: 0; + } + } + .heading { + margin-right: $spacing-internal * 0.5; + color: $color-lightertext; + } } - .tasks { - margin-top: 0; - padding-top: 0; - border-top: 0; - text-align: left; - } - } - .leaflet-control-measure-interaction { - padding: $spacing-internal $spacing-external; - } - - .results { - .group { - margin-top: $spacing-internal; - padding-top: $spacing-internal; - border-top: dotted 1px lighten($color-divider, 5); - &:first-child { - margin-top: 0; - padding-top: 0; - border-top: 0; - } + a.start { + @include button(start); } - .heading { - margin-right: $spacing-internal * 0.5; - color: $color-lightertext; + a.cancel { + @include button(cancel); + } + a.finish { + @include button(check); } - } - - a.start { - @include button(start); - } - a.cancel { - @include button(cancel); - } - a.finish { - @include button(check); - } } .leaflet-measure-resultpopup { - a.zoomto { - @include button(focus); - } - a.deletemarkup { - @include button(trash); - } -} \ No newline at end of file + a.zoomto { + @include button(focus); + } + a.deletemarkup { + @include button(trash); + } +} diff --git a/src/components/dashboard/inquiryPrivacy/city-admin/CityAdminList.jsx b/src/components/dashboard/inquiryPrivacy/city-admin/CityAdminList.jsx index 14b18ec..b732d9b 100644 --- a/src/components/dashboard/inquiryPrivacy/city-admin/CityAdminList.jsx +++ b/src/components/dashboard/inquiryPrivacy/city-admin/CityAdminList.jsx @@ -1,31 +1,32 @@ -import CustomSelectByDependency from '@/core/components/DataTable/filter/fieldsType/CustomSelectByDependency'; -import DataTableWithAuth from '@/core/components/DataTableWithAuth'; -import { GET_CITY_ADMIN_LIST } from '@/core/utils/routes'; -import useInquiryPrivacyState from '@/lib/hooks/useInquiryPrivacyState'; -import { Box, Stack } from '@mui/material'; -import moment from 'jalali-moment'; -import { useMemo } from 'react'; -import MapsHomeWorkIcon from '@mui/icons-material/MapsHomeWork'; -import SecurityIcon from '@mui/icons-material/Security'; -import ManageAccountsIcon from '@mui/icons-material/ManageAccounts'; -import PsychologyAltIcon from '@mui/icons-material/PsychologyAlt'; -import ReceiptLongIcon from '@mui/icons-material/ReceiptLong'; -import WindowIcon from '@mui/icons-material/Window'; -import DangerousIcon from '@mui/icons-material/Dangerous'; -import AutorenewIcon from '@mui/icons-material/Autorenew'; -import RowActions from './RowActions'; -import ShowPrimaryArea from './ShowPrimaryArea'; +import CustomSelectByDependency from "@/core/components/DataTable/filter/fieldsType/CustomSelectByDependency"; +import DataTableWithAuth from "@/core/components/DataTableWithAuth"; +import { GET_CITY_ADMIN_LIST } from "@/core/utils/routes"; +import useInquiryPrivacyState from "@/lib/hooks/useInquiryPrivacyState"; +import { Box, Stack } from "@mui/material"; +import moment from "jalali-moment"; +import { useMemo } from "react"; +import MapsHomeWorkIcon from "@mui/icons-material/MapsHomeWork"; +import SecurityIcon from "@mui/icons-material/Security"; +import ManageAccountsIcon from "@mui/icons-material/ManageAccounts"; +import PsychologyAltIcon from "@mui/icons-material/PsychologyAlt"; +import ReceiptLongIcon from "@mui/icons-material/ReceiptLong"; +import WindowIcon from "@mui/icons-material/Window"; +import DangerousIcon from "@mui/icons-material/Dangerous"; +import AutorenewIcon from "@mui/icons-material/Autorenew"; +import RowActions from "./RowActions"; +import ShowPrimaryArea from "./ShowPrimaryArea"; const CityAdminList = () => { const stateIcon = (state_id) => { - if (state_id === 1) return ; - if (state_id === 2 || state_id === 5 || state_id === 13) return ; - if (state_id === 3 || state_id === 6 || state_id === 14) return ; - if (state_id === 4 || state_id === 7 || state_id === 15) return ; - if (state_id === 8) return ; - if (state_id === 9 || state_id === 11) return ; - if (state_id === 10) return ; - if (state_id === 12) return ; + if (state_id === 1) return ; + if (state_id === 2 || state_id === 5 || state_id === 13) return ; + if (state_id === 3 || state_id === 6 || state_id === 14) + return ; + if (state_id === 4 || state_id === 7 || state_id === 15) return ; + if (state_id === 8) return ; + if (state_id === 9 || state_id === 11) return ; + if (state_id === 10) return ; + if (state_id === 12) return ; }; const columns = useMemo(() => { return [ @@ -96,7 +97,7 @@ const CityAdminList = () => { {stateIcon(row.original.state_id)} - {row.original.state_name} + {row.original.state_name} ), @@ -164,11 +165,14 @@ const CityAdminList = () => { columnFilterModeOptions: ["equals", "contains"], grow: false, size: 100, - Cell: ({ row }) => row.original.primary_area ? ( - - - - ) : ("-"), + Cell: ({ row }) => + row.original.primary_area ? ( + + + + ) : ( + "-" + ), }, { accessorKey: "province_id", @@ -233,7 +237,7 @@ const CityAdminList = () => { /> - ) -} + ); +}; -export default CityAdminList \ No newline at end of file +export default CityAdminList; diff --git a/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/FeedbackAction/MapDrawPolygon/DrawBound.jsx b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/FeedbackAction/MapDrawPolygon/DrawBound.jsx index 31b9706..02b567f 100644 --- a/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/FeedbackAction/MapDrawPolygon/DrawBound.jsx +++ b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/FeedbackAction/MapDrawPolygon/DrawBound.jsx @@ -5,148 +5,145 @@ import "leaflet-draw"; import { calculatePolygonMetrics } from "@/core/utils/geoCalculations"; const DrawPolygon = ({ control, controlDispach, drawBound, setDrawBound }) => { - const map = useMap(); - const featureRef = useRef(null); - const drawControlRef = useRef(null); + const map = useMap(); + const featureRef = useRef(null); + const drawControlRef = useRef(null); - const [area, setArea] = useState(0); - const [sideLengths, setSideLengths] = useState([]); + const [area, setArea] = useState(0); + const [sideLengths, setSideLengths] = useState([]); - const calculatePolygonMetricsForLayer = useCallback( - (layer) => { - if (!layer) return; + const calculatePolygonMetricsForLayer = useCallback( + (layer) => { + if (!layer) return; - const latlngs = layer.getLatLngs()[0]; - if (!latlngs || latlngs.length < 3) return; + const latlngs = layer.getLatLngs()[0]; + if (!latlngs || latlngs.length < 3) return; - const coordinates = latlngs.map((p) => [p.lat, p.lng]); + const coordinates = latlngs.map((p) => [p.lat, p.lng]); - const metrics = calculatePolygonMetrics(coordinates, true); + const metrics = calculatePolygonMetrics(coordinates, true); - setArea(metrics.area); - setSideLengths(metrics.sides); + setArea(metrics.area); + setSideLengths(metrics.sides); - setDrawBound({ - layer, - metrics, - }); - }, - [setDrawBound] - ); - - 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 = useCallback( - (layer) => { - if (!layer) return; - layer.on("edit", function (e) { - const editedLayer = e.target; - calculatePolygonMetricsForLayer(editedLayer); - }); - }, - [calculatePolygonMetricsForLayer] - ); - - const handlerCreatedBound = useCallback( - (event) => { - const { layer } = event; - layer.editing.enable(); - featureRef.current.addLayer(layer); - - calculatePolygonMetricsForLayer(layer); - bindEditEvent(layer); - - controlDispach({ type: "SET_STATUS", status: 2 }); - }, - [calculatePolygonMetricsForLayer, bindEditEvent, controlDispach] - ); - - 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 && featureRef.current) { - featureRef.current.clearLayers(); - setArea(0); - setSideLengths([]); - setDrawBound(null); - } - }, [control.status, setDrawBound]); - - useEffect(() => { - if (control.status === 2 && drawBound && featureRef.current) { - const { layer, metrics } = drawBound; - featureRef.current.addLayer(layer); - layer.editing.enable(); - safeFitBounds(layer); - bindEditEvent(layer); - - setArea(metrics?.area || 0); - setSideLengths(metrics?.sides || []); - } - }, [control.status, drawBound, bindEditEvent]); - - 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: "red", - weight: 3, - clickable: true, - }, + setDrawBound({ + layer, + metrics, + }); }, - polyline: false, - rectangle: false, - circle: false, - marker: false, - circlemarker: false, - }, - edit: { - featureGroup: featureRef.current, - edit: true, - remove: true, - }, - }); + [setDrawBound] + ); - drawControlRef.current = drawControl; - map.addControl(drawControl); - map.on(L.Draw.Event.CREATED, handlerCreatedBound); - - return () => { - map.off(L.Draw.Event.CREATED, handlerCreatedBound); - map.removeControl(drawControl); + 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); + } }; - }, [map, handlerCreatedBound]); - return ; + const bindEditEvent = useCallback( + (layer) => { + if (!layer) return; + layer.on("edit", function (e) { + const editedLayer = e.target; + calculatePolygonMetricsForLayer(editedLayer); + }); + }, + [calculatePolygonMetricsForLayer] + ); + + const handlerCreatedBound = useCallback( + (event) => { + const { layer } = event; + layer.editing.enable(); + featureRef.current.addLayer(layer); + + calculatePolygonMetricsForLayer(layer); + bindEditEvent(layer); + + controlDispach({ type: "SET_STATUS", status: 2 }); + }, + [calculatePolygonMetricsForLayer, bindEditEvent, controlDispach] + ); + + 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 && featureRef.current) { + featureRef.current.clearLayers(); + setArea(0); + setSideLengths([]); + setDrawBound(null); + } + }, [control.status, setDrawBound]); + + useEffect(() => { + if (control.status === 2 && drawBound && featureRef.current) { + const { layer, metrics } = drawBound; + featureRef.current.addLayer(layer); + layer.editing.enable(); + safeFitBounds(layer); + bindEditEvent(layer); + + setArea(metrics?.area || 0); + setSideLengths(metrics?.sides || []); + } + }, [control.status, drawBound, bindEditEvent]); + + 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: "red", + weight: 3, + clickable: true, + }, + }, + polyline: false, + rectangle: false, + circle: false, + marker: false, + circlemarker: false, + }, + edit: { + featureGroup: featureRef.current, + edit: true, + remove: true, + }, + }); + + 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 DrawPolygon; diff --git a/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/FeedbackAction/MapDrawPolygon/index.jsx b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/FeedbackAction/MapDrawPolygon/index.jsx index 41ebf0f..ab4c1f4 100644 --- a/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/FeedbackAction/MapDrawPolygon/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/FeedbackAction/MapDrawPolygon/index.jsx @@ -62,11 +62,16 @@ const MapDrawPolygon = ({ drawBound, setDrawBound }) => { return ( <> - + { +const FeedbackAction = ({ rowId, mutate, rowPrimaryArea }) => { const requestServer = useRequest({ notificationSuccess: true }); const [openFeedbackDialog, setOpenFeedbackDialog] = useState(false); const [drawBound, setDrawBound] = useState(null); const bound = useMemo(() => { - const latLngCoords = rowPrimaryArea.coordinates.map(coord => [coord[1], coord[0]]); - return rowPrimaryArea.type === "polygon" - ? L.polygon(latLngCoords) - : L.polyline(latLngCoords); - }, [rowPrimaryArea]); - + const latLngCoords = rowPrimaryArea.coordinates.map((coord) => [coord[1], coord[0]]); + return rowPrimaryArea.type === "polygon" ? L.polygon(latLngCoords) : L.polyline(latLngCoords); + }, [rowPrimaryArea]); const { register, handleSubmit, formState: { isSubmitting, errors }, - } = useForm({ - defaultValues: {expert_description: "", forbidden_area: "", forbidden_area_space: ""}, - resolver: yupResolver(validationSchema), - mode: "all" - }); + } = useForm({ + defaultValues: { expert_description: "", forbidden_area: "", forbidden_area_space: "" }, + resolver: yupResolver(validationSchema), + mode: "all", + }); const onSubmit = async (data) => { try { const payload = { - expert_description: data.expert_description, + expert_description: data.expert_description, }; if (drawBound && drawBound.metrics) { @@ -62,7 +70,6 @@ const FeedbackAction = ({rowId, mutate, rowPrimaryArea}) => { } }; - return ( <> @@ -77,7 +84,8 @@ const FeedbackAction = ({rowId, mutate, rowPrimaryArea}) => { PaperProps={{ sx: { transition: "all .3s", - boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px", + boxShadow: + "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px", borderRadius: 2, }, }} @@ -93,12 +101,17 @@ const FeedbackAction = ({rowId, mutate, rowPrimaryArea}) => { - - منطقه ممنوعه (در صورت وجود انتخاب کنید) + + + منطقه ممنوعه{" "} + + (در صورت وجود انتخاب کنید) + + - - + + { > بستن - - ) -} + ); +}; -export default FeedbackAction \ No newline at end of file +export default FeedbackAction; diff --git a/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/index.jsx b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/index.jsx index 69d588a..cb1517b 100644 --- a/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/index.jsx @@ -4,7 +4,11 @@ import FeedbackAction from "./FeedbackAction"; const RowActions = ({ row, mutate }) => { return ( - {row.original.state_id === 1 ? : "-"} + {row.original.state_id === 1 ? ( + + ) : ( + "-" + )} ); }; diff --git a/src/components/dashboard/inquiryPrivacy/city-admin/ShowPrimaryArea/index.jsx b/src/components/dashboard/inquiryPrivacy/city-admin/ShowPrimaryArea/index.jsx index 7300a1f..98e24d0 100644 --- a/src/components/dashboard/inquiryPrivacy/city-admin/ShowPrimaryArea/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/city-admin/ShowPrimaryArea/index.jsx @@ -1,61 +1,69 @@ -const { Button, IconButton, Tooltip, Box, Dialog, DialogTitle, Typography, DialogContent, DialogActions } = require("@mui/material"); -import LayersIcon from '@mui/icons-material/Layers'; +const { + Button, + IconButton, + Tooltip, + Box, + Dialog, + DialogTitle, + Typography, + DialogContent, + DialogActions, +} = require("@mui/material"); +import LayersIcon from "@mui/icons-material/Layers"; import CloseIcon from "@mui/icons-material/Close"; -import { useMemo, useState } from 'react'; -import MapLayer from '@/core/components/MapLayer'; -import ShowBound from './ShowBound'; +import { useMemo, useState } from "react"; +import MapLayer from "@/core/components/MapLayer"; +import ShowBound from "./ShowBound"; -const ShowPrimaryArea = ({primaryArea}) => { +const ShowPrimaryArea = ({ primaryArea }) => { const [openShowAreaDialog, setOpenShowAreaDialog] = useState(false); const bound = useMemo(() => { - const latLngCoords = primaryArea.coordinates.map(coord => [coord[1], coord[0]]); - return primaryArea.type === "polygon" - ? L.polygon(latLngCoords) - : L.polyline(latLngCoords); + const latLngCoords = primaryArea.coordinates.map((coord) => [coord[1], coord[0]]); + return primaryArea.type === "polygon" ? L.polygon(latLngCoords) : L.polyline(latLngCoords); }, [primaryArea]); - - return ( - - - setOpenShowAreaDialog(true)}> - - - - setOpenShowAreaDialog(false)} - PaperProps={{ - sx: { - transition: "all .3s", - boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px", - borderRadius: 2, - padding: 1, - }, - }} - maxWidth="sm" - fullWidth - dir="rtl" - > - - - محدوده طرح - - setOpenShowAreaDialog(false)} size="small"> - + + return ( + + + setOpenShowAreaDialog(true)}> + - - - + + setOpenShowAreaDialog(false)} + PaperProps={{ + sx: { + transition: "all .3s", + boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px", + borderRadius: 2, + padding: 1, + }, + }} + maxWidth="sm" + fullWidth + dir="rtl" + > + + + محدوده طرح + + setOpenShowAreaDialog(false)} size="small"> + + + + + - - - - ) -} + + + + ); +}; -export default ShowPrimaryArea \ No newline at end of file +export default ShowPrimaryArea; diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/PrivacyOfficeList.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/PrivacyOfficeList.jsx index 20fe52d..913c803 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/PrivacyOfficeList.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/PrivacyOfficeList.jsx @@ -1,31 +1,32 @@ -import CustomSelectByDependency from '@/core/components/DataTable/filter/fieldsType/CustomSelectByDependency'; -import DataTableWithAuth from '@/core/components/DataTableWithAuth'; -import useInquiryPrivacyState from '@/lib/hooks/useInquiryPrivacyState'; -import AutorenewIcon from '@mui/icons-material/Autorenew'; -import DangerousIcon from '@mui/icons-material/Dangerous'; -import ManageAccountsIcon from '@mui/icons-material/ManageAccounts'; -import MapsHomeWorkIcon from '@mui/icons-material/MapsHomeWork'; -import PsychologyAltIcon from '@mui/icons-material/PsychologyAlt'; -import ReceiptLongIcon from '@mui/icons-material/ReceiptLong'; -import SecurityIcon from '@mui/icons-material/Security'; -import WindowIcon from '@mui/icons-material/Window'; -import { Box, Stack } from '@mui/material'; -import moment from 'jalali-moment'; -import { useMemo } from 'react'; -import RowActions from './RowActions'; -import { GET_PRIVACY_ADMIN_LIST } from '@/core/utils/routes'; -import ShowPrimaryArea from './ShowPrimaryArea'; +import CustomSelectByDependency from "@/core/components/DataTable/filter/fieldsType/CustomSelectByDependency"; +import DataTableWithAuth from "@/core/components/DataTableWithAuth"; +import useInquiryPrivacyState from "@/lib/hooks/useInquiryPrivacyState"; +import AutorenewIcon from "@mui/icons-material/Autorenew"; +import DangerousIcon from "@mui/icons-material/Dangerous"; +import ManageAccountsIcon from "@mui/icons-material/ManageAccounts"; +import MapsHomeWorkIcon from "@mui/icons-material/MapsHomeWork"; +import PsychologyAltIcon from "@mui/icons-material/PsychologyAlt"; +import ReceiptLongIcon from "@mui/icons-material/ReceiptLong"; +import SecurityIcon from "@mui/icons-material/Security"; +import WindowIcon from "@mui/icons-material/Window"; +import { Box, Stack } from "@mui/material"; +import moment from "jalali-moment"; +import { useMemo } from "react"; +import RowActions from "./RowActions"; +import { GET_PRIVACY_ADMIN_LIST } from "@/core/utils/routes"; +import ShowPrimaryArea from "./ShowPrimaryArea"; const PrivacyOfficeList = () => { const stateIcon = (state_id) => { - if (state_id === 1) return ; - if (state_id === 2 || state_id === 5 || state_id === 13) return ; - if (state_id === 3 || state_id === 6 || state_id === 14) return ; - if (state_id === 4 || state_id === 7 || state_id === 15) return ; - if (state_id === 8) return ; - if (state_id === 9 || state_id === 11) return ; - if (state_id === 10) return ; - if (state_id === 12) return ; + if (state_id === 1) return ; + if (state_id === 2 || state_id === 5 || state_id === 13) return ; + if (state_id === 3 || state_id === 6 || state_id === 14) + return ; + if (state_id === 4 || state_id === 7 || state_id === 15) return ; + if (state_id === 8) return ; + if (state_id === 9 || state_id === 11) return ; + if (state_id === 10) return ; + if (state_id === 12) return ; }; const columns = useMemo(() => { return [ @@ -96,7 +97,7 @@ const PrivacyOfficeList = () => { {stateIcon(row.original.state_id)} - {row.original.state_name} + {row.original.state_name} ), @@ -164,11 +165,14 @@ const PrivacyOfficeList = () => { columnFilterModeOptions: ["equals", "contains"], grow: false, size: 100, - Cell: ({ row }) => row.original.primary_area ? ( - - - - ) : ("-"), + Cell: ({ row }) => + row.original.primary_area ? ( + + + + ) : ( + "-" + ), }, { accessorKey: "province_id", @@ -233,7 +237,7 @@ const PrivacyOfficeList = () => { /> - ) -} + ); +}; -export default PrivacyOfficeList \ No newline at end of file +export default PrivacyOfficeList; diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ConfirmAction/index.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ConfirmAction/index.jsx index 6eb22a6..c2a0cfc 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ConfirmAction/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ConfirmAction/index.jsx @@ -1,4 +1,4 @@ -import ThumbUpIcon from '@mui/icons-material/ThumbUp'; +import ThumbUpIcon from "@mui/icons-material/ThumbUp"; import { IconButton, Tooltip } from "@mui/material"; import { useState } from "react"; diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RejectAction/index.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RejectAction/index.jsx index c8a7e96..c16a405 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RejectAction/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RejectAction/index.jsx @@ -1,4 +1,4 @@ -import ThumbDownIcon from '@mui/icons-material/ThumbDown'; +import ThumbDownIcon from "@mui/icons-material/ThumbDown"; import { IconButton, Tooltip } from "@mui/material"; import { useState } from "react"; diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/index.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/index.jsx index 45e1693..06ea132 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/index.jsx @@ -3,7 +3,6 @@ import ConfirmAction from "./ConfirmAction"; import RejectAction from "./RejectAction"; const RowActions = ({ row, mutate }) => { - return ( diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/ShowPrimaryArea/index.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/ShowPrimaryArea/index.jsx index 7300a1f..98e24d0 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/ShowPrimaryArea/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/ShowPrimaryArea/index.jsx @@ -1,61 +1,69 @@ -const { Button, IconButton, Tooltip, Box, Dialog, DialogTitle, Typography, DialogContent, DialogActions } = require("@mui/material"); -import LayersIcon from '@mui/icons-material/Layers'; +const { + Button, + IconButton, + Tooltip, + Box, + Dialog, + DialogTitle, + Typography, + DialogContent, + DialogActions, +} = require("@mui/material"); +import LayersIcon from "@mui/icons-material/Layers"; import CloseIcon from "@mui/icons-material/Close"; -import { useMemo, useState } from 'react'; -import MapLayer from '@/core/components/MapLayer'; -import ShowBound from './ShowBound'; +import { useMemo, useState } from "react"; +import MapLayer from "@/core/components/MapLayer"; +import ShowBound from "./ShowBound"; -const ShowPrimaryArea = ({primaryArea}) => { +const ShowPrimaryArea = ({ primaryArea }) => { const [openShowAreaDialog, setOpenShowAreaDialog] = useState(false); const bound = useMemo(() => { - const latLngCoords = primaryArea.coordinates.map(coord => [coord[1], coord[0]]); - return primaryArea.type === "polygon" - ? L.polygon(latLngCoords) - : L.polyline(latLngCoords); + const latLngCoords = primaryArea.coordinates.map((coord) => [coord[1], coord[0]]); + return primaryArea.type === "polygon" ? L.polygon(latLngCoords) : L.polyline(latLngCoords); }, [primaryArea]); - - return ( - - - setOpenShowAreaDialog(true)}> - - - - setOpenShowAreaDialog(false)} - PaperProps={{ - sx: { - transition: "all .3s", - boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px", - borderRadius: 2, - padding: 1, - }, - }} - maxWidth="sm" - fullWidth - dir="rtl" - > - - - محدوده طرح - - setOpenShowAreaDialog(false)} size="small"> - + + return ( + + + setOpenShowAreaDialog(true)}> + - - - + + setOpenShowAreaDialog(false)} + PaperProps={{ + sx: { + transition: "all .3s", + boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px", + borderRadius: 2, + padding: 1, + }, + }} + maxWidth="sm" + fullWidth + dir="rtl" + > + + + محدوده طرح + + setOpenShowAreaDialog(false)} size="small"> + + + + + - - - - ) -} + + + + ); +}; -export default ShowPrimaryArea \ No newline at end of file +export default ShowPrimaryArea; diff --git a/src/core/utils/geoCalculations.js b/src/core/utils/geoCalculations.js index f0f9f03..ebf8a96 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: [] }; - } + 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]); + 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]); - } + 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 polygon = turf.polygon([geoCoords]); - const area = turf.area(polygon); + 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); - } + 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, - }; -}; \ No newline at end of file + return { + area, + sides, + coordinates: geoCoords, + }; +}; diff --git a/src/core/utils/pageMenuDev.js b/src/core/utils/pageMenuDev.js index 67b05dc..23c42d7 100644 --- a/src/core/utils/pageMenuDev.js +++ b/src/core/utils/pageMenuDev.js @@ -24,10 +24,10 @@ import RouteIcon from "@mui/icons-material/Route"; import ScienceIcon from "@mui/icons-material/Science"; import SpaceDashboardIcon from "@mui/icons-material/SpaceDashboard"; import SpeedIcon from "@mui/icons-material/Speed"; -import PsychologyAltIcon from '@mui/icons-material/PsychologyAlt'; -import MapsHomeWorkIcon from '@mui/icons-material/MapsHomeWork'; -import SecurityIcon from '@mui/icons-material/Security'; -import ManageAccountsIcon from '@mui/icons-material/ManageAccounts'; +import PsychologyAltIcon from "@mui/icons-material/PsychologyAlt"; +import MapsHomeWorkIcon from "@mui/icons-material/MapsHomeWork"; +import SecurityIcon from "@mui/icons-material/Security"; +import ManageAccountsIcon from "@mui/icons-material/ManageAccounts"; export const pageMenuDev = [ { diff --git a/src/core/utils/routes.js b/src/core/utils/routes.js index d51af49..8572b6f 100644 --- a/src/core/utils/routes.js +++ b/src/core/utils/routes.js @@ -239,4 +239,4 @@ export const CREATE_RAHDARAN_ITEM = api + "/api/v3/rahdaran"; export const GET_CITY_ADMIN_LIST = api + "/api/v3/harim/province_office"; export const GET_INQUIRY_PRIVACY_STATE_LIST = api + "/api/v3/harim/detail/states"; export const CITY_ADMIN_FEEDBACK = api + "/api/v3/harim/province_office/feedback"; -export const GET_PRIVACY_ADMIN_LIST = api + "/api/v3/harim/harim_office" \ No newline at end of file +export const GET_PRIVACY_ADMIN_LIST = api + "/api/v3/harim/harim_office"; From b76214574b4f12264a368be25892a931074f75df Mon Sep 17 00:00:00 2001 From: mhmjalali Date: Tue, 4 Nov 2025 09:11:26 +0330 Subject: [PATCH 05/61] remove unused file --- src/assets/scss/leaflet-measure.scss | 170 --------------------------- 1 file changed, 170 deletions(-) delete mode 100644 src/assets/scss/leaflet-measure.scss diff --git a/src/assets/scss/leaflet-measure.scss b/src/assets/scss/leaflet-measure.scss deleted file mode 100644 index 6cc4efa..0000000 --- a/src/assets/scss/leaflet-measure.scss +++ /dev/null @@ -1,170 +0,0 @@ -// leaflet-measure.scss - -$color-divider: #ddd; -$color-button: #5e66cc; -$color-lightertext: #999; - -$spacing-external: 12px; -$spacing-internal: 10px; - -$max-width: 280px; - -$button-icon-size: 12px; -$button-icon-spacing: 4px; - -@mixin hoverbutton { - color: $color-button; - text-decoration: none; - &:hover { - opacity: 0.5; - text-decoration: none; - } -} - -@mixin button($icon) { - display: inline; - width: auto; - height: auto; - padding-left: 20px; - margin-right: $button-icon-spacing; - line-height: 1em; - border: 0; - text-align: left; - color: $color-button; - &, - &:hover { - background-color: transparent; - } - background: { - image: url("assets/#{ $icon }.png"); - repeat: no-repeat; - position: 0% 50%; - size: $button-icon-size $button-icon-size; - } - .leaflet-retina & { - background-image: url("assets/#{ $icon }_@2X.png"); - } - - @include hoverbutton; -} - -.leaflet-control-measure, -.leaflet-measure-resultpopup { - h3 { - margin: 0 0 $spacing-external 0; - padding-bottom: $spacing-internal; - border-bottom: solid 1px $color-divider; - } - p { - margin: $spacing-internal 0 0 0; - line-height: 1.5em; - &:first-child { - margin-top: 0; - } - } - .tasks { - margin: $spacing-external 0 0 0; - padding: $spacing-internal 0 0 0; - border-top: solid 1px $color-divider; - text-align: right; - - list-style: none; - list-style-image: none; - - li { - display: inline; - margin: 0 $spacing-internal 0 0; - &:last-child { - margin-right: 0; - } - } - } - - .coorddivider { - color: $color-lightertext; - } -} - -.leaflet-control-measure { - max-width: $max-width; - background: #fff; - - .leaflet-control-measure-toggle, - .leaflet-control-measure-toggle:hover { - background: { - size: 14px 14px; - image: url(assets/rulers.png); - } - border: 0; - border-radius: 4px; - .leaflet-touch & { - border-radius: 2px; - } - - // Hide text - text-indent: 100%; - white-space: nowrap; - overflow: hidden; - - .leaflet-retina & { - background-image: url(assets/rulers_@2X.png); - } - - .leaflet-touch & { - background-size: 16px 16px; - } - } - - // Special styling because start prompt has no content, just header and tasks - .startprompt { - h3 { - margin-bottom: $spacing-internal; - } - .tasks { - margin-top: 0; - padding-top: 0; - border-top: 0; - text-align: left; - } - } - - .leaflet-control-measure-interaction { - padding: $spacing-internal $spacing-external; - } - - .results { - .group { - margin-top: $spacing-internal; - padding-top: $spacing-internal; - border-top: dotted 1px lighten($color-divider, 5); - &:first-child { - margin-top: 0; - padding-top: 0; - border-top: 0; - } - } - .heading { - margin-right: $spacing-internal * 0.5; - color: $color-lightertext; - } - } - - a.start { - @include button(start); - } - a.cancel { - @include button(cancel); - } - a.finish { - @include button(check); - } -} - -.leaflet-measure-resultpopup { - a.zoomto { - @include button(focus); - } - a.deletemarkup { - @include button(trash); - } -} From c636bffeb79ab8edb1cb37bbd37c69d0e7076d7a Mon Sep 17 00:00:00 2001 From: baslani Date: Mon, 17 Nov 2025 10:21:10 +0330 Subject: [PATCH 06/61] implemented privacy Office Actions modal structure --- .../privacy-office/PrivacyOfficeList.jsx | 30 +++++++- .../RowActions/ActionsDialog.jsx | 76 +++++++++++++++++++ .../RowActions/ConfirmAction/index.jsx | 6 +- .../RowActions/ReferralAction/index.jsx | 15 ++++ .../RowActions/RejectAction/index.jsx | 6 +- .../privacy-office/RowActions/index.jsx | 11 ++- 6 files changed, 129 insertions(+), 15 deletions(-) create mode 100644 src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ActionsDialog.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ReferralAction/index.jsx diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/PrivacyOfficeList.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/PrivacyOfficeList.jsx index 913c803..27a8f85 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/PrivacyOfficeList.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/PrivacyOfficeList.jsx @@ -1,5 +1,6 @@ import CustomSelectByDependency from "@/core/components/DataTable/filter/fieldsType/CustomSelectByDependency"; import DataTableWithAuth from "@/core/components/DataTableWithAuth"; +import { GET_PRIVACY_ADMIN_LIST } from "@/core/utils/routes"; import useInquiryPrivacyState from "@/lib/hooks/useInquiryPrivacyState"; import AutorenewIcon from "@mui/icons-material/Autorenew"; import DangerousIcon from "@mui/icons-material/Dangerous"; @@ -11,9 +12,10 @@ import SecurityIcon from "@mui/icons-material/Security"; import WindowIcon from "@mui/icons-material/Window"; import { Box, Stack } from "@mui/material"; import moment from "jalali-moment"; -import { useMemo } from "react"; +import { useMemo, useState } from "react"; import RowActions from "./RowActions"; -import { GET_PRIVACY_ADMIN_LIST } from "@/core/utils/routes"; + +import ActionDialog from "./RowActions/ActionsDialog"; import ShowPrimaryArea from "./ShowPrimaryArea"; const PrivacyOfficeList = () => { @@ -28,6 +30,21 @@ const PrivacyOfficeList = () => { if (state_id === 10) return ; if (state_id === 12) return ; }; + + const [modal, setModal] = useState({ + open: false, + type: null, // "reject" | "confirm" | "referral" + row: null, + }); + + const handleOpenModal = (type, row) => { + setModal({ open: true, type, row }); + }; + + const handleCloseModal = () => { + setModal({ open: false, type: null, row: null }); + }; + const columns = useMemo(() => { return [ { @@ -233,9 +250,16 @@ const PrivacyOfficeList = () => { table_name={"PrivacyOfficeList"} enableRowActions positionActionsColumn={"first"} - RowActions={RowActions} + RowActions={(props) => } /> + + ); }; diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ActionsDialog.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ActionsDialog.jsx new file mode 100644 index 0000000..1dae411 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ActionsDialog.jsx @@ -0,0 +1,76 @@ +import { + Box, + Button, + Checkbox, + Dialog, + DialogActions, + DialogContent, + DialogTitle, + FormControlLabel, + TextField, +} from "@mui/material"; +import { useEffect, useState } from "react"; + +const ActionDialog = ({ open, type, rowDataId, onClose }) => { + const [description, setDescription] = useState(""); + const [checked, setChecked] = useState(false); + + useEffect(() => { + if (open) { + setDescription(""); + setChecked(false); + } + }, [open]); + + const actionLabel = { + reject: "رد درخواست", + confirm: "تایید درخواست", + referral: "ارجاع درخواست", + }[type]; + + const handleSubmit = () => { + console.log("Row data id: ", rowDataId); + console.log("Action type: ", type); + console.log("Desctiption: ", description); + console.log("Checked: ", checked); + + // TODO: Implement api call + + onClose(); + }; + + return ( + + {actionLabel} + + + + setDescription(e.target.value)} + /> + + setChecked(e.target.checked)} />} + label="تایید انجام عملیات" + /> + + + + + + + + + ); +}; + +export default ActionDialog; diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ConfirmAction/index.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ConfirmAction/index.jsx index c2a0cfc..ca0b3d5 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ConfirmAction/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ConfirmAction/index.jsx @@ -1,13 +1,11 @@ import ThumbUpIcon from "@mui/icons-material/ThumbUp"; import { IconButton, Tooltip } from "@mui/material"; -import { useState } from "react"; -const ConfirmAction = ({ rowId, mutate }) => { - const [openConfirmDialog, setOpenConfirmDialog] = useState(false); +const ConfirmAction = ({ onClick }) => { return ( <> - setOpenConfirmDialog(true)}> + diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ReferralAction/index.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ReferralAction/index.jsx new file mode 100644 index 0000000..28667cf --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ReferralAction/index.jsx @@ -0,0 +1,15 @@ +import { Reply } from "@mui/icons-material"; +import { IconButton, Tooltip } from "@mui/material"; + +const ReferralAction = ({ onClick }) => { + return ( + <> + + + + + + + ); +}; +export default ReferralAction; diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RejectAction/index.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RejectAction/index.jsx index c16a405..b2e40ab 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RejectAction/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RejectAction/index.jsx @@ -1,13 +1,11 @@ import ThumbDownIcon from "@mui/icons-material/ThumbDown"; import { IconButton, Tooltip } from "@mui/material"; -import { useState } from "react"; -const RejectAction = ({ rowId, mutate }) => { - const [openRejectDialog, setOpenRejectDialog] = useState(false); +const RejectAction = ({ onClick }) => { return ( <> - setOpenRejectDialog(true)}> + diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/index.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/index.jsx index 06ea132..b45eb01 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/index.jsx @@ -1,13 +1,16 @@ import { Box } from "@mui/material"; import ConfirmAction from "./ConfirmAction"; +import ReferralAction from "./ReferralAction"; import RejectAction from "./RejectAction"; -const RowActions = ({ row, mutate }) => { +const RowActions = ({ row, onActionClick }) => { return ( - - - + + onActionClick("referral", row)} /> + onActionClick("reject", row)} /> + onActionClick("confirm", row)} /> ); }; + export default RowActions; From 40f54ed619a5d94e58a1f495513973602ba55ee4 Mon Sep 17 00:00:00 2001 From: baslani Date: Mon, 17 Nov 2025 11:18:08 +0330 Subject: [PATCH 07/61] implemented ActionsDialog forms logic --- .../privacy-office/PrivacyOfficeList.jsx | 15 ++-- .../RowActions/ActionsDialog.jsx | 79 +++++++++++++------ .../RowActions/ReferralAction/index.jsx | 2 +- .../privacy-office/RowActions/index.jsx | 13 ++- 4 files changed, 68 insertions(+), 41 deletions(-) diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/PrivacyOfficeList.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/PrivacyOfficeList.jsx index 27a8f85..c339a16 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/PrivacyOfficeList.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/PrivacyOfficeList.jsx @@ -34,15 +34,15 @@ const PrivacyOfficeList = () => { const [modal, setModal] = useState({ open: false, type: null, // "reject" | "confirm" | "referral" - row: null, + rowId: null, }); - const handleOpenModal = (type, row) => { - setModal({ open: true, type, row }); + const handleOpenModal = (type, rowId) => { + setModal({ open: true, type, rowId }); }; const handleCloseModal = () => { - setModal({ open: false, type: null, row: null }); + setModal({ open: false, type: null, rowId: null }); }; const columns = useMemo(() => { @@ -254,12 +254,7 @@ const PrivacyOfficeList = () => { /> - + ); }; diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ActionsDialog.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ActionsDialog.jsx index 1dae411..75a1bf6 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ActionsDialog.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ActionsDialog.jsx @@ -10,17 +10,30 @@ import { TextField, } from "@mui/material"; import { useEffect, useState } from "react"; +import { Controller, useForm } from "react-hook-form"; const ActionDialog = ({ open, type, rowDataId, onClose }) => { - const [description, setDescription] = useState(""); - const [checked, setChecked] = useState(false); + const [needsAccessRoad, setNeedsAccessRoad] = useState(false); + const { + control, + handleSubmit, + reset, + formState: { isSubmitting }, + } = useForm({ + defaultValues: { + expert_description: "", + need_payment: false, + }, + }); useEffect(() => { if (open) { - setDescription(""); - setChecked(false); + reset({ + expert_description: "", + need_payment: false, + }); } - }, [open]); + }, [open, reset]); const actionLabel = { reject: "رد درخواست", @@ -28,13 +41,12 @@ const ActionDialog = ({ open, type, rowDataId, onClose }) => { referral: "ارجاع درخواست", }[type]; - const handleSubmit = () => { - console.log("Row data id: ", rowDataId); - console.log("Action type: ", type); - console.log("Desctiption: ", description); - console.log("Checked: ", checked); + const onSubmit = (formData) => { + console.log("Row data id:", rowDataId); + console.log("Action type:", type); + console.log("Form data:", formData); - // TODO: Implement api call + // TODO: Implement the API call here onClose(); }; @@ -44,28 +56,43 @@ const ActionDialog = ({ open, type, rowDataId, onClose }) => { {actionLabel} - - setDescription(e.target.value)} - /> - - setChecked(e.target.checked)} />} - label="تایید انجام عملیات" + + } /> + {type === "confirm" && ( + <> + ( + } + label="نیاز به پرداخت" + /> + )} + /> + setNeedsAccessRoad(e.target.checked)} + /> + } + label="به راه دسترسی نیاز دارد" + /> + + )} - - diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ReferralAction/index.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ReferralAction/index.jsx index 28667cf..7f56971 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ReferralAction/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ReferralAction/index.jsx @@ -4,7 +4,7 @@ import { IconButton, Tooltip } from "@mui/material"; const ReferralAction = ({ onClick }) => { return ( <> - + diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/index.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/index.jsx index b45eb01..61c5a54 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/index.jsx @@ -3,12 +3,17 @@ import ConfirmAction from "./ConfirmAction"; import ReferralAction from "./ReferralAction"; import RejectAction from "./RejectAction"; -const RowActions = ({ row, onActionClick }) => { +const RowActions = ({ + row: { + original: { id }, + }, + onActionClick, +}) => { return ( - onActionClick("referral", row)} /> - onActionClick("reject", row)} /> - onActionClick("confirm", row)} /> + onActionClick("referral", id)} /> + onActionClick("reject", id)} /> + onActionClick("confirm", id)} /> ); }; From 16d30665d046100364f75047362937505f6917d1 Mon Sep 17 00:00:00 2001 From: baslani Date: Mon, 17 Nov 2025 17:12:11 +0330 Subject: [PATCH 08/61] restructured actions for privacy office table --- .../privacy-office/PrivacyOfficeList.jsx | 21 +--- .../RowActions/ActionsDialog.jsx | 97 ++----------------- .../RowActions/ConfirmAction/index.jsx | 4 +- .../RowActions/Forms/ComputePaymentForm.jsx | 3 + .../RowActions/Forms/ConfirmFileForm.jsx | 3 + .../RowActions/Forms/ConfirmRequestForm.jsx | 3 + .../RowActions/Forms/ReferForm.jsx | 9 ++ .../RowActions/Forms/RejectFileForm.jsx | 3 + .../RowActions/Forms/RejectRequestForm.jsx | 3 + .../RowActions/ReferralAction/index.jsx | 4 +- .../RowActions/RejectAction/index.jsx | 4 +- .../RowActions/RenderActionForm.jsx | 76 +++++++++++++++ .../privacy-office/RowActions/index.jsx | 56 ++++++++--- src/core/utils/routes.js | 1 + 14 files changed, 161 insertions(+), 126 deletions(-) create mode 100644 src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ComputePaymentForm.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ConfirmFileForm.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ConfirmRequestForm.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ReferForm.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/RejectFileForm.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/RejectRequestForm.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RenderActionForm.jsx diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/PrivacyOfficeList.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/PrivacyOfficeList.jsx index c339a16..b6932ca 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/PrivacyOfficeList.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/PrivacyOfficeList.jsx @@ -12,10 +12,9 @@ import SecurityIcon from "@mui/icons-material/Security"; import WindowIcon from "@mui/icons-material/Window"; import { Box, Stack } from "@mui/material"; import moment from "jalali-moment"; -import { useMemo, useState } from "react"; +import { useMemo } from "react"; import RowActions from "./RowActions"; -import ActionDialog from "./RowActions/ActionsDialog"; import ShowPrimaryArea from "./ShowPrimaryArea"; const PrivacyOfficeList = () => { @@ -31,20 +30,6 @@ const PrivacyOfficeList = () => { if (state_id === 12) return ; }; - const [modal, setModal] = useState({ - open: false, - type: null, // "reject" | "confirm" | "referral" - rowId: null, - }); - - const handleOpenModal = (type, rowId) => { - setModal({ open: true, type, rowId }); - }; - - const handleCloseModal = () => { - setModal({ open: false, type: null, rowId: null }); - }; - const columns = useMemo(() => { return [ { @@ -250,11 +235,9 @@ const PrivacyOfficeList = () => { table_name={"PrivacyOfficeList"} enableRowActions positionActionsColumn={"first"} - RowActions={(props) => } + RowActions={RowActions} /> - - ); }; diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ActionsDialog.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ActionsDialog.jsx index 75a1bf6..92afece 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ActionsDialog.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ActionsDialog.jsx @@ -1,101 +1,18 @@ -import { - Box, - Button, - Checkbox, - Dialog, - DialogActions, - DialogContent, - DialogTitle, - FormControlLabel, - TextField, -} from "@mui/material"; -import { useEffect, useState } from "react"; -import { Controller, useForm } from "react-hook-form"; - -const ActionDialog = ({ open, type, rowDataId, onClose }) => { - const [needsAccessRoad, setNeedsAccessRoad] = useState(false); - const { - control, - handleSubmit, - reset, - formState: { isSubmitting }, - } = useForm({ - defaultValues: { - expert_description: "", - need_payment: false, - }, - }); - - useEffect(() => { - if (open) { - reset({ - expert_description: "", - need_payment: false, - }); - } - }, [open, reset]); +import { Dialog, DialogTitle } from "@mui/material"; +import RenderActionForm from "./RenderActionForm"; +const ActionDialog = ({ open, type, rowData, onClose, mutate }) => { const actionLabel = { - reject: "رد درخواست", - confirm: "تایید درخواست", - referral: "ارجاع درخواست", + reject_request: "رد درخواست", + confirm_request: "تایید درخواست", + refer_request: "ارجاع درخواست", }[type]; - const onSubmit = (formData) => { - console.log("Row data id:", rowDataId); - console.log("Action type:", type); - console.log("Form data:", formData); - - // TODO: Implement the API call here - - onClose(); - }; - return ( {actionLabel} - - - } - /> - {type === "confirm" && ( - <> - ( - } - label="نیاز به پرداخت" - /> - )} - /> - setNeedsAccessRoad(e.target.checked)} - /> - } - label="به راه دسترسی نیاز دارد" - /> - - )} - - - - - - - + ); }; diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ConfirmAction/index.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ConfirmAction/index.jsx index ca0b3d5..bdb4b35 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ConfirmAction/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ConfirmAction/index.jsx @@ -1,11 +1,11 @@ import ThumbUpIcon from "@mui/icons-material/ThumbUp"; import { IconButton, Tooltip } from "@mui/material"; -const ConfirmAction = ({ onClick }) => { +const ConfirmAction = ({ onClick, disabled }) => { return ( <> - + diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ComputePaymentForm.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ComputePaymentForm.jsx new file mode 100644 index 0000000..d40f0a3 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ComputePaymentForm.jsx @@ -0,0 +1,3 @@ +export default function ComputePaymentForm({ mutate }) { + return
ComputePaymentForm
; +} diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ConfirmFileForm.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ConfirmFileForm.jsx new file mode 100644 index 0000000..5f98d49 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ConfirmFileForm.jsx @@ -0,0 +1,3 @@ +export default function ConfirmFileForm({ mutate }) { + return
ConfirmFileForm
; +} diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ConfirmRequestForm.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ConfirmRequestForm.jsx new file mode 100644 index 0000000..5d0ca86 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ConfirmRequestForm.jsx @@ -0,0 +1,3 @@ +export default function ConfirmRequestForm({ mutate }) { + return
ConfirmRequestForm
; +} diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ReferForm.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ReferForm.jsx new file mode 100644 index 0000000..543bc33 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ReferForm.jsx @@ -0,0 +1,9 @@ +import { Box } from "@mui/material"; + +export default function ReferForm({ mutate }) { + return ( + +
+
+ ); +} diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/RejectFileForm.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/RejectFileForm.jsx new file mode 100644 index 0000000..42080a3 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/RejectFileForm.jsx @@ -0,0 +1,3 @@ +export default function RejectFileForm({ mutate }) { + return
RejectFileForm
; +} diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/RejectRequestForm.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/RejectRequestForm.jsx new file mode 100644 index 0000000..bca7ee3 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/RejectRequestForm.jsx @@ -0,0 +1,3 @@ +export default function RejectRequestForm({ mutate }) { + return
RejectRequestForm
; +} diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ReferralAction/index.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ReferralAction/index.jsx index 7f56971..a75ef8c 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ReferralAction/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ReferralAction/index.jsx @@ -1,11 +1,11 @@ import { Reply } from "@mui/icons-material"; import { IconButton, Tooltip } from "@mui/material"; -const ReferralAction = ({ onClick }) => { +const ReferralAction = ({ onClick, disabled }) => { return ( <> - + diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RejectAction/index.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RejectAction/index.jsx index b2e40ab..edd0346 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RejectAction/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RejectAction/index.jsx @@ -1,11 +1,11 @@ import ThumbDownIcon from "@mui/icons-material/ThumbDown"; import { IconButton, Tooltip } from "@mui/material"; -const RejectAction = ({ onClick }) => { +const RejectAction = ({ onClick, disabled }) => { return ( <> - + diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RenderActionForm.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RenderActionForm.jsx new file mode 100644 index 0000000..d901c13 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RenderActionForm.jsx @@ -0,0 +1,76 @@ +import { DialogContent } from "@mui/material"; +import ComputePaymentForm from "./Forms/ComputePaymentForm"; +import ConfirmFileForm from "./Forms/ConfirmFileForm"; +import ConfirmRequestForm from "./Forms/ConfirmRequestForm"; +import ReferForm from "./Forms/ReferForm"; +import RejectFileForm from "./Forms/RejectFileForm"; +import RejectRequestForm from "./Forms/RejectRequestForm"; + +export default function RenderActionForm({ type, rowData, mutate }) { + const formType = `${type}_${rowData?.state_id}`; + + console.log(formType); + + function renderForm() { + switch (formType) { + case "refer_request_2": + return ; + case "reject_request_2": + return ; + case "reject_request_5": + return ; + case "confirm_request_2": + return ; + case "confirm_request_5": + return ; + case "confirm_request_13": + return ; + default: + return <>; + } + } + + return {renderForm(formType)}; +} + +/* + + } + /> + {type === "confirm_request" && ( + <> + ( + } + label="نیاز به پرداخت وجه خزانه" + /> + )} + /> + setNeedsAccessRoad(e.target.checked)} + /> + } + label="نیاز به راه دسترسی" + /> + + )} + + + + + + +*/ diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/index.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/index.jsx index 61c5a54..6cc004d 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/index.jsx @@ -1,20 +1,54 @@ import { Box } from "@mui/material"; +import { useState } from "react"; +import ActionDialog from "./ActionsDialog"; import ConfirmAction from "./ConfirmAction"; import ReferralAction from "./ReferralAction"; import RejectAction from "./RejectAction"; -const RowActions = ({ - row: { - original: { id }, - }, - onActionClick, -}) => { +const RowActions = ({ row: { original }, mutate }) => { + const [modal, setModal] = useState({ + open: false, + type: null, // "reject_request" | "confirm_request" | "refer_request" + rowData: null, + }); + + const handleOpenModal = (type, rowData) => { + setModal({ open: true, type, rowData }); + }; + + const handleCloseModal = () => { + setModal({ open: false, type: null, rowData: null }); + }; + + const stateId = original.state_id; + + const disabled = { + referral: stateId !== 2, + reject: stateId !== 2 && stateId !== 5, + confirm: stateId !== 2 && stateId !== 5 && stateId !== 13, + }; + return ( - - onActionClick("referral", id)} /> - onActionClick("reject", id)} /> - onActionClick("confirm", id)} /> - + <> + + handleOpenModal("refer_request", original)} + disabled={disabled.referral} + /> + handleOpenModal("reject_request", original)} disabled={disabled.reject} /> + handleOpenModal("confirm_request", original)} + disabled={disabled.confirm} + /> + + + ); }; diff --git a/src/core/utils/routes.js b/src/core/utils/routes.js index 8572b6f..b2bb76d 100644 --- a/src/core/utils/routes.js +++ b/src/core/utils/routes.js @@ -240,3 +240,4 @@ export const GET_CITY_ADMIN_LIST = api + "/api/v3/harim/province_office"; export const GET_INQUIRY_PRIVACY_STATE_LIST = api + "/api/v3/harim/detail/states"; export const CITY_ADMIN_FEEDBACK = api + "/api/v3/harim/province_office/feedback"; export const GET_PRIVACY_ADMIN_LIST = api + "/api/v3/harim/harim_office"; +export const PRIVACY_ADMIN_ACTION_API = api + "/api/v3/harim/harim_office"; From 9aa6ca961740d6bf1298436702226fa460b69d5b Mon Sep 17 00:00:00 2001 From: baslani Date: Tue, 18 Nov 2025 09:41:12 +0330 Subject: [PATCH 09/61] implemented refer modal --- .../RowActions/Forms/ReferForm.jsx | 33 +++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ReferForm.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ReferForm.jsx index 543bc33..46af9d4 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ReferForm.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ReferForm.jsx @@ -1,9 +1,36 @@ -import { Box } from "@mui/material"; +import { Box, Button, DialogActions, TextField } from "@mui/material"; +import { useState } from "react"; +import { Controller, useForm } from "react-hook-form"; + +export default function ReferForm({ mutate, onClose }) { + const [isSubmitting, setIsSubmitting] = useState(false); + const { control, handleSubmit } = useForm({ + defaultValues: { + expert_description: "", + }, + }); + + const onSubmit = (data) => { + console.log(data); + setIsSubmitting(true); + mutate(); + }; -export default function ReferForm({ mutate }) { return ( -
+ } + /> + + + +
); } From e4b17eb6cf19fed93b649a9f475805063ca6d8a3 Mon Sep 17 00:00:00 2001 From: baslani Date: Tue, 18 Nov 2025 10:11:43 +0330 Subject: [PATCH 10/61] implemented RejectRequestForm modal --- .../RowActions/Forms/RejectRequestForm.jsx | 37 ++++++++++++++++++- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/RejectRequestForm.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/RejectRequestForm.jsx index bca7ee3..9f98b33 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/RejectRequestForm.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/RejectRequestForm.jsx @@ -1,3 +1,36 @@ -export default function RejectRequestForm({ mutate }) { - return
RejectRequestForm
; +import { Box, Button, DialogActions, TextField } from "@mui/material"; +import { useState } from "react"; +import { Controller, useForm } from "react-hook-form"; + +export default function RejectRequestForm({ mutate, onClose }) { + const [isSubmitting, setIsSubmitting] = useState(false); + const { control, handleSubmit } = useForm({ + defaultValues: { + expert_description: "", + }, + }); + + const onSubmit = (data) => { + console.log(data); + setIsSubmitting(true); + mutate(); + }; + + return ( + + } + /> + + + + + + ); } From 89ab9b5ada856e683f28d1b5e3a79f05ad4f3a24 Mon Sep 17 00:00:00 2001 From: baslani Date: Tue, 18 Nov 2025 10:18:31 +0330 Subject: [PATCH 11/61] implemented RejectFileForm modal --- .../RowActions/Forms/RejectFileForm.jsx | 40 ++++++++++++++++++- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/RejectFileForm.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/RejectFileForm.jsx index 42080a3..3e1fa56 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/RejectFileForm.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/RejectFileForm.jsx @@ -1,3 +1,39 @@ -export default function RejectFileForm({ mutate }) { - return
RejectFileForm
; +import { Box, Button, DialogActions, TextField } from "@mui/material"; +import { useState } from "react"; +import { Controller, useForm } from "react-hook-form"; + +export default function RejectFileForm({ mutate, onClose }) { + const [isSubmitting, setIsSubmitting] = useState(false); + const { control, handleSubmit } = useForm({ + defaultValues: { + expert_description: "", + }, + }); + + const onSubmit = (data) => { + console.log("file rejected"); + + console.log(data); + setIsSubmitting(true); + mutate(); + onClose(); + }; + + return ( + + } + /> + + + + + + ); } From b0a8634d049ceee5f2b38271845450282853577d Mon Sep 17 00:00:00 2001 From: baslani Date: Tue, 18 Nov 2025 13:00:42 +0330 Subject: [PATCH 12/61] implemented ConfirmRequestForm modal --- .../RowActions/Forms/ConfirmRequestForm.jsx | 61 ++++++++++++++++++- 1 file changed, 59 insertions(+), 2 deletions(-) diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ConfirmRequestForm.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ConfirmRequestForm.jsx index 5d0ca86..3f090fb 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ConfirmRequestForm.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ConfirmRequestForm.jsx @@ -1,3 +1,60 @@ -export default function ConfirmRequestForm({ mutate }) { - return
ConfirmRequestForm
; +import { Box, Button, Checkbox, DialogActions, FormControlLabel, TextField } from "@mui/material"; +import { useState } from "react"; +import { Controller, useForm } from "react-hook-form"; + +export default function ConfirmRequestForm({ mutate, onClose }) { + const [isSubmitting, setIsSubmitting] = useState(false); + const { control, handleSubmit } = useForm({ + defaultValues: { + expert_description: "", + need_payment: false, + needsAccessRoad: false, + }, + }); + + const onSubmit = (data) => { + console.log(data); + setIsSubmitting(true); + mutate(); + onClose(); + }; + + return ( + + } + /> + ( + } + label="نیاز به پرداخت وجه خزانه" + /> + )} + /> + ( + } + label="نیاز به پرداخت وجه خزانه" + /> + )} + /> + + + + + + + ); } From 7901e86be6bddd75e1cc30ee64753ce13187419d Mon Sep 17 00:00:00 2001 From: baslani Date: Tue, 18 Nov 2025 14:36:09 +0330 Subject: [PATCH 13/61] implemented ConfirmFileForm modal --- .../RowActions/Forms/ConfirmFileForm.jsx | 39 ++++++++++++++++++- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ConfirmFileForm.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ConfirmFileForm.jsx index 5f98d49..1eb4d5b 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ConfirmFileForm.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ConfirmFileForm.jsx @@ -1,3 +1,38 @@ -export default function ConfirmFileForm({ mutate }) { - return
ConfirmFileForm
; +import { Box, Button, DialogActions, TextField } from "@mui/material"; +import { useState } from "react"; +import { Controller, useForm } from "react-hook-form"; + +export default function ConfirmFileForm({ mutate, onClose }) { + const [isSubmitting, setIsSubmitting] = useState(false); + const { control, handleSubmit } = useForm({ + defaultValues: { + expert_description: "", + }, + }); + + const onSubmit = (data) => { + console.log(data); + setIsSubmitting(true); + mutate(); + onClose(); + }; + + return ( + + } + /> + + + + + + + ); } From 24461ffc6a6bccc25ca3cec9347a7d83f8d0f852 Mon Sep 17 00:00:00 2001 From: baslani Date: Tue, 18 Nov 2025 14:36:38 +0330 Subject: [PATCH 14/61] implemented ComputePaymentForm modal --- .../RowActions/Forms/ComputePaymentForm.jsx | 130 +++++++++++++++++- 1 file changed, 128 insertions(+), 2 deletions(-) diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ComputePaymentForm.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ComputePaymentForm.jsx index d40f0a3..b49c61a 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ComputePaymentForm.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ComputePaymentForm.jsx @@ -1,3 +1,129 @@ -export default function ComputePaymentForm({ mutate }) { - return
ComputePaymentForm
; +import { Box, Button, DialogActions, FormControl, InputLabel, MenuItem, Select, TextField } from "@mui/material"; +import { useEffect, useState } from "react"; +import { Controller, useForm, useWatch } from "react-hook-form"; + +export default function ComputePaymentForm({ mutate, onClose }) { + const [isSubmitting, setIsSubmitting] = useState(false); + + const price_fee = 1; // TODO: Replace with value from .env + + const { control, handleSubmit, setValue } = useForm({ + defaultValues: { + expert_description: "", + traffic: "", + road_type: "", + position: "", + final_area_space: "", + payment_amount: "", + }, + }); + + // Watch dependent fields for recalculation + const { traffic, road_type, position, final_area_space } = useWatch({ + control, + }); + + useEffect(() => { + const t = parseFloat(traffic || ""); + const r = parseFloat(road_type || ""); + const p = parseFloat(position || ""); + const area = parseFloat(final_area_space || ""); + + if (t && r && p && area) { + const result = t * r * p * area * price_fee; + setValue("payment_amount", result.toString()); + } else { + setValue("payment_amount", ""); + } + }, [traffic, road_type, position, final_area_space, price_fee, setValue]); + + const onSubmit = (data) => { + console.log(data); + setIsSubmitting(true); + mutate(); + onClose(); + }; + + return ( + + + ( + + ترافیک + + + )} + /> + + ( + + نوع راه + + + )} + /> + + + + ( + + موقعیت اقتصادی + + + )} + /> + + ( + + )} + /> + + + ( + + )} + /> + + } + /> + + + + + + + ); } From 522215690df383cdd8bc62fceac3fb19d6d08021 Mon Sep 17 00:00:00 2001 From: baslani Date: Tue, 18 Nov 2025 14:39:02 +0330 Subject: [PATCH 15/61] implemented form rendering logic --- .../RowActions/ActionsDialog.jsx | 2 +- .../RowActions/RenderActionForm.jsx | 60 +++---------------- 2 files changed, 9 insertions(+), 53 deletions(-) diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ActionsDialog.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ActionsDialog.jsx index 92afece..75fe025 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ActionsDialog.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ActionsDialog.jsx @@ -12,7 +12,7 @@ const ActionDialog = ({ open, type, rowData, onClose, mutate }) => { {actionLabel} - + ); }; diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RenderActionForm.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RenderActionForm.jsx index d901c13..874916c 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RenderActionForm.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RenderActionForm.jsx @@ -6,71 +6,27 @@ import ReferForm from "./Forms/ReferForm"; import RejectFileForm from "./Forms/RejectFileForm"; import RejectRequestForm from "./Forms/RejectRequestForm"; -export default function RenderActionForm({ type, rowData, mutate }) { +export default function RenderActionForm({ type, rowData, mutate, onClose }) { const formType = `${type}_${rowData?.state_id}`; - console.log(formType); - function renderForm() { switch (formType) { case "refer_request_2": - return ; + return ; case "reject_request_2": - return ; + return ; case "reject_request_5": - return ; + return ; case "confirm_request_2": - return ; + return ; case "confirm_request_5": - return ; + return ; case "confirm_request_13": - return ; + return ; default: return <>; } } - return {renderForm(formType)}; + return {renderForm()}; } - -/* - - } - /> - {type === "confirm_request" && ( - <> - ( - } - label="نیاز به پرداخت وجه خزانه" - /> - )} - /> - setNeedsAccessRoad(e.target.checked)} - /> - } - label="نیاز به راه دسترسی" - /> - - )} - - - - - - -*/ From a6788fdaeffe2b157c7fd41a70ee9ce398b1508c Mon Sep 17 00:00:00 2001 From: baslani Date: Tue, 18 Nov 2025 15:05:38 +0330 Subject: [PATCH 16/61] implemented referal action for privacy office --- .../RowActions/Forms/ReferForm.jsx | 43 ++++++++++++++++--- .../RowActions/RenderActionForm.jsx | 2 +- 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ReferForm.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ReferForm.jsx index 46af9d4..30477f7 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ReferForm.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ReferForm.jsx @@ -1,19 +1,37 @@ +import { PRIVACY_ADMIN_ACTION_API } from "@/core/utils/routes"; +import useRequest from "@/lib/hooks/useRequest"; import { Box, Button, DialogActions, TextField } from "@mui/material"; import { useState } from "react"; import { Controller, useForm } from "react-hook-form"; -export default function ReferForm({ mutate, onClose }) { +export default function ReferForm({ mutate, onClose, rowId }) { const [isSubmitting, setIsSubmitting] = useState(false); - const { control, handleSubmit } = useForm({ + const request = useRequest({ notificationSuccess: true }); + + const { + control, + handleSubmit, + formState: { errors }, + } = useForm({ defaultValues: { expert_description: "", }, }); const onSubmit = (data) => { - console.log(data); setIsSubmitting(true); - mutate(); + try { + request(`${PRIVACY_ADMIN_ACTION_API}/refer_request/${rowId}`, "post", { + data, + }).then(() => { + onClose(); + mutate(); + }); + } catch (error) { + console.log(error); + } finally { + setIsSubmitting(false); + } }; return ( @@ -21,14 +39,27 @@ export default function ReferForm({ mutate, onClose }) { } + rules={{ + required: "توضیحات الزامی است", + }} + render={({ field }) => ( + + )} /> diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RenderActionForm.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RenderActionForm.jsx index 874916c..63a1305 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RenderActionForm.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RenderActionForm.jsx @@ -12,7 +12,7 @@ export default function RenderActionForm({ type, rowData, mutate, onClose }) { function renderForm() { switch (formType) { case "refer_request_2": - return ; + return ; case "reject_request_2": return ; case "reject_request_5": From 1276fe3079ff8e2ce2ba8e22f074370bd7618810 Mon Sep 17 00:00:00 2001 From: baslani Date: Tue, 18 Nov 2025 15:53:01 +0330 Subject: [PATCH 17/61] implemented reject action for privacy office --- .../RowActions/Forms/ReferForm.jsx | 2 +- .../RowActions/Forms/RejectRequestForm.jsx | 45 ++++++++++++++++--- .../RowActions/RenderActionForm.jsx | 2 +- 3 files changed, 41 insertions(+), 8 deletions(-) diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ReferForm.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ReferForm.jsx index 30477f7..231f08f 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ReferForm.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ReferForm.jsx @@ -6,7 +6,7 @@ import { Controller, useForm } from "react-hook-form"; export default function ReferForm({ mutate, onClose, rowId }) { const [isSubmitting, setIsSubmitting] = useState(false); - const request = useRequest({ notificationSuccess: true }); + const request = useRequest({ notificationSuccess: true, notificationFailed: true }); const { control, diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/RejectRequestForm.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/RejectRequestForm.jsx index 9f98b33..daf1961 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/RejectRequestForm.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/RejectRequestForm.jsx @@ -1,19 +1,38 @@ +import { PRIVACY_ADMIN_ACTION_API } from "@/core/utils/routes"; +import useRequest from "@/lib/hooks/useRequest"; import { Box, Button, DialogActions, TextField } from "@mui/material"; import { useState } from "react"; import { Controller, useForm } from "react-hook-form"; -export default function RejectRequestForm({ mutate, onClose }) { +export default function RejectRequestForm({ mutate, onClose, rowId }) { const [isSubmitting, setIsSubmitting] = useState(false); - const { control, handleSubmit } = useForm({ + const request = useRequest({ notificationSuccess: true, notificationFailed: true }); + + const { + control, + handleSubmit, + formState: { errors }, + } = useForm({ defaultValues: { expert_description: "", }, }); const onSubmit = (data) => { - console.log(data); setIsSubmitting(true); - mutate(); + + try { + request(`${PRIVACY_ADMIN_ACTION_API}/reject_request/${rowId}`, "post", { + data, + }).then(() => { + onClose(); + mutate(); + }); + } catch (err) { + console.log(err); + } finally { + setIsSubmitting(false); + } }; return ( @@ -21,14 +40,28 @@ export default function RejectRequestForm({ mutate, onClose }) { } + rules={{ + required: "توضیحات الزامی است", + }} + render={({ field }) => ( + + )} /> + diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RenderActionForm.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RenderActionForm.jsx index 63a1305..12b538a 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RenderActionForm.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RenderActionForm.jsx @@ -14,7 +14,7 @@ export default function RenderActionForm({ type, rowData, mutate, onClose }) { case "refer_request_2": return ; case "reject_request_2": - return ; + return ; case "reject_request_5": return ; case "confirm_request_2": From 5a7f8d167527b0e11d9ca460cd7f5ed019b4b100 Mon Sep 17 00:00:00 2001 From: baslani Date: Tue, 18 Nov 2025 15:57:44 +0330 Subject: [PATCH 18/61] implemented reject file action for privacy office --- .../RowActions/Forms/RejectFileForm.jsx | 48 +++++++++++++++---- .../RowActions/RenderActionForm.jsx | 2 +- 2 files changed, 40 insertions(+), 10 deletions(-) diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/RejectFileForm.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/RejectFileForm.jsx index 3e1fa56..0427eef 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/RejectFileForm.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/RejectFileForm.jsx @@ -1,22 +1,38 @@ +import { PRIVACY_ADMIN_ACTION_API } from "@/core/utils/routes"; +import useRequest from "@/lib/hooks/useRequest"; import { Box, Button, DialogActions, TextField } from "@mui/material"; import { useState } from "react"; import { Controller, useForm } from "react-hook-form"; -export default function RejectFileForm({ mutate, onClose }) { +export default function RejectFileForm({ mutate, onClose, rowId }) { const [isSubmitting, setIsSubmitting] = useState(false); - const { control, handleSubmit } = useForm({ + const request = useRequest({ notificationSuccess: true, notificationFailed: true }); + + const { + control, + handleSubmit, + formState: { errors }, + } = useForm({ defaultValues: { expert_description: "", }, }); const onSubmit = (data) => { - console.log("file rejected"); - - console.log(data); setIsSubmitting(true); - mutate(); - onClose(); + + try { + request(`${PRIVACY_ADMIN_ACTION_API}/file_rejected/${rowId}`, "post", { + data, + }).then(() => { + onClose(); + mutate(); + }); + } catch (err) { + console.log(err); + } finally { + setIsSubmitting(false); + } }; return ( @@ -24,14 +40,28 @@ export default function RejectFileForm({ mutate, onClose }) { } + rules={{ + required: "توضیحات الزامی است", + }} + render={({ field }) => ( + + )} /> + diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RenderActionForm.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RenderActionForm.jsx index 12b538a..43f5061 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RenderActionForm.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RenderActionForm.jsx @@ -16,7 +16,7 @@ export default function RenderActionForm({ type, rowData, mutate, onClose }) { case "reject_request_2": return ; case "reject_request_5": - return ; + return ; case "confirm_request_2": return ; case "confirm_request_5": From 2e68ac4472ad8cc03e3cdaf64d04fb7249523f41 Mon Sep 17 00:00:00 2001 From: baslani Date: Wed, 19 Nov 2025 10:06:50 +0330 Subject: [PATCH 19/61] implemented confirm action for privacy office --- .../RowActions/Forms/ConfirmRequestForm.jsx | 50 ++++++++++++++++--- .../RowActions/RenderActionForm.jsx | 2 +- 2 files changed, 44 insertions(+), 8 deletions(-) diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ConfirmRequestForm.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ConfirmRequestForm.jsx index 3f090fb..fdfabd7 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ConfirmRequestForm.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ConfirmRequestForm.jsx @@ -1,10 +1,18 @@ +import { PRIVACY_ADMIN_ACTION_API } from "@/core/utils/routes"; +import useRequest from "@/lib/hooks/useRequest"; import { Box, Button, Checkbox, DialogActions, FormControlLabel, TextField } from "@mui/material"; import { useState } from "react"; import { Controller, useForm } from "react-hook-form"; -export default function ConfirmRequestForm({ mutate, onClose }) { +export default function ConfirmRequestForm({ mutate, onClose, rowId }) { const [isSubmitting, setIsSubmitting] = useState(false); - const { control, handleSubmit } = useForm({ + const request = useRequest({ notificationSuccess: true, notificationFailed: true }); + + const { + control, + handleSubmit, + formState: { errors }, + } = useForm({ defaultValues: { expert_description: "", need_payment: false, @@ -13,10 +21,25 @@ export default function ConfirmRequestForm({ mutate, onClose }) { }); const onSubmit = (data) => { - console.log(data); + const confirmType = data.needsAccessRoad ? "need_road_access" : "without_road_access"; + const url = `${PRIVACY_ADMIN_ACTION_API}/${confirmType}/${rowId}`; + const body = { + expert_description: data.expert_description, + need_payment: data.need_payment ? 1 : 0, + }; + setIsSubmitting(true); - mutate(); - onClose(); + try { + request(url, "post", { + data: body, + }).then(() => { + mutate(); + onClose(); + }); + } catch (error) { + } finally { + setIsSubmitting(false); + } }; return ( @@ -24,8 +47,20 @@ export default function ConfirmRequestForm({ mutate, onClose }) { } + rules={{ required: "توضیحات الزامی است" }} + render={({ field }) => ( + + )} /> + )} /> + ( } - label="نیاز به پرداخت وجه خزانه" + label="نیاز به راه دسترسی" /> )} /> diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RenderActionForm.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RenderActionForm.jsx index 43f5061..7888e45 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RenderActionForm.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RenderActionForm.jsx @@ -18,7 +18,7 @@ export default function RenderActionForm({ type, rowData, mutate, onClose }) { case "reject_request_5": return ; case "confirm_request_2": - return ; + return ; case "confirm_request_5": return ; case "confirm_request_13": From 16b2e209a3f4501d7f075997c249f1f63370c396 Mon Sep 17 00:00:00 2001 From: baslani Date: Wed, 19 Nov 2025 10:16:07 +0330 Subject: [PATCH 20/61] implemented confirm file action for privacy office --- .../RowActions/Forms/ConfirmFileForm.jsx | 45 ++++++++++++++++--- .../RowActions/RenderActionForm.jsx | 2 +- 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ConfirmFileForm.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ConfirmFileForm.jsx index 1eb4d5b..80bda88 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ConfirmFileForm.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ConfirmFileForm.jsx @@ -1,20 +1,38 @@ +import { PRIVACY_ADMIN_ACTION_API } from "@/core/utils/routes"; +import useRequest from "@/lib/hooks/useRequest"; import { Box, Button, DialogActions, TextField } from "@mui/material"; import { useState } from "react"; import { Controller, useForm } from "react-hook-form"; -export default function ConfirmFileForm({ mutate, onClose }) { +export default function ConfirmFileForm({ mutate, onClose, rowId }) { const [isSubmitting, setIsSubmitting] = useState(false); - const { control, handleSubmit } = useForm({ + const request = useRequest({ notificationSuccess: true, notificationFailed: true }); + + const { + control, + handleSubmit, + formState: { errors }, + } = useForm({ defaultValues: { expert_description: "", }, }); const onSubmit = (data) => { - console.log(data); setIsSubmitting(true); - mutate(); - onClose(); + + try { + request(`${PRIVACY_ADMIN_ACTION_API}/file_accepted/${rowId}`, "post", { + data, + }).then(() => { + onClose(); + mutate(); + }); + } catch (err) { + console.log(err); + } finally { + setIsSubmitting(false); + } }; return ( @@ -22,7 +40,20 @@ export default function ConfirmFileForm({ mutate, onClose }) { } + rules={{ + required: "توضیحات الزامی است", + }} + render={({ field }) => ( + + )} /> @@ -30,7 +61,7 @@ export default function ConfirmFileForm({ mutate, onClose }) { انصراف diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RenderActionForm.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RenderActionForm.jsx index 7888e45..51c465a 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RenderActionForm.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RenderActionForm.jsx @@ -20,7 +20,7 @@ export default function RenderActionForm({ type, rowData, mutate, onClose }) { case "confirm_request_2": return ; case "confirm_request_5": - return ; + return ; case "confirm_request_13": return ; default: From 0e4fc65d25f96c8f377fdc51fff471710dce8f04 Mon Sep 17 00:00:00 2001 From: baslani Date: Wed, 19 Nov 2025 11:47:29 +0330 Subject: [PATCH 21/61] fixed MUI tooltip error --- .../privacy-office/RowActions/ConfirmAction/index.jsx | 8 +++++--- .../privacy-office/RowActions/ReferralAction/index.jsx | 8 +++++--- .../privacy-office/RowActions/RejectAction/index.jsx | 8 +++++--- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ConfirmAction/index.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ConfirmAction/index.jsx index bdb4b35..7820320 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ConfirmAction/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ConfirmAction/index.jsx @@ -5,9 +5,11 @@ const ConfirmAction = ({ onClick, disabled }) => { return ( <> - - - + + + + + ); diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ReferralAction/index.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ReferralAction/index.jsx index a75ef8c..85a693f 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ReferralAction/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ReferralAction/index.jsx @@ -5,9 +5,11 @@ const ReferralAction = ({ onClick, disabled }) => { return ( <> - - - + + + + + ); diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RejectAction/index.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RejectAction/index.jsx index edd0346..e467e87 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RejectAction/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RejectAction/index.jsx @@ -5,9 +5,11 @@ const RejectAction = ({ onClick, disabled }) => { return ( <> - - - + + + + + ); From d9f27bda742fd6ac373fff83ee654affe72c067c Mon Sep 17 00:00:00 2001 From: baslani Date: Wed, 19 Nov 2025 15:42:56 +0330 Subject: [PATCH 22/61] implemented payment computing for privacy office --- jsconfig.json | 33 +++- .../city-admin/ShowPrimaryArea/index.jsx | 18 +- .../RowActions/Forms/ComputePaymentForm.jsx | 168 ++++++++++++++---- .../RowActions/RenderActionForm.jsx | 2 +- src/core/utils/utils.js | 15 ++ 5 files changed, 176 insertions(+), 60 deletions(-) diff --git a/jsconfig.json b/jsconfig.json index d9112b4..b51472a 100644 --- a/jsconfig.json +++ b/jsconfig.json @@ -1,12 +1,27 @@ +// javascript for production { - "compilerOptions": { - "paths": { - "@/*": [ - "./src/*" - ], - "^/*": [ - "./public/*" - ] + "compilerOptions": { + "paths": { + "@/*": ["./src/*"], + "^/*": ["./public/*"] + } } - } } + +// typescript for local development +// { +// "compilerOptions": { +// "jsx": "react-jsx", +// "noUnusedLocals": true, +// "noImplicitAny": false, +// "checkJs": true, +// "allowJs": true, +// "strict": true, +// "baseUrl": ".", +// "paths": { +// "@/*": ["./src/*"], +// "^/*": ["./public/*"] +// } +// }, +// "exclude": ["node_modules"] +// } diff --git a/src/components/dashboard/inquiryPrivacy/city-admin/ShowPrimaryArea/index.jsx b/src/components/dashboard/inquiryPrivacy/city-admin/ShowPrimaryArea/index.jsx index 98e24d0..76c0980 100644 --- a/src/components/dashboard/inquiryPrivacy/city-admin/ShowPrimaryArea/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/city-admin/ShowPrimaryArea/index.jsx @@ -1,18 +1,8 @@ -const { - Button, - IconButton, - Tooltip, - Box, - Dialog, - DialogTitle, - Typography, - DialogContent, - DialogActions, -} = require("@mui/material"); -import LayersIcon from "@mui/icons-material/Layers"; -import CloseIcon from "@mui/icons-material/Close"; -import { useMemo, useState } from "react"; +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 { useMemo, useState } from "react"; import ShowBound from "./ShowBound"; const ShowPrimaryArea = ({ primaryArea }) => { diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ComputePaymentForm.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ComputePaymentForm.jsx index b49c61a..01d3a5d 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ComputePaymentForm.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ComputePaymentForm.jsx @@ -1,47 +1,92 @@ -import { Box, Button, DialogActions, FormControl, InputLabel, MenuItem, Select, TextField } from "@mui/material"; +import { calculatePolygonMetrics } from "@/core/utils/geoCalculations"; +import { PRIVACY_ADMIN_ACTION_API } from "@/core/utils/routes"; +import { safeParsePolygon } from "@/core/utils/utils"; +import useRequest from "@/lib/hooks/useRequest"; +import { + Box, + Button, + DialogActions, + FormControl, + FormHelperText, + InputLabel, + MenuItem, + Select, + TextField, +} from "@mui/material"; import { useEffect, useState } from "react"; import { Controller, useForm, useWatch } from "react-hook-form"; -export default function ComputePaymentForm({ mutate, onClose }) { +const formatNumber = (num) => { + if (!num) return ""; + return Number(num).toLocaleString("en-US"); +}; + +const price_fee = 1; // TODO: Replace with real price_fee +export default function ComputePaymentForm({ mutate, onClose, rowData }) { const [isSubmitting, setIsSubmitting] = useState(false); + const request = useRequest({ notificationSuccess: true, notificationFailed: true }); - const price_fee = 1; // TODO: Replace with value from .env + const coordsArea = safeParsePolygon(rowData.final_area); + const coordsPlan = safeParsePolygon(rowData.final_plan); - const { control, handleSubmit, setValue } = useForm({ + const areaMetrics = coordsArea ? calculatePolygonMetrics(coordsArea) : { area: 0 }; + const planMetrics = coordsPlan ? calculatePolygonMetrics(coordsPlan) : { area: 0 }; + + const calculatedArea = Number(areaMetrics.area.toFixed(2) || 0); + const calculatedPlan = Number(planMetrics.area.toFixed(2) || 0); + + const { + control, + handleSubmit, + setValue, + formState: { errors }, + } = useForm({ defaultValues: { expert_description: "", traffic: "", road_type: "", position: "", - final_area_space: "", + final_area_space: calculatedArea, // عرصه + final_plan_space: calculatedPlan, // عیان payment_amount: "", }, }); - // Watch dependent fields for recalculation - const { traffic, road_type, position, final_area_space } = useWatch({ + const { traffic, road_type, position } = useWatch({ control, }); useEffect(() => { + const hasGeometry = calculatedArea > 0 || calculatedPlan > 0; + const t = parseFloat(traffic || ""); const r = parseFloat(road_type || ""); const p = parseFloat(position || ""); - const area = parseFloat(final_area_space || ""); - if (t && r && p && area) { - const result = t * r * p * area * price_fee; - setValue("payment_amount", result.toString()); + const inputsValid = hasGeometry && !isNaN(t) && t > 0 && !isNaN(r) && r > 0 && !isNaN(p) && p > 0; + + if (inputsValid) { + const resultArea = t * r * p * calculatedArea * price_fee; + const resultPlan = t * r * p * calculatedPlan * price_fee; + + setValue("payment_amount", Math.floor(resultArea + resultPlan).toString()); } else { setValue("payment_amount", ""); } - }, [traffic, road_type, position, final_area_space, price_fee, setValue]); + }, [traffic, road_type, position, setValue, calculatedArea, calculatedPlan]); const onSubmit = (data) => { - console.log(data); setIsSubmitting(true); - mutate(); - onClose(); + + try { + request(`${PRIVACY_ADMIN_ACTION_API}/computing_payment/${rowData.id}`, "post", { + data, + }); + } catch (error) { + console.error("Error submitting payment:", error); + } finally { + setIsSubmitting(false); + } }; return ( @@ -50,14 +95,18 @@ export default function ComputePaymentForm({ mutate, onClose }) { ( ترافیک - سبک متوسط سنگین + {errors.traffic && ( + {errors.traffic.message} + )} )} /> @@ -65,39 +114,66 @@ export default function ComputePaymentForm({ mutate, onClose }) { ( نوع راه - فرعی و راه‌آهن اصلی و بزرگراه آزادراه + {errors.road_type && ( + {errors.road_type.message} + )} )} /> - - ( - - موقعیت اقتصادی - - - )} - /> + ( + + موقعیت اقتصادی + + {errors.position && ( + {errors.position.message} + )} + + )} + /> + ( - + + )} + /> + ( + )} /> @@ -105,15 +181,35 @@ export default function ComputePaymentForm({ mutate, onClose }) { ( - - )} + render={({ field }) => { + const { value } = field; + + return ( + + ); + }} /> } + rules={{ required: "توضیحات ناظر اجباری است" }} + render={({ field }) => ( + + )} /> diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RenderActionForm.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RenderActionForm.jsx index 51c465a..846cc1a 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RenderActionForm.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RenderActionForm.jsx @@ -22,7 +22,7 @@ export default function RenderActionForm({ type, rowData, mutate, onClose }) { case "confirm_request_5": return ; case "confirm_request_13": - return ; + return ; default: return <>; } diff --git a/src/core/utils/utils.js b/src/core/utils/utils.js index eec2824..1198244 100644 --- a/src/core/utils/utils.js +++ b/src/core/utils/utils.js @@ -148,3 +148,18 @@ export const getClosedPolygonCoordinates = (polygon) => { return coordinates; }; + +export function safeParsePolygon(polygonJson) { + if (!polygonJson) return null; + + try { + const parsed = JSON.parse(polygonJson); + if (parsed && parsed.coordinates) { + return parsed.coordinates; + } + return null; + } catch (err) { + console.error("Invalid polygon JSON:", err); + return null; + } +} From 6c48dd4a05749a38850295e846616d64be354892 Mon Sep 17 00:00:00 2001 From: baslani Date: Wed, 19 Nov 2025 15:47:46 +0330 Subject: [PATCH 23/61] fixed date issue and active status for toll houses --- .../tollHouse/Form/CreateTollHouse/TollHouseInfo.jsx | 4 ++-- src/components/infrastructure/tollHouse/TollHouseList.jsx | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/components/infrastructure/tollHouse/Form/CreateTollHouse/TollHouseInfo.jsx b/src/components/infrastructure/tollHouse/Form/CreateTollHouse/TollHouseInfo.jsx index dc56843..5d53fdf 100644 --- a/src/components/infrastructure/tollHouse/Form/CreateTollHouse/TollHouseInfo.jsx +++ b/src/components/infrastructure/tollHouse/Form/CreateTollHouse/TollHouseInfo.jsx @@ -82,8 +82,8 @@ const TollHouseInfo = ({ control }) => { value={field.value} label="وضعیت" selectors={[ - { id: 0, name: "فعال" }, - { id: 1, name: "غیر فعال" }, + { id: 1, name: "فعال" }, + { id: 0, name: "غیر فعال" }, ]} schema={{ name: "name", value: "id" }} error={error} diff --git a/src/components/infrastructure/tollHouse/TollHouseList.jsx b/src/components/infrastructure/tollHouse/TollHouseList.jsx index 4ef1674..11536b8 100644 --- a/src/components/infrastructure/tollHouse/TollHouseList.jsx +++ b/src/components/infrastructure/tollHouse/TollHouseList.jsx @@ -384,7 +384,8 @@ const TollHouseList = () => { ], }, { - accessorFn: (row) => moment(row.created_at).locale("fa").format("HH:mm | yyyy/MM/DD"), + accessorFn: (row) => + row.created_at ? moment(row.created_at).locale("fa").format("HH:mm | yyyy/MM/DD") : "-", header: "تاریخ ثبت", id: "created_at", enableColumnFilter: true, From 98f783ee4401c988a91cb2171bb929df916aa273 Mon Sep 17 00:00:00 2001 From: baslani Date: Wed, 26 Nov 2025 09:04:14 +0330 Subject: [PATCH 24/61] fixed computing payment form's submit action --- .../privacy-office/RowActions/Forms/ComputePaymentForm.jsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ComputePaymentForm.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ComputePaymentForm.jsx index 01d3a5d..eb0fa47 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ComputePaymentForm.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ComputePaymentForm.jsx @@ -81,6 +81,9 @@ export default function ComputePaymentForm({ mutate, onClose, rowData }) { try { request(`${PRIVACY_ADMIN_ACTION_API}/computing_payment/${rowData.id}`, "post", { data, + }).then(() => { + onClose(); + mutate(); }); } catch (error) { console.error("Error submitting payment:", error); From 294ca463ff089253a7b670da6036681684bb0d25 Mon Sep 17 00:00:00 2001 From: baslani Date: Wed, 26 Nov 2025 11:21:17 +0330 Subject: [PATCH 25/61] implemented technical deputy list table page --- .../{assistant => technical-deputy}/page.js | 3 +- .../ConfirmRoadSafetyDialog.jsx | 48 +++++ .../ConfirmRoadSafetyFormContext.jsx | 85 ++++++++ .../PrevCartableOpinion.jsx | 16 ++ .../Questions/DescriptionForm.jsx | 29 +++ .../Questions/QuestionVerifyNeedRoadForm.jsx | 34 ++++ .../QuestionVerifyRoadSafetyForm.jsx | 34 ++++ .../Questions/Refer/Form.jsx | 78 +++++++ .../Questions/Refer/index.jsx | 34 ++++ .../ConfirmRoadSafetyForm/Questions/index.jsx | 72 +++++++ .../ConfirmRoadSafetyForm/index.jsx | 51 +++++ .../ConfirmRoadSafetyDialog.jsx | 49 +++++ .../ConfirmRoadSafetyFormContext.jsx | 92 +++++++++ .../PrevCartableOpinion.jsx | 16 ++ .../Questions/DescriptionForm.jsx | 29 +++ .../Questions/QuestionVerifyNeedRoadForm.jsx | 34 ++++ .../QuestionVerifyRoadSafetyForm.jsx | 34 ++++ .../Questions/Refer/Form.jsx | 70 +++++++ .../Questions/Refer/index.jsx | 34 ++++ .../Questions/index.jsx | 65 ++++++ .../ConfirmVerifyLicenseForm/index.jsx | 51 +++++ .../ConfirmRoadSafetyDialog.jsx | 43 ++++ .../ConfirmRoadSafetyFormContext.jsx | 92 +++++++++ .../PrevCartableOpinion.jsx | 16 ++ .../Questions/DescriptionForm.jsx | 29 +++ .../Questions/QuestionVerifyNeedRoadForm.jsx | 34 ++++ .../Questions/Refer/Form.jsx | 70 +++++++ .../Questions/Refer/index.jsx | 34 ++++ .../Questions/index.jsx | 64 ++++++ .../ConfirmVerifyRoadSafetyForm/index.jsx | 51 +++++ .../technical-deputy/RowActions/index.jsx | 22 ++ .../ShowPrimaryArea/ShowBound.jsx | 29 +++ .../ShowPrimaryArea/index.jsx | 60 ++++++ .../technical-deputy/TechnicalDeputyList.jsx | 190 ++++++++++++++++++ .../inquiryPrivacy/technical-deputy/index.jsx | 15 ++ src/core/components/TabPanel.jsx | 11 + src/core/utils/pageMenuDev.js | 2 +- src/core/utils/routes.js | 1 + 38 files changed, 1719 insertions(+), 2 deletions(-) rename src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/{assistant => technical-deputy}/page.js (70%) create mode 100644 src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/ConfirmRoadSafetyDialog.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/ConfirmRoadSafetyFormContext.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/PrevCartableOpinion.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/DescriptionForm.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/QuestionVerifyNeedRoadForm.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/QuestionVerifyRoadSafetyForm.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/Refer/Form.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/Refer/index.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/index.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/index.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/ConfirmRoadSafetyDialog.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/ConfirmRoadSafetyFormContext.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/PrevCartableOpinion.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/DescriptionForm.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/QuestionVerifyNeedRoadForm.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/QuestionVerifyRoadSafetyForm.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/Refer/Form.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/Refer/index.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/index.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/index.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/ConfirmRoadSafetyDialog.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/ConfirmRoadSafetyFormContext.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/PrevCartableOpinion.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/DescriptionForm.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/QuestionVerifyNeedRoadForm.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/Refer/Form.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/Refer/index.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/index.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/index.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/index.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/technical-deputy/ShowPrimaryArea/ShowBound.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/technical-deputy/ShowPrimaryArea/index.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/technical-deputy/TechnicalDeputyList.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/technical-deputy/index.jsx create mode 100644 src/core/components/TabPanel.jsx diff --git a/src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/assistant/page.js b/src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/technical-deputy/page.js similarity index 70% rename from src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/assistant/page.js rename to src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/technical-deputy/page.js index c13a78d..ebcc6c3 100644 --- a/src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/assistant/page.js +++ b/src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/technical-deputy/page.js @@ -1,3 +1,4 @@ +import TechnicalDeputy from "@/components/dashboard/inquiryPrivacy/technical-deputy"; import WithPermission from "@/core/middlewares/withPermission"; export const metadata = { title: "کارتابل معاون", @@ -5,7 +6,7 @@ export const metadata = { const Page = () => { return ( -

کارتابل معاون

+
); }; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/ConfirmRoadSafetyDialog.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/ConfirmRoadSafetyDialog.jsx new file mode 100644 index 0000000..7b8e90e --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/ConfirmRoadSafetyDialog.jsx @@ -0,0 +1,48 @@ +import DialogLoading from "@/core/components/DialogLoading"; +import { GET_REQUEST_INQUIRY_PRIVACY_ZAMIN_GOV_ASSISTANT_DETAILS } from "@/core/utils/routes"; +import useRequest from "@/lib/hooks/useRequest"; +import { DialogContent, Typography } from "@mui/material"; +import { useEffect, useState } from "react"; +import ConfirmRoadSafetyFormContext from "./ConfirmRoadSafetyFormContext"; + +const ConfirmRoadSafetyDialog = ({ row, handleClose, rowId, mutate }) => { + 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_REQUEST_INQUIRY_PRIVACY_ZAMIN_GOV_ASSISTANT_DETAILS}/${rowId}`); + setData(response.data.data); + } catch (error) { + } finally { + setLoading(false); + } + }; + + fetchData(); + }, [request, rowId]); + + return ( + <> + {loading ? ( + + ) : data ? ( + + ) : ( + + اطلاعات درخواست در سامانه یافت نشد + + )} + + ); +}; +export default ConfirmRoadSafetyDialog; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/ConfirmRoadSafetyFormContext.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/ConfirmRoadSafetyFormContext.jsx new file mode 100644 index 0000000..ac10bf7 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/ConfirmRoadSafetyFormContext.jsx @@ -0,0 +1,85 @@ +import ApplicantRequestDetail from "@/core/components/ApplicantRequestDetail"; +import { Engineering, ExitToApp, InsertDriveFile, Route } from "@mui/icons-material"; +import { Button, DialogActions, DialogContent, Stack, Tab, Tabs } from "@mui/material"; +import { useState } from "react"; +import PrevCartableOpinion from "./PrevCartableOpinion"; +import Questions from "./Questions"; +import TabPanel from "@/core/components/TabPanel"; + +const ConfirmRoadSafetyFormContext = ({ row, data, rowId, mutate, handleClose }) => { + const [tabState, setTabState] = useState(0); + + const handleChangeTab = (event, newValue) => { + setTabState(newValue); + }; + + const handlePrev = () => { + if (tabState === 0) { + handleClose(); + } else { + setTabState((t) => t - 1); + } + }; + + return ( + <> + + } label="اطلاعات طرح متقاضی" /> + } label="جریان فرایند" /> + } label="تاییدیه ایمنی راه" /> + + + + + + + + + + + + + + {data.histories.map((item, index) => ( + + ))} + + + + + + + + + + + + ); +}; +export default ConfirmRoadSafetyFormContext; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/PrevCartableOpinion.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/PrevCartableOpinion.jsx new file mode 100644 index 0000000..37fe672 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/PrevCartableOpinion.jsx @@ -0,0 +1,16 @@ +import { Card, CardContent, CircularProgress, Stack, Typography } from "@mui/material"; + +const PrevCartableOpinion = ({ item }) => { + + return ( + + + + {item.previous_state_name}: {item.action_name} + توضیحات: {item.expert_description} + + + + ); +}; +export default PrevCartableOpinion; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/DescriptionForm.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/DescriptionForm.jsx new file mode 100644 index 0000000..a7099e7 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/DescriptionForm.jsx @@ -0,0 +1,29 @@ +import { Stack, TextField } from "@mui/material"; +import { Controller } from "react-hook-form"; + +const DescriptionForm = ({ control }) => { + return ( + + ( + + )} + /> + + ); +}; +export default DescriptionForm; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/QuestionVerifyNeedRoadForm.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/QuestionVerifyNeedRoadForm.jsx new file mode 100644 index 0000000..0a9a724 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/QuestionVerifyNeedRoadForm.jsx @@ -0,0 +1,34 @@ +import { + Card, + CardContent, + Stack, + Typography +} from "@mui/material"; + +const QuestionVerifyNeedRoadForm = ({ row }) => { + return ( + + + + + آیا نیاز به راه دسترسی است؟ + + + دفتر حریم راه : + + {row.original.need_road_access == 1 ? "بله" : "خیر"} + + + + + + ); +}; +export default QuestionVerifyNeedRoadForm; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/QuestionVerifyRoadSafetyForm.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/QuestionVerifyRoadSafetyForm.jsx new file mode 100644 index 0000000..1775856 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/QuestionVerifyRoadSafetyForm.jsx @@ -0,0 +1,34 @@ +import { + Card, + CardContent, + Stack, + Typography +} from "@mui/material"; + +const QuestionVerifyRoadSafetyForm = ({ row }) => { + return ( + + + + + آیا ایمنی راه این طرح مورد تایید است؟ + + + دفتر حریم راه : + + {row.original.is_possible == 1 ? "بله" : "خیر"} + + + + + + ); +}; +export default QuestionVerifyRoadSafetyForm; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/Refer/Form.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/Refer/Form.jsx new file mode 100644 index 0000000..3dfc3ee --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/Refer/Form.jsx @@ -0,0 +1,78 @@ +import StyledForm from "@/core/components/StyledForm"; +import { REFER_INQUIRY_PRIVACY_ZAMIN_GOV_ASSISTANT } from "@/core/utils/routes"; +import useRequest from "@/lib/hooks/useRequest"; +import { yupResolver } from "@hookform/resolvers/yup"; +import { Button, DialogActions, DialogContent, Stack, TextField } from "@mui/material"; +import { Controller, useForm } from "react-hook-form"; +import { object, string } from "yup"; + +const validationSchema = object({ + description: string().required("وارد کردن توضیحات الزامیست!"), +}); + +const defaultValues = { + description: "", +}; + +const ReferForm = ({ rowId, mutate, handleClose, setOpenReferDialog }) => { + const requestServer = useRequest({ notificationSuccess: true }); + const { + control, + handleSubmit, + formState: { isSubmitting }, + } = useForm({ defaultValues, resolver: yupResolver(validationSchema), mode: "all" }); + + const onSubmit = async (data) => { + await requestServer(`${REFER_INQUIRY_PRIVACY_ZAMIN_GOV_ASSISTANT}/${rowId}`, "post", { + data: { + expert_description: data.description, + }, + }) + .then(() => { + handleClose(); + setOpenReferDialog(false); + mutate(); + }) + .catch(() => {}); + }; + + return ( + <> + + + ( + + )} + /> + + + + + + + ); +}; +export default ReferForm; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/Refer/index.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/Refer/index.jsx new file mode 100644 index 0000000..1fc664c --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/Refer/index.jsx @@ -0,0 +1,34 @@ +import { Close } from "@mui/icons-material"; +import { Button, Dialog, DialogTitle, IconButton } from "@mui/material" +import { useState } from "react"; +import ReferForm from "./Form"; + +const Refer = ({ rowId, mutate, handleClose, isSubmitting }) => { + const [openReferDialog, setOpenReferDialog] = useState(false); + + return ( + <> + + { setOpenReferDialog(false) }} maxWidth="xs" fullWidth> + setOpenReferDialog(false)} + sx={{ + position: "absolute", + right: 8, + top: 8, + zIndex: 10, + color: (theme) => theme.palette.grey[500], + }} + > + + + مخالفت و ارجاع به دفتر حریم + {openReferDialog && } + + + ) +} +export default Refer \ No newline at end of file diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/index.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/index.jsx new file mode 100644 index 0000000..c35313e --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/index.jsx @@ -0,0 +1,72 @@ +import StyledForm from "@/core/components/StyledForm"; +import { CONFIRM_INQUIRY_PRIVACY_ZAMIN_GOV_ASSISTANT } from "@/core/utils/routes"; +import useRequest from "@/lib/hooks/useRequest"; +import { yupResolver } from "@hookform/resolvers/yup"; +import { Button, DialogActions, DialogContent, Stack } from "@mui/material"; +import { useForm } from "react-hook-form"; +import { object, string } from "yup"; +import QuestionVerifyNeedRoadForm from "./QuestionVerifyNeedRoadForm"; +import QuestionVerifyRoadSafetyForm from "./QuestionVerifyRoadSafetyForm"; +import Refer from "./Refer"; +import DescriptionForm from "./DescriptionForm"; + +const validationSchema = object({ + description: string().required("وارد کردن توضیحات الزامیست!"), +}); + +const defaultValues = { + description: "", +}; + +const Questions = ({ row, rowId, mutate, handleClose, handlePrev }) => { + const requestServer = useRequest({ notificationSuccess: true }); + + const { + control, + handleSubmit, + formState: { isSubmitting }, + } = useForm({ defaultValues, resolver: yupResolver(validationSchema), mode: "all" }); + + const onSubmit = async (data) => { + await requestServer(`${CONFIRM_INQUIRY_PRIVACY_ZAMIN_GOV_ASSISTANT}/${rowId}`, "post", { + data: { + expert_description: data.description, + }, + }) + .then(() => { + handleClose(); + mutate(); + }) + .catch(() => {}); + }; + + return ( + + + + + + + + + + + + + + + + + ); +}; +export default Questions; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/index.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/index.jsx new file mode 100644 index 0000000..8104adc --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/index.jsx @@ -0,0 +1,51 @@ +import { Close, Engineering } from "@mui/icons-material"; +import { Dialog, IconButton, Stack, Tooltip } from "@mui/material"; +import { useState } from "react"; +import ConfirmRoadSafetyDialog from "./ConfirmRoadSafetyDialog"; + +const ConfirmRoadSafetyForm = ({ row, rowId, mutate }) => { + const [openConfirmRoadSafetyForm, setOpenConfirmRoadSafetyForm] = useState(false); + + const openRoadSafetyDialog = () => { + setOpenConfirmRoadSafetyForm(true); + }; + + const handleClose = () => { + setOpenConfirmRoadSafetyForm(false); + }; + + return ( + + + { + openRoadSafetyDialog(); + }} + > + + + + + handleClose()} + sx={{ + position: "absolute", + right: 8, + top: 8, + zIndex: 10, + color: (theme) => theme.palette.grey[500], + }} + > + + + {openConfirmRoadSafetyForm && ( + + )} + + + ); +}; +export default ConfirmRoadSafetyForm; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/ConfirmRoadSafetyDialog.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/ConfirmRoadSafetyDialog.jsx new file mode 100644 index 0000000..8305cf4 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/ConfirmRoadSafetyDialog.jsx @@ -0,0 +1,49 @@ +import DialogLoading from "@/core/components/DialogLoading"; +import { GET_REQUEST_INQUIRY_PRIVACY_ZAMIN_GOV_ASSISTANT_DETAILS } from "@/core/utils/routes"; +import useRequest from "@/lib/hooks/useRequest"; +import { DialogContent, Typography } from "@mui/material"; +import { useEffect, useState } from "react"; +import ConfirmRoadSafetyFormContext from "./ConfirmRoadSafetyFormContext"; + +const ConfirmRoadSafetyDialog = ({ row, handleClose, rowId, mutate }) => { + 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_REQUEST_INQUIRY_PRIVACY_ZAMIN_GOV_ASSISTANT_DETAILS}/${rowId}`); + setData(response.data.data); + } catch (error) { + } finally { + setLoading(false); + } + }; + + fetchData(); + }, [request, rowId]); + + return ( + <> + {loading ? ( +
Loading...
+ ) : // + data ? ( + + ) : ( + + اطلاعات درخواست در سامانه یافت نشد + + )} + + ); +}; +export default ConfirmRoadSafetyDialog; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/ConfirmRoadSafetyFormContext.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/ConfirmRoadSafetyFormContext.jsx new file mode 100644 index 0000000..41e1139 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/ConfirmRoadSafetyFormContext.jsx @@ -0,0 +1,92 @@ +import ApplicantRequestDetail from "@/core/components/ApplicantRequestDetail"; +import TabPanel from "@/core/components/TabPanel"; +import { ExitToApp, InsertDriveFile, Route, ThumbUp } from "@mui/icons-material"; +import { Button, DialogActions, DialogContent, Stack, Tab, Tabs } from "@mui/material"; +import { useState } from "react"; +import PrevCartableOpinion from "./PrevCartableOpinion"; +import Questions from "./Questions"; + + + +const ConfirmRoadSafetyFormContext = ({ row, data, rowId, mutate, handleClose }) => { + const [tabState, setTabState] = useState(0); + + const handleChangeTab = (event, newValue) => { + setTabState(newValue); + }; + + const handlePrev = () => { + if (tabState === 0) { + handleClose(); + } else { + setTabState((t) => t - 1); + } + }; + + return ( + <> + + } label="اطلاعات طرح متقاضی" /> + } label="جریان فرایند" /> + } label="تاییدیه ضمانت نامه ها" /> + + + + + + + + + + + + + + {data.histories.map((item, index) => ( + + ))} + + + + + + + + + + + + ); +}; +export default ConfirmRoadSafetyFormContext; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/PrevCartableOpinion.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/PrevCartableOpinion.jsx new file mode 100644 index 0000000..37fe672 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/PrevCartableOpinion.jsx @@ -0,0 +1,16 @@ +import { Card, CardContent, CircularProgress, Stack, Typography } from "@mui/material"; + +const PrevCartableOpinion = ({ item }) => { + + return ( + + + + {item.previous_state_name}: {item.action_name} + توضیحات: {item.expert_description} + + + + ); +}; +export default PrevCartableOpinion; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/DescriptionForm.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/DescriptionForm.jsx new file mode 100644 index 0000000..a7099e7 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/DescriptionForm.jsx @@ -0,0 +1,29 @@ +import { Stack, TextField } from "@mui/material"; +import { Controller } from "react-hook-form"; + +const DescriptionForm = ({ control }) => { + return ( + + ( + + )} + /> + + ); +}; +export default DescriptionForm; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/QuestionVerifyNeedRoadForm.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/QuestionVerifyNeedRoadForm.jsx new file mode 100644 index 0000000..a39fdec --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/QuestionVerifyNeedRoadForm.jsx @@ -0,0 +1,34 @@ +import { + Card, + CardContent, + Stack, + Typography +} from "@mui/material"; + +const QuestionVerifyNeedRoadForm = () => { + return ( + + + + + آیا ضمانت نامه ها مورد تایید است؟ + + + دفتر حریم راه : + + بله + + + + + + ); +}; +export default QuestionVerifyNeedRoadForm; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/QuestionVerifyRoadSafetyForm.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/QuestionVerifyRoadSafetyForm.jsx new file mode 100644 index 0000000..edd3232 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/QuestionVerifyRoadSafetyForm.jsx @@ -0,0 +1,34 @@ +import { + Card, + CardContent, + Stack, + Typography +} from "@mui/material"; + +const QuestionVerifyRoadSafetyForm = ({ row }) => { + return ( + + + + + آیا ایمنی راه این طرح مورد تایید است؟ + + + دفتر حریم راه : + + {row.original.isSafety ? "بله" : "خیر"} + + + + + + ); +}; +export default QuestionVerifyRoadSafetyForm; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/Refer/Form.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/Refer/Form.jsx new file mode 100644 index 0000000..cf2095e --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/Refer/Form.jsx @@ -0,0 +1,70 @@ +import { REFER_VERIFY_NEADROAD_ROAD_INQUIRY_PRIVACY_ZAMIN_GOV_ASSISTANT } from "@/core/utils/routes"; +import useRequest from "@/lib/hooks/useRequest"; +import { yupResolver } from "@hookform/resolvers/yup"; +import { Button, DialogActions, DialogContent, Stack, TextField } from "@mui/material"; +import { Controller, useForm } from "react-hook-form"; +import { object, string } from "yup"; +const validationSchema = object({ + description: string().required("وارد کردن توضیحات الزامیست!"), +}); + +const defaultValues = { + description: "", +}; + +const ReferForm = ({ rowId, mutate, handleClose, setOpenReferDialog }) => { + const requestServer = useRequest({ notificationSuccess: true }); + const { + control, + handleSubmit, + formState: { isSubmitting }, + } = useForm({ defaultValues, resolver: yupResolver(validationSchema), mode: "all" }); + + const onSubmit = async (data) => { + await requestServer(`${REFER_VERIFY_NEADROAD_ROAD_INQUIRY_PRIVACY_ZAMIN_GOV_ASSISTANT}/${rowId}`, "post", { + data: { + expert_description: data.description + }, + }) + .then(() => { + handleClose(); + setOpenReferDialog(false) + mutate(); + }) + .catch(() => { }); + }; + + return ( + <> + + + ( + + )} + /> + + + + + + + ) +} +export default ReferForm \ No newline at end of file diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/Refer/index.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/Refer/index.jsx new file mode 100644 index 0000000..1fc664c --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/Refer/index.jsx @@ -0,0 +1,34 @@ +import { Close } from "@mui/icons-material"; +import { Button, Dialog, DialogTitle, IconButton } from "@mui/material" +import { useState } from "react"; +import ReferForm from "./Form"; + +const Refer = ({ rowId, mutate, handleClose, isSubmitting }) => { + const [openReferDialog, setOpenReferDialog] = useState(false); + + return ( + <> + + { setOpenReferDialog(false) }} maxWidth="xs" fullWidth> + setOpenReferDialog(false)} + sx={{ + position: "absolute", + right: 8, + top: 8, + zIndex: 10, + color: (theme) => theme.palette.grey[500], + }} + > + + + مخالفت و ارجاع به دفتر حریم + {openReferDialog && } + + + ) +} +export default Refer \ No newline at end of file diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/index.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/index.jsx new file mode 100644 index 0000000..b8b016b --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/index.jsx @@ -0,0 +1,65 @@ +import StyledForm from "@/core/components/StyledForm"; +import { CONFIRM_INQUIRY_PRIVACY_ZAMIN_GOV_ASSISTANT, CONFIRM_VERIFY_NEADROAD_ROAD_INQUIRY_PRIVACY_ZAMIN_GOV_ASSISTANT } from "@/core/utils/routes"; +import useRequest from "@/lib/hooks/useRequest"; +import { yupResolver } from "@hookform/resolvers/yup"; +import { Button, DialogActions, DialogContent, Stack } from "@mui/material"; +import { useForm } from "react-hook-form"; +import { object, string } from "yup"; +import QuestionVerifyNeedRoadForm from "./QuestionVerifyNeedRoadForm"; +import QuestionVerifyRoadSafetyForm from "./QuestionVerifyRoadSafetyForm"; +import Refer from "./Refer"; +import DescriptionForm from "./DescriptionForm"; + +const validationSchema = object({ + description: string().required("وارد کردن توضیحات الزامیست!"), +}); + +const defaultValues = { + description: "", +}; + +const Questions = ({ row, rowId, mutate, handleClose, handlePrev }) => { + const requestServer = useRequest({ notificationSuccess: true }); + + const { + control, + handleSubmit, + formState: { isSubmitting }, + } = useForm({ defaultValues, resolver: yupResolver(validationSchema), mode: "all" }); + + const onSubmit = async (data) => { + await requestServer(`${CONFIRM_VERIFY_NEADROAD_ROAD_INQUIRY_PRIVACY_ZAMIN_GOV_ASSISTANT}/${rowId}`, "post", { + data: { + expert_description: data.description + }, + }) + .then(() => { + handleClose(); + mutate(); + }) + .catch(() => { }); + }; + + return ( + + + + + + + + + + + + + + + + ) +} +export default Questions \ No newline at end of file diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/index.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/index.jsx new file mode 100644 index 0000000..d1548ed --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/index.jsx @@ -0,0 +1,51 @@ +import { Close, ThumbUp } from "@mui/icons-material"; +import { Dialog, IconButton, Stack, Tooltip } from "@mui/material"; +import { useState } from "react"; +import ConfirmRoadSafetyDialog from "./ConfirmRoadSafetyDialog"; + +const ConfirmVerifyLicenseForm = ({ row, rowId, mutate }) => { + const [openConfirmVerifyLicenseForm, setOpenConfirmVerifyLicenseForm] = useState(false); + + const openConfirmVerifyLicenseFormDialog = () => { + setOpenConfirmVerifyLicenseForm(true); + }; + + const handleClose = () => { + setOpenConfirmVerifyLicenseForm(false); + }; + + return ( + + + { + openConfirmVerifyLicenseFormDialog(); + }} + > + + + + + handleClose()} + sx={{ + position: "absolute", + right: 8, + top: 8, + zIndex: 10, + color: (theme) => theme.palette.grey[500], + }} + > + + + {openConfirmVerifyLicenseForm && ( + + )} + + + ); +}; +export default ConfirmVerifyLicenseForm; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/ConfirmRoadSafetyDialog.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/ConfirmRoadSafetyDialog.jsx new file mode 100644 index 0000000..f3a693a --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/ConfirmRoadSafetyDialog.jsx @@ -0,0 +1,43 @@ +import DialogLoading from "@/core/components/DialogLoading"; +import { GET_REQUEST_INQUIRY_PRIVACY_ZAMIN_GOV_ASSISTANT_DETAILS } from "@/core/utils/routes"; +import useRequest from "@/lib/hooks/useRequest"; +import { DialogContent, Typography } from "@mui/material"; +import { useEffect, useState } from "react"; +import ConfirmRoadSafetyFormContext from "./ConfirmRoadSafetyFormContext"; + +const ConfirmRoadSafetyDialog = ({ row, handleClose, rowId, mutate }) => { + 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_REQUEST_INQUIRY_PRIVACY_ZAMIN_GOV_ASSISTANT_DETAILS}/${rowId}`); + setData(response.data.data); + } catch (error) { + } finally { + setLoading(false); + } + }; + + fetchData(); + }, [rowId]); + + return ( + <> + {loading ? ( + + ) : data ? ( + + ) : ( + + اطلاعات درخواست در سامانه یافت نشد + + )} + + ); + +} +export default ConfirmRoadSafetyDialog \ No newline at end of file diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/ConfirmRoadSafetyFormContext.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/ConfirmRoadSafetyFormContext.jsx new file mode 100644 index 0000000..7b1fd02 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/ConfirmRoadSafetyFormContext.jsx @@ -0,0 +1,92 @@ +import ApplicantRequestDetail from "@/core/components/ApplicantRequestDetail"; +import TabPanel from "@/core/components/TabPanel"; +import { DoneAll, ExitToApp, InsertDriveFile, Route } from "@mui/icons-material"; +import { Button, DialogActions, DialogContent, Stack, Tab, Tabs } from "@mui/material"; +import { useState } from "react"; +import PrevCartableOpinion from "./PrevCartableOpinion"; +import Questions from "./Questions"; + + + +const ConfirmRoadSafetyFormContext = ({ row, data, rowId, mutate, handleClose }) => { + const [tabState, setTabState] = useState(0); + + const handleChangeTab = (event, newValue) => { + setTabState(newValue); + }; + + const handlePrev = () => { + if (tabState === 0) { + handleClose(); + } else { + setTabState((t) => t - 1); + } + }; + + return ( + <> + + } label="اطلاعات طرح متقاضی" /> + } label="جریان فرایند" /> + } label="تاییدیه دسترسی راه" /> + + + + + + + + + + + + + + {data.histories.map((item, index) => ( + + ))} + + + + + + + + + + + + ); +}; +export default ConfirmRoadSafetyFormContext; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/PrevCartableOpinion.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/PrevCartableOpinion.jsx new file mode 100644 index 0000000..37fe672 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/PrevCartableOpinion.jsx @@ -0,0 +1,16 @@ +import { Card, CardContent, CircularProgress, Stack, Typography } from "@mui/material"; + +const PrevCartableOpinion = ({ item }) => { + + return ( + + + + {item.previous_state_name}: {item.action_name} + توضیحات: {item.expert_description} + + + + ); +}; +export default PrevCartableOpinion; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/DescriptionForm.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/DescriptionForm.jsx new file mode 100644 index 0000000..a7099e7 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/DescriptionForm.jsx @@ -0,0 +1,29 @@ +import { Stack, TextField } from "@mui/material"; +import { Controller } from "react-hook-form"; + +const DescriptionForm = ({ control }) => { + return ( + + ( + + )} + /> + + ); +}; +export default DescriptionForm; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/QuestionVerifyNeedRoadForm.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/QuestionVerifyNeedRoadForm.jsx new file mode 100644 index 0000000..558d200 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/QuestionVerifyNeedRoadForm.jsx @@ -0,0 +1,34 @@ +import { + Card, + CardContent, + Stack, + Typography +} from "@mui/material"; + +const QuestionVerifyNeedRoadForm = ({ row }) => { + return ( + + + + + آیا دسترسی به راه مورد تایید است؟ + + + دفتر حریم راه : + + {row.original.is_file_good == 1 ? "بله" : "خیر"} + + + + + + ); +}; +export default QuestionVerifyNeedRoadForm; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/Refer/Form.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/Refer/Form.jsx new file mode 100644 index 0000000..cf2095e --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/Refer/Form.jsx @@ -0,0 +1,70 @@ +import { REFER_VERIFY_NEADROAD_ROAD_INQUIRY_PRIVACY_ZAMIN_GOV_ASSISTANT } from "@/core/utils/routes"; +import useRequest from "@/lib/hooks/useRequest"; +import { yupResolver } from "@hookform/resolvers/yup"; +import { Button, DialogActions, DialogContent, Stack, TextField } from "@mui/material"; +import { Controller, useForm } from "react-hook-form"; +import { object, string } from "yup"; +const validationSchema = object({ + description: string().required("وارد کردن توضیحات الزامیست!"), +}); + +const defaultValues = { + description: "", +}; + +const ReferForm = ({ rowId, mutate, handleClose, setOpenReferDialog }) => { + const requestServer = useRequest({ notificationSuccess: true }); + const { + control, + handleSubmit, + formState: { isSubmitting }, + } = useForm({ defaultValues, resolver: yupResolver(validationSchema), mode: "all" }); + + const onSubmit = async (data) => { + await requestServer(`${REFER_VERIFY_NEADROAD_ROAD_INQUIRY_PRIVACY_ZAMIN_GOV_ASSISTANT}/${rowId}`, "post", { + data: { + expert_description: data.description + }, + }) + .then(() => { + handleClose(); + setOpenReferDialog(false) + mutate(); + }) + .catch(() => { }); + }; + + return ( + <> + + + ( + + )} + /> + + + + + + + ) +} +export default ReferForm \ No newline at end of file diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/Refer/index.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/Refer/index.jsx new file mode 100644 index 0000000..1fc664c --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/Refer/index.jsx @@ -0,0 +1,34 @@ +import { Close } from "@mui/icons-material"; +import { Button, Dialog, DialogTitle, IconButton } from "@mui/material" +import { useState } from "react"; +import ReferForm from "./Form"; + +const Refer = ({ rowId, mutate, handleClose, isSubmitting }) => { + const [openReferDialog, setOpenReferDialog] = useState(false); + + return ( + <> + + { setOpenReferDialog(false) }} maxWidth="xs" fullWidth> + setOpenReferDialog(false)} + sx={{ + position: "absolute", + right: 8, + top: 8, + zIndex: 10, + color: (theme) => theme.palette.grey[500], + }} + > + + + مخالفت و ارجاع به دفتر حریم + {openReferDialog && } + + + ) +} +export default Refer \ No newline at end of file diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/index.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/index.jsx new file mode 100644 index 0000000..a52b00c --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/index.jsx @@ -0,0 +1,64 @@ +import StyledForm from "@/core/components/StyledForm"; +import { CONFIRM_VERIFY_NEADROAD_ROAD_INQUIRY_PRIVACY_ZAMIN_GOV_ASSISTANT } from "@/core/utils/routes"; +import useRequest from "@/lib/hooks/useRequest"; +import { yupResolver } from "@hookform/resolvers/yup"; +import { Button, DialogActions, DialogContent, Stack } from "@mui/material"; +import { useForm } from "react-hook-form"; +import { object, string } from "yup"; +import QuestionVerifyNeedRoadForm from "./QuestionVerifyNeedRoadForm"; +import Refer from "./Refer"; +import DescriptionForm from "./DescriptionForm"; + +const validationSchema = object({ + description: string().required("وارد کردن توضیحات الزامیست!"), +}); + +const defaultValues = { + description: "", +}; + +const Questions = ({ row, rowId, mutate, handleClose, handlePrev }) => { + const requestServer = useRequest({ notificationSuccess: true }); + + const { + control, + handleSubmit, + formState: { isSubmitting }, + } = useForm({ defaultValues, resolver: yupResolver(validationSchema), mode: "all" }); + + const onSubmit = async (data) => { + await requestServer(`${CONFIRM_VERIFY_NEADROAD_ROAD_INQUIRY_PRIVACY_ZAMIN_GOV_ASSISTANT}/${rowId}`, "post", { + data: { + expert_description: data.description + }, + }) + .then(() => { + handleClose(); + mutate(); + }) + .catch(() => { }); + }; + + return ( + + + + + + + + + + + + + + + + ) +} +export default Questions \ No newline at end of file diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/index.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/index.jsx new file mode 100644 index 0000000..213d593 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/index.jsx @@ -0,0 +1,51 @@ +import { Close, DoneAll } from "@mui/icons-material"; +import { Dialog, IconButton, Stack, Tooltip } from "@mui/material"; +import { useState } from "react"; +import ConfirmRoadSafetyDialog from "./ConfirmRoadSafetyDialog"; + +const ConfirmVerifyRoadSafetyForm = ({ row, rowId, mutate }) => { + const [openConfirmVerifyRoadSafetyForm, setOpenConfirmVerifyRoadSafetyForm] = useState(false); + + const openConfirmVerifyRoadSafetyDialog = () => { + setOpenConfirmVerifyRoadSafetyForm(true); + }; + + const handleClose = () => { + setOpenConfirmVerifyRoadSafetyForm(false); + }; + + return ( + + + { + openConfirmVerifyRoadSafetyDialog(); + }} + > + + + + + handleClose()} + sx={{ + position: "absolute", + right: 8, + top: 8, + zIndex: 10, + color: (theme) => theme.palette.grey[500], + }} + > + + + {openConfirmVerifyRoadSafetyForm && ( + + )} + + + ); +}; +export default ConfirmVerifyRoadSafetyForm; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/index.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/index.jsx new file mode 100644 index 0000000..58261f4 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/index.jsx @@ -0,0 +1,22 @@ +import { Box } from "@mui/material"; +import ConfirmRoadSafetyForm from "./ConfirmRoadSafetyForm"; +import ConfirmVerifyRoadSafetyForm from "./ConfirmVerifyRoadSafetyForm"; +import ConfirmVerifyLicenseForm from "./ConfirmVerifyLicenseForm"; + +const RowActions = ({ row, mutate }) => { + return ( + <> + // + // {row.original.state_id == 3 && ( + // + // )} + // {row.original.state_id == 6 && ( + // + // )} + // {row.original.state_id == 14 && ( + // + // )} + // + ); +}; +export default RowActions; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/ShowPrimaryArea/ShowBound.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/ShowPrimaryArea/ShowBound.jsx new file mode 100644 index 0000000..24db476 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/ShowPrimaryArea/ShowBound.jsx @@ -0,0 +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; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/ShowPrimaryArea/index.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/ShowPrimaryArea/index.jsx new file mode 100644 index 0000000..e4714de --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/ShowPrimaryArea/index.jsx @@ -0,0 +1,60 @@ +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 { useMemo, useState } from "react"; +import ShowBound from "./ShowBound"; +import L from "leaflet"; + +const ShowPrimaryArea = ({ primaryArea }) => { + const [openShowAreaDialog, setOpenShowAreaDialog] = useState(false); + const bound = useMemo(() => { + const latLngCoords = primaryArea.coordinates.map((coord) => [coord[1], coord[0]]); + return primaryArea.type === "polygon" ? L.polygon(latLngCoords) : L.polyline(latLngCoords); + }, [primaryArea]); + + return ( + + + setOpenShowAreaDialog(true)}> + + + + setOpenShowAreaDialog(false)} + PaperProps={{ + sx: { + transition: "all .3s", + boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px", + borderRadius: 2, + padding: 1, + }, + }} + maxWidth="sm" + fullWidth + dir="rtl" + > + + + محدوده طرح + + setOpenShowAreaDialog(false)} size="small"> + + + + + + + + + + + + + + + ); +}; + +export default ShowPrimaryArea; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/TechnicalDeputyList.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/TechnicalDeputyList.jsx new file mode 100644 index 0000000..bb3ec27 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/TechnicalDeputyList.jsx @@ -0,0 +1,190 @@ +"use client"; + +import DataTableWithAuth from "@/core/components/DataTableWithAuth"; +import { GET_INQUIRY_PRIVACY_TABLE_LIST } from "@/core/utils/routes"; +import { Box, Stack } from "@mui/material"; +import moment from "jalali-moment"; +import { useMemo } from "react"; +import RowActions from "./RowActions"; +import ShowPrimaryArea from "./ShowPrimaryArea"; + +const TechnicalDeputyList = () => { + const columns = useMemo( + () => [ + { + accessorKey: "id", + header: "کد یکتا", + id: "id", + enableColumnFilter: false, + datatype: "text", + filterMode: "notEquals", + size: 100, + }, + { + accessorKey: "panjare_vahed_id", + header: "کدرهگیری پنجره واحد", + id: "panjare_vahed_id", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 150, + }, + { + accessorKey: "national_id", + header: "کد ملی", + id: "national_id", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + size: 120, + }, + { + accessorKey: "phone_number", + header: "تلفن", + id: "phone_number", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + size: 120, + }, + { + accessorKey: "state_name", + header: "وضعیت درخواست", + id: "state_name", + enableColumnFilter: false, + datatype: "text", + filterMode: "equals", + }, + { + accessorKey: "payment_amount", + header: "مبلغ پرداختی", + id: "payment_amount", + enableColumnFilter: true, + datatype: "text", + filterMode: "between", + Cell: ({ row }) => <>{row.original.payment_amount || "-"}, + }, + { + accessorKey: "requested_organization", + header: "دستگاه صادر کننده", + id: "requested_organization", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + }, + { + accessorKey: "province_name", + header: "استان", + id: "province_name", + enableColumnFilter: false, + datatype: "text", + filterMode: "equals", + }, + { + accessorKey: "city_name", + header: "شهر", + id: "city_name", + enableColumnFilter: false, + datatype: "text", + filterMode: "equals", + }, + { + accessorKey: "plan_group", + header: "گروه طرح", + id: "plan_group", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + }, + { + accessorKey: "plan_title", + header: "عنوان طرح", + id: "plan_title", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + }, + { + accessorKey: "primary_area", + header: "نمایش محدوده طرح", + id: "primary_area", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ row }) => + row.original.primary_area ? ( + + + + ) : ( + "-" + ), + }, + { + accessorKey: "worksheet_id", + header: "شناسه کاربرگ", + id: "worksheet_id", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + }, + { + accessorKey: "isic", + header: "کد آیسیک", + id: "isic", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + }, + { + accessorFn: (row) => moment(row.request_date).locale("fa").format("YYYY/MM/DD"), + header: "تاریخ درخواست", + id: "request_date", + enableColumnFilter: true, + datatype: "date", + filterMode: "between", + grow: false, + size: 120, + }, + ], + [] + ); + + return ( + <> + + + + + ); +}; +export default TechnicalDeputyList; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/index.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/index.jsx new file mode 100644 index 0000000..2b9a26a --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/index.jsx @@ -0,0 +1,15 @@ +"use client"; + +import PageTitle from "@/core/components/PageTitle"; +import { Stack } from "@mui/material"; +import TechnicalDeputyList from "./TechnicalDeputyList"; + +const TechnicalDeputy = () => { + return ( + + + + + ); +}; +export default TechnicalDeputy; diff --git a/src/core/components/TabPanel.jsx b/src/core/components/TabPanel.jsx new file mode 100644 index 0000000..529fad0 --- /dev/null +++ b/src/core/components/TabPanel.jsx @@ -0,0 +1,11 @@ +import { Box } from "@mui/material"; + +const TabPanel = (props) => { + const { children, value, index } = props; + return ( + + ); +}; +export default TabPanel; diff --git a/src/core/utils/pageMenuDev.js b/src/core/utils/pageMenuDev.js index 23c42d7..7a68cb6 100644 --- a/src/core/utils/pageMenuDev.js +++ b/src/core/utils/pageMenuDev.js @@ -318,7 +318,7 @@ export const pageMenuDev = [ id: "assistant", label: "کارتابل معاون", type: "page", - route: "/dashboard/inquiry-privacy/assistant", + route: "/dashboard/inquiry-privacy/technical-deputy", icon: , permissions: ["all"], }, diff --git a/src/core/utils/routes.js b/src/core/utils/routes.js index b2bb76d..e9e7119 100644 --- a/src/core/utils/routes.js +++ b/src/core/utils/routes.js @@ -241,3 +241,4 @@ export const GET_INQUIRY_PRIVACY_STATE_LIST = api + "/api/v3/harim/detail/states export const CITY_ADMIN_FEEDBACK = api + "/api/v3/harim/province_office/feedback"; export const GET_PRIVACY_ADMIN_LIST = api + "/api/v3/harim/harim_office"; export const PRIVACY_ADMIN_ACTION_API = api + "/api/v3/harim/harim_office"; +export const GET_INQUIRY_PRIVACY_TABLE_LIST = api + "/api/v3/harim/technical_deputy"; From 65beffa11eb5fbc904cb0c978bbb028b9538d2b2 Mon Sep 17 00:00:00 2001 From: AminGhasempoor Date: Wed, 26 Nov 2025 11:33:09 +0330 Subject: [PATCH 26/61] general manager show --- .../inquiry-privacy/general-manager/page.js | 3 +- .../general-manager/GeneralManagerList.jsx | 243 ++++++++++++++++++ .../RowActions/ConfirmAction/index.jsx | 17 ++ .../RowActions/RejectAction/index.jsx | 17 ++ .../general-manager/RowActions/index.jsx | 13 + .../ShowPrimaryArea/ShowBound.jsx | 29 +++ .../general-manager/ShowPrimaryArea/index.jsx | 69 +++++ .../inquiryPrivacy/general-manager/index.jsx | 14 + src/core/utils/routes.js | 1 + 9 files changed, 405 insertions(+), 1 deletion(-) create mode 100644 src/components/dashboard/inquiryPrivacy/general-manager/GeneralManagerList.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/general-manager/RowActions/ConfirmAction/index.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/general-manager/RowActions/RejectAction/index.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/general-manager/RowActions/index.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/general-manager/ShowPrimaryArea/ShowBound.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/general-manager/ShowPrimaryArea/index.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/general-manager/index.jsx diff --git a/src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/general-manager/page.js b/src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/general-manager/page.js index e24a103..763114c 100644 --- a/src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/general-manager/page.js +++ b/src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/general-manager/page.js @@ -1,11 +1,12 @@ import WithPermission from "@/core/middlewares/withPermission"; +import GeneralManagerPage from "@/components/dashboard/inquiryPrivacy/general-manager"; export const metadata = { title: "کارتابل مدیر", }; const Page = () => { return ( -

کارتابل مدیر

+
); }; diff --git a/src/components/dashboard/inquiryPrivacy/general-manager/GeneralManagerList.jsx b/src/components/dashboard/inquiryPrivacy/general-manager/GeneralManagerList.jsx new file mode 100644 index 0000000..4abd643 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/general-manager/GeneralManagerList.jsx @@ -0,0 +1,243 @@ +import CustomSelectByDependency from "@/core/components/DataTable/filter/fieldsType/CustomSelectByDependency"; +import DataTableWithAuth from "@/core/components/DataTableWithAuth"; +import useInquiryPrivacyState from "@/lib/hooks/useInquiryPrivacyState"; +import AutorenewIcon from "@mui/icons-material/Autorenew"; +import DangerousIcon from "@mui/icons-material/Dangerous"; +import ManageAccountsIcon from "@mui/icons-material/ManageAccounts"; +import MapsHomeWorkIcon from "@mui/icons-material/MapsHomeWork"; +import PsychologyAltIcon from "@mui/icons-material/PsychologyAlt"; +import ReceiptLongIcon from "@mui/icons-material/ReceiptLong"; +import SecurityIcon from "@mui/icons-material/Security"; +import WindowIcon from "@mui/icons-material/Window"; +import { Box, Stack } from "@mui/material"; +import moment from "jalali-moment"; +import { useMemo } from "react"; +import RowActions from "./RowActions"; +import { GET_GENERAL_MANAGER_LIST } from "@/core/utils/routes"; +import ShowPrimaryArea from "./ShowPrimaryArea"; + +const GeneralManagerList = () => { + const stateIcon = (state_id) => { + if (state_id === 1) return ; + if (state_id === 2 || state_id === 5 || state_id === 13) return ; + if (state_id === 3 || state_id === 6 || state_id === 14) + return ; + if (state_id === 4 || state_id === 7 || state_id === 15) return ; + if (state_id === 8) return ; + if (state_id === 9 || state_id === 11) return ; + if (state_id === 10) return ; + if (state_id === 12) return ; + }; + const columns = useMemo(() => { + return [ + { + accessorKey: "panjare_vahed_id", + header: "کدرهگیری درخواست", + id: "panjare_vahed_id", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ row }) => <>{row.original.panjare_vahed_id}, + }, + { + accessorKey: "national_id", + header: "کد ملی", + id: "national_id", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ row }) => <>{row.original.national_id}, + }, + { + accessorKey: "state_id", + header: "وضعیت", + id: "state_id", + enableColumnFilter: true, + datatype: "numeric", + filterMode: "equals", + sortDescFirst: false, + grow: false, + size: 100, + ColumnSelectComponent: (props) => { + const { itemsList, loadingItemsList, errorItemsList } = useInquiryPrivacyState(); + + const getColumnSelectOptions = useMemo(() => { + if (loadingItemsList) { + return [{ value: "loading", label: "در حال بارگذاری..." }]; + } + if (errorItemsList) { + return [{ value: "error", label: "خطا در بارگذاری" }]; + } + return [ + { value: "", label: "همه موارد" }, + ...itemsList.map((item) => ({ + value: item.id, + label: item.name, + })), + ]; + }, [itemsList, loadingItemsList, errorItemsList]); + + return ( + + ); + }, + Cell: ({ row }) => ( + + {stateIcon(row.original.state_id)} + + {row.original.state_name} + + + ), + }, + { + accessorKey: "plan_title", + header: "عنوان طرح", + id: "plan_title", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ row }) => <>{row.original.plan_title}, + }, + { + accessorKey: "plan_group", + header: "گروه طرح", + id: "plan_group", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ row }) => <>{row.original.plan_group}, + }, + { + accessorKey: "requested_organization", + header: "دستگاه صادر کننده", + id: "requested_organization", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ row }) => <>{row.original.requested_organization}, + }, + { + accessorKey: "worksheet_id", + header: "شناسه کاربرگ", + id: "worksheet_id", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ row }) => <>{row.original.worksheet_id}, + }, + { + accessorKey: "primary_area", + header: "نمایش محدوده طرح", + id: "primary_area", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ row }) => + row.original.primary_area ? ( + + + + ) : ( + "-" + ), + }, + { + accessorKey: "province_id", + header: "استان", + id: "province_id", + enableColumnFilter: false, + datatype: "numeric", + sortDescFirst: false, + grow: false, + size: 100, + Cell: ({ row }) => <>{row.original.province_name}, + }, + { + accessorKey: "city_id", + header: "شهر", + id: "city_id", + enableColumnFilter: false, + datatype: "numeric", + sortDescFirst: false, + grow: false, + size: 100, + Cell: ({ row }) => <>{row.original.city_name}, + }, + { + accessorKey: "isic", + header: "کد آیسیک", + id: "isic", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ row }) => <>{row.original.isic}, + }, + { + accessorFn: (row) => moment(row.request_date).locale("fa").format("YYYY/MM/DD"), + header: "تاریخ درخواست", + id: "request_date", + enableColumnFilter: true, + datatype: "date", + filterMode: "between", + grow: false, + size: 100, + }, + ]; + }, []); + + return ( + <> + + + + + ); +}; + +export default GeneralManagerList; diff --git a/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/ConfirmAction/index.jsx b/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/ConfirmAction/index.jsx new file mode 100644 index 0000000..c2a0cfc --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/ConfirmAction/index.jsx @@ -0,0 +1,17 @@ +import ThumbUpIcon from "@mui/icons-material/ThumbUp"; +import { IconButton, Tooltip } from "@mui/material"; +import { useState } from "react"; + +const ConfirmAction = ({ rowId, mutate }) => { + const [openConfirmDialog, setOpenConfirmDialog] = useState(false); + return ( + <> + + setOpenConfirmDialog(true)}> + + + + + ); +}; +export default ConfirmAction; diff --git a/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/RejectAction/index.jsx b/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/RejectAction/index.jsx new file mode 100644 index 0000000..c16a405 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/RejectAction/index.jsx @@ -0,0 +1,17 @@ +import ThumbDownIcon from "@mui/icons-material/ThumbDown"; +import { IconButton, Tooltip } from "@mui/material"; +import { useState } from "react"; + +const RejectAction = ({ rowId, mutate }) => { + const [openRejectDialog, setOpenRejectDialog] = useState(false); + return ( + <> + + setOpenRejectDialog(true)}> + + + + + ); +}; +export default RejectAction; diff --git a/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/index.jsx b/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/index.jsx new file mode 100644 index 0000000..06ea132 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/index.jsx @@ -0,0 +1,13 @@ +import { Box } from "@mui/material"; +import ConfirmAction from "./ConfirmAction"; +import RejectAction from "./RejectAction"; + +const RowActions = ({ row, mutate }) => { + return ( + + + + + ); +}; +export default RowActions; diff --git a/src/components/dashboard/inquiryPrivacy/general-manager/ShowPrimaryArea/ShowBound.jsx b/src/components/dashboard/inquiryPrivacy/general-manager/ShowPrimaryArea/ShowBound.jsx new file mode 100644 index 0000000..24db476 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/general-manager/ShowPrimaryArea/ShowBound.jsx @@ -0,0 +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; diff --git a/src/components/dashboard/inquiryPrivacy/general-manager/ShowPrimaryArea/index.jsx b/src/components/dashboard/inquiryPrivacy/general-manager/ShowPrimaryArea/index.jsx new file mode 100644 index 0000000..98e24d0 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/general-manager/ShowPrimaryArea/index.jsx @@ -0,0 +1,69 @@ +const { + Button, + IconButton, + Tooltip, + Box, + Dialog, + DialogTitle, + Typography, + DialogContent, + DialogActions, +} = require("@mui/material"); +import LayersIcon from "@mui/icons-material/Layers"; +import CloseIcon from "@mui/icons-material/Close"; +import { useMemo, useState } from "react"; +import MapLayer from "@/core/components/MapLayer"; +import ShowBound from "./ShowBound"; + +const ShowPrimaryArea = ({ primaryArea }) => { + const [openShowAreaDialog, setOpenShowAreaDialog] = useState(false); + const bound = useMemo(() => { + const latLngCoords = primaryArea.coordinates.map((coord) => [coord[1], coord[0]]); + return primaryArea.type === "polygon" ? L.polygon(latLngCoords) : L.polyline(latLngCoords); + }, [primaryArea]); + + return ( + + + setOpenShowAreaDialog(true)}> + + + + setOpenShowAreaDialog(false)} + PaperProps={{ + sx: { + transition: "all .3s", + boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px", + borderRadius: 2, + padding: 1, + }, + }} + maxWidth="sm" + fullWidth + dir="rtl" + > + + + محدوده طرح + + setOpenShowAreaDialog(false)} size="small"> + + + + + + + + + + + + + + + ); +}; + +export default ShowPrimaryArea; diff --git a/src/components/dashboard/inquiryPrivacy/general-manager/index.jsx b/src/components/dashboard/inquiryPrivacy/general-manager/index.jsx new file mode 100644 index 0000000..3e166e3 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/general-manager/index.jsx @@ -0,0 +1,14 @@ +"use client"; +import PageTitle from "@/core/components/PageTitle"; +import { Stack } from "@mui/material"; +import GeneralManagerList from "./GeneralManagerList"; + +const GeneralManagerPage = () => { + return ( + + + + + ); +}; +export default GeneralManagerPage; diff --git a/src/core/utils/routes.js b/src/core/utils/routes.js index 8572b6f..a2e65a9 100644 --- a/src/core/utils/routes.js +++ b/src/core/utils/routes.js @@ -240,3 +240,4 @@ export const GET_CITY_ADMIN_LIST = api + "/api/v3/harim/province_office"; export const GET_INQUIRY_PRIVACY_STATE_LIST = api + "/api/v3/harim/detail/states"; export const CITY_ADMIN_FEEDBACK = api + "/api/v3/harim/province_office/feedback"; export const GET_PRIVACY_ADMIN_LIST = api + "/api/v3/harim/harim_office"; +export const GET_GENERAL_MANAGER_LIST = api + "/api/v3/harim/general_manager"; From efe47523a20d09b94f150a590f6099791016356b Mon Sep 17 00:00:00 2001 From: AminGhasempoor Date: Wed, 26 Nov 2025 15:06:53 +0330 Subject: [PATCH 27/61] harim manager --- .../RowActions/History/HistoryContent.jsx | 17 ++++++ .../RowActions/History/TableContent.jsx | 56 +++++++++++++++++++ .../city-admin/RowActions/History/index.jsx | 33 +++++++++++ .../city-admin/RowActions/index.jsx | 2 + .../RowActions/History/HistoryContent.jsx | 17 ++++++ .../RowActions/History/TableContent.jsx | 56 +++++++++++++++++++ .../RowActions/History/index.jsx | 33 +++++++++++ .../general-manager/RowActions/index.jsx | 9 +++ .../RowActions/ConfirmAction/index.jsx | 1 + .../RowActions/History/HistoryContent.jsx | 17 ++++++ .../RowActions/History/TableContent.jsx | 56 +++++++++++++++++++ .../RowActions/History/index.jsx | 33 +++++++++++ .../RowActions/ReferralAction/index.jsx | 1 + .../RowActions/RejectAction/index.jsx | 1 + .../privacy-office/RowActions/index.jsx | 2 + .../RowActions/History/HistoryContent.jsx | 17 ++++++ .../RowActions/History/TableContent.jsx | 56 +++++++++++++++++++ .../RowActions/History/index.jsx | 33 +++++++++++ src/core/utils/routes.js | 3 + src/lib/hooks/useHistory.js | 30 ++++++++++ 20 files changed, 473 insertions(+) create mode 100644 src/components/dashboard/inquiryPrivacy/city-admin/RowActions/History/HistoryContent.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/city-admin/RowActions/History/TableContent.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/city-admin/RowActions/History/index.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/general-manager/RowActions/History/HistoryContent.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/general-manager/RowActions/History/TableContent.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/general-manager/RowActions/History/index.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/History/HistoryContent.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/History/TableContent.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/History/index.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/History/HistoryContent.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/History/TableContent.jsx create mode 100644 src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/History/index.jsx create mode 100644 src/lib/hooks/useHistory.js diff --git a/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/History/HistoryContent.jsx b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/History/HistoryContent.jsx new file mode 100644 index 0000000..71f59c1 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/History/HistoryContent.jsx @@ -0,0 +1,17 @@ +import { Button, DialogActions, DialogContent } from "@mui/material"; +import TableContent from "./TableContent"; +const HistoryContent = ({ setOpenReferReasonDialog, rowId }) => { + return ( + <> + + + + + + + + ); +}; +export default HistoryContent; diff --git a/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/History/TableContent.jsx b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/History/TableContent.jsx new file mode 100644 index 0000000..cd3afb0 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/History/TableContent.jsx @@ -0,0 +1,56 @@ +import { Box, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, CircularProgress, Typography } from "@mui/material"; +import "moment/locale/fa"; +import { useHistory } from "@/lib/hooks/useHistory"; + +const TableContent = ({ rowId }) => { + const { historyData, loading, error } = useHistory(rowId); + + if (loading) { + return ( + + + + ); + } + + if (error) { + return ( + + {error} + + ); + } + + if (!historyData.length) { + return ( + + اطلاعاتی وجود ندارد + + ); + } + + return ( + + + + + + وضعیت + توضیحات کارشناس + + + + {historyData.map((row) => ( + + {row.previous_state_name} + {row.expert_description} + + ))} + +
+
+
+ ); +}; + +export default TableContent; diff --git a/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/History/index.jsx b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/History/index.jsx new file mode 100644 index 0000000..234ac15 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/History/index.jsx @@ -0,0 +1,33 @@ +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { RestorePage } from "@mui/icons-material"; +import HistoryContent from "./HistoryContent"; +import { useState } from "react"; + +const History = ({ rowId }) => { + const [openReferReasonDialog, setOpenReferReasonDialog] = useState(false); + + return ( + <> + + setOpenReferReasonDialog(true)}> + + + + + تاریخچه + + + + ); +}; + +export default History; diff --git a/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/index.jsx b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/index.jsx index cb1517b..a432d18 100644 --- a/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/index.jsx @@ -1,5 +1,6 @@ import { Box } from "@mui/material"; import FeedbackAction from "./FeedbackAction"; +import History from "./History"; const RowActions = ({ row, mutate }) => { return ( @@ -9,6 +10,7 @@ const RowActions = ({ row, mutate }) => { ) : ( "-" )} +
); }; diff --git a/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/History/HistoryContent.jsx b/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/History/HistoryContent.jsx new file mode 100644 index 0000000..71f59c1 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/History/HistoryContent.jsx @@ -0,0 +1,17 @@ +import { Button, DialogActions, DialogContent } from "@mui/material"; +import TableContent from "./TableContent"; +const HistoryContent = ({ setOpenReferReasonDialog, rowId }) => { + return ( + <> + + + + + + + + ); +}; +export default HistoryContent; diff --git a/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/History/TableContent.jsx b/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/History/TableContent.jsx new file mode 100644 index 0000000..cd3afb0 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/History/TableContent.jsx @@ -0,0 +1,56 @@ +import { Box, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, CircularProgress, Typography } from "@mui/material"; +import "moment/locale/fa"; +import { useHistory } from "@/lib/hooks/useHistory"; + +const TableContent = ({ rowId }) => { + const { historyData, loading, error } = useHistory(rowId); + + if (loading) { + return ( + + + + ); + } + + if (error) { + return ( + + {error} + + ); + } + + if (!historyData.length) { + return ( + + اطلاعاتی وجود ندارد + + ); + } + + return ( + + + + + + وضعیت + توضیحات کارشناس + + + + {historyData.map((row) => ( + + {row.previous_state_name} + {row.expert_description} + + ))} + +
+
+
+ ); +}; + +export default TableContent; diff --git a/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/History/index.jsx b/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/History/index.jsx new file mode 100644 index 0000000..234ac15 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/History/index.jsx @@ -0,0 +1,33 @@ +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { RestorePage } from "@mui/icons-material"; +import HistoryContent from "./HistoryContent"; +import { useState } from "react"; + +const History = ({ rowId }) => { + const [openReferReasonDialog, setOpenReferReasonDialog] = useState(false); + + return ( + <> + + setOpenReferReasonDialog(true)}> + + + + + تاریخچه + + + + ); +}; + +export default History; diff --git a/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/index.jsx b/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/index.jsx index 06ea132..1251678 100644 --- a/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/index.jsx @@ -1,12 +1,21 @@ import { Box } from "@mui/material"; import ConfirmAction from "./ConfirmAction"; import RejectAction from "./RejectAction"; +import History from "./History"; const RowActions = ({ row, mutate }) => { + // const stateId = row.original.state_id; + // + // const disabled = { + // referral: stateId !== 2, + // reject: stateId !== 2 && stateId !== 5, + // confirm: stateId !== 2 && stateId !== 5 && stateId !== 13, + // }; return ( + ); }; diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ConfirmAction/index.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ConfirmAction/index.jsx index 7820320..3903560 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ConfirmAction/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ConfirmAction/index.jsx @@ -2,6 +2,7 @@ import ThumbUpIcon from "@mui/icons-material/ThumbUp"; import { IconButton, Tooltip } from "@mui/material"; const ConfirmAction = ({ onClick, disabled }) => { + if (disabled) return return ( <> diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/History/HistoryContent.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/History/HistoryContent.jsx new file mode 100644 index 0000000..71f59c1 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/History/HistoryContent.jsx @@ -0,0 +1,17 @@ +import { Button, DialogActions, DialogContent } from "@mui/material"; +import TableContent from "./TableContent"; +const HistoryContent = ({ setOpenReferReasonDialog, rowId }) => { + return ( + <> + + + + + + + + ); +}; +export default HistoryContent; diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/History/TableContent.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/History/TableContent.jsx new file mode 100644 index 0000000..cd3afb0 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/History/TableContent.jsx @@ -0,0 +1,56 @@ +import { Box, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, CircularProgress, Typography } from "@mui/material"; +import "moment/locale/fa"; +import { useHistory } from "@/lib/hooks/useHistory"; + +const TableContent = ({ rowId }) => { + const { historyData, loading, error } = useHistory(rowId); + + if (loading) { + return ( + + + + ); + } + + if (error) { + return ( + + {error} + + ); + } + + if (!historyData.length) { + return ( + + اطلاعاتی وجود ندارد + + ); + } + + return ( + + + + + + وضعیت + توضیحات کارشناس + + + + {historyData.map((row) => ( + + {row.previous_state_name} + {row.expert_description} + + ))} + +
+
+
+ ); +}; + +export default TableContent; diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/History/index.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/History/index.jsx new file mode 100644 index 0000000..234ac15 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/History/index.jsx @@ -0,0 +1,33 @@ +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { RestorePage } from "@mui/icons-material"; +import HistoryContent from "./HistoryContent"; +import { useState } from "react"; + +const History = ({ rowId }) => { + const [openReferReasonDialog, setOpenReferReasonDialog] = useState(false); + + return ( + <> + + setOpenReferReasonDialog(true)}> + + + + + تاریخچه + + + + ); +}; + +export default History; diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ReferralAction/index.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ReferralAction/index.jsx index 85a693f..a5326f5 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ReferralAction/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ReferralAction/index.jsx @@ -2,6 +2,7 @@ import { Reply } from "@mui/icons-material"; import { IconButton, Tooltip } from "@mui/material"; const ReferralAction = ({ onClick, disabled }) => { + if (disabled) return return ( <> diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RejectAction/index.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RejectAction/index.jsx index e467e87..a4647b7 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RejectAction/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RejectAction/index.jsx @@ -2,6 +2,7 @@ import ThumbDownIcon from "@mui/icons-material/ThumbDown"; import { IconButton, Tooltip } from "@mui/material"; const RejectAction = ({ onClick, disabled }) => { + if (disabled) return return ( <> diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/index.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/index.jsx index 6cc004d..ed3df15 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/index.jsx @@ -4,6 +4,7 @@ import ActionDialog from "./ActionsDialog"; import ConfirmAction from "./ConfirmAction"; import ReferralAction from "./ReferralAction"; import RejectAction from "./RejectAction"; +import History from "./History"; const RowActions = ({ row: { original }, mutate }) => { const [modal, setModal] = useState({ @@ -31,6 +32,7 @@ const RowActions = ({ row: { original }, mutate }) => { return ( <> + handleOpenModal("refer_request", original)} disabled={disabled.referral} diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/History/HistoryContent.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/History/HistoryContent.jsx new file mode 100644 index 0000000..71f59c1 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/History/HistoryContent.jsx @@ -0,0 +1,17 @@ +import { Button, DialogActions, DialogContent } from "@mui/material"; +import TableContent from "./TableContent"; +const HistoryContent = ({ setOpenReferReasonDialog, rowId }) => { + return ( + <> + + + + + + + + ); +}; +export default HistoryContent; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/History/TableContent.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/History/TableContent.jsx new file mode 100644 index 0000000..cd3afb0 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/History/TableContent.jsx @@ -0,0 +1,56 @@ +import { Box, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, CircularProgress, Typography } from "@mui/material"; +import "moment/locale/fa"; +import { useHistory } from "@/lib/hooks/useHistory"; + +const TableContent = ({ rowId }) => { + const { historyData, loading, error } = useHistory(rowId); + + if (loading) { + return ( + + + + ); + } + + if (error) { + return ( + + {error} + + ); + } + + if (!historyData.length) { + return ( + + اطلاعاتی وجود ندارد + + ); + } + + return ( + + + + + + وضعیت + توضیحات کارشناس + + + + {historyData.map((row) => ( + + {row.previous_state_name} + {row.expert_description} + + ))} + +
+
+
+ ); +}; + +export default TableContent; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/History/index.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/History/index.jsx new file mode 100644 index 0000000..234ac15 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/History/index.jsx @@ -0,0 +1,33 @@ +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { RestorePage } from "@mui/icons-material"; +import HistoryContent from "./HistoryContent"; +import { useState } from "react"; + +const History = ({ rowId }) => { + const [openReferReasonDialog, setOpenReferReasonDialog] = useState(false); + + return ( + <> + + setOpenReferReasonDialog(true)}> + + + + + تاریخچه + + + + ); +}; + +export default History; diff --git a/src/core/utils/routes.js b/src/core/utils/routes.js index f479220..bbbe9f3 100644 --- a/src/core/utils/routes.js +++ b/src/core/utils/routes.js @@ -243,3 +243,6 @@ export const GET_PRIVACY_ADMIN_LIST = api + "/api/v3/harim/harim_office"; export const PRIVACY_ADMIN_ACTION_API = api + "/api/v3/harim/harim_office"; export const GET_INQUIRY_PRIVACY_TABLE_LIST = api + "/api/v3/harim/technical_deputy"; export const GET_GENERAL_MANAGER_LIST = api + "/api/v3/harim/general_manager"; + +// History +export const GET_HISTORY_LIST = api + "/api/v3/harim/detail/histories"; diff --git a/src/lib/hooks/useHistory.js b/src/lib/hooks/useHistory.js new file mode 100644 index 0000000..df1836c --- /dev/null +++ b/src/lib/hooks/useHistory.js @@ -0,0 +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 }; +}; From f2456bba795f0ffa95ce1230553bda53df305795 Mon Sep 17 00:00:00 2001 From: AminGhasempoor Date: Wed, 26 Nov 2025 15:10:56 +0330 Subject: [PATCH 28/61] build and format --- .../RowActions/History/TableContent.jsx | 12 ++++++- .../RowActions/History/TableContent.jsx | 12 ++++++- .../RowActions/ConfirmAction/index.jsx | 2 +- .../RowActions/History/TableContent.jsx | 12 ++++++- .../RowActions/ReferralAction/index.jsx | 2 +- .../RowActions/RejectAction/index.jsx | 2 +- .../PrevCartableOpinion.jsx | 5 +-- .../Questions/QuestionVerifyNeedRoadForm.jsx | 7 +--- .../QuestionVerifyRoadSafetyForm.jsx | 7 +--- .../Questions/Refer/index.jsx | 34 +++++++++++++++---- .../ConfirmRoadSafetyFormContext.jsx | 13 ++----- .../PrevCartableOpinion.jsx | 5 +-- .../Questions/QuestionVerifyNeedRoadForm.jsx | 7 +--- .../QuestionVerifyRoadSafetyForm.jsx | 7 +--- .../Questions/Refer/Form.jsx | 20 +++++++---- .../Questions/Refer/index.jsx | 34 +++++++++++++++---- .../Questions/index.jsx | 27 ++++++++++----- .../ConfirmRoadSafetyDialog.jsx | 13 ++++--- .../ConfirmRoadSafetyFormContext.jsx | 13 ++----- .../PrevCartableOpinion.jsx | 5 +-- .../Questions/QuestionVerifyNeedRoadForm.jsx | 7 +--- .../Questions/Refer/Form.jsx | 20 +++++++---- .../Questions/Refer/index.jsx | 34 +++++++++++++++---- .../Questions/index.jsx | 22 +++++++----- .../RowActions/History/TableContent.jsx | 12 ++++++- 25 files changed, 215 insertions(+), 119 deletions(-) diff --git a/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/History/TableContent.jsx b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/History/TableContent.jsx index cd3afb0..b405a41 100644 --- a/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/History/TableContent.jsx +++ b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/History/TableContent.jsx @@ -1,4 +1,14 @@ -import { Box, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, CircularProgress, Typography } from "@mui/material"; +import { + Box, + Table, + TableBody, + TableCell, + TableContainer, + TableHead, + TableRow, + CircularProgress, + Typography, +} from "@mui/material"; import "moment/locale/fa"; import { useHistory } from "@/lib/hooks/useHistory"; diff --git a/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/History/TableContent.jsx b/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/History/TableContent.jsx index cd3afb0..b405a41 100644 --- a/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/History/TableContent.jsx +++ b/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/History/TableContent.jsx @@ -1,4 +1,14 @@ -import { Box, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, CircularProgress, Typography } from "@mui/material"; +import { + Box, + Table, + TableBody, + TableCell, + TableContainer, + TableHead, + TableRow, + CircularProgress, + Typography, +} from "@mui/material"; import "moment/locale/fa"; import { useHistory } from "@/lib/hooks/useHistory"; diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ConfirmAction/index.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ConfirmAction/index.jsx index 3903560..230e4c7 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ConfirmAction/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ConfirmAction/index.jsx @@ -2,7 +2,7 @@ import ThumbUpIcon from "@mui/icons-material/ThumbUp"; import { IconButton, Tooltip } from "@mui/material"; const ConfirmAction = ({ onClick, disabled }) => { - if (disabled) return + if (disabled) return; return ( <> diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/History/TableContent.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/History/TableContent.jsx index cd3afb0..b405a41 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/History/TableContent.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/History/TableContent.jsx @@ -1,4 +1,14 @@ -import { Box, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, CircularProgress, Typography } from "@mui/material"; +import { + Box, + Table, + TableBody, + TableCell, + TableContainer, + TableHead, + TableRow, + CircularProgress, + Typography, +} from "@mui/material"; import "moment/locale/fa"; import { useHistory } from "@/lib/hooks/useHistory"; diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ReferralAction/index.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ReferralAction/index.jsx index a5326f5..46d36c3 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ReferralAction/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ReferralAction/index.jsx @@ -2,7 +2,7 @@ import { Reply } from "@mui/icons-material"; import { IconButton, Tooltip } from "@mui/material"; const ReferralAction = ({ onClick, disabled }) => { - if (disabled) return + if (disabled) return; return ( <> diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RejectAction/index.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RejectAction/index.jsx index a4647b7..47b3382 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RejectAction/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RejectAction/index.jsx @@ -2,7 +2,7 @@ import ThumbDownIcon from "@mui/icons-material/ThumbDown"; import { IconButton, Tooltip } from "@mui/material"; const RejectAction = ({ onClick, disabled }) => { - if (disabled) return + if (disabled) return; return ( <> diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/PrevCartableOpinion.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/PrevCartableOpinion.jsx index 37fe672..f6ca361 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/PrevCartableOpinion.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/PrevCartableOpinion.jsx @@ -1,12 +1,13 @@ import { Card, CardContent, CircularProgress, Stack, Typography } from "@mui/material"; const PrevCartableOpinion = ({ item }) => { - return ( - {item.previous_state_name}: {item.action_name} + + {item.previous_state_name}: {item.action_name} + توضیحات: {item.expert_description} diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/QuestionVerifyNeedRoadForm.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/QuestionVerifyNeedRoadForm.jsx index 0a9a724..747d178 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/QuestionVerifyNeedRoadForm.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/QuestionVerifyNeedRoadForm.jsx @@ -1,9 +1,4 @@ -import { - Card, - CardContent, - Stack, - Typography -} from "@mui/material"; +import { Card, CardContent, Stack, Typography } from "@mui/material"; const QuestionVerifyNeedRoadForm = ({ row }) => { return ( diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/QuestionVerifyRoadSafetyForm.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/QuestionVerifyRoadSafetyForm.jsx index 1775856..3da9f78 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/QuestionVerifyRoadSafetyForm.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/QuestionVerifyRoadSafetyForm.jsx @@ -1,9 +1,4 @@ -import { - Card, - CardContent, - Stack, - Typography -} from "@mui/material"; +import { Card, CardContent, Stack, Typography } from "@mui/material"; const QuestionVerifyRoadSafetyForm = ({ row }) => { return ( diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/Refer/index.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/Refer/index.jsx index 1fc664c..e18024f 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/Refer/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/Refer/index.jsx @@ -1,5 +1,5 @@ import { Close } from "@mui/icons-material"; -import { Button, Dialog, DialogTitle, IconButton } from "@mui/material" +import { Button, Dialog, DialogTitle, IconButton } from "@mui/material"; import { useState } from "react"; import ReferForm from "./Form"; @@ -8,10 +8,23 @@ const Refer = ({ rowId, mutate, handleClose, isSubmitting }) => { return ( <> - - { setOpenReferDialog(false) }} maxWidth="xs" fullWidth> + { + setOpenReferDialog(false); + }} + maxWidth="xs" + fullWidth + > setOpenReferDialog(false)} @@ -26,9 +39,16 @@ const Refer = ({ rowId, mutate, handleClose, isSubmitting }) => { مخالفت و ارجاع به دفتر حریم - {openReferDialog && } + {openReferDialog && ( + + )} - ) -} -export default Refer \ No newline at end of file + ); +}; +export default Refer; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/ConfirmRoadSafetyFormContext.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/ConfirmRoadSafetyFormContext.jsx index 41e1139..fb3834f 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/ConfirmRoadSafetyFormContext.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/ConfirmRoadSafetyFormContext.jsx @@ -6,8 +6,6 @@ import { useState } from "react"; import PrevCartableOpinion from "./PrevCartableOpinion"; import Questions from "./Questions"; - - const ConfirmRoadSafetyFormContext = ({ row, data, rowId, mutate, handleClose }) => { const [tabState, setTabState] = useState(0); @@ -56,7 +54,7 @@ const ConfirmRoadSafetyFormContext = ({ row, data, rowId, mutate, handleClose }) > {"بستن"} - @@ -70,15 +68,10 @@ const ConfirmRoadSafetyFormContext = ({ row, data, rowId, mutate, handleClose }) - - diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/PrevCartableOpinion.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/PrevCartableOpinion.jsx index 37fe672..f6ca361 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/PrevCartableOpinion.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/PrevCartableOpinion.jsx @@ -1,12 +1,13 @@ import { Card, CardContent, CircularProgress, Stack, Typography } from "@mui/material"; const PrevCartableOpinion = ({ item }) => { - return ( - {item.previous_state_name}: {item.action_name} + + {item.previous_state_name}: {item.action_name} + توضیحات: {item.expert_description} diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/QuestionVerifyNeedRoadForm.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/QuestionVerifyNeedRoadForm.jsx index a39fdec..927ef9e 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/QuestionVerifyNeedRoadForm.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/QuestionVerifyNeedRoadForm.jsx @@ -1,9 +1,4 @@ -import { - Card, - CardContent, - Stack, - Typography -} from "@mui/material"; +import { Card, CardContent, Stack, Typography } from "@mui/material"; const QuestionVerifyNeedRoadForm = () => { return ( diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/QuestionVerifyRoadSafetyForm.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/QuestionVerifyRoadSafetyForm.jsx index edd3232..8c1e4e3 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/QuestionVerifyRoadSafetyForm.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/QuestionVerifyRoadSafetyForm.jsx @@ -1,9 +1,4 @@ -import { - Card, - CardContent, - Stack, - Typography -} from "@mui/material"; +import { Card, CardContent, Stack, Typography } from "@mui/material"; const QuestionVerifyRoadSafetyForm = ({ row }) => { return ( diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/Refer/Form.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/Refer/Form.jsx index cf2095e..c3a58b1 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/Refer/Form.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/Refer/Form.jsx @@ -23,15 +23,15 @@ const ReferForm = ({ rowId, mutate, handleClose, setOpenReferDialog }) => { const onSubmit = async (data) => { await requestServer(`${REFER_VERIFY_NEADROAD_ROAD_INQUIRY_PRIVACY_ZAMIN_GOV_ASSISTANT}/${rowId}`, "post", { data: { - expert_description: data.description + expert_description: data.description, }, }) .then(() => { handleClose(); - setOpenReferDialog(false) + setOpenReferDialog(false); mutate(); }) - .catch(() => { }); + .catch(() => {}); }; return ( @@ -60,11 +60,17 @@ const ReferForm = ({ rowId, mutate, handleClose, setOpenReferDialog }) => { - - ) -} -export default ReferForm \ No newline at end of file + ); +}; +export default ReferForm; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/Refer/index.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/Refer/index.jsx index 1fc664c..e18024f 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/Refer/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/Refer/index.jsx @@ -1,5 +1,5 @@ import { Close } from "@mui/icons-material"; -import { Button, Dialog, DialogTitle, IconButton } from "@mui/material" +import { Button, Dialog, DialogTitle, IconButton } from "@mui/material"; import { useState } from "react"; import ReferForm from "./Form"; @@ -8,10 +8,23 @@ const Refer = ({ rowId, mutate, handleClose, isSubmitting }) => { return ( <> - - { setOpenReferDialog(false) }} maxWidth="xs" fullWidth> + { + setOpenReferDialog(false); + }} + maxWidth="xs" + fullWidth + > setOpenReferDialog(false)} @@ -26,9 +39,16 @@ const Refer = ({ rowId, mutate, handleClose, isSubmitting }) => { مخالفت و ارجاع به دفتر حریم - {openReferDialog && } + {openReferDialog && ( + + )} - ) -} -export default Refer \ No newline at end of file + ); +}; +export default Refer; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/index.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/index.jsx index b8b016b..2f89a8f 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/index.jsx @@ -1,5 +1,8 @@ import StyledForm from "@/core/components/StyledForm"; -import { CONFIRM_INQUIRY_PRIVACY_ZAMIN_GOV_ASSISTANT, CONFIRM_VERIFY_NEADROAD_ROAD_INQUIRY_PRIVACY_ZAMIN_GOV_ASSISTANT } from "@/core/utils/routes"; +import { + CONFIRM_INQUIRY_PRIVACY_ZAMIN_GOV_ASSISTANT, + CONFIRM_VERIFY_NEADROAD_ROAD_INQUIRY_PRIVACY_ZAMIN_GOV_ASSISTANT, +} from "@/core/utils/routes"; import useRequest from "@/lib/hooks/useRequest"; import { yupResolver } from "@hookform/resolvers/yup"; import { Button, DialogActions, DialogContent, Stack } from "@mui/material"; @@ -30,27 +33,33 @@ const Questions = ({ row, rowId, mutate, handleClose, handlePrev }) => { const onSubmit = async (data) => { await requestServer(`${CONFIRM_VERIFY_NEADROAD_ROAD_INQUIRY_PRIVACY_ZAMIN_GOV_ASSISTANT}/${rowId}`, "post", { data: { - expert_description: data.description + expert_description: data.description, }, }) .then(() => { handleClose(); mutate(); }) - .catch(() => { }); + .catch(() => {}); }; return ( - + - - @@ -60,6 +69,6 @@ const Questions = ({ row, rowId, mutate, handleClose, handlePrev }) => { - ) -} -export default Questions \ No newline at end of file + ); +}; +export default Questions; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/ConfirmRoadSafetyDialog.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/ConfirmRoadSafetyDialog.jsx index f3a693a..5bcd863 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/ConfirmRoadSafetyDialog.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/ConfirmRoadSafetyDialog.jsx @@ -30,7 +30,13 @@ const ConfirmRoadSafetyDialog = ({ row, handleClose, rowId, mutate }) => { {loading ? ( ) : data ? ( - + ) : ( اطلاعات درخواست در سامانه یافت نشد @@ -38,6 +44,5 @@ const ConfirmRoadSafetyDialog = ({ row, handleClose, rowId, mutate }) => { )} ); - -} -export default ConfirmRoadSafetyDialog \ No newline at end of file +}; +export default ConfirmRoadSafetyDialog; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/ConfirmRoadSafetyFormContext.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/ConfirmRoadSafetyFormContext.jsx index 7b1fd02..633d2e9 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/ConfirmRoadSafetyFormContext.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/ConfirmRoadSafetyFormContext.jsx @@ -6,8 +6,6 @@ import { useState } from "react"; import PrevCartableOpinion from "./PrevCartableOpinion"; import Questions from "./Questions"; - - const ConfirmRoadSafetyFormContext = ({ row, data, rowId, mutate, handleClose }) => { const [tabState, setTabState] = useState(0); @@ -56,7 +54,7 @@ const ConfirmRoadSafetyFormContext = ({ row, data, rowId, mutate, handleClose }) > {"بستن"} - @@ -70,15 +68,10 @@ const ConfirmRoadSafetyFormContext = ({ row, data, rowId, mutate, handleClose }) - - diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/PrevCartableOpinion.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/PrevCartableOpinion.jsx index 37fe672..f6ca361 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/PrevCartableOpinion.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/PrevCartableOpinion.jsx @@ -1,12 +1,13 @@ import { Card, CardContent, CircularProgress, Stack, Typography } from "@mui/material"; const PrevCartableOpinion = ({ item }) => { - return ( - {item.previous_state_name}: {item.action_name} + + {item.previous_state_name}: {item.action_name} + توضیحات: {item.expert_description} diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/QuestionVerifyNeedRoadForm.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/QuestionVerifyNeedRoadForm.jsx index 558d200..18fb601 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/QuestionVerifyNeedRoadForm.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/QuestionVerifyNeedRoadForm.jsx @@ -1,9 +1,4 @@ -import { - Card, - CardContent, - Stack, - Typography -} from "@mui/material"; +import { Card, CardContent, Stack, Typography } from "@mui/material"; const QuestionVerifyNeedRoadForm = ({ row }) => { return ( diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/Refer/Form.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/Refer/Form.jsx index cf2095e..c3a58b1 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/Refer/Form.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/Refer/Form.jsx @@ -23,15 +23,15 @@ const ReferForm = ({ rowId, mutate, handleClose, setOpenReferDialog }) => { const onSubmit = async (data) => { await requestServer(`${REFER_VERIFY_NEADROAD_ROAD_INQUIRY_PRIVACY_ZAMIN_GOV_ASSISTANT}/${rowId}`, "post", { data: { - expert_description: data.description + expert_description: data.description, }, }) .then(() => { handleClose(); - setOpenReferDialog(false) + setOpenReferDialog(false); mutate(); }) - .catch(() => { }); + .catch(() => {}); }; return ( @@ -60,11 +60,17 @@ const ReferForm = ({ rowId, mutate, handleClose, setOpenReferDialog }) => { - - ) -} -export default ReferForm \ No newline at end of file + ); +}; +export default ReferForm; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/Refer/index.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/Refer/index.jsx index 1fc664c..e18024f 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/Refer/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/Refer/index.jsx @@ -1,5 +1,5 @@ import { Close } from "@mui/icons-material"; -import { Button, Dialog, DialogTitle, IconButton } from "@mui/material" +import { Button, Dialog, DialogTitle, IconButton } from "@mui/material"; import { useState } from "react"; import ReferForm from "./Form"; @@ -8,10 +8,23 @@ const Refer = ({ rowId, mutate, handleClose, isSubmitting }) => { return ( <> - - { setOpenReferDialog(false) }} maxWidth="xs" fullWidth> + { + setOpenReferDialog(false); + }} + maxWidth="xs" + fullWidth + > setOpenReferDialog(false)} @@ -26,9 +39,16 @@ const Refer = ({ rowId, mutate, handleClose, isSubmitting }) => { مخالفت و ارجاع به دفتر حریم - {openReferDialog && } + {openReferDialog && ( + + )} - ) -} -export default Refer \ No newline at end of file + ); +}; +export default Refer; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/index.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/index.jsx index a52b00c..d020ad8 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/index.jsx @@ -29,27 +29,33 @@ const Questions = ({ row, rowId, mutate, handleClose, handlePrev }) => { const onSubmit = async (data) => { await requestServer(`${CONFIRM_VERIFY_NEADROAD_ROAD_INQUIRY_PRIVACY_ZAMIN_GOV_ASSISTANT}/${rowId}`, "post", { data: { - expert_description: data.description + expert_description: data.description, }, }) .then(() => { handleClose(); mutate(); }) - .catch(() => { }); + .catch(() => {}); }; return ( - + - - @@ -59,6 +65,6 @@ const Questions = ({ row, rowId, mutate, handleClose, handlePrev }) => { - ) -} -export default Questions \ No newline at end of file + ); +}; +export default Questions; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/History/TableContent.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/History/TableContent.jsx index cd3afb0..b405a41 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/History/TableContent.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/History/TableContent.jsx @@ -1,4 +1,14 @@ -import { Box, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, CircularProgress, Typography } from "@mui/material"; +import { + Box, + Table, + TableBody, + TableCell, + TableContainer, + TableHead, + TableRow, + CircularProgress, + Typography, +} from "@mui/material"; import "moment/locale/fa"; import { useHistory } from "@/lib/hooks/useHistory"; From ea36ee0c77c2f039abeecd96842f7543adbab7a2 Mon Sep 17 00:00:00 2001 From: baslani Date: Wed, 26 Nov 2025 15:13:54 +0330 Subject: [PATCH 29/61] [wip] implementing technical deputy list table --- jsconfig.json | 38 +++++++++---------- .../ConfirmRoadSafetyDialog.jsx | 4 +- .../ConfirmRoadSafetyDialog.jsx | 9 ++--- .../ConfirmRoadSafetyDialog.jsx | 19 ++++++---- .../technical-deputy/RowActions/index.jsx | 23 ++++++----- src/core/utils/routes.js | 1 + 6 files changed, 49 insertions(+), 45 deletions(-) diff --git a/jsconfig.json b/jsconfig.json index b51472a..c136578 100644 --- a/jsconfig.json +++ b/jsconfig.json @@ -1,27 +1,27 @@ // javascript for production -{ - "compilerOptions": { - "paths": { - "@/*": ["./src/*"], - "^/*": ["./public/*"] - } - } -} - -// typescript for local development // { // "compilerOptions": { -// "jsx": "react-jsx", -// "noUnusedLocals": true, -// "noImplicitAny": false, -// "checkJs": true, -// "allowJs": true, -// "strict": true, -// "baseUrl": ".", // "paths": { // "@/*": ["./src/*"], // "^/*": ["./public/*"] // } -// }, -// "exclude": ["node_modules"] +// } // } + +// typescript for local development +{ + "compilerOptions": { + "jsx": "react-jsx", + "noUnusedLocals": true, + "noImplicitAny": false, + "checkJs": true, + "allowJs": true, + "strict": true, + "baseUrl": ".", + "paths": { + "@/*": ["./src/*"], + "^/*": ["./public/*"] + } + }, + "exclude": ["node_modules"] +} diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/ConfirmRoadSafetyDialog.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/ConfirmRoadSafetyDialog.jsx index 7b8e90e..862fb85 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/ConfirmRoadSafetyDialog.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/ConfirmRoadSafetyDialog.jsx @@ -1,5 +1,5 @@ import DialogLoading from "@/core/components/DialogLoading"; -import { GET_REQUEST_INQUIRY_PRIVACY_ZAMIN_GOV_ASSISTANT_DETAILS } from "@/core/utils/routes"; +import { GET_REQUEST_INQUIRY_PRIVACY } from "@/core/utils/routes"; import useRequest from "@/lib/hooks/useRequest"; import { DialogContent, Typography } from "@mui/material"; import { useEffect, useState } from "react"; @@ -14,7 +14,7 @@ const ConfirmRoadSafetyDialog = ({ row, handleClose, rowId, mutate }) => { const fetchData = async () => { try { setLoading(true); - const response = await request(`${GET_REQUEST_INQUIRY_PRIVACY_ZAMIN_GOV_ASSISTANT_DETAILS}/${rowId}`); + const response = await request(`${GET_REQUEST_INQUIRY_PRIVACY}/${rowId}`); setData(response.data.data); } catch (error) { } finally { diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/ConfirmRoadSafetyDialog.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/ConfirmRoadSafetyDialog.jsx index 8305cf4..862fb85 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/ConfirmRoadSafetyDialog.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/ConfirmRoadSafetyDialog.jsx @@ -1,5 +1,5 @@ import DialogLoading from "@/core/components/DialogLoading"; -import { GET_REQUEST_INQUIRY_PRIVACY_ZAMIN_GOV_ASSISTANT_DETAILS } from "@/core/utils/routes"; +import { GET_REQUEST_INQUIRY_PRIVACY } from "@/core/utils/routes"; import useRequest from "@/lib/hooks/useRequest"; import { DialogContent, Typography } from "@mui/material"; import { useEffect, useState } from "react"; @@ -14,7 +14,7 @@ const ConfirmRoadSafetyDialog = ({ row, handleClose, rowId, mutate }) => { const fetchData = async () => { try { setLoading(true); - const response = await request(`${GET_REQUEST_INQUIRY_PRIVACY_ZAMIN_GOV_ASSISTANT_DETAILS}/${rowId}`); + const response = await request(`${GET_REQUEST_INQUIRY_PRIVACY}/${rowId}`); setData(response.data.data); } catch (error) { } finally { @@ -28,9 +28,8 @@ const ConfirmRoadSafetyDialog = ({ row, handleClose, rowId, mutate }) => { return ( <> {loading ? ( -
Loading...
- ) : // - data ? ( + + ) : data ? ( { const fetchData = async () => { try { setLoading(true); - const response = await request(`${GET_REQUEST_INQUIRY_PRIVACY_ZAMIN_GOV_ASSISTANT_DETAILS}/${rowId}`); + const response = await request(`${GET_REQUEST_INQUIRY_PRIVACY}/${rowId}`); setData(response.data.data); } catch (error) { } finally { @@ -28,9 +28,15 @@ const ConfirmRoadSafetyDialog = ({ row, handleClose, rowId, mutate }) => { return ( <> {loading ? ( - + ) : data ? ( - + ) : ( اطلاعات درخواست در سامانه یافت نشد @@ -38,6 +44,5 @@ const ConfirmRoadSafetyDialog = ({ row, handleClose, rowId, mutate }) => { )} ); - -} -export default ConfirmRoadSafetyDialog \ No newline at end of file +}; +export default ConfirmRoadSafetyDialog; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/index.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/index.jsx index 58261f4..cb1ecf7 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/index.jsx @@ -5,18 +5,17 @@ import ConfirmVerifyLicenseForm from "./ConfirmVerifyLicenseForm"; const RowActions = ({ row, mutate }) => { return ( - <> - // - // {row.original.state_id == 3 && ( - // - // )} - // {row.original.state_id == 6 && ( - // - // )} - // {row.original.state_id == 14 && ( - // - // )} - // + + {row.original.state_id == 3 && ( + + )} + {row.original.state_id == 6 && ( + + )} + {row.original.state_id == 14 && ( + + )} + ); }; export default RowActions; diff --git a/src/core/utils/routes.js b/src/core/utils/routes.js index e9e7119..070a222 100644 --- a/src/core/utils/routes.js +++ b/src/core/utils/routes.js @@ -242,3 +242,4 @@ export const CITY_ADMIN_FEEDBACK = api + "/api/v3/harim/province_office/feedback export const GET_PRIVACY_ADMIN_LIST = api + "/api/v3/harim/harim_office"; export const PRIVACY_ADMIN_ACTION_API = api + "/api/v3/harim/harim_office"; export const GET_INQUIRY_PRIVACY_TABLE_LIST = api + "/api/v3/harim/technical_deputy"; +export const GET_REQUEST_INQUIRY_PRIVACY = api + "/api/v3/harim/technical_deputy"; From 88b1f02a91e79f4eec0624567d37d9b0a0c2e019 Mon Sep 17 00:00:00 2001 From: baslani Date: Wed, 26 Nov 2025 15:23:29 +0330 Subject: [PATCH 30/61] added history item to tables --- .../ConfirmRoadSafetyForm/ConfirmRoadSafetyFormContext.jsx | 1 + .../inquiryPrivacy/technical-deputy/RowActions/index.jsx | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/ConfirmRoadSafetyFormContext.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/ConfirmRoadSafetyFormContext.jsx index ac10bf7..a3543b8 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/ConfirmRoadSafetyFormContext.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/ConfirmRoadSafetyFormContext.jsx @@ -8,6 +8,7 @@ import TabPanel from "@/core/components/TabPanel"; const ConfirmRoadSafetyFormContext = ({ row, data, rowId, mutate, handleClose }) => { const [tabState, setTabState] = useState(0); + console.log("DATA: ", data); const handleChangeTab = (event, newValue) => { setTabState(newValue); diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/index.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/index.jsx index cb1ecf7..757d292 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/index.jsx @@ -2,10 +2,12 @@ import { Box } from "@mui/material"; import ConfirmRoadSafetyForm from "./ConfirmRoadSafetyForm"; import ConfirmVerifyRoadSafetyForm from "./ConfirmVerifyRoadSafetyForm"; import ConfirmVerifyLicenseForm from "./ConfirmVerifyLicenseForm"; +import History from "./History"; const RowActions = ({ row, mutate }) => { return ( + {row.original.state_id == 3 && ( )} From e4b993dededac1494890a92f7d150f80631e7b5f Mon Sep 17 00:00:00 2001 From: baslani Date: Wed, 26 Nov 2025 15:35:49 +0330 Subject: [PATCH 31/61] changed to js --- jsconfig.json | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/jsconfig.json b/jsconfig.json index c136578..b51472a 100644 --- a/jsconfig.json +++ b/jsconfig.json @@ -1,27 +1,27 @@ // javascript for production -// { -// "compilerOptions": { -// "paths": { -// "@/*": ["./src/*"], -// "^/*": ["./public/*"] -// } -// } -// } - -// typescript for local development { "compilerOptions": { - "jsx": "react-jsx", - "noUnusedLocals": true, - "noImplicitAny": false, - "checkJs": true, - "allowJs": true, - "strict": true, - "baseUrl": ".", "paths": { "@/*": ["./src/*"], "^/*": ["./public/*"] } - }, - "exclude": ["node_modules"] + } } + +// typescript for local development +// { +// "compilerOptions": { +// "jsx": "react-jsx", +// "noUnusedLocals": true, +// "noImplicitAny": false, +// "checkJs": true, +// "allowJs": true, +// "strict": true, +// "baseUrl": ".", +// "paths": { +// "@/*": ["./src/*"], +// "^/*": ["./public/*"] +// } +// }, +// "exclude": ["node_modules"] +// } From 9768c9f451d9b91965b4955762d9413c4ddaedac Mon Sep 17 00:00:00 2001 From: baslani Date: Wed, 26 Nov 2025 16:12:25 +0330 Subject: [PATCH 32/61] implemented displaying project and plans areas --- .../RowActions/Forms/ComputePaymentForm.jsx | 2 +- .../ShowBound.jsx | 0 .../ShowProjectArea/ShowForbiddenBound.jsx | 29 +++++++++++++++++ .../index.jsx | 19 ++++++++--- .../technical-deputy/TechnicalDeputyList.jsx | 32 +++++++++++++++++-- 5 files changed, 74 insertions(+), 8 deletions(-) rename src/components/dashboard/inquiryPrivacy/technical-deputy/{ShowPrimaryArea => ShowProjectArea}/ShowBound.jsx (100%) create mode 100644 src/components/dashboard/inquiryPrivacy/technical-deputy/ShowProjectArea/ShowForbiddenBound.jsx rename src/components/dashboard/inquiryPrivacy/technical-deputy/{ShowPrimaryArea => ShowProjectArea}/index.jsx (78%) diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ComputePaymentForm.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ComputePaymentForm.jsx index eb0fa47..0df367b 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ComputePaymentForm.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ComputePaymentForm.jsx @@ -175,7 +175,7 @@ export default function ComputePaymentForm({ mutate, onClose, rowData }) { type="number" InputProps={{ readOnly: true }} fullWidth - label="مساحت عیان (متر مربع)" + label="مساحت اعیان (متر مربع)" /> )} /> diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/ShowPrimaryArea/ShowBound.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/ShowProjectArea/ShowBound.jsx similarity index 100% rename from src/components/dashboard/inquiryPrivacy/technical-deputy/ShowPrimaryArea/ShowBound.jsx rename to src/components/dashboard/inquiryPrivacy/technical-deputy/ShowProjectArea/ShowBound.jsx diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/ShowProjectArea/ShowForbiddenBound.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/ShowProjectArea/ShowForbiddenBound.jsx new file mode 100644 index 0000000..c8d28d1 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/ShowProjectArea/ShowForbiddenBound.jsx @@ -0,0 +1,29 @@ +import { useEffect, useRef } from "react"; +import { FeatureGroup, useMap } from "react-leaflet"; + +const ShowForbiddenBound = ({ 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 ShowForbiddenBound; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/ShowPrimaryArea/index.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/ShowProjectArea/index.jsx similarity index 78% rename from src/components/dashboard/inquiryPrivacy/technical-deputy/ShowPrimaryArea/index.jsx rename to src/components/dashboard/inquiryPrivacy/technical-deputy/ShowProjectArea/index.jsx index e4714de..e7386fc 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/ShowPrimaryArea/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/ShowProjectArea/index.jsx @@ -2,17 +2,27 @@ const { IconButton, Tooltip, Box, Dialog, DialogTitle, Typography, DialogContent 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"; -import L from "leaflet"; +import ShowForbiddenBound from "./ShowForbiddenBound"; -const ShowPrimaryArea = ({ primaryArea }) => { +const ShowProjectArea = ({ primaryArea, forbiddenArea }) => { const [openShowAreaDialog, setOpenShowAreaDialog] = useState(false); const bound = useMemo(() => { const latLngCoords = primaryArea.coordinates.map((coord) => [coord[1], coord[0]]); - return primaryArea.type === "polygon" ? L.polygon(latLngCoords) : L.polyline(latLngCoords); + return primaryArea.type === "polygon" + ? L.polygon(latLngCoords, { + color: "#ff5555", + }) + : L.polyline(latLngCoords); }, [primaryArea]); + const forbiddenBound = useMemo(() => { + const latLngCoords = forbiddenArea.coordinates.map((coord) => [coord[1], coord[0]]); + return forbiddenArea.type === "polygon" ? L.polygon(latLngCoords) : L.polyline(latLngCoords); + }, [forbiddenArea]); + return ( @@ -48,6 +58,7 @@ const ShowPrimaryArea = ({ primaryArea }) => { + @@ -57,4 +68,4 @@ const ShowPrimaryArea = ({ primaryArea }) => { ); }; -export default ShowPrimaryArea; +export default ShowProjectArea; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/TechnicalDeputyList.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/TechnicalDeputyList.jsx index bb3ec27..cb3a82f 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/TechnicalDeputyList.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/TechnicalDeputyList.jsx @@ -6,7 +6,7 @@ import { Box, Stack } from "@mui/material"; import moment from "jalali-moment"; import { useMemo } from "react"; import RowActions from "./RowActions"; -import ShowPrimaryArea from "./ShowPrimaryArea"; +import ShowProjectArea from "./ShowProjectArea"; const TechnicalDeputyList = () => { const columns = useMemo( @@ -127,9 +127,35 @@ const TechnicalDeputyList = () => { grow: false, size: 100, Cell: ({ row }) => - row.original.primary_area ? ( + row.original.primary_area && row.original.forbidden_area ? ( - + + + ) : ( + "-" + ), + }, + { + accessorKey: "final_area", + header: "نمایش محدوده عرصه و اعیان", + id: "final_area", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ row }) => + row.original.final_area && row.original.final_plan ? ( + + ) : ( "-" From a5b30d13feb753ce4831e6a705ab574bf3515f9a Mon Sep 17 00:00:00 2001 From: AminGhasempoor Date: Wed, 26 Nov 2025 16:24:15 +0330 Subject: [PATCH 33/61] confirm modal of technical deputy --- .../ConfirmRoadSafetyDialog.jsx | 7 +- .../ConfirmRoadSafetyFormContext.jsx | 128 ++++++++---------- .../PrevCartableOpinion.jsx | 17 --- .../ConfirmRoadSafetyDialog.jsx | 9 +- .../ConfirmRoadSafetyFormContext.jsx | 126 +++++++---------- .../ConfirmRoadSafetyDialog.jsx | 5 +- .../ConfirmRoadSafetyFormContext.jsx | 126 +++++++---------- .../PrevCartableOpinion.jsx | 17 --- .../Questions/DescriptionForm.jsx | 29 ---- .../Questions/QuestionVerifyNeedRoadForm.jsx | 29 ---- .../Questions/Refer/Form.jsx | 76 ----------- .../Questions/Refer/index.jsx | 54 -------- .../Questions/index.jsx | 70 ---------- src/core/utils/routes.js | 6 + 14 files changed, 172 insertions(+), 527 deletions(-) delete mode 100644 src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/PrevCartableOpinion.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/PrevCartableOpinion.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/DescriptionForm.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/QuestionVerifyNeedRoadForm.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/Refer/Form.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/Refer/index.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/index.jsx diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/ConfirmRoadSafetyDialog.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/ConfirmRoadSafetyDialog.jsx index 862fb85..88c69c8 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/ConfirmRoadSafetyDialog.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/ConfirmRoadSafetyDialog.jsx @@ -1,7 +1,7 @@ import DialogLoading from "@/core/components/DialogLoading"; import { GET_REQUEST_INQUIRY_PRIVACY } from "@/core/utils/routes"; import useRequest from "@/lib/hooks/useRequest"; -import { DialogContent, Typography } from "@mui/material"; +import { DialogContent, DialogTitle, Typography } from "@mui/material"; import { useEffect, useState } from "react"; import ConfirmRoadSafetyFormContext from "./ConfirmRoadSafetyFormContext"; @@ -23,17 +23,16 @@ const ConfirmRoadSafetyDialog = ({ row, handleClose, rowId, mutate }) => { }; fetchData(); - }, [request, rowId]); + }, [rowId]); return ( <> + تاییدیه ایمنی راه {loading ? ( ) : data ? ( diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/ConfirmRoadSafetyFormContext.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/ConfirmRoadSafetyFormContext.jsx index a3543b8..da232da 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/ConfirmRoadSafetyFormContext.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/ConfirmRoadSafetyFormContext.jsx @@ -1,86 +1,64 @@ -import ApplicantRequestDetail from "@/core/components/ApplicantRequestDetail"; -import { Engineering, ExitToApp, InsertDriveFile, Route } from "@mui/icons-material"; -import { Button, DialogActions, DialogContent, Stack, Tab, Tabs } from "@mui/material"; import { useState } from "react"; -import PrevCartableOpinion from "./PrevCartableOpinion"; -import Questions from "./Questions"; -import TabPanel from "@/core/components/TabPanel"; +import { Box, TextField, Button, CircularProgress, Alert, DialogContent } from "@mui/material"; +import useRequest from "@/lib/hooks/useRequest"; +import { CONFIRM_ROAD_SAFETY_FORM } from "@/core/utils/routes"; -const ConfirmRoadSafetyFormContext = ({ row, data, rowId, mutate, handleClose }) => { - const [tabState, setTabState] = useState(0); - console.log("DATA: ", data); +const ConfirmRoadSafetyFormContext = ({ rowId, mutate, handleClose }) => { + const requestServer = useRequest({notificationShow : true, notificationSuccess : true}); + const [description, setDescription] = useState(""); + const [loading, setLoading] = useState(false); + const [error, setError] = useState(null); + const [success, setSuccess] = useState(false); - const handleChangeTab = (event, newValue) => { - setTabState(newValue); - }; + const handleSubmit = async () => { + if (!description.trim()) { + setError("لطفاً توضیحات را وارد کنید"); + return; + } - const handlePrev = () => { - if (tabState === 0) { - handleClose(); - } else { - setTabState((t) => t - 1); + setLoading(true); + setError(null); + setSuccess(false); + + try { + const res = await requestServer(`${CONFIRM_ROAD_SAFETY_FORM}/${rowId}`, "post", { + data: { + expert_description: description, + }, + }); + + setSuccess(true); + mutate(); + setDescription(""); + handleClose() + } catch (err) { + setError(err.message); + } finally { + setLoading(false); } }; return ( - <> - - } label="اطلاعات طرح متقاضی" /> - } label="جریان فرایند" /> - } label="تاییدیه ایمنی راه" /> - - - - - - - - - - - - - - {data.histories.map((item, index) => ( - - ))} - - - - - - - - - - - + + + {error && {error}} + {success && با موفقیت ثبت شد} + + setDescription(e.target.value)} + fullWidth + /> + + + + ); }; + export default ConfirmRoadSafetyFormContext; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/PrevCartableOpinion.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/PrevCartableOpinion.jsx deleted file mode 100644 index f6ca361..0000000 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/PrevCartableOpinion.jsx +++ /dev/null @@ -1,17 +0,0 @@ -import { Card, CardContent, CircularProgress, Stack, Typography } from "@mui/material"; - -const PrevCartableOpinion = ({ item }) => { - return ( - - - - - {item.previous_state_name}: {item.action_name} - - توضیحات: {item.expert_description} - - - - ); -}; -export default PrevCartableOpinion; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/ConfirmRoadSafetyDialog.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/ConfirmRoadSafetyDialog.jsx index 862fb85..f1779ad 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/ConfirmRoadSafetyDialog.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/ConfirmRoadSafetyDialog.jsx @@ -1,11 +1,11 @@ import DialogLoading from "@/core/components/DialogLoading"; import { GET_REQUEST_INQUIRY_PRIVACY } from "@/core/utils/routes"; import useRequest from "@/lib/hooks/useRequest"; -import { DialogContent, Typography } from "@mui/material"; +import { DialogContent, DialogTitle, Typography } from "@mui/material"; import { useEffect, useState } from "react"; import ConfirmRoadSafetyFormContext from "./ConfirmRoadSafetyFormContext"; -const ConfirmRoadSafetyDialog = ({ row, handleClose, rowId, mutate }) => { +const ConfirmRoadSafetyDialog = ({ handleClose, rowId, mutate }) => { const [loading, setLoading] = useState(true); const [data, setData] = useState(null); const request = useRequest(); @@ -23,17 +23,16 @@ const ConfirmRoadSafetyDialog = ({ row, handleClose, rowId, mutate }) => { }; fetchData(); - }, [request, rowId]); + }, [rowId]); return ( <> + تاییدیه ضمانت نامه ها {loading ? ( ) : data ? ( diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/ConfirmRoadSafetyFormContext.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/ConfirmRoadSafetyFormContext.jsx index fb3834f..bf9c691 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/ConfirmRoadSafetyFormContext.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/ConfirmRoadSafetyFormContext.jsx @@ -1,85 +1,63 @@ -import ApplicantRequestDetail from "@/core/components/ApplicantRequestDetail"; -import TabPanel from "@/core/components/TabPanel"; -import { ExitToApp, InsertDriveFile, Route, ThumbUp } from "@mui/icons-material"; -import { Button, DialogActions, DialogContent, Stack, Tab, Tabs } from "@mui/material"; +import { Alert, Box, Button, CircularProgress, DialogContent, TextField } from "@mui/material"; +import { CONFIRM_VERIFY_LICENSE_FORM } from "@/core/utils/routes"; +import useRequest from "@/lib/hooks/useRequest"; import { useState } from "react"; -import PrevCartableOpinion from "./PrevCartableOpinion"; -import Questions from "./Questions"; -const ConfirmRoadSafetyFormContext = ({ row, data, rowId, mutate, handleClose }) => { - const [tabState, setTabState] = useState(0); +const ConfirmRoadSafetyFormContext = ({ rowId, mutate, handleClose }) => { + const requestServer = useRequest({notificationShow : true, notificationSuccess : true}); + const [description, setDescription] = useState(""); + const [loading, setLoading] = useState(false); + const [error, setError] = useState(null); + const [success, setSuccess] = useState(false); - const handleChangeTab = (event, newValue) => { - setTabState(newValue); - }; + const handleSubmit = async () => { + if (!description.trim()) { + setError("لطفاً توضیحات را وارد کنید"); + return; + } - const handlePrev = () => { - if (tabState === 0) { - handleClose(); - } else { - setTabState((t) => t - 1); + setLoading(true); + setError(null); + setSuccess(false); + + try { + const res = await requestServer(`${CONFIRM_VERIFY_LICENSE_FORM}/${rowId}`, "post", { + data: { + expert_description: description, + }, + }); + + setSuccess(true); + mutate(); + setDescription(""); + handleClose() + } catch (err) { + setError(err.message); + } finally { + setLoading(false); } }; return ( - <> - - } label="اطلاعات طرح متقاضی" /> - } label="جریان فرایند" /> - } label="تاییدیه ضمانت نامه ها" /> - - - - - - - - - - - - - - {data.histories.map((item, index) => ( - - ))} - - - - - - - - - - - + + + {error && {error}} + {success && با موفقیت ثبت شد} + + setDescription(e.target.value)} + fullWidth + /> + + + + ); }; export default ConfirmRoadSafetyFormContext; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/ConfirmRoadSafetyDialog.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/ConfirmRoadSafetyDialog.jsx index a9328a0..940982a 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/ConfirmRoadSafetyDialog.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/ConfirmRoadSafetyDialog.jsx @@ -1,7 +1,7 @@ import DialogLoading from "@/core/components/DialogLoading"; import { GET_REQUEST_INQUIRY_PRIVACY } from "@/core/utils/routes"; import useRequest from "@/lib/hooks/useRequest"; -import { DialogContent, Typography } from "@mui/material"; +import { DialogContent, DialogTitle, Typography } from "@mui/material"; import { useEffect, useState } from "react"; import ConfirmRoadSafetyFormContext from "./ConfirmRoadSafetyFormContext"; @@ -27,13 +27,12 @@ const ConfirmRoadSafetyDialog = ({ row, handleClose, rowId, mutate }) => { return ( <> + تاییدیه دسترسی راه {loading ? ( ) : data ? ( diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/ConfirmRoadSafetyFormContext.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/ConfirmRoadSafetyFormContext.jsx index 633d2e9..1738b35 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/ConfirmRoadSafetyFormContext.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/ConfirmRoadSafetyFormContext.jsx @@ -1,85 +1,63 @@ -import ApplicantRequestDetail from "@/core/components/ApplicantRequestDetail"; -import TabPanel from "@/core/components/TabPanel"; -import { DoneAll, ExitToApp, InsertDriveFile, Route } from "@mui/icons-material"; -import { Button, DialogActions, DialogContent, Stack, Tab, Tabs } from "@mui/material"; +import useRequest from "@/lib/hooks/useRequest"; import { useState } from "react"; -import PrevCartableOpinion from "./PrevCartableOpinion"; -import Questions from "./Questions"; +import { CONFIRM_VERIFY_ROAD_SAFETY_FORM } from "@/core/utils/routes"; +import { Alert, Box, Button, CircularProgress, DialogContent, TextField } from "@mui/material"; -const ConfirmRoadSafetyFormContext = ({ row, data, rowId, mutate, handleClose }) => { - const [tabState, setTabState] = useState(0); +const ConfirmRoadSafetyFormContext = ({ rowId, mutate, handleClose }) => { + const requestServer = useRequest({notificationShow : true, notificationSuccess : true}); + const [description, setDescription] = useState(""); + const [loading, setLoading] = useState(false); + const [error, setError] = useState(null); + const [success, setSuccess] = useState(false); - const handleChangeTab = (event, newValue) => { - setTabState(newValue); - }; + const handleSubmit = async () => { + if (!description.trim()) { + setError("لطفاً توضیحات را وارد کنید"); + return; + } - const handlePrev = () => { - if (tabState === 0) { - handleClose(); - } else { - setTabState((t) => t - 1); + setLoading(true); + setError(null); + setSuccess(false); + + try { + const res = await requestServer(`${CONFIRM_VERIFY_ROAD_SAFETY_FORM}/${rowId}`, "post", { + data: { + expert_description: description, + }, + }); + + setSuccess(true); + mutate(); + setDescription(""); + handleClose() + } catch (err) { + setError(err.message); + } finally { + setLoading(false); } }; return ( - <> - - } label="اطلاعات طرح متقاضی" /> - } label="جریان فرایند" /> - } label="تاییدیه دسترسی راه" /> - - - - - - - - - - - - - - {data.histories.map((item, index) => ( - - ))} - - - - - - - - - - - + + + {error && {error}} + {success && با موفقیت ثبت شد} + + setDescription(e.target.value)} + fullWidth + /> + + + + ); }; export default ConfirmRoadSafetyFormContext; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/PrevCartableOpinion.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/PrevCartableOpinion.jsx deleted file mode 100644 index f6ca361..0000000 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/PrevCartableOpinion.jsx +++ /dev/null @@ -1,17 +0,0 @@ -import { Card, CardContent, CircularProgress, Stack, Typography } from "@mui/material"; - -const PrevCartableOpinion = ({ item }) => { - return ( - - - - - {item.previous_state_name}: {item.action_name} - - توضیحات: {item.expert_description} - - - - ); -}; -export default PrevCartableOpinion; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/DescriptionForm.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/DescriptionForm.jsx deleted file mode 100644 index a7099e7..0000000 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/DescriptionForm.jsx +++ /dev/null @@ -1,29 +0,0 @@ -import { Stack, TextField } from "@mui/material"; -import { Controller } from "react-hook-form"; - -const DescriptionForm = ({ control }) => { - return ( - - ( - - )} - /> - - ); -}; -export default DescriptionForm; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/QuestionVerifyNeedRoadForm.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/QuestionVerifyNeedRoadForm.jsx deleted file mode 100644 index 18fb601..0000000 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/QuestionVerifyNeedRoadForm.jsx +++ /dev/null @@ -1,29 +0,0 @@ -import { Card, CardContent, Stack, Typography } from "@mui/material"; - -const QuestionVerifyNeedRoadForm = ({ row }) => { - return ( - - - - - آیا دسترسی به راه مورد تایید است؟ - - - دفتر حریم راه : - - {row.original.is_file_good == 1 ? "بله" : "خیر"} - - - - - - ); -}; -export default QuestionVerifyNeedRoadForm; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/Refer/Form.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/Refer/Form.jsx deleted file mode 100644 index c3a58b1..0000000 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/Refer/Form.jsx +++ /dev/null @@ -1,76 +0,0 @@ -import { REFER_VERIFY_NEADROAD_ROAD_INQUIRY_PRIVACY_ZAMIN_GOV_ASSISTANT } from "@/core/utils/routes"; -import useRequest from "@/lib/hooks/useRequest"; -import { yupResolver } from "@hookform/resolvers/yup"; -import { Button, DialogActions, DialogContent, Stack, TextField } from "@mui/material"; -import { Controller, useForm } from "react-hook-form"; -import { object, string } from "yup"; -const validationSchema = object({ - description: string().required("وارد کردن توضیحات الزامیست!"), -}); - -const defaultValues = { - description: "", -}; - -const ReferForm = ({ rowId, mutate, handleClose, setOpenReferDialog }) => { - const requestServer = useRequest({ notificationSuccess: true }); - const { - control, - handleSubmit, - formState: { isSubmitting }, - } = useForm({ defaultValues, resolver: yupResolver(validationSchema), mode: "all" }); - - const onSubmit = async (data) => { - await requestServer(`${REFER_VERIFY_NEADROAD_ROAD_INQUIRY_PRIVACY_ZAMIN_GOV_ASSISTANT}/${rowId}`, "post", { - data: { - expert_description: data.description, - }, - }) - .then(() => { - handleClose(); - setOpenReferDialog(false); - mutate(); - }) - .catch(() => {}); - }; - - return ( - <> - - - ( - - )} - /> - - - - - - - ); -}; -export default ReferForm; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/Refer/index.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/Refer/index.jsx deleted file mode 100644 index e18024f..0000000 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/Refer/index.jsx +++ /dev/null @@ -1,54 +0,0 @@ -import { Close } from "@mui/icons-material"; -import { Button, Dialog, DialogTitle, IconButton } from "@mui/material"; -import { useState } from "react"; -import ReferForm from "./Form"; - -const Refer = ({ rowId, mutate, handleClose, isSubmitting }) => { - const [openReferDialog, setOpenReferDialog] = useState(false); - - return ( - <> - - { - setOpenReferDialog(false); - }} - maxWidth="xs" - fullWidth - > - setOpenReferDialog(false)} - sx={{ - position: "absolute", - right: 8, - top: 8, - zIndex: 10, - color: (theme) => theme.palette.grey[500], - }} - > - - - مخالفت و ارجاع به دفتر حریم - {openReferDialog && ( - - )} - - - ); -}; -export default Refer; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/index.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/index.jsx deleted file mode 100644 index d020ad8..0000000 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/Questions/index.jsx +++ /dev/null @@ -1,70 +0,0 @@ -import StyledForm from "@/core/components/StyledForm"; -import { CONFIRM_VERIFY_NEADROAD_ROAD_INQUIRY_PRIVACY_ZAMIN_GOV_ASSISTANT } from "@/core/utils/routes"; -import useRequest from "@/lib/hooks/useRequest"; -import { yupResolver } from "@hookform/resolvers/yup"; -import { Button, DialogActions, DialogContent, Stack } from "@mui/material"; -import { useForm } from "react-hook-form"; -import { object, string } from "yup"; -import QuestionVerifyNeedRoadForm from "./QuestionVerifyNeedRoadForm"; -import Refer from "./Refer"; -import DescriptionForm from "./DescriptionForm"; - -const validationSchema = object({ - description: string().required("وارد کردن توضیحات الزامیست!"), -}); - -const defaultValues = { - description: "", -}; - -const Questions = ({ row, rowId, mutate, handleClose, handlePrev }) => { - const requestServer = useRequest({ notificationSuccess: true }); - - const { - control, - handleSubmit, - formState: { isSubmitting }, - } = useForm({ defaultValues, resolver: yupResolver(validationSchema), mode: "all" }); - - const onSubmit = async (data) => { - await requestServer(`${CONFIRM_VERIFY_NEADROAD_ROAD_INQUIRY_PRIVACY_ZAMIN_GOV_ASSISTANT}/${rowId}`, "post", { - data: { - expert_description: data.description, - }, - }) - .then(() => { - handleClose(); - mutate(); - }) - .catch(() => {}); - }; - - return ( - - - - - - - - - - - - - - - - ); -}; -export default Questions; diff --git a/src/core/utils/routes.js b/src/core/utils/routes.js index a42b84c..13cc378 100644 --- a/src/core/utils/routes.js +++ b/src/core/utils/routes.js @@ -244,6 +244,12 @@ export const PRIVACY_ADMIN_ACTION_API = api + "/api/v3/harim/harim_office"; export const GET_INQUIRY_PRIVACY_TABLE_LIST = api + "/api/v3/harim/technical_deputy"; export const GET_GENERAL_MANAGER_LIST = api + "/api/v3/harim/general_manager"; +// technical deputy actions +export const CONFIRM_ROAD_SAFETY_FORM = api + "/api/v3/harim/technical_deputy/confirm_request"; +export const CONFIRM_VERIFY_ROAD_SAFETY_FORM = api + "/api/v3/harim/technical_deputy/confirm_road_access"; +export const CONFIRM_VERIFY_LICENSE_FORM = api + "/api/v3/harim/technical_deputy/confirm_payment"; + + // History export const GET_HISTORY_LIST = api + "/api/v3/harim/detail/histories"; export const GET_REQUEST_INQUIRY_PRIVACY = api + "/api/v3/harim/technical_deputy"; From 9f622baca8ec40dd6675f37c374b17f5bb6ccad7 Mon Sep 17 00:00:00 2001 From: AminGhasempoor Date: Wed, 26 Nov 2025 16:27:27 +0330 Subject: [PATCH 34/61] build and format --- .../PrevCartableOpinion.jsx | 17 ----- .../Questions/DescriptionForm.jsx | 29 ------- .../Questions/QuestionVerifyNeedRoadForm.jsx | 29 ------- .../QuestionVerifyRoadSafetyForm.jsx | 29 ------- .../Questions/Refer/Form.jsx | 76 ------------------- .../Questions/Refer/index.jsx | 54 ------------- .../Questions/index.jsx | 74 ------------------ 7 files changed, 308 deletions(-) delete mode 100644 src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/PrevCartableOpinion.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/DescriptionForm.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/QuestionVerifyNeedRoadForm.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/QuestionVerifyRoadSafetyForm.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/Refer/Form.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/Refer/index.jsx delete mode 100644 src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/index.jsx diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/PrevCartableOpinion.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/PrevCartableOpinion.jsx deleted file mode 100644 index f6ca361..0000000 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/PrevCartableOpinion.jsx +++ /dev/null @@ -1,17 +0,0 @@ -import { Card, CardContent, CircularProgress, Stack, Typography } from "@mui/material"; - -const PrevCartableOpinion = ({ item }) => { - return ( - - - - - {item.previous_state_name}: {item.action_name} - - توضیحات: {item.expert_description} - - - - ); -}; -export default PrevCartableOpinion; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/DescriptionForm.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/DescriptionForm.jsx deleted file mode 100644 index a7099e7..0000000 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/DescriptionForm.jsx +++ /dev/null @@ -1,29 +0,0 @@ -import { Stack, TextField } from "@mui/material"; -import { Controller } from "react-hook-form"; - -const DescriptionForm = ({ control }) => { - return ( - - ( - - )} - /> - - ); -}; -export default DescriptionForm; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/QuestionVerifyNeedRoadForm.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/QuestionVerifyNeedRoadForm.jsx deleted file mode 100644 index 927ef9e..0000000 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/QuestionVerifyNeedRoadForm.jsx +++ /dev/null @@ -1,29 +0,0 @@ -import { Card, CardContent, Stack, Typography } from "@mui/material"; - -const QuestionVerifyNeedRoadForm = () => { - return ( - - - - - آیا ضمانت نامه ها مورد تایید است؟ - - - دفتر حریم راه : - - بله - - - - - - ); -}; -export default QuestionVerifyNeedRoadForm; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/QuestionVerifyRoadSafetyForm.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/QuestionVerifyRoadSafetyForm.jsx deleted file mode 100644 index 8c1e4e3..0000000 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/QuestionVerifyRoadSafetyForm.jsx +++ /dev/null @@ -1,29 +0,0 @@ -import { Card, CardContent, Stack, Typography } from "@mui/material"; - -const QuestionVerifyRoadSafetyForm = ({ row }) => { - return ( - - - - - آیا ایمنی راه این طرح مورد تایید است؟ - - - دفتر حریم راه : - - {row.original.isSafety ? "بله" : "خیر"} - - - - - - ); -}; -export default QuestionVerifyRoadSafetyForm; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/Refer/Form.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/Refer/Form.jsx deleted file mode 100644 index c3a58b1..0000000 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/Refer/Form.jsx +++ /dev/null @@ -1,76 +0,0 @@ -import { REFER_VERIFY_NEADROAD_ROAD_INQUIRY_PRIVACY_ZAMIN_GOV_ASSISTANT } from "@/core/utils/routes"; -import useRequest from "@/lib/hooks/useRequest"; -import { yupResolver } from "@hookform/resolvers/yup"; -import { Button, DialogActions, DialogContent, Stack, TextField } from "@mui/material"; -import { Controller, useForm } from "react-hook-form"; -import { object, string } from "yup"; -const validationSchema = object({ - description: string().required("وارد کردن توضیحات الزامیست!"), -}); - -const defaultValues = { - description: "", -}; - -const ReferForm = ({ rowId, mutate, handleClose, setOpenReferDialog }) => { - const requestServer = useRequest({ notificationSuccess: true }); - const { - control, - handleSubmit, - formState: { isSubmitting }, - } = useForm({ defaultValues, resolver: yupResolver(validationSchema), mode: "all" }); - - const onSubmit = async (data) => { - await requestServer(`${REFER_VERIFY_NEADROAD_ROAD_INQUIRY_PRIVACY_ZAMIN_GOV_ASSISTANT}/${rowId}`, "post", { - data: { - expert_description: data.description, - }, - }) - .then(() => { - handleClose(); - setOpenReferDialog(false); - mutate(); - }) - .catch(() => {}); - }; - - return ( - <> - - - ( - - )} - /> - - - - - - - ); -}; -export default ReferForm; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/Refer/index.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/Refer/index.jsx deleted file mode 100644 index e18024f..0000000 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/Refer/index.jsx +++ /dev/null @@ -1,54 +0,0 @@ -import { Close } from "@mui/icons-material"; -import { Button, Dialog, DialogTitle, IconButton } from "@mui/material"; -import { useState } from "react"; -import ReferForm from "./Form"; - -const Refer = ({ rowId, mutate, handleClose, isSubmitting }) => { - const [openReferDialog, setOpenReferDialog] = useState(false); - - return ( - <> - - { - setOpenReferDialog(false); - }} - maxWidth="xs" - fullWidth - > - setOpenReferDialog(false)} - sx={{ - position: "absolute", - right: 8, - top: 8, - zIndex: 10, - color: (theme) => theme.palette.grey[500], - }} - > - - - مخالفت و ارجاع به دفتر حریم - {openReferDialog && ( - - )} - - - ); -}; -export default Refer; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/index.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/index.jsx deleted file mode 100644 index 2f89a8f..0000000 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/Questions/index.jsx +++ /dev/null @@ -1,74 +0,0 @@ -import StyledForm from "@/core/components/StyledForm"; -import { - CONFIRM_INQUIRY_PRIVACY_ZAMIN_GOV_ASSISTANT, - CONFIRM_VERIFY_NEADROAD_ROAD_INQUIRY_PRIVACY_ZAMIN_GOV_ASSISTANT, -} from "@/core/utils/routes"; -import useRequest from "@/lib/hooks/useRequest"; -import { yupResolver } from "@hookform/resolvers/yup"; -import { Button, DialogActions, DialogContent, Stack } from "@mui/material"; -import { useForm } from "react-hook-form"; -import { object, string } from "yup"; -import QuestionVerifyNeedRoadForm from "./QuestionVerifyNeedRoadForm"; -import QuestionVerifyRoadSafetyForm from "./QuestionVerifyRoadSafetyForm"; -import Refer from "./Refer"; -import DescriptionForm from "./DescriptionForm"; - -const validationSchema = object({ - description: string().required("وارد کردن توضیحات الزامیست!"), -}); - -const defaultValues = { - description: "", -}; - -const Questions = ({ row, rowId, mutate, handleClose, handlePrev }) => { - const requestServer = useRequest({ notificationSuccess: true }); - - const { - control, - handleSubmit, - formState: { isSubmitting }, - } = useForm({ defaultValues, resolver: yupResolver(validationSchema), mode: "all" }); - - const onSubmit = async (data) => { - await requestServer(`${CONFIRM_VERIFY_NEADROAD_ROAD_INQUIRY_PRIVACY_ZAMIN_GOV_ASSISTANT}/${rowId}`, "post", { - data: { - expert_description: data.description, - }, - }) - .then(() => { - handleClose(); - mutate(); - }) - .catch(() => {}); - }; - - return ( - - - - - - - - - - - - - - - - ); -}; -export default Questions; From a6d1e7db29b63c95ec97e40d6683c0a3ad68428e Mon Sep 17 00:00:00 2001 From: AminGhasempoor Date: Wed, 26 Nov 2025 16:27:43 +0330 Subject: [PATCH 35/61] build and format2 --- .../ConfirmVerifyLicenseForm/ConfirmRoadSafetyDialog.jsx | 6 +----- .../ConfirmRoadSafetyFormContext.jsx | 4 ++-- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/ConfirmRoadSafetyDialog.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/ConfirmRoadSafetyDialog.jsx index f1779ad..b0beb30 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/ConfirmRoadSafetyDialog.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/ConfirmRoadSafetyDialog.jsx @@ -31,11 +31,7 @@ const ConfirmRoadSafetyDialog = ({ handleClose, rowId, mutate }) => { {loading ? ( ) : data ? ( - + ) : ( اطلاعات درخواست در سامانه یافت نشد diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/ConfirmRoadSafetyFormContext.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/ConfirmRoadSafetyFormContext.jsx index bf9c691..98c2d55 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/ConfirmRoadSafetyFormContext.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/ConfirmRoadSafetyFormContext.jsx @@ -4,7 +4,7 @@ import useRequest from "@/lib/hooks/useRequest"; import { useState } from "react"; const ConfirmRoadSafetyFormContext = ({ rowId, mutate, handleClose }) => { - const requestServer = useRequest({notificationShow : true, notificationSuccess : true}); + const requestServer = useRequest({ notificationShow: true, notificationSuccess: true }); const [description, setDescription] = useState(""); const [loading, setLoading] = useState(false); const [error, setError] = useState(null); @@ -30,7 +30,7 @@ const ConfirmRoadSafetyFormContext = ({ rowId, mutate, handleClose }) => { setSuccess(true); mutate(); setDescription(""); - handleClose() + handleClose(); } catch (err) { setError(err.message); } finally { From 16c3c505c8e4d49ce8a4b507538a4cf420cde3f2 Mon Sep 17 00:00:00 2001 From: AminGhasempoor Date: Wed, 26 Nov 2025 16:28:09 +0330 Subject: [PATCH 36/61] build and format3 --- .../ConfirmRoadSafetyForm/ConfirmRoadSafetyDialog.jsx | 6 +----- .../ConfirmRoadSafetyForm/ConfirmRoadSafetyFormContext.jsx | 4 ++-- .../ConfirmVerifyRoadSafetyForm/ConfirmRoadSafetyDialog.jsx | 6 +----- .../ConfirmRoadSafetyFormContext.jsx | 4 ++-- src/core/utils/routes.js | 1 - 5 files changed, 6 insertions(+), 15 deletions(-) diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/ConfirmRoadSafetyDialog.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/ConfirmRoadSafetyDialog.jsx index 88c69c8..512e9a5 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/ConfirmRoadSafetyDialog.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/ConfirmRoadSafetyDialog.jsx @@ -31,11 +31,7 @@ const ConfirmRoadSafetyDialog = ({ row, handleClose, rowId, mutate }) => { {loading ? ( ) : data ? ( - + ) : ( اطلاعات درخواست در سامانه یافت نشد diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/ConfirmRoadSafetyFormContext.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/ConfirmRoadSafetyFormContext.jsx index da232da..5b4dd3d 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/ConfirmRoadSafetyFormContext.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/ConfirmRoadSafetyFormContext.jsx @@ -4,7 +4,7 @@ import useRequest from "@/lib/hooks/useRequest"; import { CONFIRM_ROAD_SAFETY_FORM } from "@/core/utils/routes"; const ConfirmRoadSafetyFormContext = ({ rowId, mutate, handleClose }) => { - const requestServer = useRequest({notificationShow : true, notificationSuccess : true}); + const requestServer = useRequest({ notificationShow: true, notificationSuccess: true }); const [description, setDescription] = useState(""); const [loading, setLoading] = useState(false); const [error, setError] = useState(null); @@ -30,7 +30,7 @@ const ConfirmRoadSafetyFormContext = ({ rowId, mutate, handleClose }) => { setSuccess(true); mutate(); setDescription(""); - handleClose() + handleClose(); } catch (err) { setError(err.message); } finally { diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/ConfirmRoadSafetyDialog.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/ConfirmRoadSafetyDialog.jsx index 940982a..933dda4 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/ConfirmRoadSafetyDialog.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/ConfirmRoadSafetyDialog.jsx @@ -31,11 +31,7 @@ const ConfirmRoadSafetyDialog = ({ row, handleClose, rowId, mutate }) => { {loading ? ( ) : data ? ( - + ) : ( اطلاعات درخواست در سامانه یافت نشد diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/ConfirmRoadSafetyFormContext.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/ConfirmRoadSafetyFormContext.jsx index 1738b35..79c8e46 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/ConfirmRoadSafetyFormContext.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/ConfirmRoadSafetyFormContext.jsx @@ -4,7 +4,7 @@ import { CONFIRM_VERIFY_ROAD_SAFETY_FORM } from "@/core/utils/routes"; import { Alert, Box, Button, CircularProgress, DialogContent, TextField } from "@mui/material"; const ConfirmRoadSafetyFormContext = ({ rowId, mutate, handleClose }) => { - const requestServer = useRequest({notificationShow : true, notificationSuccess : true}); + const requestServer = useRequest({ notificationShow: true, notificationSuccess: true }); const [description, setDescription] = useState(""); const [loading, setLoading] = useState(false); const [error, setError] = useState(null); @@ -30,7 +30,7 @@ const ConfirmRoadSafetyFormContext = ({ rowId, mutate, handleClose }) => { setSuccess(true); mutate(); setDescription(""); - handleClose() + handleClose(); } catch (err) { setError(err.message); } finally { diff --git a/src/core/utils/routes.js b/src/core/utils/routes.js index 13cc378..7e23042 100644 --- a/src/core/utils/routes.js +++ b/src/core/utils/routes.js @@ -249,7 +249,6 @@ export const CONFIRM_ROAD_SAFETY_FORM = api + "/api/v3/harim/technical_deputy/co export const CONFIRM_VERIFY_ROAD_SAFETY_FORM = api + "/api/v3/harim/technical_deputy/confirm_road_access"; export const CONFIRM_VERIFY_LICENSE_FORM = api + "/api/v3/harim/technical_deputy/confirm_payment"; - // History export const GET_HISTORY_LIST = api + "/api/v3/harim/detail/histories"; export const GET_REQUEST_INQUIRY_PRIVACY = api + "/api/v3/harim/technical_deputy"; From 9d10fefaca47a266fed9d54a609da9e05329b5be Mon Sep 17 00:00:00 2001 From: AminGhasempoor Date: Mon, 1 Dec 2025 11:05:50 +0330 Subject: [PATCH 37/61] add map to toll house --- .env.example | 1 + next.config.mjs | 4 + .../infrastructure/map/loading.jsx | 7 + .../infrastructure/map/page.js | 16 ++ .../tollHouse/ShowProjectArea/ShowBound.jsx | 29 +++ .../tollHouse/ShowProjectArea/index.jsx | 69 ++++++ .../tollHouse/TollHouseList.jsx | 23 ++ .../tollHouseMap/ClusterSwitch/index.jsx | 25 ++ .../tollHouseMap/Filter/index.jsx | 44 ++++ .../tollHouseMap/Legend/index.jsx | 35 +++ .../DialogInfoItem/ContentInfoItem.jsx | 71 ++++++ .../PointsOnMap/DialogInfoItem/index.jsx | 51 ++++ .../tollHouseMap/PointsOnMap/index.jsx | 79 ++++++ .../infrastructure/tollHouseMap/index.jsx | 231 ++++++++++++++++++ src/core/utils/headerMenu.js | 2 +- src/core/utils/routes.js | 1 + 16 files changed, 687 insertions(+), 1 deletion(-) create mode 100644 src/app/(withAuth)/(dashboardLayout)/infrastructure/map/loading.jsx create mode 100644 src/app/(withAuth)/(dashboardLayout)/infrastructure/map/page.js create mode 100644 src/components/infrastructure/tollHouse/ShowProjectArea/ShowBound.jsx create mode 100644 src/components/infrastructure/tollHouse/ShowProjectArea/index.jsx create mode 100644 src/components/infrastructure/tollHouseMap/ClusterSwitch/index.jsx create mode 100644 src/components/infrastructure/tollHouseMap/Filter/index.jsx create mode 100644 src/components/infrastructure/tollHouseMap/Legend/index.jsx create mode 100644 src/components/infrastructure/tollHouseMap/PointsOnMap/DialogInfoItem/ContentInfoItem.jsx create mode 100644 src/components/infrastructure/tollHouseMap/PointsOnMap/DialogInfoItem/index.jsx create mode 100644 src/components/infrastructure/tollHouseMap/PointsOnMap/index.jsx create mode 100644 src/components/infrastructure/tollHouseMap/index.jsx diff --git a/.env.example b/.env.example index 8368bd5..d6c1f1b 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,5 @@ HOST="rms.witel.ir" +HOST_RMTO="rms.rmto.ir" NEXT_PUBLIC_VERSION="1.8.3" NEXT_PUBLIC_API_URL="https://rms.witel.ir" NEXT_PUBLIC_MAPTILE_ENDPOINT="https://rmsmap.rmto.ir/141map" \ No newline at end of file diff --git a/next.config.mjs b/next.config.mjs index e33199c..ac3621e 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -7,6 +7,10 @@ const nextConfig = { protocol: 'https', hostname: process.env.HOST, }, + { + protocol: 'https', + hostname: process.env.HOST_RMTO, + }, ], }, }; diff --git a/src/app/(withAuth)/(dashboardLayout)/infrastructure/map/loading.jsx b/src/app/(withAuth)/(dashboardLayout)/infrastructure/map/loading.jsx new file mode 100644 index 0000000..4535a8d --- /dev/null +++ b/src/app/(withAuth)/(dashboardLayout)/infrastructure/map/loading.jsx @@ -0,0 +1,7 @@ +"use client"; +import PageLoading from "@/core/components/PageLoading"; + +const Loading = () => { + return ; +}; +export default Loading; diff --git a/src/app/(withAuth)/(dashboardLayout)/infrastructure/map/page.js b/src/app/(withAuth)/(dashboardLayout)/infrastructure/map/page.js new file mode 100644 index 0000000..a4cad6b --- /dev/null +++ b/src/app/(withAuth)/(dashboardLayout)/infrastructure/map/page.js @@ -0,0 +1,16 @@ +import WithPermission from "@/core/middlewares/withPermission"; +import TollHouseMapPage from "@/components/infrastructure/tollHouseMap"; + +export const metadata = { + title: "پراکندگی بر روی نقشه راهدارخانه ها", +}; + +const Page = () => { + return ( + + + + ); +}; + +export default Page; diff --git a/src/components/infrastructure/tollHouse/ShowProjectArea/ShowBound.jsx b/src/components/infrastructure/tollHouse/ShowProjectArea/ShowBound.jsx new file mode 100644 index 0000000..24db476 --- /dev/null +++ b/src/components/infrastructure/tollHouse/ShowProjectArea/ShowBound.jsx @@ -0,0 +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; diff --git a/src/components/infrastructure/tollHouse/ShowProjectArea/index.jsx b/src/components/infrastructure/tollHouse/ShowProjectArea/index.jsx new file mode 100644 index 0000000..202ef61 --- /dev/null +++ b/src/components/infrastructure/tollHouse/ShowProjectArea/index.jsx @@ -0,0 +1,69 @@ +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)}> + + + + setOpenShowAreaDialog(false)} + PaperProps={{ + sx: { + transition: "all .3s", + boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px", + borderRadius: 2, + padding: 1, + }, + }} + maxWidth="sm" + fullWidth + dir="rtl" + > + + + محدوده طرح + + setOpenShowAreaDialog(false)} size="small"> + + + + + + + + + + + + + + + ); +}; + +export default ShowProjectArea; diff --git a/src/components/infrastructure/tollHouse/TollHouseList.jsx b/src/components/infrastructure/tollHouse/TollHouseList.jsx index 11536b8..e8e6d2f 100644 --- a/src/components/infrastructure/tollHouse/TollHouseList.jsx +++ b/src/components/infrastructure/tollHouse/TollHouseList.jsx @@ -13,6 +13,7 @@ import { usePermissions } from "@/lib/hooks/usePermissions"; import LocationForm from "./RowActions/LocationForm"; import ImageDialog from "./RowActions/ImageForm"; import { useAuth } from "@/lib/contexts/auth"; +import ShowProjectArea from "./ShowProjectArea"; const statusOptions = [ { value: "", label: "همه وضعیت ها" }, @@ -225,6 +226,28 @@ const TollHouseList = () => { ); }, }, + { + accessorKey: "area", + header: "نمایش محدوده طرح", + id: "area", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ row }) => + row.original.area ? ( + + + + ) : ( + "-" + ), + }, { accessorKey: "phone", header: "تلفن راهدارخانه", diff --git a/src/components/infrastructure/tollHouseMap/ClusterSwitch/index.jsx b/src/components/infrastructure/tollHouseMap/ClusterSwitch/index.jsx new file mode 100644 index 0000000..e8fac87 --- /dev/null +++ b/src/components/infrastructure/tollHouseMap/ClusterSwitch/index.jsx @@ -0,0 +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; diff --git a/src/components/infrastructure/tollHouseMap/Filter/index.jsx b/src/components/infrastructure/tollHouseMap/Filter/index.jsx new file mode 100644 index 0000000..3cbbe5d --- /dev/null +++ b/src/components/infrastructure/tollHouseMap/Filter/index.jsx @@ -0,0 +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; diff --git a/src/components/infrastructure/tollHouseMap/Legend/index.jsx b/src/components/infrastructure/tollHouseMap/Legend/index.jsx new file mode 100644 index 0000000..b6f5936 --- /dev/null +++ b/src/components/infrastructure/tollHouseMap/Legend/index.jsx @@ -0,0 +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; diff --git a/src/components/infrastructure/tollHouseMap/PointsOnMap/DialogInfoItem/ContentInfoItem.jsx b/src/components/infrastructure/tollHouseMap/PointsOnMap/DialogInfoItem/ContentInfoItem.jsx new file mode 100644 index 0000000..5061fe9 --- /dev/null +++ b/src/components/infrastructure/tollHouseMap/PointsOnMap/DialogInfoItem/ContentInfoItem.jsx @@ -0,0 +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" ? "فعال" : "غیرفعال"} + + + + + + + recognize_picture + + + + + + recognize_picture_second + + + + + ); +}; +export default ContentInfoItem; diff --git a/src/components/infrastructure/tollHouseMap/PointsOnMap/DialogInfoItem/index.jsx b/src/components/infrastructure/tollHouseMap/PointsOnMap/DialogInfoItem/index.jsx new file mode 100644 index 0000000..232c2a4 --- /dev/null +++ b/src/components/infrastructure/tollHouseMap/PointsOnMap/DialogInfoItem/index.jsx @@ -0,0 +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; diff --git a/src/components/infrastructure/tollHouseMap/PointsOnMap/index.jsx b/src/components/infrastructure/tollHouseMap/PointsOnMap/index.jsx new file mode 100644 index 0000000..e0b3f16 --- /dev/null +++ b/src/components/infrastructure/tollHouseMap/PointsOnMap/index.jsx @@ -0,0 +1,79 @@ +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 }) => ( + { + openDialog(); + setSelectedId(id); + }, + }} + color={getMarkerColor(Number(status))} + /> + )); + + }, [data, theme]); + + useEffect(() => { + if (data.length === 0) return; + + const bounds = L.latLngBounds( + data.map(({ lat, lng }) => { + return L.latLng(Number(lat), Number(lng)); + }) + ); + + 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 + )} + + {open && } + + + ); +}; +export default PointsOnMap; diff --git a/src/components/infrastructure/tollHouseMap/index.jsx b/src/components/infrastructure/tollHouseMap/index.jsx new file mode 100644 index 0000000..2177397 --- /dev/null +++ b/src/components/infrastructure/tollHouseMap/index.jsx @@ -0,0 +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; diff --git a/src/core/utils/headerMenu.js b/src/core/utils/headerMenu.js index 6faa5fa..dcadc5e 100644 --- a/src/core/utils/headerMenu.js +++ b/src/core/utils/headerMenu.js @@ -33,7 +33,7 @@ export const headerMenu = [ [ { title: "پراکندگی بر روی نقشه راهدارخانه ها", - href: api + "/v2/map?type=rahdar", + href: "/infrastructure/map", }, { title: "راهدارخانه ها", diff --git a/src/core/utils/routes.js b/src/core/utils/routes.js index 7e23042..11cf9b4 100644 --- a/src/core/utils/routes.js +++ b/src/core/utils/routes.js @@ -210,6 +210,7 @@ export const GET_TOLL_HOUSE_DETAILS = api + "/api/v3/road_maintenance_station"; export const DELETE_TOLL_HOUSE_ITEM = api + "/api/v3/road_maintenance_station"; export const UPDATE_TOLL_HOUSE_ITEM = api + "/api/v3/road_maintenance_station"; export const GET_TOLL_HOUSE_IMAGES = api + "/api/v3/road_maintenance_station/images"; +export const GET_TOLL_HOUSE_MAP = api + "/api/v3/road_maintenance_station/map"; // road missions export const GET_ROAD_MISSIONS_OPERATOR_LIST = api + "/api/v3/missions/request_portal"; From 15106d02c0c8d575ab17257c4f5b93bc305e2672 Mon Sep 17 00:00:00 2001 From: AminGhasempoor Date: Mon, 1 Dec 2025 11:08:53 +0330 Subject: [PATCH 38/61] build and format --- .../infrastructure/tollHouse/ShowProjectArea/index.jsx | 6 +----- src/components/infrastructure/tollHouse/TollHouseList.jsx | 6 ++---- .../infrastructure/tollHouseMap/PointsOnMap/index.jsx | 2 -- src/components/infrastructure/tollHouseMap/index.jsx | 4 ++-- 4 files changed, 5 insertions(+), 13 deletions(-) diff --git a/src/components/infrastructure/tollHouse/ShowProjectArea/index.jsx b/src/components/infrastructure/tollHouse/ShowProjectArea/index.jsx index 202ef61..250cd52 100644 --- a/src/components/infrastructure/tollHouse/ShowProjectArea/index.jsx +++ b/src/components/infrastructure/tollHouse/ShowProjectArea/index.jsx @@ -11,17 +11,13 @@ const ShowProjectArea = ({ primaryArea }) => { const bound = useMemo(() => { const coordinates = Object.values(primaryArea.coordinates); - const latLngCoords = coordinates.map(([lat, lng]) => [ - parseFloat(lng), - parseFloat(lat), - ]); + const latLngCoords = coordinates.map(([lat, lng]) => [parseFloat(lng), parseFloat(lat)]); return primaryArea.type === "polygon" ? L.polygon(latLngCoords, { color: "#ff5555" }) : L.polyline(latLngCoords); }, [primaryArea]); - return ( diff --git a/src/components/infrastructure/tollHouse/TollHouseList.jsx b/src/components/infrastructure/tollHouse/TollHouseList.jsx index e8e6d2f..dc115ec 100644 --- a/src/components/infrastructure/tollHouse/TollHouseList.jsx +++ b/src/components/infrastructure/tollHouse/TollHouseList.jsx @@ -238,11 +238,9 @@ const TollHouseList = () => { grow: false, size: 100, Cell: ({ row }) => - row.original.area ? ( + row.original.area ? ( - + ) : ( "-" diff --git a/src/components/infrastructure/tollHouseMap/PointsOnMap/index.jsx b/src/components/infrastructure/tollHouseMap/PointsOnMap/index.jsx index e0b3f16..05b4d03 100644 --- a/src/components/infrastructure/tollHouseMap/PointsOnMap/index.jsx +++ b/src/components/infrastructure/tollHouseMap/PointsOnMap/index.jsx @@ -34,7 +34,6 @@ const PointsOnMap = ({ data, isCluster }) => { color={getMarkerColor(Number(status))} /> )); - }, [data, theme]); useEffect(() => { @@ -49,7 +48,6 @@ const PointsOnMap = ({ data, isCluster }) => { map.flyToBounds(bounds, { duration: 0.7 }); }, [data]); - const createClusterCustomIcon = (cluster) => { const count = cluster.getChildCount(); return L.divIcon({ diff --git a/src/components/infrastructure/tollHouseMap/index.jsx b/src/components/infrastructure/tollHouseMap/index.jsx index 2177397..f7b5a86 100644 --- a/src/components/infrastructure/tollHouseMap/index.jsx +++ b/src/components/infrastructure/tollHouseMap/index.jsx @@ -122,8 +122,8 @@ const RoadSafetyReportMap = () => { props.dependencyFieldValue?.value === "" ? "empty" : loadingEdaratList - ? "loading" - : props.filterParameters.value + ? "loading" + : props.filterParameters.value } selectOption={getSelectOptions} /> From 7c197c2bf0d21a3cca30818ee0b90c90cbe78d80 Mon Sep 17 00:00:00 2001 From: AminGhasempoor Date: Mon, 1 Dec 2025 13:05:54 +0330 Subject: [PATCH 39/61] add km to control panel --- .../StartMission/StartMissionContent.jsx | 24 ++++++++++++++++ .../RowActions/Allocation/Form/index.jsx | 28 ++++--------------- 2 files changed, 29 insertions(+), 23 deletions(-) diff --git a/src/components/dashboard/roadMissions/control/RowActions/StartMission/StartMissionContent.jsx b/src/components/dashboard/roadMissions/control/RowActions/StartMission/StartMissionContent.jsx index c7f516d..72fc54b 100644 --- a/src/components/dashboard/roadMissions/control/RowActions/StartMission/StartMissionContent.jsx +++ b/src/components/dashboard/roadMissions/control/RowActions/StartMission/StartMissionContent.jsx @@ -11,6 +11,7 @@ const StartMissionContent = ({ rowId, mutate, setOpenStartMissionDialog }) => { const validationSchema = object().shape({ code: string().length(6, "کد خروج باید 6 رقم باشد").required("لطفاً کد خروج را وارد کنید."), + km: string().required("لطفاً کیلومتر را وارد کنید."), }); const { @@ -20,6 +21,7 @@ const StartMissionContent = ({ rowId, mutate, setOpenStartMissionDialog }) => { } = useForm({ defaultValues: { code: "", + km : "" }, resolver: yupResolver(validationSchema), mode: "all", @@ -29,6 +31,7 @@ const StartMissionContent = ({ rowId, mutate, setOpenStartMissionDialog }) => { requestServer(`${START_MISSION}/${rowId}`, "post", { data: { code: values.code, + km: values.km, }, hasSidebarUpdate: true, }) @@ -69,6 +72,27 @@ const StartMissionContent = ({ rowId, mutate, setOpenStartMissionDialog }) => { )} /> + + ( + { + if (isNaN(Number(e.target.value))) return; + field.onChange(e.target.value) + }} + size="small" + fullWidth + label="کیلومتر خودرو / ساعت کار" + InputLabelProps={{ shrink: true }} + /> + )} + /> +
diff --git a/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/index.jsx b/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/index.jsx index f5d4395..eb591e8 100644 --- a/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/index.jsx +++ b/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/index.jsx @@ -22,16 +22,14 @@ const AllocationForm = ({ row, mutate, setOpenAllocationDialog }) => { const requestServer = useRequest({ notificationSuccess: true }); const [machine, setMachine] = useState(); const [driver, setDriver] = useState(); - const [kilometer, setKilometer] = useState(); const [isSubmitting, setIsSubmitting] = useState(false); - const handleSubmit = async (_machine, _driver, _kilometer) => { + const handleSubmit = async (_machine, _driver) => { setIsSubmitting(true); await requestServer(`${ALLOCATE_REQUEST_MISSION}/${row.id}`, "post", { data: { - machines: [_machine.id], + machines: _machine.id, driver: _driver.id, - km: kilometer, }, hasSidebarUpdate: true, }) @@ -110,23 +108,7 @@ const AllocationForm = ({ row, mutate, setOpenAllocationDialog }) => { )} )} - {driver && ( - - { - if (isNaN(Number(e.target.value))) return; - setKilometer(e.target.value); - }} - size="small" - fullWidth - label="کیلومتر خودرو" - InputLabelProps={{ shrink: true }} - /> - - )} + @@ -208,10 +190,10 @@ const AllocationForm = ({ row, mutate, setOpenAllocationDialog }) => { + ))} + + + + ); +}; +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 new file mode 100644 index 0000000..682be24 --- /dev/null +++ b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/Area/MapControlPolyline/DrawBound/index.jsx @@ -0,0 +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; 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 new file mode 100644 index 0000000..edd6cac --- /dev/null +++ b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/Area/MapControlPolyline/index.jsx @@ -0,0 +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; 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 new file mode 100644 index 0000000..a69a0ba --- /dev/null +++ b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/Area/SelectBoundType/index.jsx @@ -0,0 +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; 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 new file mode 100644 index 0000000..91dd0d3 --- /dev/null +++ b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/Area/index.jsx @@ -0,0 +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; 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 new file mode 100644 index 0000000..c002df3 --- /dev/null +++ b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/GetDateTime/MissionDates/index.jsx @@ -0,0 +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; 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 new file mode 100644 index 0000000..9e35f41 --- /dev/null +++ b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/GetDateTime/index.jsx @@ -0,0 +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; 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 new file mode 100644 index 0000000..1e7e881 --- /dev/null +++ b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/GetItemInfo/FastReactCode/Dialog/List/RowActions/SelectId/index.jsx @@ -0,0 +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; 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 new file mode 100644 index 0000000..3d0b958 --- /dev/null +++ b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/GetItemInfo/FastReactCode/Dialog/List/RowActions/index.jsx @@ -0,0 +1,10 @@ +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 new file mode 100644 index 0000000..82a0472 --- /dev/null +++ b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/GetItemInfo/FastReactCode/Dialog/List/index.jsx @@ -0,0 +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; 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 new file mode 100644 index 0000000..013f73f --- /dev/null +++ b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/GetItemInfo/FastReactCode/Dialog/index.jsx @@ -0,0 +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)} + /> + )} + + + setOpenFastReactDialog(false)} + sx={(theme) => ({ + position: "absolute", + right: 8, + top: 8, + zIndex: 50, + color: theme.palette.grey[500], + })} + > + + + {openFastReactDialog && ( + + )} + + + ); +}); + +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 new file mode 100644 index 0000000..1545046 --- /dev/null +++ b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/GetItemInfo/FastReactCode/index.jsx @@ -0,0 +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; 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 new file mode 100644 index 0000000..3b3b513 --- /dev/null +++ b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/GetItemInfo/index.jsx @@ -0,0 +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; 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 new file mode 100644 index 0000000..93bb1d6 --- /dev/null +++ b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/MachineAndDriver/DriversDialog/DriversSearch/Form/index.jsx @@ -0,0 +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; 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 new file mode 100644 index 0000000..b7136c9 --- /dev/null +++ b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/MachineAndDriver/DriversDialog/DriversSearch/index.jsx @@ -0,0 +1,11 @@ +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 new file mode 100644 index 0000000..3c1d406 --- /dev/null +++ b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/MachineAndDriver/DriversDialog/index.jsx @@ -0,0 +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"> + + + ) : ( + + )} + + setOpenDriversDialog(false)} + sx={(theme) => ({ + position: "absolute", + right: 8, + top: 8, + zIndex: 50, + color: theme.palette.grey[500], + })} + > + + + انتخاب راننده + {openDriversDialog && ( + + )} + + + ); +}; +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 new file mode 100644 index 0000000..f03579a --- /dev/null +++ b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/MachineAndDriver/MachinesDialog/MachineList/RowActions/Allocate/index.jsx @@ -0,0 +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; 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 new file mode 100644 index 0000000..bcfcc03 --- /dev/null +++ b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/MachineAndDriver/MachinesDialog/MachineList/RowActions/index.jsx @@ -0,0 +1,6 @@ +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 new file mode 100644 index 0000000..e070b01 --- /dev/null +++ b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/MachineAndDriver/MachinesDialog/MachineList/index.jsx @@ -0,0 +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; 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 new file mode 100644 index 0000000..8750142 --- /dev/null +++ b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/MachineAndDriver/MachinesDialog/index.jsx @@ -0,0 +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"> + + + ) : ( + + )} + + setOpenMachinesDialog(false)} + sx={(theme) => ({ + position: "absolute", + right: 8, + top: 8, + zIndex: 50, + color: theme.palette.grey[500], + })} + > + + + {openMachinesDialog && ( + + )} + + + ); +}; +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 new file mode 100644 index 0000000..24bfb15 --- /dev/null +++ b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/MachineAndDriver/index.jsx @@ -0,0 +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; 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 new file mode 100644 index 0000000..a4449fe --- /dev/null +++ b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/Rahdaran/Form/index.jsx @@ -0,0 +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; 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 new file mode 100644 index 0000000..ebc4edc --- /dev/null +++ b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/Rahdaran/List/index.jsx @@ -0,0 +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; 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 new file mode 100644 index 0000000..af01fe6 --- /dev/null +++ b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/Rahdaran/index.jsx @@ -0,0 +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; 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 new file mode 100644 index 0000000..0393018 --- /dev/null +++ b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/Verify/index.jsx @@ -0,0 +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; diff --git a/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/index.jsx b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/index.jsx new file mode 100644 index 0000000..00f9ef1 --- /dev/null +++ b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/index.jsx @@ -0,0 +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 ( + + ); +} + +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 new file mode 100644 index 0000000..2e3cb75 --- /dev/null +++ b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/index.jsx @@ -0,0 +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 ? ( + + + + ) : ( + + )} + + setOpen(false)} + sx={(theme) => ({ + position: "absolute", + right: 8, + top: 8, + zIndex: 50, + color: theme.palette.grey[500], + })} + > + + + {open && ( + + )} + + + ); +}; +export default CreateWithoutProcess; diff --git a/src/components/dashboard/roadMissions/violations/RowActions/index.jsx b/src/components/dashboard/roadMissions/violations/RowActions/index.jsx new file mode 100644 index 0000000..192bfe1 --- /dev/null +++ b/src/components/dashboard/roadMissions/violations/RowActions/index.jsx @@ -0,0 +1,4 @@ +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 new file mode 100644 index 0000000..49223c2 --- /dev/null +++ b/src/components/dashboard/roadMissions/violations/ViolationsList.jsx @@ -0,0 +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; diff --git a/src/components/dashboard/roadMissions/violations/index.jsx b/src/components/dashboard/roadMissions/violations/index.jsx new file mode 100644 index 0000000..ace0981 --- /dev/null +++ b/src/components/dashboard/roadMissions/violations/index.jsx @@ -0,0 +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; diff --git a/src/core/utils/pageMenuDev.js b/src/core/utils/pageMenuDev.js index 7a68cb6..41e811d 100644 --- a/src/core/utils/pageMenuDev.js +++ b/src/core/utils/pageMenuDev.js @@ -131,6 +131,14 @@ export const pageMenuDev = [ badges: [{ key: "mission.control" }], permissions: ["manage-control-unit"], }, + { + id: "roadMissionsViolations", + label: "تخلفات", + type: "page", + route: "/dashboard/road-missions/violation", + // badges: [{ key: "mission.control" }], // TODO: add badge and permission + permissions: ["all"], + }, ], }, { diff --git a/src/core/utils/routes.js b/src/core/utils/routes.js index 11cf9b4..6bf7001 100644 --- a/src/core/utils/routes.js +++ b/src/core/utils/routes.js @@ -227,6 +227,7 @@ export const ALLOCATE_REQUEST_MISSION = api + "/api/v3/missions/transportation_u export const DEALLOCATE_REQUEST_MISSION = api + "/api/v3/missions/transportation_unit/deallocate"; export const START_MISSION = api + "/api/v3/missions/control_unit/start"; export const FINISH_MISSION = api + "/api/v3/missions/control_unit/finish"; +export const GET_ROAD_MISSIONS_VIOLATIONS_LIST = api + "/api/v3/missions/violation_management"; export const GET_MACHINES_TABLE_LIST = api + "/api/v3/cmms_machines"; From 078f1c527350ba2510792ef6c42a505bdf692d1f Mon Sep 17 00:00:00 2001 From: baslani Date: Sun, 7 Dec 2025 15:28:19 +0330 Subject: [PATCH 43/61] synced source control with server --- jsconfig.json | 38 ++++---- .../privacy-office/PrivacyOfficeList.jsx | 7 +- .../ShowPrimaryArea/ShowForbiddenBound.jsx | 29 ++++++ .../privacy-office/ShowPrimaryArea/index.jsx | 31 +++---- src/core/utils/pageMenu.js | 90 +++++++++++-------- 5 files changed, 122 insertions(+), 73 deletions(-) create mode 100644 src/components/dashboard/inquiryPrivacy/privacy-office/ShowPrimaryArea/ShowForbiddenBound.jsx diff --git a/jsconfig.json b/jsconfig.json index c136578..b51472a 100644 --- a/jsconfig.json +++ b/jsconfig.json @@ -1,27 +1,27 @@ // javascript for production -// { -// "compilerOptions": { -// "paths": { -// "@/*": ["./src/*"], -// "^/*": ["./public/*"] -// } -// } -// } - -// typescript for local development { "compilerOptions": { - "jsx": "react-jsx", - "noUnusedLocals": true, - "noImplicitAny": false, - "checkJs": true, - "allowJs": true, - "strict": true, - "baseUrl": ".", "paths": { "@/*": ["./src/*"], "^/*": ["./public/*"] } - }, - "exclude": ["node_modules"] + } } + +// typescript for local development +// { +// "compilerOptions": { +// "jsx": "react-jsx", +// "noUnusedLocals": true, +// "noImplicitAny": false, +// "checkJs": true, +// "allowJs": true, +// "strict": true, +// "baseUrl": ".", +// "paths": { +// "@/*": ["./src/*"], +// "^/*": ["./public/*"] +// } +// }, +// "exclude": ["node_modules"] +// } diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/PrivacyOfficeList.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/PrivacyOfficeList.jsx index b6932ca..487c46d 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/PrivacyOfficeList.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/PrivacyOfficeList.jsx @@ -168,9 +168,12 @@ const PrivacyOfficeList = () => { grow: false, size: 100, Cell: ({ row }) => - row.original.primary_area ? ( + row.original.primary_area && row.original.forbidden_area ? ( - + ) : ( "-" diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/ShowPrimaryArea/ShowForbiddenBound.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/ShowPrimaryArea/ShowForbiddenBound.jsx new file mode 100644 index 0000000..c8d28d1 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/ShowPrimaryArea/ShowForbiddenBound.jsx @@ -0,0 +1,29 @@ +import { useEffect, useRef } from "react"; +import { FeatureGroup, useMap } from "react-leaflet"; + +const ShowForbiddenBound = ({ 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 ShowForbiddenBound; diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/ShowPrimaryArea/index.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/ShowPrimaryArea/index.jsx index 98e24d0..996a2cd 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/ShowPrimaryArea/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/ShowPrimaryArea/index.jsx @@ -1,27 +1,27 @@ -const { - Button, - IconButton, - Tooltip, - Box, - Dialog, - DialogTitle, - Typography, - DialogContent, - DialogActions, -} = require("@mui/material"); -import LayersIcon from "@mui/icons-material/Layers"; -import CloseIcon from "@mui/icons-material/Close"; -import { useMemo, useState } from "react"; +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 { useMemo, useState } from "react"; import ShowBound from "./ShowBound"; +import ShowForbiddenBound from "./ShowForbiddenBound"; -const ShowPrimaryArea = ({ primaryArea }) => { +const ShowPrimaryArea = ({ primaryArea, forbiddenArea }) => { const [openShowAreaDialog, setOpenShowAreaDialog] = useState(false); const bound = useMemo(() => { const latLngCoords = primaryArea.coordinates.map((coord) => [coord[1], coord[0]]); return primaryArea.type === "polygon" ? L.polygon(latLngCoords) : L.polyline(latLngCoords); }, [primaryArea]); + const forbiddenBound = useMemo(() => { + const latLngCoords = forbiddenArea.coordinates.map((coord) => [coord[1], coord[0]]); + return forbiddenArea.type === "polygon" + ? L.polygon(latLngCoords, { + color: "#ff5555", + }) + : L.polyline(latLngCoords); + }, [forbiddenArea]); + return ( @@ -57,6 +57,7 @@ const ShowPrimaryArea = ({ primaryArea }) => { + diff --git a/src/core/utils/pageMenu.js b/src/core/utils/pageMenu.js index 0c9bfd3..f812b52 100644 --- a/src/core/utils/pageMenu.js +++ b/src/core/utils/pageMenu.js @@ -1,30 +1,34 @@ -import SpaceDashboardIcon from "@mui/icons-material/SpaceDashboard"; -import GroupsIcon from "@mui/icons-material/Groups"; import AccountTreeIcon from "@mui/icons-material/AccountTree"; -import FactCheckIcon from "@mui/icons-material/FactCheck"; -import FireTruckIcon from "@mui/icons-material/FireTruck"; -import RouteIcon from "@mui/icons-material/Route"; -import DoorbellIcon from "@mui/icons-material/Doorbell"; -import ElectricBoltIcon from "@mui/icons-material/ElectricBolt"; -import CottageIcon from "@mui/icons-material/Cottage"; -import GppMaybeIcon from "@mui/icons-material/GppMaybe"; -import GavelIcon from "@mui/icons-material/Gavel"; -import BallotIcon from "@mui/icons-material/Ballot"; -import AssistantIcon from "@mui/icons-material/Assistant"; import AdminPanelSettingsIcon from "@mui/icons-material/AdminPanelSettings"; -import MapIcon from "@mui/icons-material/Map"; -import SpeedIcon from "@mui/icons-material/Speed"; -import EngineeringIcon from "@mui/icons-material/Engineering"; -import ReportIcon from "@mui/icons-material/Report"; import AssessmentIcon from "@mui/icons-material/Assessment"; import AssignmentLateIcon from "@mui/icons-material/AssignmentLate"; -import LockPersonIcon from "@mui/icons-material/LockPerson"; -import LineAxisIcon from "@mui/icons-material/LineAxis"; -import ScienceIcon from "@mui/icons-material/Science"; -import HandymanIcon from "@mui/icons-material/Handyman"; -import DriveEtaIcon from "@mui/icons-material/DriveEta"; +import AssistantIcon from "@mui/icons-material/Assistant"; +import BallotIcon from "@mui/icons-material/Ballot"; import BiotechIcon from "@mui/icons-material/Biotech"; +import CottageIcon from "@mui/icons-material/Cottage"; +import DoorbellIcon from "@mui/icons-material/Doorbell"; +import DriveEtaIcon from "@mui/icons-material/DriveEta"; +import ElectricBoltIcon from "@mui/icons-material/ElectricBolt"; +import EngineeringIcon from "@mui/icons-material/Engineering"; +import FactCheckIcon from "@mui/icons-material/FactCheck"; +import FireTruckIcon from "@mui/icons-material/FireTruck"; +import GavelIcon from "@mui/icons-material/Gavel"; +import GppMaybeIcon from "@mui/icons-material/GppMaybe"; +import GroupsIcon from "@mui/icons-material/Groups"; +import HandymanIcon from "@mui/icons-material/Handyman"; +import LineAxisIcon from "@mui/icons-material/LineAxis"; +import LockPersonIcon from "@mui/icons-material/LockPerson"; +import ManageAccountsIcon from "@mui/icons-material/ManageAccounts"; +import MapIcon from "@mui/icons-material/Map"; +import MapsHomeWorkIcon from "@mui/icons-material/MapsHomeWork"; import Mediation from "@mui/icons-material/Mediation"; +import PsychologyAltIcon from "@mui/icons-material/PsychologyAlt"; +import ReportIcon from "@mui/icons-material/Report"; +import RouteIcon from "@mui/icons-material/Route"; +import ScienceIcon from "@mui/icons-material/Science"; +import SecurityIcon from "@mui/icons-material/Security"; +import SpaceDashboardIcon from "@mui/icons-material/SpaceDashboard"; +import SpeedIcon from "@mui/icons-material/Speed"; export const pageMenu = [ { @@ -128,6 +132,14 @@ export const pageMenu = [ badges: [{ key: "mission.control" }], permissions: ["manage-control-unit"], }, + { + id: "roadMissionsViolations", + label: "تخلفات", + type: "page", + route: "/dashboard/road-missions/violation", + // badges: [{ key: "mission.control" }], // TODO: add badge and permission + permissions: ["all"], + }, ], }, { @@ -296,32 +308,36 @@ export const pageMenu = [ hasSubitems: true, Subitems: [ { - id: "cityAdminZaminGov", - label: "استعلام حرائم پنجره واحد", + id: "cityAdmin", + label: "کارتابل شهرستان", type: "page", - route: "/dashboard/inquiry-privacy/city-admin/zamin-gov", - permissions: [], + route: "/dashboard/inquiry-privacy/city-admin", + icon: , + permissions: ["all"], }, { - id: "provinceAdminZaminGov", - label: "استعلام حرائم پنجره واحد", + id: "privacyOffice", + label: "کارتابل اداره حریم", type: "page", - route: "/dashboard/inquiry-privacy/province-admin/zamin-gov", - permissions: [], + route: "/dashboard/inquiry-privacy/privacy-office", + icon: , + permissions: ["all"], }, { - id: "assistantZaminGov", - label: "استعلام حرائم پنجره واحد", + id: "assistant", + label: "کارتابل معاون", type: "page", - route: "/dashboard/inquiry-privacy/assistant/zamin-gov", - permissions: [], + route: "/dashboard/inquiry-privacy/technical-deputy", + icon: , + permissions: ["all"], }, { - id: "generalManagerZaminGov", - label: "استعلام حرائم پنجره واحد", + id: "generalManager", + label: "کارتابل مدیر", type: "page", - route: "/dashboard/inquiry-privacy/general-manager/zamin-gov", - permissions: [], + route: "/dashboard/inquiry-privacy/general-manager", + icon: , + permissions: ["all"], }, ], }, From c37a1010fd964bae9725739f6231a2e6cba749c1 Mon Sep 17 00:00:00 2001 From: AminGhasempoor Date: Sun, 7 Dec 2025 15:52:07 +0330 Subject: [PATCH 44/61] add main changes of edit control --- .../tollHouse/Form/Edit/EditController.jsx | 32 +++++++++++-------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/src/components/infrastructure/tollHouse/Form/Edit/EditController.jsx b/src/components/infrastructure/tollHouse/Form/Edit/EditController.jsx index 58b108b..7d2ce1e 100644 --- a/src/components/infrastructure/tollHouse/Form/Edit/EditController.jsx +++ b/src/components/infrastructure/tollHouse/Form/Edit/EditController.jsx @@ -42,17 +42,20 @@ const EditController = ({ rowId, mutate, setOpenEditDialog }) => { machines_light: tollHouseItemDetails?.machines_light || "", machines_sheavy: tollHouseItemDetails?.machines_sheavy || "", machines_heavy: tollHouseItemDetails?.machines_heavy || "", - overview_files_1: tollHouseItemDetails?.files[0]?.path || null, - overview_files_2: tollHouseItemDetails?.files[1]?.path || null, - overview_files_3: tollHouseItemDetails?.files[2]?.path || null, - overview_files_4: tollHouseItemDetails?.files[3]?.path || null, - overview_files_5: tollHouseItemDetails?.files[4]?.path || null, - area: tollHouseItemDetails?.area?.coordinates.map(([lat, lon]) => ({ lat, lon })) || [ - { lat: "", lon: "" }, - { lat: "", lon: "" }, - { lat: "", lon: "" }, - { lat: "", lon: "" }, - ], + overview_files_1: tollHouseItemDetails?.files?.[0]?.path || null, + overview_files_2: tollHouseItemDetails?.files?.[1]?.path || null, + overview_files_3: tollHouseItemDetails?.files?.[2]?.path || null, + overview_files_4: tollHouseItemDetails?.files?.[3]?.path || null, + overview_files_5: tollHouseItemDetails?.files?.[4]?.path || null, + area: + tollHouseItemDetails?.area?.coordinates + ?.map(([lon, lat]) => ({ lat, lon })) + ?.slice(0, -1) || [ + { lat: "", lon: "" }, + { lat: "", lon: "" }, + { lat: "", lon: "" }, + { lat: "", lon: "" }, + ], }; const HandleSubmit = async (result) => { const fields = [ @@ -87,10 +90,13 @@ const EditController = ({ rowId, mutate, setOpenEditDialog }) => { 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(`${UPDATE_TOLL_HOUSE_ITEM}/${rowId}`, "post", { data: formData, notificationSuccess: true, From 036a13a7fc2b1f66139e20c3d0e1ac9ffe1fec1c Mon Sep 17 00:00:00 2001 From: AminGhasempoor Date: Sun, 7 Dec 2025 15:54:02 +0330 Subject: [PATCH 45/61] build and format --- .../tollHouse/Form/Edit/EditController.jsx | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/components/infrastructure/tollHouse/Form/Edit/EditController.jsx b/src/components/infrastructure/tollHouse/Form/Edit/EditController.jsx index 7d2ce1e..eb30008 100644 --- a/src/components/infrastructure/tollHouse/Form/Edit/EditController.jsx +++ b/src/components/infrastructure/tollHouse/Form/Edit/EditController.jsx @@ -47,15 +47,12 @@ const EditController = ({ rowId, mutate, setOpenEditDialog }) => { overview_files_3: tollHouseItemDetails?.files?.[2]?.path || null, overview_files_4: tollHouseItemDetails?.files?.[3]?.path || null, overview_files_5: tollHouseItemDetails?.files?.[4]?.path || null, - area: - tollHouseItemDetails?.area?.coordinates - ?.map(([lon, lat]) => ({ lat, lon })) - ?.slice(0, -1) || [ - { lat: "", lon: "" }, - { lat: "", lon: "" }, - { lat: "", lon: "" }, - { lat: "", lon: "" }, - ], + area: tollHouseItemDetails?.area?.coordinates?.map(([lon, lat]) => ({ lat, lon }))?.slice(0, -1) || [ + { lat: "", lon: "" }, + { lat: "", lon: "" }, + { lat: "", lon: "" }, + { lat: "", lon: "" }, + ], }; const HandleSubmit = async (result) => { const fields = [ From 80748262bd98eab947597fab2d59e9fe8cf3f9c1 Mon Sep 17 00:00:00 2001 From: AminGhasempoor Date: Mon, 8 Dec 2025 13:22:53 +0330 Subject: [PATCH 46/61] debug show points tollhouse --- .../tollHouseMap/PointsOnMap/index.jsx | 40 ++++++++++++++----- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/src/components/infrastructure/tollHouseMap/PointsOnMap/index.jsx b/src/components/infrastructure/tollHouseMap/PointsOnMap/index.jsx index 05b4d03..2cdd91c 100644 --- a/src/components/infrastructure/tollHouseMap/PointsOnMap/index.jsx +++ b/src/components/infrastructure/tollHouseMap/PointsOnMap/index.jsx @@ -20,8 +20,9 @@ const PointsOnMap = ({ data, isCluster }) => { }; const markers = useMemo(() => { - return data.map(({ id, lat, lng, step }) => ( - { + if (!lat && !lng) return + return { }, }} color={getMarkerColor(Number(status))} - /> - )); + />; + }); }, [data, theme]); useEffect(() => { - if (data.length === 0) return; + if (data.length === 0) { + // fly to Iran + map.flyTo([32.4279, 53.6880], 6, { duration: 0.7 }); + return; + } - const bounds = L.latLngBounds( - data.map(({ lat, lng }) => { - return L.latLng(Number(lat), Number(lng)); - }) - ); + // ساختن 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.6880], 6, { duration: 0.7 }); + return; + } + + const bounds = L.latLngBounds(validPoints); + + if (!bounds.isValid()) { + // اگر bounds معتبر نبود → fallback روی ایران + map.flyTo([32.4279, 53.6880], 6, { duration: 0.7 }); + return; + } map.flyToBounds(bounds, { duration: 0.7 }); + }, [data]); + const createClusterCustomIcon = (cluster) => { const count = cluster.getChildCount(); return L.divIcon({ From a29891e59ce1a0b518134bee8ffdfefdfaa41f90 Mon Sep 17 00:00:00 2001 From: AminGhasempoor Date: Mon, 8 Dec 2025 13:23:37 +0330 Subject: [PATCH 47/61] build and format --- .../tollHouseMap/PointsOnMap/index.jsx | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/components/infrastructure/tollHouseMap/PointsOnMap/index.jsx b/src/components/infrastructure/tollHouseMap/PointsOnMap/index.jsx index 2cdd91c..8283bbf 100644 --- a/src/components/infrastructure/tollHouseMap/PointsOnMap/index.jsx +++ b/src/components/infrastructure/tollHouseMap/PointsOnMap/index.jsx @@ -21,26 +21,28 @@ const PointsOnMap = ({ data, isCluster }) => { const markers = useMemo(() => { return data.map(({ id, lat, lng, step }) => { - if (!lat && !lng) return - return { - openDialog(); - setSelectedId(id); - }, - }} - color={getMarkerColor(Number(status))} - />; + 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.6880], 6, { duration: 0.7 }); + map.flyTo([32.4279, 53.688], 6, { duration: 0.7 }); return; } @@ -51,7 +53,7 @@ const PointsOnMap = ({ data, isCluster }) => { if (validPoints.length === 0) { // اگر هیچ مختصات معتبری نبود → ایران - map.flyTo([32.4279, 53.6880], 6, { duration: 0.7 }); + map.flyTo([32.4279, 53.688], 6, { duration: 0.7 }); return; } @@ -59,15 +61,13 @@ const PointsOnMap = ({ data, isCluster }) => { if (!bounds.isValid()) { // اگر bounds معتبر نبود → fallback روی ایران - map.flyTo([32.4279, 53.6880], 6, { duration: 0.7 }); + 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({ From 633da895c2c78de4c1ffda0c6acd4c0f91cb4d67 Mon Sep 17 00:00:00 2001 From: AminGhasempoor Date: Wed, 17 Dec 2025 14:47:06 +0330 Subject: [PATCH 48/61] debug road mission cartable area view --- .../control/Actions/showArea/index.jsx | 9 +- .../operator/Actions/Create/index.jsx | 20 +- .../Actions/CreateWithoutProcess/index.jsx | 248 +++++++++--------- .../operator/Actions/showArea/index.jsx | 11 +- .../roadMissions/operator/OperatorList.jsx | 30 ++- .../Add/AddController/Dialog/index.jsx | 13 +- .../RowActions/DescriptionDialog/index.jsx | 59 +++++ .../transportation/Actions/showArea/index.jsx | 11 +- .../RowActions/Allocation/Form/index.jsx | 2 +- .../tollHouse/Form/CreateTollHouse/index.jsx | 8 +- 10 files changed, 270 insertions(+), 141 deletions(-) create mode 100644 src/components/dashboard/roadMissions/operator/RowActions/DescriptionDialog/index.jsx diff --git a/src/components/dashboard/roadMissions/control/Actions/showArea/index.jsx b/src/components/dashboard/roadMissions/control/Actions/showArea/index.jsx index be4ee7a..ef25c6b 100644 --- a/src/components/dashboard/roadMissions/control/Actions/showArea/index.jsx +++ b/src/components/dashboard/roadMissions/control/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/Actions/Create/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/Create/index.jsx index e48ab26..f956b94 100644 --- a/src/components/dashboard/roadMissions/operator/Actions/Create/index.jsx +++ b/src/components/dashboard/roadMissions/operator/Actions/Create/index.jsx @@ -21,10 +21,24 @@ const Create = ({ mutate }) => { 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]); + 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, "post", { data: { explanation: result.explanation, 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 ? ( - - - - ) : ( - - )} - - setOpen(false)} - sx={(theme) => ({ - position: "absolute", - right: 8, - top: 8, - zIndex: 50, - color: theme.palette.grey[500], - })} - > - - - {open && ( - - )} - - - ); -}; -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 ? ( + + + + ) : ( + + )} + + setOpen(false)} + sx={(theme) => ({ + position: "absolute", + right: 8, + top: 8, + zIndex: 50, + color: theme.palette.grey[500], + })} + > + + + {open && ( + + )} + + + ); +}; +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..f2d9f4b 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 ( @@ -54,5 +59,5 @@ const ShowArea = ({ area }) => {
); -}; +};; export default ShowArea; 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/index.jsx b/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/index.jsx index 440c4e9..25ff1c3 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 @@ -12,14 +12,19 @@ const DialogAdd = ({ mutate, setOpen, oldBound, rahdaran, machine, row }) => { 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]); + 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) } : {}), - machines: [result.machine.id], + machine_id: result.machine.id, driver: result.driver.id, zone: result.region, type: result.type, 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)}> + + + + setOpenDescriptionDialog(false)} + PaperProps={{ + sx: { + boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px", + }, + }} + dir="rtl" + maxWidth={"sm"} + > + دلیل رد درخواست + + + + {description || "هیچ توضیحی موجود نیست"} + + + + + + + + + ); +}; +export default DescriptionDialog; diff --git a/src/components/dashboard/roadMissions/transportation/Actions/showArea/index.jsx b/src/components/dashboard/roadMissions/transportation/Actions/showArea/index.jsx index be4ee7a..f2d9f4b 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 ( @@ -54,5 +59,5 @@ const ShowArea = ({ area }) => {
); -}; +};; export default ShowArea; 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/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, }) From f78ee620cde0f1b4df4cf6d27255afaaf4c14d76 Mon Sep 17 00:00:00 2001 From: AminGhasempoor Date: Wed, 17 Dec 2025 14:53:19 +0330 Subject: [PATCH 49/61] build and format --- .../inquiry-privacy/city-admin/page.js | 28 +- .../inquiry-privacy/general-manager/page.js | 28 +- .../inquiry-privacy/privacy-office/page.js | 28 +- .../inquiry-privacy/technical-deputy/page.js | 28 +- .../dashboard/rahdaran/page.js | 24 +- .../dashboard/road-missions/violation/page.js | 34 +- .../road-safety/reports/access-road/page.js | 38 +- .../reports/construction-activity/page.js | 38 +- .../reports/utility-passing-activity/page.js | 38 +- .../infrastructure/map/loading.jsx | 14 +- .../infrastructure/map/page.js | 32 +- .../damageItems/ExcelPrint/index.jsx | 150 +-- .../Actions/create/Forms/LocationInputs.jsx | 114 +-- .../RowActions/ButtonDownload/index.jsx | 26 +- .../RowActions/ChangeStatus/Dialog.jsx | 52 +- .../operator/RowActions/ChangeStatus/Form.jsx | 192 ++-- .../RowActions/ChangeStatus/index.jsx | 38 +- .../city-admin/CityAdminList.jsx | 486 ++++----- .../MapDrawPolygon/DrawBound.jsx | 298 +++--- .../FeedbackAction/MapDrawPolygon/index.jsx | 242 ++--- .../RowActions/FeedbackAction/index.jsx | 312 +++--- .../RowActions/History/HistoryContent.jsx | 34 +- .../RowActions/History/TableContent.jsx | 132 +-- .../city-admin/RowActions/History/index.jsx | 66 +- .../city-admin/RowActions/index.jsx | 34 +- .../city-admin/ShowPrimaryArea/ShowBound.jsx | 58 +- .../city-admin/ShowPrimaryArea/index.jsx | 118 +-- .../inquiryPrivacy/city-admin/index.jsx | 28 +- .../general-manager/GeneralManagerList.jsx | 486 ++++----- .../RowActions/ConfirmAction/index.jsx | 34 +- .../RowActions/History/HistoryContent.jsx | 34 +- .../RowActions/History/TableContent.jsx | 132 +-- .../RowActions/History/index.jsx | 66 +- .../RowActions/RejectAction/index.jsx | 34 +- .../general-manager/RowActions/index.jsx | 44 +- .../ShowPrimaryArea/ShowBound.jsx | 58 +- .../general-manager/ShowPrimaryArea/index.jsx | 138 +-- .../inquiryPrivacy/general-manager/index.jsx | 28 +- .../privacy-office/PrivacyOfficeList.jsx | 496 +++++----- .../RowActions/ActionsDialog.jsx | 40 +- .../RowActions/ConfirmAction/index.jsx | 36 +- .../RowActions/Forms/ComputePaymentForm.jsx | 456 ++++----- .../RowActions/Forms/ConfirmFileForm.jsx | 138 +-- .../RowActions/Forms/ConfirmRequestForm.jsx | 192 ++-- .../RowActions/Forms/ReferForm.jsx | 134 +-- .../RowActions/Forms/RejectFileForm.jsx | 138 +-- .../RowActions/Forms/RejectRequestForm.jsx | 138 +-- .../RowActions/History/HistoryContent.jsx | 34 +- .../RowActions/History/TableContent.jsx | 132 +-- .../RowActions/History/index.jsx | 66 +- .../RowActions/ReferralAction/index.jsx | 36 +- .../RowActions/RejectAction/index.jsx | 36 +- .../RowActions/RenderActionForm.jsx | 64 +- .../privacy-office/RowActions/index.jsx | 114 +-- .../ShowPrimaryArea/ShowBound.jsx | 58 +- .../ShowPrimaryArea/ShowForbiddenBound.jsx | 58 +- .../privacy-office/ShowPrimaryArea/index.jsx | 140 +-- .../inquiryPrivacy/privacy-office/index.jsx | 28 +- .../ConfirmRoadSafetyDialog.jsx | 86 +- .../ConfirmRoadSafetyFormContext.jsx | 128 +-- .../Questions/DescriptionForm.jsx | 58 +- .../Questions/QuestionVerifyNeedRoadForm.jsx | 58 +- .../QuestionVerifyRoadSafetyForm.jsx | 58 +- .../Questions/Refer/Form.jsx | 156 +-- .../Questions/Refer/index.jsx | 108 +- .../ConfirmRoadSafetyForm/Questions/index.jsx | 144 +-- .../ConfirmRoadSafetyForm/index.jsx | 102 +- .../ConfirmRoadSafetyDialog.jsx | 86 +- .../ConfirmRoadSafetyFormContext.jsx | 126 +-- .../ConfirmVerifyLicenseForm/index.jsx | 102 +- .../ConfirmRoadSafetyDialog.jsx | 86 +- .../ConfirmRoadSafetyFormContext.jsx | 126 +-- .../ConfirmVerifyRoadSafetyForm/index.jsx | 102 +- .../RowActions/History/HistoryContent.jsx | 34 +- .../RowActions/History/TableContent.jsx | 132 +-- .../RowActions/History/index.jsx | 66 +- .../technical-deputy/RowActions/index.jsx | 46 +- .../ShowProjectArea/ShowBound.jsx | 58 +- .../ShowProjectArea/ShowForbiddenBound.jsx | 58 +- .../ShowProjectArea/index.jsx | 142 +-- .../technical-deputy/TechnicalDeputyList.jsx | 432 ++++---- .../inquiryPrivacy/technical-deputy/index.jsx | 30 +- .../Actions/Create/Form/CityContent.jsx | 78 +- .../Actions/Create/Form/CityController.jsx | 28 +- .../Actions/Create/Form/CreateFormContent.jsx | 366 +++---- .../Create/Form/LogesticController.jsx | 84 +- .../rahdaran/Actions/Create/Form/index.jsx | 144 +-- .../rahdaran/Actions/Create/index.jsx | 72 +- .../rahdaran/Actions/Edit/EditController.jsx | 90 +- .../dashboard/rahdaran/Actions/Edit/index.jsx | 102 +- .../dashboard/rahdaran/RahdaranList.jsx | 362 +++---- .../RowActions/DeleteDialog/DeleteContent.jsx | 78 +- .../RowActions/DeleteDialog/index.jsx | 68 +- .../dashboard/rahdaran/RowActions/index.jsx | 24 +- src/components/dashboard/rahdaran/Toolbar.jsx | 18 +- src/components/dashboard/rahdaran/index.jsx | 26 +- .../Create/Forms/GetItemInfo/ImageUpload.jsx | 346 +++---- .../RowActions/Allocate/index.jsx | 46 +- .../MissionsList/RowActions/index.jsx | 12 +- .../MissionsDialog/MissionsList/index.jsx | 210 ++-- .../GetItemInfo/MissionsDialog/index.jsx | 76 +- .../Forms/GetItemInfo/PreviousStatesInfo.jsx | 86 +- .../Create/Forms/GetItemInfo/index.jsx | 218 ++--- .../RowActions/Machines/MachinesContent.jsx | 146 +-- .../control/RowActions/Machines/index.jsx | 76 +- .../RowActions/Rahdaran/RahdaranContent.jsx | 148 +-- .../control/RowActions/Rahdaran/index.jsx | 76 +- .../MapControlPolygon/DrawBound/index.jsx | 258 ++--- .../Form/Area/MapControlPolygon/index.jsx | 232 ++--- .../MapControlPolyline/DrawBound/index.jsx | 258 ++--- .../Form/Area/MapControlPolyline/index.jsx | 232 ++--- .../Form/Area/SelectBoundType/index.jsx | 50 +- .../Form/GetDateTime/MissionDates/index.jsx | 238 ++--- .../Actions/Create/Form/GetDateTime/index.jsx | 172 ++-- .../Dialog/List/RowActions/SelectId/index.jsx | 40 +- .../Dialog/List/RowActions/index.jsx | 20 +- .../FastReactCode/Dialog/List/index.jsx | 548 +++++------ .../FastReactCode/Dialog/index.jsx | 98 +- .../Form/GetItemInfo/FastReactCode/index.jsx | 44 +- .../operator/Actions/Create/index.jsx | 13 +- .../MapControlPolygon/DrawBound/index.jsx | 258 ++--- .../Form/Area/MapControlPolygon/index.jsx | 232 ++--- .../MapControlPolyline/DrawBound/index.jsx | 258 ++--- .../Form/Area/MapControlPolyline/index.jsx | 232 ++--- .../Form/Area/SelectBoundType/index.jsx | 50 +- .../CreateWithoutProcess/Form/Area/index.jsx | 108 +- .../Form/GetDateTime/MissionDates/index.jsx | 238 ++--- .../Form/GetDateTime/index.jsx | 118 +-- .../Dialog/List/RowActions/SelectId/index.jsx | 40 +- .../Dialog/List/RowActions/index.jsx | 20 +- .../FastReactCode/Dialog/List/index.jsx | 548 +++++------ .../FastReactCode/Dialog/index.jsx | 98 +- .../Form/GetItemInfo/FastReactCode/index.jsx | 44 +- .../Form/GetItemInfo/index.jsx | 306 +++--- .../DriversSearch/Form/index.jsx | 122 +-- .../DriversDialog/DriversSearch/index.jsx | 22 +- .../MachineAndDriver/DriversDialog/index.jsx | 82 +- .../MachineList/RowActions/Allocate/index.jsx | 40 +- .../MachineList/RowActions/index.jsx | 12 +- .../MachinesDialog/MachineList/index.jsx | 136 +-- .../MachineAndDriver/MachinesDialog/index.jsx | 80 +- .../Form/MachineAndDriver/index.jsx | 154 +-- .../Form/Rahdaran/Form/index.jsx | 132 +-- .../Form/Rahdaran/List/index.jsx | 112 +-- .../Form/Rahdaran/index.jsx | 72 +- .../Form/Verify/index.jsx | 260 ++--- .../CreateWithoutProcess/Form/index.jsx | 250 ++--- .../operator/Actions/showArea/index.jsx | 2 +- .../MapControlPolygon/DrawBound/index.jsx | 258 ++--- .../Form/Area/MapControlPolygon/index.jsx | 232 ++--- .../MapControlPolyline/DrawBound/index.jsx | 258 ++--- .../Form/Area/MapControlPolyline/index.jsx | 232 ++--- .../Dialog/Form/Area/OldBoundLayer/index.jsx | 60 +- .../Form/Area/SelectBoundType/index.jsx | 50 +- .../AddController/Dialog/Form/Area/index.jsx | 112 +-- .../Form/GetDateTime/MissionDates/index.jsx | 120 +-- .../Dialog/Form/GetDateTime/index.jsx | 166 ++-- .../Dialog/List/RowActions/SelectId/index.jsx | 40 +- .../Dialog/List/RowActions/index.jsx | 20 +- .../FastReactCode/Dialog/List/index.jsx | 548 +++++------ .../FastReactCode/Dialog/index.jsx | 98 +- .../Form/GetItemInfo/FastReactCode/index.jsx | 44 +- .../Dialog/Form/GetItemInfo/index.jsx | 306 +++--- .../Dialog/Form/Verify/index.jsx | 268 ++--- .../Add/AddController/Dialog/Form/index.jsx | 204 ++-- .../Add/AddController/Dialog/index.jsx | 176 ++-- .../RowActions/Add/AddController/index.jsx | 104 +- .../operator/RowActions/Add/index.jsx | 82 +- .../RowActions/Machines/MachinesContent.jsx | 146 +-- .../operator/RowActions/Machines/index.jsx | 76 +- .../RowActions/Rahdaran/RahdaranContent.jsx | 148 +-- .../operator/RowActions/Rahdaran/index.jsx | 76 +- .../transportation/Actions/showArea/index.jsx | 2 +- .../DriversSearch/Form/index.jsx | 122 +-- .../DriversDialog/DriversSearch/index.jsx | 22 +- .../Allocation/Form/DriversDialog/index.jsx | 82 +- .../MapControlPolygon/DrawBound/index.jsx | 258 ++--- .../Form/Area/MapControlPolygon/index.jsx | 232 ++--- .../MapControlPolyline/DrawBound/index.jsx | 258 ++--- .../Form/Area/MapControlPolyline/index.jsx | 232 ++--- .../Form/Area/SelectBoundType/index.jsx | 50 +- .../CreateWithoutProcess/Form/Area/index.jsx | 108 +- .../Form/GetDateTime/MissionDates/index.jsx | 238 ++--- .../Form/GetDateTime/index.jsx | 118 +-- .../Dialog/List/RowActions/SelectId/index.jsx | 40 +- .../Dialog/List/RowActions/index.jsx | 20 +- .../FastReactCode/Dialog/List/index.jsx | 548 +++++------ .../FastReactCode/Dialog/index.jsx | 98 +- .../Form/GetItemInfo/FastReactCode/index.jsx | 44 +- .../Form/GetItemInfo/index.jsx | 306 +++--- .../DriversSearch/Form/index.jsx | 122 +-- .../DriversDialog/DriversSearch/index.jsx | 22 +- .../MachineAndDriver/DriversDialog/index.jsx | 82 +- .../MachineList/RowActions/Allocate/index.jsx | 40 +- .../MachineList/RowActions/index.jsx | 12 +- .../MachinesDialog/MachineList/index.jsx | 136 +-- .../MachineAndDriver/MachinesDialog/index.jsx | 80 +- .../Form/MachineAndDriver/index.jsx | 154 +-- .../Form/Rahdaran/Form/index.jsx | 132 +-- .../Form/Rahdaran/List/index.jsx | 112 +-- .../Form/Rahdaran/index.jsx | 72 +- .../Form/Verify/index.jsx | 260 ++--- .../CreateWithoutProcess/Form/index.jsx | 250 ++--- .../Actions/CreateWithoutProcess/index.jsx | 238 ++--- .../violations/RowActions/index.jsx | 8 +- .../violations/ViolationsList.jsx | 166 ++-- .../roadMissions/violations/index.jsx | 28 +- .../RowActions/ActionPictureDialog/List.jsx | 26 +- .../RecognizePictureDialog/List.jsx | 24 +- .../reports/accessRoad/ExcelPrint/index.jsx | 144 +-- .../reports/accessRoad/ReportLists.jsx | 926 +++++++++--------- .../roadSafety/reports/accessRoad/Toolbar.jsx | 22 +- .../roadSafety/reports/accessRoad/index.jsx | 410 ++++---- .../constructionActivity/ExcelPrint/index.jsx | 140 +-- .../constructionActivity/ReportLists.jsx | 926 +++++++++--------- .../reports/constructionActivity/Toolbar.jsx | 22 +- .../reports/constructionActivity/index.jsx | 410 ++++---- .../ExcelPrint/index.jsx | 140 +-- .../utilityPassingActivity/ReportLists.jsx | 926 +++++++++--------- .../utilityPassingActivity/Toolbar.jsx | 22 +- .../reports/utilityPassingActivity/index.jsx | 410 ++++---- .../RowActions/ActionPictureDialog/List.jsx | 26 +- .../RecognizePictureDialog/List.jsx | 24 +- .../Form/CreateTollHouse/TollHouseArea.jsx | 160 +-- .../tollHouse/ShowProjectArea/ShowBound.jsx | 58 +- .../tollHouse/ShowProjectArea/index.jsx | 130 +-- .../tollHouseMap/ClusterSwitch/index.jsx | 50 +- .../tollHouseMap/Filter/index.jsx | 88 +- .../tollHouseMap/Legend/index.jsx | 70 +- .../DialogInfoItem/ContentInfoItem.jsx | 142 +-- .../PointsOnMap/DialogInfoItem/index.jsx | 102 +- .../tollHouseMap/PointsOnMap/index.jsx | 194 ++-- .../infrastructure/tollHouseMap/index.jsx | 462 ++++----- src/core/components/RahdarNameOrCode.jsx | 186 ++-- src/core/components/TabPanel.jsx | 22 +- src/core/utils/geoCalculations.js | 70 +- src/core/utils/groupByEdareAxisStep.js | 24 +- src/core/utils/groupByProvinceAxisStep.js | 24 +- src/core/utils/makeDateTime.js | 18 +- src/core/utils/missionCategoryTypes.js | 10 +- src/core/utils/missionRegions.js | 10 +- src/core/utils/missionTypes.js | 8 +- src/lib/hooks/useHistory.js | 60 +- src/lib/hooks/useInquiryPrivacyState.js | 60 +- 244 files changed, 16542 insertions(+), 16551 deletions(-) diff --git a/src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/city-admin/page.js b/src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/city-admin/page.js index 3fd1888..a32607b 100644 --- a/src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/city-admin/page.js +++ b/src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/city-admin/page.js @@ -1,14 +1,14 @@ -import CityAdminPage from "@/components/dashboard/inquiryPrivacy/city-admin"; -import WithPermission from "@/core/middlewares/withPermission"; -export const metadata = { - title: "کارتابل شهرستان", -}; -const Page = () => { - return ( - - - - ); -}; - -export default Page; +import CityAdminPage from "@/components/dashboard/inquiryPrivacy/city-admin"; +import WithPermission from "@/core/middlewares/withPermission"; +export const metadata = { + title: "کارتابل شهرستان", +}; +const Page = () => { + return ( + + + + ); +}; + +export default Page; diff --git a/src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/general-manager/page.js b/src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/general-manager/page.js index 763114c..e773ad7 100644 --- a/src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/general-manager/page.js +++ b/src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/general-manager/page.js @@ -1,14 +1,14 @@ -import WithPermission from "@/core/middlewares/withPermission"; -import GeneralManagerPage from "@/components/dashboard/inquiryPrivacy/general-manager"; -export const metadata = { - title: "کارتابل مدیر", -}; -const Page = () => { - return ( - - - - ); -}; - -export default Page; +import WithPermission from "@/core/middlewares/withPermission"; +import GeneralManagerPage from "@/components/dashboard/inquiryPrivacy/general-manager"; +export const metadata = { + title: "کارتابل مدیر", +}; +const Page = () => { + return ( + + + + ); +}; + +export default Page; diff --git a/src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/privacy-office/page.js b/src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/privacy-office/page.js index c0de9c5..7649f59 100644 --- a/src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/privacy-office/page.js +++ b/src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/privacy-office/page.js @@ -1,14 +1,14 @@ -import PrivacyOfficePage from "@/components/dashboard/inquiryPrivacy/privacy-office"; -import WithPermission from "@/core/middlewares/withPermission"; -export const metadata = { - title: "کارتابل اداره حریم", -}; -const Page = () => { - return ( - - - - ); -}; - -export default Page; +import PrivacyOfficePage from "@/components/dashboard/inquiryPrivacy/privacy-office"; +import WithPermission from "@/core/middlewares/withPermission"; +export const metadata = { + title: "کارتابل اداره حریم", +}; +const Page = () => { + return ( + + + + ); +}; + +export default Page; diff --git a/src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/technical-deputy/page.js b/src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/technical-deputy/page.js index ebcc6c3..4594fd0 100644 --- a/src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/technical-deputy/page.js +++ b/src/app/(withAuth)/(dashboardLayout)/dashboard/inquiry-privacy/technical-deputy/page.js @@ -1,14 +1,14 @@ -import TechnicalDeputy from "@/components/dashboard/inquiryPrivacy/technical-deputy"; -import WithPermission from "@/core/middlewares/withPermission"; -export const metadata = { - title: "کارتابل معاون", -}; -const Page = () => { - return ( - - - - ); -}; - -export default Page; +import TechnicalDeputy from "@/components/dashboard/inquiryPrivacy/technical-deputy"; +import WithPermission from "@/core/middlewares/withPermission"; +export const metadata = { + title: "کارتابل معاون", +}; +const Page = () => { + return ( + + + + ); +}; + +export default Page; diff --git a/src/app/(withAuth)/(dashboardLayout)/dashboard/rahdaran/page.js b/src/app/(withAuth)/(dashboardLayout)/dashboard/rahdaran/page.js index abb3645..2eccf87 100644 --- a/src/app/(withAuth)/(dashboardLayout)/dashboard/rahdaran/page.js +++ b/src/app/(withAuth)/(dashboardLayout)/dashboard/rahdaran/page.js @@ -1,12 +1,12 @@ -import RahdaranTablePage from "@/components/dashboard/rahdaran"; -import WithPermission from "@/core/middlewares/withPermission"; - -export default function page() { - return ( - - - - ); -} +import RahdaranTablePage from "@/components/dashboard/rahdaran"; +import WithPermission from "@/core/middlewares/withPermission"; + +export default function page() { + return ( + + + + ); +} diff --git a/src/app/(withAuth)/(dashboardLayout)/dashboard/road-missions/violation/page.js b/src/app/(withAuth)/(dashboardLayout)/dashboard/road-missions/violation/page.js index 99cde66..2f810e0 100644 --- a/src/app/(withAuth)/(dashboardLayout)/dashboard/road-missions/violation/page.js +++ b/src/app/(withAuth)/(dashboardLayout)/dashboard/road-missions/violation/page.js @@ -1,17 +1,17 @@ -import ViolationsPage from "@/components/dashboard/roadMissions/violations"; -import WithPermission from "@/core/middlewares/withPermission"; -export const metadata = { - title: "کارتابل تخلفات", -}; -const Page = () => { - return ( - <> - - - {/* */} - - - ); -}; - -export default Page; +import ViolationsPage from "@/components/dashboard/roadMissions/violations"; +import WithPermission from "@/core/middlewares/withPermission"; +export const metadata = { + title: "کارتابل تخلفات", +}; +const Page = () => { + return ( + <> + + + {/* */} + + + ); +}; + +export default Page; diff --git a/src/app/(withAuth)/(dashboardLayout)/dashboard/road-safety/reports/access-road/page.js b/src/app/(withAuth)/(dashboardLayout)/dashboard/road-safety/reports/access-road/page.js index 8de26fd..88409e6 100644 --- a/src/app/(withAuth)/(dashboardLayout)/dashboard/road-safety/reports/access-road/page.js +++ b/src/app/(withAuth)/(dashboardLayout)/dashboard/road-safety/reports/access-road/page.js @@ -1,19 +1,19 @@ -import ReportAccessRoadPage from "@/components/dashboard/roadSafety/reports/accessRoad"; -import WithPermission from "@/core/middlewares/withPermission"; -export const metadata = { - title: "گزارش بر اساس راه دسترسی غیر مجاز", -}; -const Page = () => { - return ( - - - - ); -}; -export default Page; +import ReportAccessRoadPage from "@/components/dashboard/roadSafety/reports/accessRoad"; +import WithPermission from "@/core/middlewares/withPermission"; +export const metadata = { + title: "گزارش بر اساس راه دسترسی غیر مجاز", +}; +const Page = () => { + return ( + + + + ); +}; +export default Page; diff --git a/src/app/(withAuth)/(dashboardLayout)/dashboard/road-safety/reports/construction-activity/page.js b/src/app/(withAuth)/(dashboardLayout)/dashboard/road-safety/reports/construction-activity/page.js index 8f8ffbe..0c367b7 100644 --- a/src/app/(withAuth)/(dashboardLayout)/dashboard/road-safety/reports/construction-activity/page.js +++ b/src/app/(withAuth)/(dashboardLayout)/dashboard/road-safety/reports/construction-activity/page.js @@ -1,19 +1,19 @@ -import ReportConstructionActivityPage from "@/components/dashboard/roadSafety/reports/constructionActivity"; -import WithPermission from "@/core/middlewares/withPermission"; -export const metadata = { - title: "گزارش بر اساس ساخت و ساز غیر مجاز", -}; -const Page = () => { - return ( - - - - ); -}; -export default Page; +import ReportConstructionActivityPage from "@/components/dashboard/roadSafety/reports/constructionActivity"; +import WithPermission from "@/core/middlewares/withPermission"; +export const metadata = { + title: "گزارش بر اساس ساخت و ساز غیر مجاز", +}; +const Page = () => { + return ( + + + + ); +}; +export default Page; diff --git a/src/app/(withAuth)/(dashboardLayout)/dashboard/road-safety/reports/utility-passing-activity/page.js b/src/app/(withAuth)/(dashboardLayout)/dashboard/road-safety/reports/utility-passing-activity/page.js index 096a8dc..2eb823c 100644 --- a/src/app/(withAuth)/(dashboardLayout)/dashboard/road-safety/reports/utility-passing-activity/page.js +++ b/src/app/(withAuth)/(dashboardLayout)/dashboard/road-safety/reports/utility-passing-activity/page.js @@ -1,19 +1,19 @@ -import ReportUtilityPassingActivityPage from "@/components/dashboard/roadSafety/reports/utilityPassingActivity"; -import WithPermission from "@/core/middlewares/withPermission"; -export const metadata = { - title: "گزارش بر اساس عبور تاسیسات زیربنایی غیر مجاز", -}; -const Page = () => { - return ( - - - - ); -}; -export default Page; +import ReportUtilityPassingActivityPage from "@/components/dashboard/roadSafety/reports/utilityPassingActivity"; +import WithPermission from "@/core/middlewares/withPermission"; +export const metadata = { + title: "گزارش بر اساس عبور تاسیسات زیربنایی غیر مجاز", +}; +const Page = () => { + return ( + + + + ); +}; +export default Page; diff --git a/src/app/(withAuth)/(dashboardLayout)/infrastructure/map/loading.jsx b/src/app/(withAuth)/(dashboardLayout)/infrastructure/map/loading.jsx index 4535a8d..c3935ed 100644 --- a/src/app/(withAuth)/(dashboardLayout)/infrastructure/map/loading.jsx +++ b/src/app/(withAuth)/(dashboardLayout)/infrastructure/map/loading.jsx @@ -1,7 +1,7 @@ -"use client"; -import PageLoading from "@/core/components/PageLoading"; - -const Loading = () => { - return ; -}; -export default Loading; +"use client"; +import PageLoading from "@/core/components/PageLoading"; + +const Loading = () => { + return ; +}; +export default Loading; diff --git a/src/app/(withAuth)/(dashboardLayout)/infrastructure/map/page.js b/src/app/(withAuth)/(dashboardLayout)/infrastructure/map/page.js index a4cad6b..0174fcf 100644 --- a/src/app/(withAuth)/(dashboardLayout)/infrastructure/map/page.js +++ b/src/app/(withAuth)/(dashboardLayout)/infrastructure/map/page.js @@ -1,16 +1,16 @@ -import WithPermission from "@/core/middlewares/withPermission"; -import TollHouseMapPage from "@/components/infrastructure/tollHouseMap"; - -export const metadata = { - title: "پراکندگی بر روی نقشه راهدارخانه ها", -}; - -const Page = () => { - return ( - - - - ); -}; - -export default Page; +import WithPermission from "@/core/middlewares/withPermission"; +import TollHouseMapPage from "@/components/infrastructure/tollHouseMap"; + +export const metadata = { + title: "پراکندگی بر روی نقشه راهدارخانه ها", +}; + +const Page = () => { + return ( + + + + ); +}; + +export default Page; diff --git a/src/components/dashboard/damageItems/ExcelPrint/index.jsx b/src/components/dashboard/damageItems/ExcelPrint/index.jsx index 4c6a825..ddb8ad6 100644 --- a/src/components/dashboard/damageItems/ExcelPrint/index.jsx +++ b/src/components/dashboard/damageItems/ExcelPrint/index.jsx @@ -1,75 +1,75 @@ -"use client"; -import DataTableFilterDataStructure from "@/core/utils/DataTableFilterDataStructure"; -import isArrayEmpty from "@/core/utils/isArrayEmpty"; -import { EXPORT_DAMAGES_ITEMS } 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 { useMemo, 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 activeFilters = Object.entries(filterData).reduce((acc, [key, filter]) => { - if (filter.value && (!Array.isArray(filter.value) || filter.value.some((item) => item.trim() !== ""))) { - acc.push({ id: key, value: filter.value }); - } - return acc; - }, []); - - const filterParams = useMemo(() => { - const params = new URLSearchParams(); - if (activeFilters.length > 0) { - activeFilters.map((filter, index) => { - const filteredFilterData = DataTableFilterDataStructure(filterData, isArrayEmpty); - params.set("filters", JSON.stringify(filteredFilterData.length === 0 ? [] : filteredFilterData)); - }); - } else { - params.set("filters", JSON.stringify([])); - } - return params; - }, [activeFilters]); - - const clickHandler = () => { - setLoading(true); - requestServer(`${EXPORT_DAMAGES_ITEMS}?${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 ? ( - - - - ) : ( - - )} - - ); -}; -export default PrintExcel; +"use client"; +import DataTableFilterDataStructure from "@/core/utils/DataTableFilterDataStructure"; +import isArrayEmpty from "@/core/utils/isArrayEmpty"; +import { EXPORT_DAMAGES_ITEMS } 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 { useMemo, 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 activeFilters = Object.entries(filterData).reduce((acc, [key, filter]) => { + if (filter.value && (!Array.isArray(filter.value) || filter.value.some((item) => item.trim() !== ""))) { + acc.push({ id: key, value: filter.value }); + } + return acc; + }, []); + + const filterParams = useMemo(() => { + const params = new URLSearchParams(); + if (activeFilters.length > 0) { + activeFilters.map((filter, index) => { + const filteredFilterData = DataTableFilterDataStructure(filterData, isArrayEmpty); + params.set("filters", JSON.stringify(filteredFilterData.length === 0 ? [] : filteredFilterData)); + }); + } else { + params.set("filters", JSON.stringify([])); + } + return params; + }, [activeFilters]); + + const clickHandler = () => { + setLoading(true); + requestServer(`${EXPORT_DAMAGES_ITEMS}?${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 ? ( + + + + ) : ( + + )} + + ); +}; +export default PrintExcel; diff --git a/src/components/dashboard/damages/operator/Actions/create/Forms/LocationInputs.jsx b/src/components/dashboard/damages/operator/Actions/create/Forms/LocationInputs.jsx index 056e534..f4b22ee 100644 --- a/src/components/dashboard/damages/operator/Actions/create/Forms/LocationInputs.jsx +++ b/src/components/dashboard/damages/operator/Actions/create/Forms/LocationInputs.jsx @@ -1,57 +1,57 @@ -import LtrTextField from "@/core/components/LtrTextField"; -import { useState } from "react"; -import { useWatch } from "react-hook-form"; - -const LocationInputs = ({ control, setValue, errors }) => { - const StartPoint = useWatch({ control, name: "start_point" }); - const [coords, setCoords] = useState(StartPoint ? `${StartPoint.lat},${StartPoint.lng}` : ""); - const [error, setError] = useState(false); - - return ( - { - const value = e.target.value.trim(); - setCoords(value); - - if (value === "") { - setValue("start_point", null); - setError(false); - return; - } - - const parts = value.split(",").map((p) => p.trim()); - if (parts.length !== 2) { - setError(true); - return; - } - - const lat = Number(parts[0]); - const lng = Number(parts[1]); - - if (!isNaN(lat) && !isNaN(lng) && lat >= 25 && lat <= 40 && lng >= 44 && lng <= 64) { - setValue("start_point", { lat: lat, lng: lng }); - setError(false); - } else { - setValue("start_point", null); - setError(true); - } - }} - InputLabelProps={{ shrink: true }} - /> - ); -}; -export default LocationInputs; +import LtrTextField from "@/core/components/LtrTextField"; +import { useState } from "react"; +import { useWatch } from "react-hook-form"; + +const LocationInputs = ({ control, setValue, errors }) => { + const StartPoint = useWatch({ control, name: "start_point" }); + const [coords, setCoords] = useState(StartPoint ? `${StartPoint.lat},${StartPoint.lng}` : ""); + const [error, setError] = useState(false); + + return ( + { + const value = e.target.value.trim(); + setCoords(value); + + if (value === "") { + setValue("start_point", null); + setError(false); + return; + } + + const parts = value.split(",").map((p) => p.trim()); + if (parts.length !== 2) { + setError(true); + return; + } + + const lat = Number(parts[0]); + const lng = Number(parts[1]); + + if (!isNaN(lat) && !isNaN(lng) && lat >= 25 && lat <= 40 && lng >= 44 && lng <= 64) { + setValue("start_point", { lat: lat, lng: lng }); + setError(false); + } else { + setValue("start_point", null); + setError(true); + } + }} + InputLabelProps={{ shrink: true }} + /> + ); +}; +export default LocationInputs; diff --git a/src/components/dashboard/damages/operator/RowActions/ButtonDownload/index.jsx b/src/components/dashboard/damages/operator/RowActions/ButtonDownload/index.jsx index 73e91ee..3f729d0 100644 --- a/src/components/dashboard/damages/operator/RowActions/ButtonDownload/index.jsx +++ b/src/components/dashboard/damages/operator/RowActions/ButtonDownload/index.jsx @@ -1,13 +1,13 @@ -import { Download } from "@mui/icons-material"; -import { IconButton, Tooltip } from "@mui/material"; - -const ButtonDownload = ({ url, title }) => { - return ( - - - - - - ); -}; -export default ButtonDownload; +import { Download } from "@mui/icons-material"; +import { IconButton, Tooltip } from "@mui/material"; + +const ButtonDownload = ({ url, title }) => { + return ( + + + + + + ); +}; +export default ButtonDownload; diff --git a/src/components/dashboard/damages/operator/RowActions/ChangeStatus/Dialog.jsx b/src/components/dashboard/damages/operator/RowActions/ChangeStatus/Dialog.jsx index 64a3c70..44a22d5 100644 --- a/src/components/dashboard/damages/operator/RowActions/ChangeStatus/Dialog.jsx +++ b/src/components/dashboard/damages/operator/RowActions/ChangeStatus/Dialog.jsx @@ -1,26 +1,26 @@ -import { Close } from "@mui/icons-material"; -import { Dialog, DialogTitle, IconButton } from "@mui/material"; -import ChangeStatusForm from "./Form"; - -const ChangeStatusDialog = ({ open, setOpen, mutate, row }) => { - return ( - - setOpen(false)} - sx={(theme) => ({ - position: "absolute", - right: 8, - top: 8, - zIndex: 50, - color: theme.palette.grey[500], - })} - > - - - تغییر وضعیت - {open && } - - ); -}; -export default ChangeStatusDialog; +import { Close } from "@mui/icons-material"; +import { Dialog, DialogTitle, IconButton } from "@mui/material"; +import ChangeStatusForm from "./Form"; + +const ChangeStatusDialog = ({ open, setOpen, mutate, row }) => { + return ( + + setOpen(false)} + sx={(theme) => ({ + position: "absolute", + right: 8, + top: 8, + zIndex: 50, + color: theme.palette.grey[500], + })} + > + + + تغییر وضعیت + {open && } + + ); +}; +export default ChangeStatusDialog; diff --git a/src/components/dashboard/damages/operator/RowActions/ChangeStatus/Form.jsx b/src/components/dashboard/damages/operator/RowActions/ChangeStatus/Form.jsx index 370587c..742c1a8 100644 --- a/src/components/dashboard/damages/operator/RowActions/ChangeStatus/Form.jsx +++ b/src/components/dashboard/damages/operator/RowActions/ChangeStatus/Form.jsx @@ -1,96 +1,96 @@ -import SelectBox from "@/core/components/SelectBox"; -import StyledForm from "@/core/components/StyledForm"; -import { CHANGE_STATUS_RECEIPT } from "@/core/utils/routes"; -import useRequest from "@/lib/hooks/useRequest"; -import { yupResolver } from "@hookform/resolvers/yup"; -import { Beenhere, ExitToApp } from "@mui/icons-material"; -import { Button, DialogActions, DialogContent, Grid, Stack } from "@mui/material"; -import { Controller, useForm } from "react-hook-form"; -import { object, string } from "yup"; - -const validationSchema = object({ - status: string().required("وضعیت را مشخص کنید!"), -}); - -const ChangeStatusForm = ({ setOpen, mutate, row }) => { - const requestServer = useRequest({ notificationSuccess: true }); - const defaultValues = { - status: row.original.status || "", - }; - - const handleClose = () => { - setOpen(false); - }; - - const { - control, - handleSubmit, - formState: { isSubmitting }, - } = useForm({ - defaultValues, - resolver: yupResolver(validationSchema), - mode: "all", - }); - const onSubmitBase = async (data) => { - const formData = new FormData(); - formData.append("status_id", data.status); - await requestServer(`${CHANGE_STATUS_RECEIPT}/${row.original.id}`, "post", { - data: formData, - }) - .then((response) => { - mutate(); - setOpen(false); - }) - .catch((error) => {}); - }; - - return ( - - - - - - ( - - )} - /> - - - - - - - - - - ); -}; -export default ChangeStatusForm; +import SelectBox from "@/core/components/SelectBox"; +import StyledForm from "@/core/components/StyledForm"; +import { CHANGE_STATUS_RECEIPT } from "@/core/utils/routes"; +import useRequest from "@/lib/hooks/useRequest"; +import { yupResolver } from "@hookform/resolvers/yup"; +import { Beenhere, ExitToApp } from "@mui/icons-material"; +import { Button, DialogActions, DialogContent, Grid, Stack } from "@mui/material"; +import { Controller, useForm } from "react-hook-form"; +import { object, string } from "yup"; + +const validationSchema = object({ + status: string().required("وضعیت را مشخص کنید!"), +}); + +const ChangeStatusForm = ({ setOpen, mutate, row }) => { + const requestServer = useRequest({ notificationSuccess: true }); + const defaultValues = { + status: row.original.status || "", + }; + + const handleClose = () => { + setOpen(false); + }; + + const { + control, + handleSubmit, + formState: { isSubmitting }, + } = useForm({ + defaultValues, + resolver: yupResolver(validationSchema), + mode: "all", + }); + const onSubmitBase = async (data) => { + const formData = new FormData(); + formData.append("status_id", data.status); + await requestServer(`${CHANGE_STATUS_RECEIPT}/${row.original.id}`, "post", { + data: formData, + }) + .then((response) => { + mutate(); + setOpen(false); + }) + .catch((error) => {}); + }; + + return ( + + + + + + ( + + )} + /> + + + + + + + + + + ); +}; +export default ChangeStatusForm; diff --git a/src/components/dashboard/damages/operator/RowActions/ChangeStatus/index.jsx b/src/components/dashboard/damages/operator/RowActions/ChangeStatus/index.jsx index 6c237be..bc5c9b4 100644 --- a/src/components/dashboard/damages/operator/RowActions/ChangeStatus/index.jsx +++ b/src/components/dashboard/damages/operator/RowActions/ChangeStatus/index.jsx @@ -1,19 +1,19 @@ -import { Reply } from "@mui/icons-material"; -import { IconButton, Tooltip } from "@mui/material"; -import { useState } from "react"; -import ChangeStatusDialog from "./Dialog"; - -const ChangeStatus = ({ row, mutate }) => { - const [open, setOpen] = useState(false); - return ( - <> - - setOpen(true)}> - - - - - - ); -}; -export default ChangeStatus; +import { Reply } from "@mui/icons-material"; +import { IconButton, Tooltip } from "@mui/material"; +import { useState } from "react"; +import ChangeStatusDialog from "./Dialog"; + +const ChangeStatus = ({ row, mutate }) => { + const [open, setOpen] = useState(false); + return ( + <> + + setOpen(true)}> + + + + + + ); +}; +export default ChangeStatus; diff --git a/src/components/dashboard/inquiryPrivacy/city-admin/CityAdminList.jsx b/src/components/dashboard/inquiryPrivacy/city-admin/CityAdminList.jsx index b732d9b..216311a 100644 --- a/src/components/dashboard/inquiryPrivacy/city-admin/CityAdminList.jsx +++ b/src/components/dashboard/inquiryPrivacy/city-admin/CityAdminList.jsx @@ -1,243 +1,243 @@ -import CustomSelectByDependency from "@/core/components/DataTable/filter/fieldsType/CustomSelectByDependency"; -import DataTableWithAuth from "@/core/components/DataTableWithAuth"; -import { GET_CITY_ADMIN_LIST } from "@/core/utils/routes"; -import useInquiryPrivacyState from "@/lib/hooks/useInquiryPrivacyState"; -import { Box, Stack } from "@mui/material"; -import moment from "jalali-moment"; -import { useMemo } from "react"; -import MapsHomeWorkIcon from "@mui/icons-material/MapsHomeWork"; -import SecurityIcon from "@mui/icons-material/Security"; -import ManageAccountsIcon from "@mui/icons-material/ManageAccounts"; -import PsychologyAltIcon from "@mui/icons-material/PsychologyAlt"; -import ReceiptLongIcon from "@mui/icons-material/ReceiptLong"; -import WindowIcon from "@mui/icons-material/Window"; -import DangerousIcon from "@mui/icons-material/Dangerous"; -import AutorenewIcon from "@mui/icons-material/Autorenew"; -import RowActions from "./RowActions"; -import ShowPrimaryArea from "./ShowPrimaryArea"; - -const CityAdminList = () => { - const stateIcon = (state_id) => { - if (state_id === 1) return ; - if (state_id === 2 || state_id === 5 || state_id === 13) return ; - if (state_id === 3 || state_id === 6 || state_id === 14) - return ; - if (state_id === 4 || state_id === 7 || state_id === 15) return ; - if (state_id === 8) return ; - if (state_id === 9 || state_id === 11) return ; - if (state_id === 10) return ; - if (state_id === 12) return ; - }; - const columns = useMemo(() => { - return [ - { - accessorKey: "panjare_vahed_id", - header: "کدرهگیری درخواست", - id: "panjare_vahed_id", - enableColumnFilter: true, - datatype: "text", - filterMode: "equals", - sortDescFirst: false, - columnFilterModeOptions: ["equals", "contains"], - grow: false, - size: 100, - Cell: ({ row }) => <>{row.original.panjare_vahed_id}, - }, - { - accessorKey: "national_id", - header: "کد ملی", - id: "national_id", - enableColumnFilter: true, - datatype: "text", - filterMode: "equals", - sortDescFirst: false, - columnFilterModeOptions: ["equals", "contains"], - grow: false, - size: 100, - Cell: ({ row }) => <>{row.original.national_id}, - }, - { - accessorKey: "state_id", - header: "وضعیت", - id: "state_id", - enableColumnFilter: true, - datatype: "numeric", - filterMode: "equals", - sortDescFirst: false, - grow: false, - size: 100, - ColumnSelectComponent: (props) => { - const { itemsList, loadingItemsList, errorItemsList } = useInquiryPrivacyState(); - - const getColumnSelectOptions = useMemo(() => { - if (loadingItemsList) { - return [{ value: "loading", label: "در حال بارگذاری..." }]; - } - if (errorItemsList) { - return [{ value: "error", label: "خطا در بارگذاری" }]; - } - return [ - { value: "", label: "همه موارد" }, - ...itemsList.map((item) => ({ - value: item.id, - label: item.name, - })), - ]; - }, [itemsList, loadingItemsList, errorItemsList]); - - return ( - - ); - }, - Cell: ({ row }) => ( - - {stateIcon(row.original.state_id)} - - {row.original.state_name} - - - ), - }, - { - accessorKey: "plan_title", - header: "عنوان طرح", - id: "plan_title", - enableColumnFilter: true, - datatype: "text", - filterMode: "equals", - sortDescFirst: false, - columnFilterModeOptions: ["equals", "contains"], - grow: false, - size: 100, - Cell: ({ row }) => <>{row.original.plan_title}, - }, - { - accessorKey: "plan_group", - header: "گروه طرح", - id: "plan_group", - enableColumnFilter: true, - datatype: "text", - filterMode: "equals", - sortDescFirst: false, - columnFilterModeOptions: ["equals", "contains"], - grow: false, - size: 100, - Cell: ({ row }) => <>{row.original.plan_group}, - }, - { - accessorKey: "requested_organization", - header: "دستگاه صادر کننده", - id: "requested_organization", - enableColumnFilter: true, - datatype: "text", - filterMode: "equals", - sortDescFirst: false, - columnFilterModeOptions: ["equals", "contains"], - grow: false, - size: 100, - Cell: ({ row }) => <>{row.original.requested_organization}, - }, - { - accessorKey: "worksheet_id", - header: "شناسه کاربرگ", - id: "worksheet_id", - enableColumnFilter: true, - datatype: "text", - filterMode: "equals", - sortDescFirst: false, - columnFilterModeOptions: ["equals", "contains"], - grow: false, - size: 100, - Cell: ({ row }) => <>{row.original.worksheet_id}, - }, - { - accessorKey: "primary_area", - header: "نمایش محدوده طرح", - id: "primary_area", - enableColumnFilter: true, - datatype: "text", - filterMode: "equals", - sortDescFirst: false, - columnFilterModeOptions: ["equals", "contains"], - grow: false, - size: 100, - Cell: ({ row }) => - row.original.primary_area ? ( - - - - ) : ( - "-" - ), - }, - { - accessorKey: "province_id", - header: "استان", - id: "province_id", - enableColumnFilter: false, - datatype: "numeric", - sortDescFirst: false, - grow: false, - size: 100, - Cell: ({ row }) => <>{row.original.province_name}, - }, - { - accessorKey: "city_id", - header: "شهر", - id: "city_id", - enableColumnFilter: false, - datatype: "numeric", - sortDescFirst: false, - grow: false, - size: 100, - Cell: ({ row }) => <>{row.original.city_name}, - }, - { - accessorKey: "isic", - header: "کد آیسیک", - id: "isic", - enableColumnFilter: true, - datatype: "text", - filterMode: "equals", - sortDescFirst: false, - columnFilterModeOptions: ["equals", "contains"], - grow: false, - size: 100, - Cell: ({ row }) => <>{row.original.isic}, - }, - { - accessorFn: (row) => moment(row.request_date).locale("fa").format("YYYY/MM/DD"), - header: "تاریخ درخواست", - id: "request_date", - enableColumnFilter: true, - datatype: "date", - filterMode: "between", - grow: false, - size: 100, - }, - ]; - }, []); - - return ( - <> - - - - - ); -}; - -export default CityAdminList; +import CustomSelectByDependency from "@/core/components/DataTable/filter/fieldsType/CustomSelectByDependency"; +import DataTableWithAuth from "@/core/components/DataTableWithAuth"; +import { GET_CITY_ADMIN_LIST } from "@/core/utils/routes"; +import useInquiryPrivacyState from "@/lib/hooks/useInquiryPrivacyState"; +import { Box, Stack } from "@mui/material"; +import moment from "jalali-moment"; +import { useMemo } from "react"; +import MapsHomeWorkIcon from "@mui/icons-material/MapsHomeWork"; +import SecurityIcon from "@mui/icons-material/Security"; +import ManageAccountsIcon from "@mui/icons-material/ManageAccounts"; +import PsychologyAltIcon from "@mui/icons-material/PsychologyAlt"; +import ReceiptLongIcon from "@mui/icons-material/ReceiptLong"; +import WindowIcon from "@mui/icons-material/Window"; +import DangerousIcon from "@mui/icons-material/Dangerous"; +import AutorenewIcon from "@mui/icons-material/Autorenew"; +import RowActions from "./RowActions"; +import ShowPrimaryArea from "./ShowPrimaryArea"; + +const CityAdminList = () => { + const stateIcon = (state_id) => { + if (state_id === 1) return ; + if (state_id === 2 || state_id === 5 || state_id === 13) return ; + if (state_id === 3 || state_id === 6 || state_id === 14) + return ; + if (state_id === 4 || state_id === 7 || state_id === 15) return ; + if (state_id === 8) return ; + if (state_id === 9 || state_id === 11) return ; + if (state_id === 10) return ; + if (state_id === 12) return ; + }; + const columns = useMemo(() => { + return [ + { + accessorKey: "panjare_vahed_id", + header: "کدرهگیری درخواست", + id: "panjare_vahed_id", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ row }) => <>{row.original.panjare_vahed_id}, + }, + { + accessorKey: "national_id", + header: "کد ملی", + id: "national_id", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ row }) => <>{row.original.national_id}, + }, + { + accessorKey: "state_id", + header: "وضعیت", + id: "state_id", + enableColumnFilter: true, + datatype: "numeric", + filterMode: "equals", + sortDescFirst: false, + grow: false, + size: 100, + ColumnSelectComponent: (props) => { + const { itemsList, loadingItemsList, errorItemsList } = useInquiryPrivacyState(); + + const getColumnSelectOptions = useMemo(() => { + if (loadingItemsList) { + return [{ value: "loading", label: "در حال بارگذاری..." }]; + } + if (errorItemsList) { + return [{ value: "error", label: "خطا در بارگذاری" }]; + } + return [ + { value: "", label: "همه موارد" }, + ...itemsList.map((item) => ({ + value: item.id, + label: item.name, + })), + ]; + }, [itemsList, loadingItemsList, errorItemsList]); + + return ( + + ); + }, + Cell: ({ row }) => ( + + {stateIcon(row.original.state_id)} + + {row.original.state_name} + + + ), + }, + { + accessorKey: "plan_title", + header: "عنوان طرح", + id: "plan_title", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ row }) => <>{row.original.plan_title}, + }, + { + accessorKey: "plan_group", + header: "گروه طرح", + id: "plan_group", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ row }) => <>{row.original.plan_group}, + }, + { + accessorKey: "requested_organization", + header: "دستگاه صادر کننده", + id: "requested_organization", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ row }) => <>{row.original.requested_organization}, + }, + { + accessorKey: "worksheet_id", + header: "شناسه کاربرگ", + id: "worksheet_id", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ row }) => <>{row.original.worksheet_id}, + }, + { + accessorKey: "primary_area", + header: "نمایش محدوده طرح", + id: "primary_area", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ row }) => + row.original.primary_area ? ( + + + + ) : ( + "-" + ), + }, + { + accessorKey: "province_id", + header: "استان", + id: "province_id", + enableColumnFilter: false, + datatype: "numeric", + sortDescFirst: false, + grow: false, + size: 100, + Cell: ({ row }) => <>{row.original.province_name}, + }, + { + accessorKey: "city_id", + header: "شهر", + id: "city_id", + enableColumnFilter: false, + datatype: "numeric", + sortDescFirst: false, + grow: false, + size: 100, + Cell: ({ row }) => <>{row.original.city_name}, + }, + { + accessorKey: "isic", + header: "کد آیسیک", + id: "isic", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ row }) => <>{row.original.isic}, + }, + { + accessorFn: (row) => moment(row.request_date).locale("fa").format("YYYY/MM/DD"), + header: "تاریخ درخواست", + id: "request_date", + enableColumnFilter: true, + datatype: "date", + filterMode: "between", + grow: false, + size: 100, + }, + ]; + }, []); + + return ( + <> + + + + + ); +}; + +export default CityAdminList; diff --git a/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/FeedbackAction/MapDrawPolygon/DrawBound.jsx b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/FeedbackAction/MapDrawPolygon/DrawBound.jsx index 02b567f..951fe6c 100644 --- a/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/FeedbackAction/MapDrawPolygon/DrawBound.jsx +++ b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/FeedbackAction/MapDrawPolygon/DrawBound.jsx @@ -1,149 +1,149 @@ -import React, { useCallback, useEffect, useRef, useState } from "react"; -import L from "leaflet"; -import { FeatureGroup, useMap } from "react-leaflet"; -import "leaflet-draw"; -import { calculatePolygonMetrics } from "@/core/utils/geoCalculations"; - -const DrawPolygon = ({ control, controlDispach, drawBound, setDrawBound }) => { - const map = useMap(); - const featureRef = useRef(null); - const drawControlRef = useRef(null); - - const [area, setArea] = useState(0); - const [sideLengths, setSideLengths] = useState([]); - - const calculatePolygonMetricsForLayer = useCallback( - (layer) => { - if (!layer) return; - - const latlngs = layer.getLatLngs()[0]; - if (!latlngs || latlngs.length < 3) return; - - const coordinates = latlngs.map((p) => [p.lat, p.lng]); - - const metrics = calculatePolygonMetrics(coordinates, true); - - setArea(metrics.area); - setSideLengths(metrics.sides); - - setDrawBound({ - layer, - metrics, - }); - }, - [setDrawBound] - ); - - 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 = useCallback( - (layer) => { - if (!layer) return; - layer.on("edit", function (e) { - const editedLayer = e.target; - calculatePolygonMetricsForLayer(editedLayer); - }); - }, - [calculatePolygonMetricsForLayer] - ); - - const handlerCreatedBound = useCallback( - (event) => { - const { layer } = event; - layer.editing.enable(); - featureRef.current.addLayer(layer); - - calculatePolygonMetricsForLayer(layer); - bindEditEvent(layer); - - controlDispach({ type: "SET_STATUS", status: 2 }); - }, - [calculatePolygonMetricsForLayer, bindEditEvent, controlDispach] - ); - - 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 && featureRef.current) { - featureRef.current.clearLayers(); - setArea(0); - setSideLengths([]); - setDrawBound(null); - } - }, [control.status, setDrawBound]); - - useEffect(() => { - if (control.status === 2 && drawBound && featureRef.current) { - const { layer, metrics } = drawBound; - featureRef.current.addLayer(layer); - layer.editing.enable(); - safeFitBounds(layer); - bindEditEvent(layer); - - setArea(metrics?.area || 0); - setSideLengths(metrics?.sides || []); - } - }, [control.status, drawBound, bindEditEvent]); - - 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: "red", - weight: 3, - clickable: true, - }, - }, - polyline: false, - rectangle: false, - circle: false, - marker: false, - circlemarker: false, - }, - edit: { - featureGroup: featureRef.current, - edit: true, - remove: true, - }, - }); - - 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 DrawPolygon; +import React, { useCallback, useEffect, useRef, useState } from "react"; +import L from "leaflet"; +import { FeatureGroup, useMap } from "react-leaflet"; +import "leaflet-draw"; +import { calculatePolygonMetrics } from "@/core/utils/geoCalculations"; + +const DrawPolygon = ({ control, controlDispach, drawBound, setDrawBound }) => { + const map = useMap(); + const featureRef = useRef(null); + const drawControlRef = useRef(null); + + const [area, setArea] = useState(0); + const [sideLengths, setSideLengths] = useState([]); + + const calculatePolygonMetricsForLayer = useCallback( + (layer) => { + if (!layer) return; + + const latlngs = layer.getLatLngs()[0]; + if (!latlngs || latlngs.length < 3) return; + + const coordinates = latlngs.map((p) => [p.lat, p.lng]); + + const metrics = calculatePolygonMetrics(coordinates, true); + + setArea(metrics.area); + setSideLengths(metrics.sides); + + setDrawBound({ + layer, + metrics, + }); + }, + [setDrawBound] + ); + + 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 = useCallback( + (layer) => { + if (!layer) return; + layer.on("edit", function (e) { + const editedLayer = e.target; + calculatePolygonMetricsForLayer(editedLayer); + }); + }, + [calculatePolygonMetricsForLayer] + ); + + const handlerCreatedBound = useCallback( + (event) => { + const { layer } = event; + layer.editing.enable(); + featureRef.current.addLayer(layer); + + calculatePolygonMetricsForLayer(layer); + bindEditEvent(layer); + + controlDispach({ type: "SET_STATUS", status: 2 }); + }, + [calculatePolygonMetricsForLayer, bindEditEvent, controlDispach] + ); + + 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 && featureRef.current) { + featureRef.current.clearLayers(); + setArea(0); + setSideLengths([]); + setDrawBound(null); + } + }, [control.status, setDrawBound]); + + useEffect(() => { + if (control.status === 2 && drawBound && featureRef.current) { + const { layer, metrics } = drawBound; + featureRef.current.addLayer(layer); + layer.editing.enable(); + safeFitBounds(layer); + bindEditEvent(layer); + + setArea(metrics?.area || 0); + setSideLengths(metrics?.sides || []); + } + }, [control.status, drawBound, bindEditEvent]); + + 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: "red", + weight: 3, + clickable: true, + }, + }, + polyline: false, + rectangle: false, + circle: false, + marker: false, + circlemarker: false, + }, + edit: { + featureGroup: featureRef.current, + edit: true, + remove: true, + }, + }); + + 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 DrawPolygon; diff --git a/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/FeedbackAction/MapDrawPolygon/index.jsx b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/FeedbackAction/MapDrawPolygon/index.jsx index ab4c1f4..25f4125 100644 --- a/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/FeedbackAction/MapDrawPolygon/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/FeedbackAction/MapDrawPolygon/index.jsx @@ -1,121 +1,121 @@ -import { Delete, Route } from "@mui/icons-material"; -import { Box, Button, Stack, Typography } from "@mui/material"; -import { useReducer } from "react"; -import DrawPolygon from "./DrawBound"; - -const statusType = [ - { - id: 0, - message: "برای آغاز ترسیم محدوده، کلیک کنید!", - buttons: [ - { - label: "شروع ترسیم محدوده", - key: "start", - color: "warning", - 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 = (drawBound) => { - if (drawBound) { - 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 MapDrawPolygon = ({ drawBound, setDrawBound }) => { - const [control, controlDispach] = useReducer(reducer, drawBound, createInitialState); - - return ( - <> - - - theme.palette.secondary.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 MapDrawPolygon; +import { Delete, Route } from "@mui/icons-material"; +import { Box, Button, Stack, Typography } from "@mui/material"; +import { useReducer } from "react"; +import DrawPolygon from "./DrawBound"; + +const statusType = [ + { + id: 0, + message: "برای آغاز ترسیم محدوده، کلیک کنید!", + buttons: [ + { + label: "شروع ترسیم محدوده", + key: "start", + color: "warning", + 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 = (drawBound) => { + if (drawBound) { + 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 MapDrawPolygon = ({ drawBound, setDrawBound }) => { + const [control, controlDispach] = useReducer(reducer, drawBound, createInitialState); + + return ( + <> + + + theme.palette.secondary.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 MapDrawPolygon; diff --git a/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/FeedbackAction/index.jsx b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/FeedbackAction/index.jsx index 0f64405..50c4180 100644 --- a/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/FeedbackAction/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/FeedbackAction/index.jsx @@ -1,156 +1,156 @@ -import MapLayer from "@/core/components/MapLayer"; -import { CITY_ADMIN_FEEDBACK } from "@/core/utils/routes"; -import useRequest from "@/lib/hooks/useRequest"; -import { yupResolver } from "@hookform/resolvers/yup"; -import CloseIcon from "@mui/icons-material/Close"; -import ForumIcon from "@mui/icons-material/Forum"; -import { - Box, - Button, - Dialog, - DialogActions, - DialogContent, - DialogTitle, - IconButton, - TextField, - Tooltip, - Typography, -} from "@mui/material"; -import { useMemo, useState } from "react"; -import { useForm } from "react-hook-form"; -import { object, string } from "yup"; -import ShowBound from "../../ShowPrimaryArea/ShowBound"; -import MapDrawPolygon from "./MapDrawPolygon"; - -const validationSchema = object({ - expert_description: string().required("توضیحات ناظر اجباری است!"), -}); - -const FeedbackAction = ({ rowId, mutate, rowPrimaryArea }) => { - const requestServer = useRequest({ notificationSuccess: true }); - const [openFeedbackDialog, setOpenFeedbackDialog] = useState(false); - const [drawBound, setDrawBound] = useState(null); - const bound = useMemo(() => { - const latLngCoords = rowPrimaryArea.coordinates.map((coord) => [coord[1], coord[0]]); - return rowPrimaryArea.type === "polygon" ? L.polygon(latLngCoords) : L.polyline(latLngCoords); - }, [rowPrimaryArea]); - - const { - register, - handleSubmit, - formState: { isSubmitting, errors }, - } = useForm({ - defaultValues: { expert_description: "", forbidden_area: "", forbidden_area_space: "" }, - resolver: yupResolver(validationSchema), - mode: "all", - }); - - const onSubmit = async (data) => { - try { - const payload = { - expert_description: data.expert_description, - }; - - if (drawBound && drawBound.metrics) { - const { metrics } = drawBound; - payload.forbidden_area = { - type: "polygon", - coordinates: metrics.coordinates, - }; - payload.forbidden_area_space = metrics.area.toFixed(2); - } - await requestServer(`${CITY_ADMIN_FEEDBACK}/${rowId}`, "post", { - data: payload, - }); - - mutate(); - setOpenFeedbackDialog(false); - } catch (error) { - console.error("❌ Error submitting feedback:", error); - } - }; - - return ( - <> - - - setOpenFeedbackDialog(true)}> - - - - setOpenFeedbackDialog(false)} - PaperProps={{ - sx: { - transition: "all .3s", - boxShadow: - "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px", - borderRadius: 2, - }, - }} - maxWidth="sm" - fullWidth - dir="rtl" - > - - - توضیحات ناظر - - setOpenFeedbackDialog(false)} size="small"> - - - - - - منطقه ممنوعه{" "} - - (در صورت وجود انتخاب کنید) - - - - - - - - - - - - - - - - - - ); -}; - -export default FeedbackAction; +import MapLayer from "@/core/components/MapLayer"; +import { CITY_ADMIN_FEEDBACK } from "@/core/utils/routes"; +import useRequest from "@/lib/hooks/useRequest"; +import { yupResolver } from "@hookform/resolvers/yup"; +import CloseIcon from "@mui/icons-material/Close"; +import ForumIcon from "@mui/icons-material/Forum"; +import { + Box, + Button, + Dialog, + DialogActions, + DialogContent, + DialogTitle, + IconButton, + TextField, + Tooltip, + Typography, +} from "@mui/material"; +import { useMemo, useState } from "react"; +import { useForm } from "react-hook-form"; +import { object, string } from "yup"; +import ShowBound from "../../ShowPrimaryArea/ShowBound"; +import MapDrawPolygon from "./MapDrawPolygon"; + +const validationSchema = object({ + expert_description: string().required("توضیحات ناظر اجباری است!"), +}); + +const FeedbackAction = ({ rowId, mutate, rowPrimaryArea }) => { + const requestServer = useRequest({ notificationSuccess: true }); + const [openFeedbackDialog, setOpenFeedbackDialog] = useState(false); + const [drawBound, setDrawBound] = useState(null); + const bound = useMemo(() => { + const latLngCoords = rowPrimaryArea.coordinates.map((coord) => [coord[1], coord[0]]); + return rowPrimaryArea.type === "polygon" ? L.polygon(latLngCoords) : L.polyline(latLngCoords); + }, [rowPrimaryArea]); + + const { + register, + handleSubmit, + formState: { isSubmitting, errors }, + } = useForm({ + defaultValues: { expert_description: "", forbidden_area: "", forbidden_area_space: "" }, + resolver: yupResolver(validationSchema), + mode: "all", + }); + + const onSubmit = async (data) => { + try { + const payload = { + expert_description: data.expert_description, + }; + + if (drawBound && drawBound.metrics) { + const { metrics } = drawBound; + payload.forbidden_area = { + type: "polygon", + coordinates: metrics.coordinates, + }; + payload.forbidden_area_space = metrics.area.toFixed(2); + } + await requestServer(`${CITY_ADMIN_FEEDBACK}/${rowId}`, "post", { + data: payload, + }); + + mutate(); + setOpenFeedbackDialog(false); + } catch (error) { + console.error("❌ Error submitting feedback:", error); + } + }; + + return ( + <> + + + setOpenFeedbackDialog(true)}> + + + + setOpenFeedbackDialog(false)} + PaperProps={{ + sx: { + transition: "all .3s", + boxShadow: + "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px", + borderRadius: 2, + }, + }} + maxWidth="sm" + fullWidth + dir="rtl" + > + + + توضیحات ناظر + + setOpenFeedbackDialog(false)} size="small"> + + + + + + منطقه ممنوعه{" "} + + (در صورت وجود انتخاب کنید) + + + + + + + + + + + + + + + + + + ); +}; + +export default FeedbackAction; diff --git a/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/History/HistoryContent.jsx b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/History/HistoryContent.jsx index 71f59c1..76fcbf0 100644 --- a/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/History/HistoryContent.jsx +++ b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/History/HistoryContent.jsx @@ -1,17 +1,17 @@ -import { Button, DialogActions, DialogContent } from "@mui/material"; -import TableContent from "./TableContent"; -const HistoryContent = ({ setOpenReferReasonDialog, rowId }) => { - return ( - <> - - - - - - - - ); -}; -export default HistoryContent; +import { Button, DialogActions, DialogContent } from "@mui/material"; +import TableContent from "./TableContent"; +const HistoryContent = ({ setOpenReferReasonDialog, rowId }) => { + return ( + <> + + + + + + + + ); +}; +export default HistoryContent; diff --git a/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/History/TableContent.jsx b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/History/TableContent.jsx index b405a41..be6e82b 100644 --- a/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/History/TableContent.jsx +++ b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/History/TableContent.jsx @@ -1,66 +1,66 @@ -import { - Box, - Table, - TableBody, - TableCell, - TableContainer, - TableHead, - TableRow, - CircularProgress, - Typography, -} from "@mui/material"; -import "moment/locale/fa"; -import { useHistory } from "@/lib/hooks/useHistory"; - -const TableContent = ({ rowId }) => { - const { historyData, loading, error } = useHistory(rowId); - - if (loading) { - return ( - - - - ); - } - - if (error) { - return ( - - {error} - - ); - } - - if (!historyData.length) { - return ( - - اطلاعاتی وجود ندارد - - ); - } - - return ( - - - - - - وضعیت - توضیحات کارشناس - - - - {historyData.map((row) => ( - - {row.previous_state_name} - {row.expert_description} - - ))} - -
-
-
- ); -}; - -export default TableContent; +import { + Box, + Table, + TableBody, + TableCell, + TableContainer, + TableHead, + TableRow, + CircularProgress, + Typography, +} from "@mui/material"; +import "moment/locale/fa"; +import { useHistory } from "@/lib/hooks/useHistory"; + +const TableContent = ({ rowId }) => { + const { historyData, loading, error } = useHistory(rowId); + + if (loading) { + return ( + + + + ); + } + + if (error) { + return ( + + {error} + + ); + } + + if (!historyData.length) { + return ( + + اطلاعاتی وجود ندارد + + ); + } + + return ( + + + + + + وضعیت + توضیحات کارشناس + + + + {historyData.map((row) => ( + + {row.previous_state_name} + {row.expert_description} + + ))} + +
+
+
+ ); +}; + +export default TableContent; diff --git a/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/History/index.jsx b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/History/index.jsx index 234ac15..cc3df74 100644 --- a/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/History/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/History/index.jsx @@ -1,33 +1,33 @@ -import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; -import { RestorePage } from "@mui/icons-material"; -import HistoryContent from "./HistoryContent"; -import { useState } from "react"; - -const History = ({ rowId }) => { - const [openReferReasonDialog, setOpenReferReasonDialog] = useState(false); - - return ( - <> - - setOpenReferReasonDialog(true)}> - - - - - تاریخچه - - - - ); -}; - -export default History; +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { RestorePage } from "@mui/icons-material"; +import HistoryContent from "./HistoryContent"; +import { useState } from "react"; + +const History = ({ rowId }) => { + const [openReferReasonDialog, setOpenReferReasonDialog] = useState(false); + + return ( + <> + + setOpenReferReasonDialog(true)}> + + + + + تاریخچه + + + + ); +}; + +export default History; diff --git a/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/index.jsx b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/index.jsx index a432d18..6533a0b 100644 --- a/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/index.jsx @@ -1,17 +1,17 @@ -import { Box } from "@mui/material"; -import FeedbackAction from "./FeedbackAction"; -import History from "./History"; - -const RowActions = ({ row, mutate }) => { - return ( - - {row.original.state_id === 1 ? ( - - ) : ( - "-" - )} - - - ); -}; -export default RowActions; +import { Box } from "@mui/material"; +import FeedbackAction from "./FeedbackAction"; +import History from "./History"; + +const RowActions = ({ row, mutate }) => { + return ( + + {row.original.state_id === 1 ? ( + + ) : ( + "-" + )} + + + ); +}; +export default RowActions; diff --git a/src/components/dashboard/inquiryPrivacy/city-admin/ShowPrimaryArea/ShowBound.jsx b/src/components/dashboard/inquiryPrivacy/city-admin/ShowPrimaryArea/ShowBound.jsx index 24db476..43dd0b8 100644 --- a/src/components/dashboard/inquiryPrivacy/city-admin/ShowPrimaryArea/ShowBound.jsx +++ b/src/components/dashboard/inquiryPrivacy/city-admin/ShowPrimaryArea/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/dashboard/inquiryPrivacy/city-admin/ShowPrimaryArea/index.jsx b/src/components/dashboard/inquiryPrivacy/city-admin/ShowPrimaryArea/index.jsx index 76c0980..34914bc 100644 --- a/src/components/dashboard/inquiryPrivacy/city-admin/ShowPrimaryArea/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/city-admin/ShowPrimaryArea/index.jsx @@ -1,59 +1,59 @@ -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 { useMemo, useState } from "react"; -import ShowBound from "./ShowBound"; - -const ShowPrimaryArea = ({ primaryArea }) => { - const [openShowAreaDialog, setOpenShowAreaDialog] = useState(false); - const bound = useMemo(() => { - const latLngCoords = primaryArea.coordinates.map((coord) => [coord[1], coord[0]]); - return primaryArea.type === "polygon" ? L.polygon(latLngCoords) : L.polyline(latLngCoords); - }, [primaryArea]); - - return ( - - - setOpenShowAreaDialog(true)}> - - - - setOpenShowAreaDialog(false)} - PaperProps={{ - sx: { - transition: "all .3s", - boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px", - borderRadius: 2, - padding: 1, - }, - }} - maxWidth="sm" - fullWidth - dir="rtl" - > - - - محدوده طرح - - setOpenShowAreaDialog(false)} size="small"> - - - - - - - - - - - - - - - ); -}; - -export default ShowPrimaryArea; +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 { useMemo, useState } from "react"; +import ShowBound from "./ShowBound"; + +const ShowPrimaryArea = ({ primaryArea }) => { + const [openShowAreaDialog, setOpenShowAreaDialog] = useState(false); + const bound = useMemo(() => { + const latLngCoords = primaryArea.coordinates.map((coord) => [coord[1], coord[0]]); + return primaryArea.type === "polygon" ? L.polygon(latLngCoords) : L.polyline(latLngCoords); + }, [primaryArea]); + + return ( + + + setOpenShowAreaDialog(true)}> + + + + setOpenShowAreaDialog(false)} + PaperProps={{ + sx: { + transition: "all .3s", + boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px", + borderRadius: 2, + padding: 1, + }, + }} + maxWidth="sm" + fullWidth + dir="rtl" + > + + + محدوده طرح + + setOpenShowAreaDialog(false)} size="small"> + + + + + + + + + + + + + + + ); +}; + +export default ShowPrimaryArea; diff --git a/src/components/dashboard/inquiryPrivacy/city-admin/index.jsx b/src/components/dashboard/inquiryPrivacy/city-admin/index.jsx index b8d7433..6275052 100644 --- a/src/components/dashboard/inquiryPrivacy/city-admin/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/city-admin/index.jsx @@ -1,14 +1,14 @@ -"use client"; -import PageTitle from "@/core/components/PageTitle"; -import { Stack } from "@mui/material"; -import CityAdminList from "./CityAdminList"; - -const CityAdminPage = () => { - return ( - - - - - ); -}; -export default CityAdminPage; +"use client"; +import PageTitle from "@/core/components/PageTitle"; +import { Stack } from "@mui/material"; +import CityAdminList from "./CityAdminList"; + +const CityAdminPage = () => { + return ( + + + + + ); +}; +export default CityAdminPage; diff --git a/src/components/dashboard/inquiryPrivacy/general-manager/GeneralManagerList.jsx b/src/components/dashboard/inquiryPrivacy/general-manager/GeneralManagerList.jsx index 4abd643..0dc7762 100644 --- a/src/components/dashboard/inquiryPrivacy/general-manager/GeneralManagerList.jsx +++ b/src/components/dashboard/inquiryPrivacy/general-manager/GeneralManagerList.jsx @@ -1,243 +1,243 @@ -import CustomSelectByDependency from "@/core/components/DataTable/filter/fieldsType/CustomSelectByDependency"; -import DataTableWithAuth from "@/core/components/DataTableWithAuth"; -import useInquiryPrivacyState from "@/lib/hooks/useInquiryPrivacyState"; -import AutorenewIcon from "@mui/icons-material/Autorenew"; -import DangerousIcon from "@mui/icons-material/Dangerous"; -import ManageAccountsIcon from "@mui/icons-material/ManageAccounts"; -import MapsHomeWorkIcon from "@mui/icons-material/MapsHomeWork"; -import PsychologyAltIcon from "@mui/icons-material/PsychologyAlt"; -import ReceiptLongIcon from "@mui/icons-material/ReceiptLong"; -import SecurityIcon from "@mui/icons-material/Security"; -import WindowIcon from "@mui/icons-material/Window"; -import { Box, Stack } from "@mui/material"; -import moment from "jalali-moment"; -import { useMemo } from "react"; -import RowActions from "./RowActions"; -import { GET_GENERAL_MANAGER_LIST } from "@/core/utils/routes"; -import ShowPrimaryArea from "./ShowPrimaryArea"; - -const GeneralManagerList = () => { - const stateIcon = (state_id) => { - if (state_id === 1) return ; - if (state_id === 2 || state_id === 5 || state_id === 13) return ; - if (state_id === 3 || state_id === 6 || state_id === 14) - return ; - if (state_id === 4 || state_id === 7 || state_id === 15) return ; - if (state_id === 8) return ; - if (state_id === 9 || state_id === 11) return ; - if (state_id === 10) return ; - if (state_id === 12) return ; - }; - const columns = useMemo(() => { - return [ - { - accessorKey: "panjare_vahed_id", - header: "کدرهگیری درخواست", - id: "panjare_vahed_id", - enableColumnFilter: true, - datatype: "text", - filterMode: "equals", - sortDescFirst: false, - columnFilterModeOptions: ["equals", "contains"], - grow: false, - size: 100, - Cell: ({ row }) => <>{row.original.panjare_vahed_id}, - }, - { - accessorKey: "national_id", - header: "کد ملی", - id: "national_id", - enableColumnFilter: true, - datatype: "text", - filterMode: "equals", - sortDescFirst: false, - columnFilterModeOptions: ["equals", "contains"], - grow: false, - size: 100, - Cell: ({ row }) => <>{row.original.national_id}, - }, - { - accessorKey: "state_id", - header: "وضعیت", - id: "state_id", - enableColumnFilter: true, - datatype: "numeric", - filterMode: "equals", - sortDescFirst: false, - grow: false, - size: 100, - ColumnSelectComponent: (props) => { - const { itemsList, loadingItemsList, errorItemsList } = useInquiryPrivacyState(); - - const getColumnSelectOptions = useMemo(() => { - if (loadingItemsList) { - return [{ value: "loading", label: "در حال بارگذاری..." }]; - } - if (errorItemsList) { - return [{ value: "error", label: "خطا در بارگذاری" }]; - } - return [ - { value: "", label: "همه موارد" }, - ...itemsList.map((item) => ({ - value: item.id, - label: item.name, - })), - ]; - }, [itemsList, loadingItemsList, errorItemsList]); - - return ( - - ); - }, - Cell: ({ row }) => ( - - {stateIcon(row.original.state_id)} - - {row.original.state_name} - - - ), - }, - { - accessorKey: "plan_title", - header: "عنوان طرح", - id: "plan_title", - enableColumnFilter: true, - datatype: "text", - filterMode: "equals", - sortDescFirst: false, - columnFilterModeOptions: ["equals", "contains"], - grow: false, - size: 100, - Cell: ({ row }) => <>{row.original.plan_title}, - }, - { - accessorKey: "plan_group", - header: "گروه طرح", - id: "plan_group", - enableColumnFilter: true, - datatype: "text", - filterMode: "equals", - sortDescFirst: false, - columnFilterModeOptions: ["equals", "contains"], - grow: false, - size: 100, - Cell: ({ row }) => <>{row.original.plan_group}, - }, - { - accessorKey: "requested_organization", - header: "دستگاه صادر کننده", - id: "requested_organization", - enableColumnFilter: true, - datatype: "text", - filterMode: "equals", - sortDescFirst: false, - columnFilterModeOptions: ["equals", "contains"], - grow: false, - size: 100, - Cell: ({ row }) => <>{row.original.requested_organization}, - }, - { - accessorKey: "worksheet_id", - header: "شناسه کاربرگ", - id: "worksheet_id", - enableColumnFilter: true, - datatype: "text", - filterMode: "equals", - sortDescFirst: false, - columnFilterModeOptions: ["equals", "contains"], - grow: false, - size: 100, - Cell: ({ row }) => <>{row.original.worksheet_id}, - }, - { - accessorKey: "primary_area", - header: "نمایش محدوده طرح", - id: "primary_area", - enableColumnFilter: true, - datatype: "text", - filterMode: "equals", - sortDescFirst: false, - columnFilterModeOptions: ["equals", "contains"], - grow: false, - size: 100, - Cell: ({ row }) => - row.original.primary_area ? ( - - - - ) : ( - "-" - ), - }, - { - accessorKey: "province_id", - header: "استان", - id: "province_id", - enableColumnFilter: false, - datatype: "numeric", - sortDescFirst: false, - grow: false, - size: 100, - Cell: ({ row }) => <>{row.original.province_name}, - }, - { - accessorKey: "city_id", - header: "شهر", - id: "city_id", - enableColumnFilter: false, - datatype: "numeric", - sortDescFirst: false, - grow: false, - size: 100, - Cell: ({ row }) => <>{row.original.city_name}, - }, - { - accessorKey: "isic", - header: "کد آیسیک", - id: "isic", - enableColumnFilter: true, - datatype: "text", - filterMode: "equals", - sortDescFirst: false, - columnFilterModeOptions: ["equals", "contains"], - grow: false, - size: 100, - Cell: ({ row }) => <>{row.original.isic}, - }, - { - accessorFn: (row) => moment(row.request_date).locale("fa").format("YYYY/MM/DD"), - header: "تاریخ درخواست", - id: "request_date", - enableColumnFilter: true, - datatype: "date", - filterMode: "between", - grow: false, - size: 100, - }, - ]; - }, []); - - return ( - <> - - - - - ); -}; - -export default GeneralManagerList; +import CustomSelectByDependency from "@/core/components/DataTable/filter/fieldsType/CustomSelectByDependency"; +import DataTableWithAuth from "@/core/components/DataTableWithAuth"; +import useInquiryPrivacyState from "@/lib/hooks/useInquiryPrivacyState"; +import AutorenewIcon from "@mui/icons-material/Autorenew"; +import DangerousIcon from "@mui/icons-material/Dangerous"; +import ManageAccountsIcon from "@mui/icons-material/ManageAccounts"; +import MapsHomeWorkIcon from "@mui/icons-material/MapsHomeWork"; +import PsychologyAltIcon from "@mui/icons-material/PsychologyAlt"; +import ReceiptLongIcon from "@mui/icons-material/ReceiptLong"; +import SecurityIcon from "@mui/icons-material/Security"; +import WindowIcon from "@mui/icons-material/Window"; +import { Box, Stack } from "@mui/material"; +import moment from "jalali-moment"; +import { useMemo } from "react"; +import RowActions from "./RowActions"; +import { GET_GENERAL_MANAGER_LIST } from "@/core/utils/routes"; +import ShowPrimaryArea from "./ShowPrimaryArea"; + +const GeneralManagerList = () => { + const stateIcon = (state_id) => { + if (state_id === 1) return ; + if (state_id === 2 || state_id === 5 || state_id === 13) return ; + if (state_id === 3 || state_id === 6 || state_id === 14) + return ; + if (state_id === 4 || state_id === 7 || state_id === 15) return ; + if (state_id === 8) return ; + if (state_id === 9 || state_id === 11) return ; + if (state_id === 10) return ; + if (state_id === 12) return ; + }; + const columns = useMemo(() => { + return [ + { + accessorKey: "panjare_vahed_id", + header: "کدرهگیری درخواست", + id: "panjare_vahed_id", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ row }) => <>{row.original.panjare_vahed_id}, + }, + { + accessorKey: "national_id", + header: "کد ملی", + id: "national_id", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ row }) => <>{row.original.national_id}, + }, + { + accessorKey: "state_id", + header: "وضعیت", + id: "state_id", + enableColumnFilter: true, + datatype: "numeric", + filterMode: "equals", + sortDescFirst: false, + grow: false, + size: 100, + ColumnSelectComponent: (props) => { + const { itemsList, loadingItemsList, errorItemsList } = useInquiryPrivacyState(); + + const getColumnSelectOptions = useMemo(() => { + if (loadingItemsList) { + return [{ value: "loading", label: "در حال بارگذاری..." }]; + } + if (errorItemsList) { + return [{ value: "error", label: "خطا در بارگذاری" }]; + } + return [ + { value: "", label: "همه موارد" }, + ...itemsList.map((item) => ({ + value: item.id, + label: item.name, + })), + ]; + }, [itemsList, loadingItemsList, errorItemsList]); + + return ( + + ); + }, + Cell: ({ row }) => ( + + {stateIcon(row.original.state_id)} + + {row.original.state_name} + + + ), + }, + { + accessorKey: "plan_title", + header: "عنوان طرح", + id: "plan_title", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ row }) => <>{row.original.plan_title}, + }, + { + accessorKey: "plan_group", + header: "گروه طرح", + id: "plan_group", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ row }) => <>{row.original.plan_group}, + }, + { + accessorKey: "requested_organization", + header: "دستگاه صادر کننده", + id: "requested_organization", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ row }) => <>{row.original.requested_organization}, + }, + { + accessorKey: "worksheet_id", + header: "شناسه کاربرگ", + id: "worksheet_id", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ row }) => <>{row.original.worksheet_id}, + }, + { + accessorKey: "primary_area", + header: "نمایش محدوده طرح", + id: "primary_area", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ row }) => + row.original.primary_area ? ( + + + + ) : ( + "-" + ), + }, + { + accessorKey: "province_id", + header: "استان", + id: "province_id", + enableColumnFilter: false, + datatype: "numeric", + sortDescFirst: false, + grow: false, + size: 100, + Cell: ({ row }) => <>{row.original.province_name}, + }, + { + accessorKey: "city_id", + header: "شهر", + id: "city_id", + enableColumnFilter: false, + datatype: "numeric", + sortDescFirst: false, + grow: false, + size: 100, + Cell: ({ row }) => <>{row.original.city_name}, + }, + { + accessorKey: "isic", + header: "کد آیسیک", + id: "isic", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ row }) => <>{row.original.isic}, + }, + { + accessorFn: (row) => moment(row.request_date).locale("fa").format("YYYY/MM/DD"), + header: "تاریخ درخواست", + id: "request_date", + enableColumnFilter: true, + datatype: "date", + filterMode: "between", + grow: false, + size: 100, + }, + ]; + }, []); + + return ( + <> + + + + + ); +}; + +export default GeneralManagerList; diff --git a/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/ConfirmAction/index.jsx b/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/ConfirmAction/index.jsx index c2a0cfc..16163c1 100644 --- a/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/ConfirmAction/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/ConfirmAction/index.jsx @@ -1,17 +1,17 @@ -import ThumbUpIcon from "@mui/icons-material/ThumbUp"; -import { IconButton, Tooltip } from "@mui/material"; -import { useState } from "react"; - -const ConfirmAction = ({ rowId, mutate }) => { - const [openConfirmDialog, setOpenConfirmDialog] = useState(false); - return ( - <> - - setOpenConfirmDialog(true)}> - - - - - ); -}; -export default ConfirmAction; +import ThumbUpIcon from "@mui/icons-material/ThumbUp"; +import { IconButton, Tooltip } from "@mui/material"; +import { useState } from "react"; + +const ConfirmAction = ({ rowId, mutate }) => { + const [openConfirmDialog, setOpenConfirmDialog] = useState(false); + return ( + <> + + setOpenConfirmDialog(true)}> + + + + + ); +}; +export default ConfirmAction; diff --git a/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/History/HistoryContent.jsx b/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/History/HistoryContent.jsx index 71f59c1..76fcbf0 100644 --- a/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/History/HistoryContent.jsx +++ b/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/History/HistoryContent.jsx @@ -1,17 +1,17 @@ -import { Button, DialogActions, DialogContent } from "@mui/material"; -import TableContent from "./TableContent"; -const HistoryContent = ({ setOpenReferReasonDialog, rowId }) => { - return ( - <> - - - - - - - - ); -}; -export default HistoryContent; +import { Button, DialogActions, DialogContent } from "@mui/material"; +import TableContent from "./TableContent"; +const HistoryContent = ({ setOpenReferReasonDialog, rowId }) => { + return ( + <> + + + + + + + + ); +}; +export default HistoryContent; diff --git a/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/History/TableContent.jsx b/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/History/TableContent.jsx index b405a41..be6e82b 100644 --- a/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/History/TableContent.jsx +++ b/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/History/TableContent.jsx @@ -1,66 +1,66 @@ -import { - Box, - Table, - TableBody, - TableCell, - TableContainer, - TableHead, - TableRow, - CircularProgress, - Typography, -} from "@mui/material"; -import "moment/locale/fa"; -import { useHistory } from "@/lib/hooks/useHistory"; - -const TableContent = ({ rowId }) => { - const { historyData, loading, error } = useHistory(rowId); - - if (loading) { - return ( - - - - ); - } - - if (error) { - return ( - - {error} - - ); - } - - if (!historyData.length) { - return ( - - اطلاعاتی وجود ندارد - - ); - } - - return ( - - - - - - وضعیت - توضیحات کارشناس - - - - {historyData.map((row) => ( - - {row.previous_state_name} - {row.expert_description} - - ))} - -
-
-
- ); -}; - -export default TableContent; +import { + Box, + Table, + TableBody, + TableCell, + TableContainer, + TableHead, + TableRow, + CircularProgress, + Typography, +} from "@mui/material"; +import "moment/locale/fa"; +import { useHistory } from "@/lib/hooks/useHistory"; + +const TableContent = ({ rowId }) => { + const { historyData, loading, error } = useHistory(rowId); + + if (loading) { + return ( + + + + ); + } + + if (error) { + return ( + + {error} + + ); + } + + if (!historyData.length) { + return ( + + اطلاعاتی وجود ندارد + + ); + } + + return ( + + + + + + وضعیت + توضیحات کارشناس + + + + {historyData.map((row) => ( + + {row.previous_state_name} + {row.expert_description} + + ))} + +
+
+
+ ); +}; + +export default TableContent; diff --git a/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/History/index.jsx b/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/History/index.jsx index 234ac15..cc3df74 100644 --- a/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/History/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/History/index.jsx @@ -1,33 +1,33 @@ -import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; -import { RestorePage } from "@mui/icons-material"; -import HistoryContent from "./HistoryContent"; -import { useState } from "react"; - -const History = ({ rowId }) => { - const [openReferReasonDialog, setOpenReferReasonDialog] = useState(false); - - return ( - <> - - setOpenReferReasonDialog(true)}> - - - - - تاریخچه - - - - ); -}; - -export default History; +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { RestorePage } from "@mui/icons-material"; +import HistoryContent from "./HistoryContent"; +import { useState } from "react"; + +const History = ({ rowId }) => { + const [openReferReasonDialog, setOpenReferReasonDialog] = useState(false); + + return ( + <> + + setOpenReferReasonDialog(true)}> + + + + + تاریخچه + + + + ); +}; + +export default History; diff --git a/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/RejectAction/index.jsx b/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/RejectAction/index.jsx index c16a405..9075e0b 100644 --- a/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/RejectAction/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/RejectAction/index.jsx @@ -1,17 +1,17 @@ -import ThumbDownIcon from "@mui/icons-material/ThumbDown"; -import { IconButton, Tooltip } from "@mui/material"; -import { useState } from "react"; - -const RejectAction = ({ rowId, mutate }) => { - const [openRejectDialog, setOpenRejectDialog] = useState(false); - return ( - <> - - setOpenRejectDialog(true)}> - - - - - ); -}; -export default RejectAction; +import ThumbDownIcon from "@mui/icons-material/ThumbDown"; +import { IconButton, Tooltip } from "@mui/material"; +import { useState } from "react"; + +const RejectAction = ({ rowId, mutate }) => { + const [openRejectDialog, setOpenRejectDialog] = useState(false); + return ( + <> + + setOpenRejectDialog(true)}> + + + + + ); +}; +export default RejectAction; diff --git a/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/index.jsx b/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/index.jsx index 1251678..255dad3 100644 --- a/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/index.jsx @@ -1,22 +1,22 @@ -import { Box } from "@mui/material"; -import ConfirmAction from "./ConfirmAction"; -import RejectAction from "./RejectAction"; -import History from "./History"; - -const RowActions = ({ row, mutate }) => { - // const stateId = row.original.state_id; - // - // const disabled = { - // referral: stateId !== 2, - // reject: stateId !== 2 && stateId !== 5, - // confirm: stateId !== 2 && stateId !== 5 && stateId !== 13, - // }; - return ( - - - - - - ); -}; -export default RowActions; +import { Box } from "@mui/material"; +import ConfirmAction from "./ConfirmAction"; +import RejectAction from "./RejectAction"; +import History from "./History"; + +const RowActions = ({ row, mutate }) => { + // const stateId = row.original.state_id; + // + // const disabled = { + // referral: stateId !== 2, + // reject: stateId !== 2 && stateId !== 5, + // confirm: stateId !== 2 && stateId !== 5 && stateId !== 13, + // }; + return ( + + + + + + ); +}; +export default RowActions; diff --git a/src/components/dashboard/inquiryPrivacy/general-manager/ShowPrimaryArea/ShowBound.jsx b/src/components/dashboard/inquiryPrivacy/general-manager/ShowPrimaryArea/ShowBound.jsx index 24db476..43dd0b8 100644 --- a/src/components/dashboard/inquiryPrivacy/general-manager/ShowPrimaryArea/ShowBound.jsx +++ b/src/components/dashboard/inquiryPrivacy/general-manager/ShowPrimaryArea/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/dashboard/inquiryPrivacy/general-manager/ShowPrimaryArea/index.jsx b/src/components/dashboard/inquiryPrivacy/general-manager/ShowPrimaryArea/index.jsx index 98e24d0..fe638ad 100644 --- a/src/components/dashboard/inquiryPrivacy/general-manager/ShowPrimaryArea/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/general-manager/ShowPrimaryArea/index.jsx @@ -1,69 +1,69 @@ -const { - Button, - IconButton, - Tooltip, - Box, - Dialog, - DialogTitle, - Typography, - DialogContent, - DialogActions, -} = require("@mui/material"); -import LayersIcon from "@mui/icons-material/Layers"; -import CloseIcon from "@mui/icons-material/Close"; -import { useMemo, useState } from "react"; -import MapLayer from "@/core/components/MapLayer"; -import ShowBound from "./ShowBound"; - -const ShowPrimaryArea = ({ primaryArea }) => { - const [openShowAreaDialog, setOpenShowAreaDialog] = useState(false); - const bound = useMemo(() => { - const latLngCoords = primaryArea.coordinates.map((coord) => [coord[1], coord[0]]); - return primaryArea.type === "polygon" ? L.polygon(latLngCoords) : L.polyline(latLngCoords); - }, [primaryArea]); - - return ( - - - setOpenShowAreaDialog(true)}> - - - - setOpenShowAreaDialog(false)} - PaperProps={{ - sx: { - transition: "all .3s", - boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px", - borderRadius: 2, - padding: 1, - }, - }} - maxWidth="sm" - fullWidth - dir="rtl" - > - - - محدوده طرح - - setOpenShowAreaDialog(false)} size="small"> - - - - - - - - - - - - - - - ); -}; - -export default ShowPrimaryArea; +const { + Button, + IconButton, + Tooltip, + Box, + Dialog, + DialogTitle, + Typography, + DialogContent, + DialogActions, +} = require("@mui/material"); +import LayersIcon from "@mui/icons-material/Layers"; +import CloseIcon from "@mui/icons-material/Close"; +import { useMemo, useState } from "react"; +import MapLayer from "@/core/components/MapLayer"; +import ShowBound from "./ShowBound"; + +const ShowPrimaryArea = ({ primaryArea }) => { + const [openShowAreaDialog, setOpenShowAreaDialog] = useState(false); + const bound = useMemo(() => { + const latLngCoords = primaryArea.coordinates.map((coord) => [coord[1], coord[0]]); + return primaryArea.type === "polygon" ? L.polygon(latLngCoords) : L.polyline(latLngCoords); + }, [primaryArea]); + + return ( + + + setOpenShowAreaDialog(true)}> + + + + setOpenShowAreaDialog(false)} + PaperProps={{ + sx: { + transition: "all .3s", + boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px", + borderRadius: 2, + padding: 1, + }, + }} + maxWidth="sm" + fullWidth + dir="rtl" + > + + + محدوده طرح + + setOpenShowAreaDialog(false)} size="small"> + + + + + + + + + + + + + + + ); +}; + +export default ShowPrimaryArea; diff --git a/src/components/dashboard/inquiryPrivacy/general-manager/index.jsx b/src/components/dashboard/inquiryPrivacy/general-manager/index.jsx index 3e166e3..fbc3152 100644 --- a/src/components/dashboard/inquiryPrivacy/general-manager/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/general-manager/index.jsx @@ -1,14 +1,14 @@ -"use client"; -import PageTitle from "@/core/components/PageTitle"; -import { Stack } from "@mui/material"; -import GeneralManagerList from "./GeneralManagerList"; - -const GeneralManagerPage = () => { - return ( - - - - - ); -}; -export default GeneralManagerPage; +"use client"; +import PageTitle from "@/core/components/PageTitle"; +import { Stack } from "@mui/material"; +import GeneralManagerList from "./GeneralManagerList"; + +const GeneralManagerPage = () => { + return ( + + + + + ); +}; +export default GeneralManagerPage; diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/PrivacyOfficeList.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/PrivacyOfficeList.jsx index 487c46d..c734b07 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/PrivacyOfficeList.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/PrivacyOfficeList.jsx @@ -1,248 +1,248 @@ -import CustomSelectByDependency from "@/core/components/DataTable/filter/fieldsType/CustomSelectByDependency"; -import DataTableWithAuth from "@/core/components/DataTableWithAuth"; -import { GET_PRIVACY_ADMIN_LIST } from "@/core/utils/routes"; -import useInquiryPrivacyState from "@/lib/hooks/useInquiryPrivacyState"; -import AutorenewIcon from "@mui/icons-material/Autorenew"; -import DangerousIcon from "@mui/icons-material/Dangerous"; -import ManageAccountsIcon from "@mui/icons-material/ManageAccounts"; -import MapsHomeWorkIcon from "@mui/icons-material/MapsHomeWork"; -import PsychologyAltIcon from "@mui/icons-material/PsychologyAlt"; -import ReceiptLongIcon from "@mui/icons-material/ReceiptLong"; -import SecurityIcon from "@mui/icons-material/Security"; -import WindowIcon from "@mui/icons-material/Window"; -import { Box, Stack } from "@mui/material"; -import moment from "jalali-moment"; -import { useMemo } from "react"; -import RowActions from "./RowActions"; - -import ShowPrimaryArea from "./ShowPrimaryArea"; - -const PrivacyOfficeList = () => { - const stateIcon = (state_id) => { - if (state_id === 1) return ; - if (state_id === 2 || state_id === 5 || state_id === 13) return ; - if (state_id === 3 || state_id === 6 || state_id === 14) - return ; - if (state_id === 4 || state_id === 7 || state_id === 15) return ; - if (state_id === 8) return ; - if (state_id === 9 || state_id === 11) return ; - if (state_id === 10) return ; - if (state_id === 12) return ; - }; - - const columns = useMemo(() => { - return [ - { - accessorKey: "panjare_vahed_id", - header: "کدرهگیری درخواست", - id: "panjare_vahed_id", - enableColumnFilter: true, - datatype: "text", - filterMode: "equals", - sortDescFirst: false, - columnFilterModeOptions: ["equals", "contains"], - grow: false, - size: 100, - Cell: ({ row }) => <>{row.original.panjare_vahed_id}, - }, - { - accessorKey: "national_id", - header: "کد ملی", - id: "national_id", - enableColumnFilter: true, - datatype: "text", - filterMode: "equals", - sortDescFirst: false, - columnFilterModeOptions: ["equals", "contains"], - grow: false, - size: 100, - Cell: ({ row }) => <>{row.original.national_id}, - }, - { - accessorKey: "state_id", - header: "وضعیت", - id: "state_id", - enableColumnFilter: true, - datatype: "numeric", - filterMode: "equals", - sortDescFirst: false, - grow: false, - size: 100, - ColumnSelectComponent: (props) => { - const { itemsList, loadingItemsList, errorItemsList } = useInquiryPrivacyState(); - - const getColumnSelectOptions = useMemo(() => { - if (loadingItemsList) { - return [{ value: "loading", label: "در حال بارگذاری..." }]; - } - if (errorItemsList) { - return [{ value: "error", label: "خطا در بارگذاری" }]; - } - return [ - { value: "", label: "همه موارد" }, - ...itemsList.map((item) => ({ - value: item.id, - label: item.name, - })), - ]; - }, [itemsList, loadingItemsList, errorItemsList]); - - return ( - - ); - }, - Cell: ({ row }) => ( - - {stateIcon(row.original.state_id)} - - {row.original.state_name} - - - ), - }, - { - accessorKey: "plan_title", - header: "عنوان طرح", - id: "plan_title", - enableColumnFilter: true, - datatype: "text", - filterMode: "equals", - sortDescFirst: false, - columnFilterModeOptions: ["equals", "contains"], - grow: false, - size: 100, - Cell: ({ row }) => <>{row.original.plan_title}, - }, - { - accessorKey: "plan_group", - header: "گروه طرح", - id: "plan_group", - enableColumnFilter: true, - datatype: "text", - filterMode: "equals", - sortDescFirst: false, - columnFilterModeOptions: ["equals", "contains"], - grow: false, - size: 100, - Cell: ({ row }) => <>{row.original.plan_group}, - }, - { - accessorKey: "requested_organization", - header: "دستگاه صادر کننده", - id: "requested_organization", - enableColumnFilter: true, - datatype: "text", - filterMode: "equals", - sortDescFirst: false, - columnFilterModeOptions: ["equals", "contains"], - grow: false, - size: 100, - Cell: ({ row }) => <>{row.original.requested_organization}, - }, - { - accessorKey: "worksheet_id", - header: "شناسه کاربرگ", - id: "worksheet_id", - enableColumnFilter: true, - datatype: "text", - filterMode: "equals", - sortDescFirst: false, - columnFilterModeOptions: ["equals", "contains"], - grow: false, - size: 100, - Cell: ({ row }) => <>{row.original.worksheet_id}, - }, - { - accessorKey: "primary_area", - header: "نمایش محدوده طرح", - id: "primary_area", - enableColumnFilter: true, - datatype: "text", - filterMode: "equals", - sortDescFirst: false, - columnFilterModeOptions: ["equals", "contains"], - grow: false, - size: 100, - Cell: ({ row }) => - row.original.primary_area && row.original.forbidden_area ? ( - - - - ) : ( - "-" - ), - }, - { - accessorKey: "province_id", - header: "استان", - id: "province_id", - enableColumnFilter: false, - datatype: "numeric", - sortDescFirst: false, - grow: false, - size: 100, - Cell: ({ row }) => <>{row.original.province_name}, - }, - { - accessorKey: "city_id", - header: "شهر", - id: "city_id", - enableColumnFilter: false, - datatype: "numeric", - sortDescFirst: false, - grow: false, - size: 100, - Cell: ({ row }) => <>{row.original.city_name}, - }, - { - accessorKey: "isic", - header: "کد آیسیک", - id: "isic", - enableColumnFilter: true, - datatype: "text", - filterMode: "equals", - sortDescFirst: false, - columnFilterModeOptions: ["equals", "contains"], - grow: false, - size: 100, - Cell: ({ row }) => <>{row.original.isic}, - }, - { - accessorFn: (row) => moment(row.request_date).locale("fa").format("YYYY/MM/DD"), - header: "تاریخ درخواست", - id: "request_date", - enableColumnFilter: true, - datatype: "date", - filterMode: "between", - grow: false, - size: 100, - }, - ]; - }, []); - - return ( - <> - - - - - ); -}; - -export default PrivacyOfficeList; +import CustomSelectByDependency from "@/core/components/DataTable/filter/fieldsType/CustomSelectByDependency"; +import DataTableWithAuth from "@/core/components/DataTableWithAuth"; +import { GET_PRIVACY_ADMIN_LIST } from "@/core/utils/routes"; +import useInquiryPrivacyState from "@/lib/hooks/useInquiryPrivacyState"; +import AutorenewIcon from "@mui/icons-material/Autorenew"; +import DangerousIcon from "@mui/icons-material/Dangerous"; +import ManageAccountsIcon from "@mui/icons-material/ManageAccounts"; +import MapsHomeWorkIcon from "@mui/icons-material/MapsHomeWork"; +import PsychologyAltIcon from "@mui/icons-material/PsychologyAlt"; +import ReceiptLongIcon from "@mui/icons-material/ReceiptLong"; +import SecurityIcon from "@mui/icons-material/Security"; +import WindowIcon from "@mui/icons-material/Window"; +import { Box, Stack } from "@mui/material"; +import moment from "jalali-moment"; +import { useMemo } from "react"; +import RowActions from "./RowActions"; + +import ShowPrimaryArea from "./ShowPrimaryArea"; + +const PrivacyOfficeList = () => { + const stateIcon = (state_id) => { + if (state_id === 1) return ; + if (state_id === 2 || state_id === 5 || state_id === 13) return ; + if (state_id === 3 || state_id === 6 || state_id === 14) + return ; + if (state_id === 4 || state_id === 7 || state_id === 15) return ; + if (state_id === 8) return ; + if (state_id === 9 || state_id === 11) return ; + if (state_id === 10) return ; + if (state_id === 12) return ; + }; + + const columns = useMemo(() => { + return [ + { + accessorKey: "panjare_vahed_id", + header: "کدرهگیری درخواست", + id: "panjare_vahed_id", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ row }) => <>{row.original.panjare_vahed_id}, + }, + { + accessorKey: "national_id", + header: "کد ملی", + id: "national_id", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ row }) => <>{row.original.national_id}, + }, + { + accessorKey: "state_id", + header: "وضعیت", + id: "state_id", + enableColumnFilter: true, + datatype: "numeric", + filterMode: "equals", + sortDescFirst: false, + grow: false, + size: 100, + ColumnSelectComponent: (props) => { + const { itemsList, loadingItemsList, errorItemsList } = useInquiryPrivacyState(); + + const getColumnSelectOptions = useMemo(() => { + if (loadingItemsList) { + return [{ value: "loading", label: "در حال بارگذاری..." }]; + } + if (errorItemsList) { + return [{ value: "error", label: "خطا در بارگذاری" }]; + } + return [ + { value: "", label: "همه موارد" }, + ...itemsList.map((item) => ({ + value: item.id, + label: item.name, + })), + ]; + }, [itemsList, loadingItemsList, errorItemsList]); + + return ( + + ); + }, + Cell: ({ row }) => ( + + {stateIcon(row.original.state_id)} + + {row.original.state_name} + + + ), + }, + { + accessorKey: "plan_title", + header: "عنوان طرح", + id: "plan_title", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ row }) => <>{row.original.plan_title}, + }, + { + accessorKey: "plan_group", + header: "گروه طرح", + id: "plan_group", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ row }) => <>{row.original.plan_group}, + }, + { + accessorKey: "requested_organization", + header: "دستگاه صادر کننده", + id: "requested_organization", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ row }) => <>{row.original.requested_organization}, + }, + { + accessorKey: "worksheet_id", + header: "شناسه کاربرگ", + id: "worksheet_id", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ row }) => <>{row.original.worksheet_id}, + }, + { + accessorKey: "primary_area", + header: "نمایش محدوده طرح", + id: "primary_area", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ row }) => + row.original.primary_area && row.original.forbidden_area ? ( + + + + ) : ( + "-" + ), + }, + { + accessorKey: "province_id", + header: "استان", + id: "province_id", + enableColumnFilter: false, + datatype: "numeric", + sortDescFirst: false, + grow: false, + size: 100, + Cell: ({ row }) => <>{row.original.province_name}, + }, + { + accessorKey: "city_id", + header: "شهر", + id: "city_id", + enableColumnFilter: false, + datatype: "numeric", + sortDescFirst: false, + grow: false, + size: 100, + Cell: ({ row }) => <>{row.original.city_name}, + }, + { + accessorKey: "isic", + header: "کد آیسیک", + id: "isic", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ row }) => <>{row.original.isic}, + }, + { + accessorFn: (row) => moment(row.request_date).locale("fa").format("YYYY/MM/DD"), + header: "تاریخ درخواست", + id: "request_date", + enableColumnFilter: true, + datatype: "date", + filterMode: "between", + grow: false, + size: 100, + }, + ]; + }, []); + + return ( + <> + + + + + ); +}; + +export default PrivacyOfficeList; diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ActionsDialog.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ActionsDialog.jsx index 75fe025..bb5d2e1 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ActionsDialog.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ActionsDialog.jsx @@ -1,20 +1,20 @@ -import { Dialog, DialogTitle } from "@mui/material"; -import RenderActionForm from "./RenderActionForm"; - -const ActionDialog = ({ open, type, rowData, onClose, mutate }) => { - const actionLabel = { - reject_request: "رد درخواست", - confirm_request: "تایید درخواست", - refer_request: "ارجاع درخواست", - }[type]; - - return ( - - {actionLabel} - - - - ); -}; - -export default ActionDialog; +import { Dialog, DialogTitle } from "@mui/material"; +import RenderActionForm from "./RenderActionForm"; + +const ActionDialog = ({ open, type, rowData, onClose, mutate }) => { + const actionLabel = { + reject_request: "رد درخواست", + confirm_request: "تایید درخواست", + refer_request: "ارجاع درخواست", + }[type]; + + return ( + + {actionLabel} + + + + ); +}; + +export default ActionDialog; diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ConfirmAction/index.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ConfirmAction/index.jsx index 230e4c7..8d7f4d3 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ConfirmAction/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ConfirmAction/index.jsx @@ -1,18 +1,18 @@ -import ThumbUpIcon from "@mui/icons-material/ThumbUp"; -import { IconButton, Tooltip } from "@mui/material"; - -const ConfirmAction = ({ onClick, disabled }) => { - if (disabled) return; - return ( - <> - - - - - - - - - ); -}; -export default ConfirmAction; +import ThumbUpIcon from "@mui/icons-material/ThumbUp"; +import { IconButton, Tooltip } from "@mui/material"; + +const ConfirmAction = ({ onClick, disabled }) => { + if (disabled) return; + return ( + <> + + + + + + + + + ); +}; +export default ConfirmAction; diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ComputePaymentForm.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ComputePaymentForm.jsx index 0df367b..8459360 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ComputePaymentForm.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ComputePaymentForm.jsx @@ -1,228 +1,228 @@ -import { calculatePolygonMetrics } from "@/core/utils/geoCalculations"; -import { PRIVACY_ADMIN_ACTION_API } from "@/core/utils/routes"; -import { safeParsePolygon } from "@/core/utils/utils"; -import useRequest from "@/lib/hooks/useRequest"; -import { - Box, - Button, - DialogActions, - FormControl, - FormHelperText, - InputLabel, - MenuItem, - Select, - TextField, -} from "@mui/material"; -import { useEffect, useState } from "react"; -import { Controller, useForm, useWatch } from "react-hook-form"; - -const formatNumber = (num) => { - if (!num) return ""; - return Number(num).toLocaleString("en-US"); -}; - -const price_fee = 1; // TODO: Replace with real price_fee -export default function ComputePaymentForm({ mutate, onClose, rowData }) { - const [isSubmitting, setIsSubmitting] = useState(false); - const request = useRequest({ notificationSuccess: true, notificationFailed: true }); - - const coordsArea = safeParsePolygon(rowData.final_area); - const coordsPlan = safeParsePolygon(rowData.final_plan); - - const areaMetrics = coordsArea ? calculatePolygonMetrics(coordsArea) : { area: 0 }; - const planMetrics = coordsPlan ? calculatePolygonMetrics(coordsPlan) : { area: 0 }; - - const calculatedArea = Number(areaMetrics.area.toFixed(2) || 0); - const calculatedPlan = Number(planMetrics.area.toFixed(2) || 0); - - const { - control, - handleSubmit, - setValue, - formState: { errors }, - } = useForm({ - defaultValues: { - expert_description: "", - traffic: "", - road_type: "", - position: "", - final_area_space: calculatedArea, // عرصه - final_plan_space: calculatedPlan, // عیان - payment_amount: "", - }, - }); - - const { traffic, road_type, position } = useWatch({ - control, - }); - - useEffect(() => { - const hasGeometry = calculatedArea > 0 || calculatedPlan > 0; - - const t = parseFloat(traffic || ""); - const r = parseFloat(road_type || ""); - const p = parseFloat(position || ""); - - const inputsValid = hasGeometry && !isNaN(t) && t > 0 && !isNaN(r) && r > 0 && !isNaN(p) && p > 0; - - if (inputsValid) { - const resultArea = t * r * p * calculatedArea * price_fee; - const resultPlan = t * r * p * calculatedPlan * price_fee; - - setValue("payment_amount", Math.floor(resultArea + resultPlan).toString()); - } else { - setValue("payment_amount", ""); - } - }, [traffic, road_type, position, setValue, calculatedArea, calculatedPlan]); - - const onSubmit = (data) => { - setIsSubmitting(true); - - try { - request(`${PRIVACY_ADMIN_ACTION_API}/computing_payment/${rowData.id}`, "post", { - data, - }).then(() => { - onClose(); - mutate(); - }); - } catch (error) { - console.error("Error submitting payment:", error); - } finally { - setIsSubmitting(false); - } - }; - - return ( - - - ( - - ترافیک - - {errors.traffic && ( - {errors.traffic.message} - )} - - )} - /> - - ( - - نوع راه - - {errors.road_type && ( - {errors.road_type.message} - )} - - )} - /> - - - ( - - موقعیت اقتصادی - - {errors.position && ( - {errors.position.message} - )} - - )} - /> - - - ( - - )} - /> - ( - - )} - /> - - - { - const { value } = field; - - return ( - - ); - }} - /> - - ( - - )} - /> - - - - - - - ); -} +import { calculatePolygonMetrics } from "@/core/utils/geoCalculations"; +import { PRIVACY_ADMIN_ACTION_API } from "@/core/utils/routes"; +import { safeParsePolygon } from "@/core/utils/utils"; +import useRequest from "@/lib/hooks/useRequest"; +import { + Box, + Button, + DialogActions, + FormControl, + FormHelperText, + InputLabel, + MenuItem, + Select, + TextField, +} from "@mui/material"; +import { useEffect, useState } from "react"; +import { Controller, useForm, useWatch } from "react-hook-form"; + +const formatNumber = (num) => { + if (!num) return ""; + return Number(num).toLocaleString("en-US"); +}; + +const price_fee = 1; // TODO: Replace with real price_fee +export default function ComputePaymentForm({ mutate, onClose, rowData }) { + const [isSubmitting, setIsSubmitting] = useState(false); + const request = useRequest({ notificationSuccess: true, notificationFailed: true }); + + const coordsArea = safeParsePolygon(rowData.final_area); + const coordsPlan = safeParsePolygon(rowData.final_plan); + + const areaMetrics = coordsArea ? calculatePolygonMetrics(coordsArea) : { area: 0 }; + const planMetrics = coordsPlan ? calculatePolygonMetrics(coordsPlan) : { area: 0 }; + + const calculatedArea = Number(areaMetrics.area.toFixed(2) || 0); + const calculatedPlan = Number(planMetrics.area.toFixed(2) || 0); + + const { + control, + handleSubmit, + setValue, + formState: { errors }, + } = useForm({ + defaultValues: { + expert_description: "", + traffic: "", + road_type: "", + position: "", + final_area_space: calculatedArea, // عرصه + final_plan_space: calculatedPlan, // عیان + payment_amount: "", + }, + }); + + const { traffic, road_type, position } = useWatch({ + control, + }); + + useEffect(() => { + const hasGeometry = calculatedArea > 0 || calculatedPlan > 0; + + const t = parseFloat(traffic || ""); + const r = parseFloat(road_type || ""); + const p = parseFloat(position || ""); + + const inputsValid = hasGeometry && !isNaN(t) && t > 0 && !isNaN(r) && r > 0 && !isNaN(p) && p > 0; + + if (inputsValid) { + const resultArea = t * r * p * calculatedArea * price_fee; + const resultPlan = t * r * p * calculatedPlan * price_fee; + + setValue("payment_amount", Math.floor(resultArea + resultPlan).toString()); + } else { + setValue("payment_amount", ""); + } + }, [traffic, road_type, position, setValue, calculatedArea, calculatedPlan]); + + const onSubmit = (data) => { + setIsSubmitting(true); + + try { + request(`${PRIVACY_ADMIN_ACTION_API}/computing_payment/${rowData.id}`, "post", { + data, + }).then(() => { + onClose(); + mutate(); + }); + } catch (error) { + console.error("Error submitting payment:", error); + } finally { + setIsSubmitting(false); + } + }; + + return ( + + + ( + + ترافیک + + {errors.traffic && ( + {errors.traffic.message} + )} + + )} + /> + + ( + + نوع راه + + {errors.road_type && ( + {errors.road_type.message} + )} + + )} + /> + + + ( + + موقعیت اقتصادی + + {errors.position && ( + {errors.position.message} + )} + + )} + /> + + + ( + + )} + /> + ( + + )} + /> + + + { + const { value } = field; + + return ( + + ); + }} + /> + + ( + + )} + /> + + + + + + + ); +} diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ConfirmFileForm.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ConfirmFileForm.jsx index 80bda88..f0d775f 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ConfirmFileForm.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ConfirmFileForm.jsx @@ -1,69 +1,69 @@ -import { PRIVACY_ADMIN_ACTION_API } from "@/core/utils/routes"; -import useRequest from "@/lib/hooks/useRequest"; -import { Box, Button, DialogActions, TextField } from "@mui/material"; -import { useState } from "react"; -import { Controller, useForm } from "react-hook-form"; - -export default function ConfirmFileForm({ mutate, onClose, rowId }) { - const [isSubmitting, setIsSubmitting] = useState(false); - const request = useRequest({ notificationSuccess: true, notificationFailed: true }); - - const { - control, - handleSubmit, - formState: { errors }, - } = useForm({ - defaultValues: { - expert_description: "", - }, - }); - - const onSubmit = (data) => { - setIsSubmitting(true); - - try { - request(`${PRIVACY_ADMIN_ACTION_API}/file_accepted/${rowId}`, "post", { - data, - }).then(() => { - onClose(); - mutate(); - }); - } catch (err) { - console.log(err); - } finally { - setIsSubmitting(false); - } - }; - - return ( - - ( - - )} - /> - - - - - - - ); -} +import { PRIVACY_ADMIN_ACTION_API } from "@/core/utils/routes"; +import useRequest from "@/lib/hooks/useRequest"; +import { Box, Button, DialogActions, TextField } from "@mui/material"; +import { useState } from "react"; +import { Controller, useForm } from "react-hook-form"; + +export default function ConfirmFileForm({ mutate, onClose, rowId }) { + const [isSubmitting, setIsSubmitting] = useState(false); + const request = useRequest({ notificationSuccess: true, notificationFailed: true }); + + const { + control, + handleSubmit, + formState: { errors }, + } = useForm({ + defaultValues: { + expert_description: "", + }, + }); + + const onSubmit = (data) => { + setIsSubmitting(true); + + try { + request(`${PRIVACY_ADMIN_ACTION_API}/file_accepted/${rowId}`, "post", { + data, + }).then(() => { + onClose(); + mutate(); + }); + } catch (err) { + console.log(err); + } finally { + setIsSubmitting(false); + } + }; + + return ( + + ( + + )} + /> + + + + + + + ); +} diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ConfirmRequestForm.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ConfirmRequestForm.jsx index fdfabd7..f2b9f1f 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ConfirmRequestForm.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ConfirmRequestForm.jsx @@ -1,96 +1,96 @@ -import { PRIVACY_ADMIN_ACTION_API } from "@/core/utils/routes"; -import useRequest from "@/lib/hooks/useRequest"; -import { Box, Button, Checkbox, DialogActions, FormControlLabel, TextField } from "@mui/material"; -import { useState } from "react"; -import { Controller, useForm } from "react-hook-form"; - -export default function ConfirmRequestForm({ mutate, onClose, rowId }) { - const [isSubmitting, setIsSubmitting] = useState(false); - const request = useRequest({ notificationSuccess: true, notificationFailed: true }); - - const { - control, - handleSubmit, - formState: { errors }, - } = useForm({ - defaultValues: { - expert_description: "", - need_payment: false, - needsAccessRoad: false, - }, - }); - - const onSubmit = (data) => { - const confirmType = data.needsAccessRoad ? "need_road_access" : "without_road_access"; - const url = `${PRIVACY_ADMIN_ACTION_API}/${confirmType}/${rowId}`; - const body = { - expert_description: data.expert_description, - need_payment: data.need_payment ? 1 : 0, - }; - - setIsSubmitting(true); - try { - request(url, "post", { - data: body, - }).then(() => { - mutate(); - onClose(); - }); - } catch (error) { - } finally { - setIsSubmitting(false); - } - }; - - return ( - - ( - - )} - /> - - ( - } - label="نیاز به پرداخت وجه خزانه" - /> - )} - /> - - ( - } - label="نیاز به راه دسترسی" - /> - )} - /> - - - - - - - ); -} +import { PRIVACY_ADMIN_ACTION_API } from "@/core/utils/routes"; +import useRequest from "@/lib/hooks/useRequest"; +import { Box, Button, Checkbox, DialogActions, FormControlLabel, TextField } from "@mui/material"; +import { useState } from "react"; +import { Controller, useForm } from "react-hook-form"; + +export default function ConfirmRequestForm({ mutate, onClose, rowId }) { + const [isSubmitting, setIsSubmitting] = useState(false); + const request = useRequest({ notificationSuccess: true, notificationFailed: true }); + + const { + control, + handleSubmit, + formState: { errors }, + } = useForm({ + defaultValues: { + expert_description: "", + need_payment: false, + needsAccessRoad: false, + }, + }); + + const onSubmit = (data) => { + const confirmType = data.needsAccessRoad ? "need_road_access" : "without_road_access"; + const url = `${PRIVACY_ADMIN_ACTION_API}/${confirmType}/${rowId}`; + const body = { + expert_description: data.expert_description, + need_payment: data.need_payment ? 1 : 0, + }; + + setIsSubmitting(true); + try { + request(url, "post", { + data: body, + }).then(() => { + mutate(); + onClose(); + }); + } catch (error) { + } finally { + setIsSubmitting(false); + } + }; + + return ( + + ( + + )} + /> + + ( + } + label="نیاز به پرداخت وجه خزانه" + /> + )} + /> + + ( + } + label="نیاز به راه دسترسی" + /> + )} + /> + + + + + + + ); +} diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ReferForm.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ReferForm.jsx index 231f08f..9ec9ac2 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ReferForm.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/ReferForm.jsx @@ -1,67 +1,67 @@ -import { PRIVACY_ADMIN_ACTION_API } from "@/core/utils/routes"; -import useRequest from "@/lib/hooks/useRequest"; -import { Box, Button, DialogActions, TextField } from "@mui/material"; -import { useState } from "react"; -import { Controller, useForm } from "react-hook-form"; - -export default function ReferForm({ mutate, onClose, rowId }) { - const [isSubmitting, setIsSubmitting] = useState(false); - const request = useRequest({ notificationSuccess: true, notificationFailed: true }); - - const { - control, - handleSubmit, - formState: { errors }, - } = useForm({ - defaultValues: { - expert_description: "", - }, - }); - - const onSubmit = (data) => { - setIsSubmitting(true); - try { - request(`${PRIVACY_ADMIN_ACTION_API}/refer_request/${rowId}`, "post", { - data, - }).then(() => { - onClose(); - mutate(); - }); - } catch (error) { - console.log(error); - } finally { - setIsSubmitting(false); - } - }; - - return ( - - ( - - )} - /> - - - - - - ); -} +import { PRIVACY_ADMIN_ACTION_API } from "@/core/utils/routes"; +import useRequest from "@/lib/hooks/useRequest"; +import { Box, Button, DialogActions, TextField } from "@mui/material"; +import { useState } from "react"; +import { Controller, useForm } from "react-hook-form"; + +export default function ReferForm({ mutate, onClose, rowId }) { + const [isSubmitting, setIsSubmitting] = useState(false); + const request = useRequest({ notificationSuccess: true, notificationFailed: true }); + + const { + control, + handleSubmit, + formState: { errors }, + } = useForm({ + defaultValues: { + expert_description: "", + }, + }); + + const onSubmit = (data) => { + setIsSubmitting(true); + try { + request(`${PRIVACY_ADMIN_ACTION_API}/refer_request/${rowId}`, "post", { + data, + }).then(() => { + onClose(); + mutate(); + }); + } catch (error) { + console.log(error); + } finally { + setIsSubmitting(false); + } + }; + + return ( + + ( + + )} + /> + + + + + + ); +} diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/RejectFileForm.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/RejectFileForm.jsx index 0427eef..f4c07b7 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/RejectFileForm.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/RejectFileForm.jsx @@ -1,69 +1,69 @@ -import { PRIVACY_ADMIN_ACTION_API } from "@/core/utils/routes"; -import useRequest from "@/lib/hooks/useRequest"; -import { Box, Button, DialogActions, TextField } from "@mui/material"; -import { useState } from "react"; -import { Controller, useForm } from "react-hook-form"; - -export default function RejectFileForm({ mutate, onClose, rowId }) { - const [isSubmitting, setIsSubmitting] = useState(false); - const request = useRequest({ notificationSuccess: true, notificationFailed: true }); - - const { - control, - handleSubmit, - formState: { errors }, - } = useForm({ - defaultValues: { - expert_description: "", - }, - }); - - const onSubmit = (data) => { - setIsSubmitting(true); - - try { - request(`${PRIVACY_ADMIN_ACTION_API}/file_rejected/${rowId}`, "post", { - data, - }).then(() => { - onClose(); - mutate(); - }); - } catch (err) { - console.log(err); - } finally { - setIsSubmitting(false); - } - }; - - return ( - - ( - - )} - /> - - - - - - - ); -} +import { PRIVACY_ADMIN_ACTION_API } from "@/core/utils/routes"; +import useRequest from "@/lib/hooks/useRequest"; +import { Box, Button, DialogActions, TextField } from "@mui/material"; +import { useState } from "react"; +import { Controller, useForm } from "react-hook-form"; + +export default function RejectFileForm({ mutate, onClose, rowId }) { + const [isSubmitting, setIsSubmitting] = useState(false); + const request = useRequest({ notificationSuccess: true, notificationFailed: true }); + + const { + control, + handleSubmit, + formState: { errors }, + } = useForm({ + defaultValues: { + expert_description: "", + }, + }); + + const onSubmit = (data) => { + setIsSubmitting(true); + + try { + request(`${PRIVACY_ADMIN_ACTION_API}/file_rejected/${rowId}`, "post", { + data, + }).then(() => { + onClose(); + mutate(); + }); + } catch (err) { + console.log(err); + } finally { + setIsSubmitting(false); + } + }; + + return ( + + ( + + )} + /> + + + + + + + ); +} diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/RejectRequestForm.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/RejectRequestForm.jsx index daf1961..8ae8183 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/RejectRequestForm.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/Forms/RejectRequestForm.jsx @@ -1,69 +1,69 @@ -import { PRIVACY_ADMIN_ACTION_API } from "@/core/utils/routes"; -import useRequest from "@/lib/hooks/useRequest"; -import { Box, Button, DialogActions, TextField } from "@mui/material"; -import { useState } from "react"; -import { Controller, useForm } from "react-hook-form"; - -export default function RejectRequestForm({ mutate, onClose, rowId }) { - const [isSubmitting, setIsSubmitting] = useState(false); - const request = useRequest({ notificationSuccess: true, notificationFailed: true }); - - const { - control, - handleSubmit, - formState: { errors }, - } = useForm({ - defaultValues: { - expert_description: "", - }, - }); - - const onSubmit = (data) => { - setIsSubmitting(true); - - try { - request(`${PRIVACY_ADMIN_ACTION_API}/reject_request/${rowId}`, "post", { - data, - }).then(() => { - onClose(); - mutate(); - }); - } catch (err) { - console.log(err); - } finally { - setIsSubmitting(false); - } - }; - - return ( - - ( - - )} - /> - - - - - - - ); -} +import { PRIVACY_ADMIN_ACTION_API } from "@/core/utils/routes"; +import useRequest from "@/lib/hooks/useRequest"; +import { Box, Button, DialogActions, TextField } from "@mui/material"; +import { useState } from "react"; +import { Controller, useForm } from "react-hook-form"; + +export default function RejectRequestForm({ mutate, onClose, rowId }) { + const [isSubmitting, setIsSubmitting] = useState(false); + const request = useRequest({ notificationSuccess: true, notificationFailed: true }); + + const { + control, + handleSubmit, + formState: { errors }, + } = useForm({ + defaultValues: { + expert_description: "", + }, + }); + + const onSubmit = (data) => { + setIsSubmitting(true); + + try { + request(`${PRIVACY_ADMIN_ACTION_API}/reject_request/${rowId}`, "post", { + data, + }).then(() => { + onClose(); + mutate(); + }); + } catch (err) { + console.log(err); + } finally { + setIsSubmitting(false); + } + }; + + return ( + + ( + + )} + /> + + + + + + + ); +} diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/History/HistoryContent.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/History/HistoryContent.jsx index 71f59c1..76fcbf0 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/History/HistoryContent.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/History/HistoryContent.jsx @@ -1,17 +1,17 @@ -import { Button, DialogActions, DialogContent } from "@mui/material"; -import TableContent from "./TableContent"; -const HistoryContent = ({ setOpenReferReasonDialog, rowId }) => { - return ( - <> - - - - - - - - ); -}; -export default HistoryContent; +import { Button, DialogActions, DialogContent } from "@mui/material"; +import TableContent from "./TableContent"; +const HistoryContent = ({ setOpenReferReasonDialog, rowId }) => { + return ( + <> + + + + + + + + ); +}; +export default HistoryContent; diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/History/TableContent.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/History/TableContent.jsx index b405a41..be6e82b 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/History/TableContent.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/History/TableContent.jsx @@ -1,66 +1,66 @@ -import { - Box, - Table, - TableBody, - TableCell, - TableContainer, - TableHead, - TableRow, - CircularProgress, - Typography, -} from "@mui/material"; -import "moment/locale/fa"; -import { useHistory } from "@/lib/hooks/useHistory"; - -const TableContent = ({ rowId }) => { - const { historyData, loading, error } = useHistory(rowId); - - if (loading) { - return ( - - - - ); - } - - if (error) { - return ( - - {error} - - ); - } - - if (!historyData.length) { - return ( - - اطلاعاتی وجود ندارد - - ); - } - - return ( - - - - - - وضعیت - توضیحات کارشناس - - - - {historyData.map((row) => ( - - {row.previous_state_name} - {row.expert_description} - - ))} - -
-
-
- ); -}; - -export default TableContent; +import { + Box, + Table, + TableBody, + TableCell, + TableContainer, + TableHead, + TableRow, + CircularProgress, + Typography, +} from "@mui/material"; +import "moment/locale/fa"; +import { useHistory } from "@/lib/hooks/useHistory"; + +const TableContent = ({ rowId }) => { + const { historyData, loading, error } = useHistory(rowId); + + if (loading) { + return ( + + + + ); + } + + if (error) { + return ( + + {error} + + ); + } + + if (!historyData.length) { + return ( + + اطلاعاتی وجود ندارد + + ); + } + + return ( + + + + + + وضعیت + توضیحات کارشناس + + + + {historyData.map((row) => ( + + {row.previous_state_name} + {row.expert_description} + + ))} + +
+
+
+ ); +}; + +export default TableContent; diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/History/index.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/History/index.jsx index 234ac15..cc3df74 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/History/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/History/index.jsx @@ -1,33 +1,33 @@ -import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; -import { RestorePage } from "@mui/icons-material"; -import HistoryContent from "./HistoryContent"; -import { useState } from "react"; - -const History = ({ rowId }) => { - const [openReferReasonDialog, setOpenReferReasonDialog] = useState(false); - - return ( - <> - - setOpenReferReasonDialog(true)}> - - - - - تاریخچه - - - - ); -}; - -export default History; +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { RestorePage } from "@mui/icons-material"; +import HistoryContent from "./HistoryContent"; +import { useState } from "react"; + +const History = ({ rowId }) => { + const [openReferReasonDialog, setOpenReferReasonDialog] = useState(false); + + return ( + <> + + setOpenReferReasonDialog(true)}> + + + + + تاریخچه + + + + ); +}; + +export default History; diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ReferralAction/index.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ReferralAction/index.jsx index 46d36c3..813569e 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ReferralAction/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ReferralAction/index.jsx @@ -1,18 +1,18 @@ -import { Reply } from "@mui/icons-material"; -import { IconButton, Tooltip } from "@mui/material"; - -const ReferralAction = ({ onClick, disabled }) => { - if (disabled) return; - return ( - <> - - - - - - - - - ); -}; -export default ReferralAction; +import { Reply } from "@mui/icons-material"; +import { IconButton, Tooltip } from "@mui/material"; + +const ReferralAction = ({ onClick, disabled }) => { + if (disabled) return; + return ( + <> + + + + + + + + + ); +}; +export default ReferralAction; diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RejectAction/index.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RejectAction/index.jsx index 47b3382..c6055a3 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RejectAction/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RejectAction/index.jsx @@ -1,18 +1,18 @@ -import ThumbDownIcon from "@mui/icons-material/ThumbDown"; -import { IconButton, Tooltip } from "@mui/material"; - -const RejectAction = ({ onClick, disabled }) => { - if (disabled) return; - return ( - <> - - - - - - - - - ); -}; -export default RejectAction; +import ThumbDownIcon from "@mui/icons-material/ThumbDown"; +import { IconButton, Tooltip } from "@mui/material"; + +const RejectAction = ({ onClick, disabled }) => { + if (disabled) return; + return ( + <> + + + + + + + + + ); +}; +export default RejectAction; diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RenderActionForm.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RenderActionForm.jsx index 846cc1a..7f48650 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RenderActionForm.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RenderActionForm.jsx @@ -1,32 +1,32 @@ -import { DialogContent } from "@mui/material"; -import ComputePaymentForm from "./Forms/ComputePaymentForm"; -import ConfirmFileForm from "./Forms/ConfirmFileForm"; -import ConfirmRequestForm from "./Forms/ConfirmRequestForm"; -import ReferForm from "./Forms/ReferForm"; -import RejectFileForm from "./Forms/RejectFileForm"; -import RejectRequestForm from "./Forms/RejectRequestForm"; - -export default function RenderActionForm({ type, rowData, mutate, onClose }) { - const formType = `${type}_${rowData?.state_id}`; - - function renderForm() { - switch (formType) { - case "refer_request_2": - return ; - case "reject_request_2": - return ; - case "reject_request_5": - return ; - case "confirm_request_2": - return ; - case "confirm_request_5": - return ; - case "confirm_request_13": - return ; - default: - return <>; - } - } - - return {renderForm()}; -} +import { DialogContent } from "@mui/material"; +import ComputePaymentForm from "./Forms/ComputePaymentForm"; +import ConfirmFileForm from "./Forms/ConfirmFileForm"; +import ConfirmRequestForm from "./Forms/ConfirmRequestForm"; +import ReferForm from "./Forms/ReferForm"; +import RejectFileForm from "./Forms/RejectFileForm"; +import RejectRequestForm from "./Forms/RejectRequestForm"; + +export default function RenderActionForm({ type, rowData, mutate, onClose }) { + const formType = `${type}_${rowData?.state_id}`; + + function renderForm() { + switch (formType) { + case "refer_request_2": + return ; + case "reject_request_2": + return ; + case "reject_request_5": + return ; + case "confirm_request_2": + return ; + case "confirm_request_5": + return ; + case "confirm_request_13": + return ; + default: + return <>; + } + } + + return {renderForm()}; +} diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/index.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/index.jsx index ed3df15..86c6bef 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/index.jsx @@ -1,57 +1,57 @@ -import { Box } from "@mui/material"; -import { useState } from "react"; -import ActionDialog from "./ActionsDialog"; -import ConfirmAction from "./ConfirmAction"; -import ReferralAction from "./ReferralAction"; -import RejectAction from "./RejectAction"; -import History from "./History"; - -const RowActions = ({ row: { original }, mutate }) => { - const [modal, setModal] = useState({ - open: false, - type: null, // "reject_request" | "confirm_request" | "refer_request" - rowData: null, - }); - - const handleOpenModal = (type, rowData) => { - setModal({ open: true, type, rowData }); - }; - - const handleCloseModal = () => { - setModal({ open: false, type: null, rowData: null }); - }; - - const stateId = original.state_id; - - const disabled = { - referral: stateId !== 2, - reject: stateId !== 2 && stateId !== 5, - confirm: stateId !== 2 && stateId !== 5 && stateId !== 13, - }; - - return ( - <> - - - handleOpenModal("refer_request", original)} - disabled={disabled.referral} - /> - handleOpenModal("reject_request", original)} disabled={disabled.reject} /> - handleOpenModal("confirm_request", original)} - disabled={disabled.confirm} - /> - - - - ); -}; - -export default RowActions; +import { Box } from "@mui/material"; +import { useState } from "react"; +import ActionDialog from "./ActionsDialog"; +import ConfirmAction from "./ConfirmAction"; +import ReferralAction from "./ReferralAction"; +import RejectAction from "./RejectAction"; +import History from "./History"; + +const RowActions = ({ row: { original }, mutate }) => { + const [modal, setModal] = useState({ + open: false, + type: null, // "reject_request" | "confirm_request" | "refer_request" + rowData: null, + }); + + const handleOpenModal = (type, rowData) => { + setModal({ open: true, type, rowData }); + }; + + const handleCloseModal = () => { + setModal({ open: false, type: null, rowData: null }); + }; + + const stateId = original.state_id; + + const disabled = { + referral: stateId !== 2, + reject: stateId !== 2 && stateId !== 5, + confirm: stateId !== 2 && stateId !== 5 && stateId !== 13, + }; + + return ( + <> + + + handleOpenModal("refer_request", original)} + disabled={disabled.referral} + /> + handleOpenModal("reject_request", original)} disabled={disabled.reject} /> + handleOpenModal("confirm_request", original)} + disabled={disabled.confirm} + /> + + + + ); +}; + +export default RowActions; diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/ShowPrimaryArea/ShowBound.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/ShowPrimaryArea/ShowBound.jsx index 24db476..43dd0b8 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/ShowPrimaryArea/ShowBound.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/ShowPrimaryArea/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/dashboard/inquiryPrivacy/privacy-office/ShowPrimaryArea/ShowForbiddenBound.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/ShowPrimaryArea/ShowForbiddenBound.jsx index c8d28d1..6631907 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/ShowPrimaryArea/ShowForbiddenBound.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/ShowPrimaryArea/ShowForbiddenBound.jsx @@ -1,29 +1,29 @@ -import { useEffect, useRef } from "react"; -import { FeatureGroup, useMap } from "react-leaflet"; - -const ShowForbiddenBound = ({ 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 ShowForbiddenBound; +import { useEffect, useRef } from "react"; +import { FeatureGroup, useMap } from "react-leaflet"; + +const ShowForbiddenBound = ({ 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 ShowForbiddenBound; diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/ShowPrimaryArea/index.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/ShowPrimaryArea/index.jsx index 996a2cd..7fc1a7d 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/ShowPrimaryArea/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/ShowPrimaryArea/index.jsx @@ -1,70 +1,70 @@ -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 { useMemo, useState } from "react"; -import ShowBound from "./ShowBound"; -import ShowForbiddenBound from "./ShowForbiddenBound"; - -const ShowPrimaryArea = ({ primaryArea, forbiddenArea }) => { - const [openShowAreaDialog, setOpenShowAreaDialog] = useState(false); - const bound = useMemo(() => { - const latLngCoords = primaryArea.coordinates.map((coord) => [coord[1], coord[0]]); - return primaryArea.type === "polygon" ? L.polygon(latLngCoords) : L.polyline(latLngCoords); - }, [primaryArea]); - - const forbiddenBound = useMemo(() => { - const latLngCoords = forbiddenArea.coordinates.map((coord) => [coord[1], coord[0]]); - return forbiddenArea.type === "polygon" - ? L.polygon(latLngCoords, { - color: "#ff5555", - }) - : L.polyline(latLngCoords); - }, [forbiddenArea]); - - return ( - - - setOpenShowAreaDialog(true)}> - - - - setOpenShowAreaDialog(false)} - PaperProps={{ - sx: { - transition: "all .3s", - boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px", - borderRadius: 2, - padding: 1, - }, - }} - maxWidth="sm" - fullWidth - dir="rtl" - > - - - محدوده طرح - - setOpenShowAreaDialog(false)} size="small"> - - - - - - - - - - - - - - - - ); -}; - -export default ShowPrimaryArea; +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 { useMemo, useState } from "react"; +import ShowBound from "./ShowBound"; +import ShowForbiddenBound from "./ShowForbiddenBound"; + +const ShowPrimaryArea = ({ primaryArea, forbiddenArea }) => { + const [openShowAreaDialog, setOpenShowAreaDialog] = useState(false); + const bound = useMemo(() => { + const latLngCoords = primaryArea.coordinates.map((coord) => [coord[1], coord[0]]); + return primaryArea.type === "polygon" ? L.polygon(latLngCoords) : L.polyline(latLngCoords); + }, [primaryArea]); + + const forbiddenBound = useMemo(() => { + const latLngCoords = forbiddenArea.coordinates.map((coord) => [coord[1], coord[0]]); + return forbiddenArea.type === "polygon" + ? L.polygon(latLngCoords, { + color: "#ff5555", + }) + : L.polyline(latLngCoords); + }, [forbiddenArea]); + + return ( + + + setOpenShowAreaDialog(true)}> + + + + setOpenShowAreaDialog(false)} + PaperProps={{ + sx: { + transition: "all .3s", + boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px", + borderRadius: 2, + padding: 1, + }, + }} + maxWidth="sm" + fullWidth + dir="rtl" + > + + + محدوده طرح + + setOpenShowAreaDialog(false)} size="small"> + + + + + + + + + + + + + + + + ); +}; + +export default ShowPrimaryArea; diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/index.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/index.jsx index ce52276..948b5f6 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/index.jsx @@ -1,14 +1,14 @@ -"use client"; -import PageTitle from "@/core/components/PageTitle"; -import { Stack } from "@mui/material"; -import PrivacyOfficeList from "./PrivacyOfficeList"; - -const PrivacyOfficePage = () => { - return ( - - - - - ); -}; -export default PrivacyOfficePage; +"use client"; +import PageTitle from "@/core/components/PageTitle"; +import { Stack } from "@mui/material"; +import PrivacyOfficeList from "./PrivacyOfficeList"; + +const PrivacyOfficePage = () => { + return ( + + + + + ); +}; +export default PrivacyOfficePage; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/ConfirmRoadSafetyDialog.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/ConfirmRoadSafetyDialog.jsx index 512e9a5..ad0af62 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/ConfirmRoadSafetyDialog.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/ConfirmRoadSafetyDialog.jsx @@ -1,43 +1,43 @@ -import DialogLoading from "@/core/components/DialogLoading"; -import { GET_REQUEST_INQUIRY_PRIVACY } from "@/core/utils/routes"; -import useRequest from "@/lib/hooks/useRequest"; -import { DialogContent, DialogTitle, Typography } from "@mui/material"; -import { useEffect, useState } from "react"; -import ConfirmRoadSafetyFormContext from "./ConfirmRoadSafetyFormContext"; - -const ConfirmRoadSafetyDialog = ({ row, handleClose, rowId, mutate }) => { - 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_REQUEST_INQUIRY_PRIVACY}/${rowId}`); - setData(response.data.data); - } catch (error) { - } finally { - setLoading(false); - } - }; - - fetchData(); - }, [rowId]); - - return ( - <> - تاییدیه ایمنی راه - {loading ? ( - - ) : data ? ( - - ) : ( - - اطلاعات درخواست در سامانه یافت نشد - - )} - - ); -}; -export default ConfirmRoadSafetyDialog; +import DialogLoading from "@/core/components/DialogLoading"; +import { GET_REQUEST_INQUIRY_PRIVACY } from "@/core/utils/routes"; +import useRequest from "@/lib/hooks/useRequest"; +import { DialogContent, DialogTitle, Typography } from "@mui/material"; +import { useEffect, useState } from "react"; +import ConfirmRoadSafetyFormContext from "./ConfirmRoadSafetyFormContext"; + +const ConfirmRoadSafetyDialog = ({ row, handleClose, rowId, mutate }) => { + 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_REQUEST_INQUIRY_PRIVACY}/${rowId}`); + setData(response.data.data); + } catch (error) { + } finally { + setLoading(false); + } + }; + + fetchData(); + }, [rowId]); + + return ( + <> + تاییدیه ایمنی راه + {loading ? ( + + ) : data ? ( + + ) : ( + + اطلاعات درخواست در سامانه یافت نشد + + )} + + ); +}; +export default ConfirmRoadSafetyDialog; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/ConfirmRoadSafetyFormContext.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/ConfirmRoadSafetyFormContext.jsx index 5b4dd3d..b9ba653 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/ConfirmRoadSafetyFormContext.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/ConfirmRoadSafetyFormContext.jsx @@ -1,64 +1,64 @@ -import { useState } from "react"; -import { Box, TextField, Button, CircularProgress, Alert, DialogContent } from "@mui/material"; -import useRequest from "@/lib/hooks/useRequest"; -import { CONFIRM_ROAD_SAFETY_FORM } from "@/core/utils/routes"; - -const ConfirmRoadSafetyFormContext = ({ rowId, mutate, handleClose }) => { - const requestServer = useRequest({ notificationShow: true, notificationSuccess: true }); - const [description, setDescription] = useState(""); - const [loading, setLoading] = useState(false); - const [error, setError] = useState(null); - const [success, setSuccess] = useState(false); - - const handleSubmit = async () => { - if (!description.trim()) { - setError("لطفاً توضیحات را وارد کنید"); - return; - } - - setLoading(true); - setError(null); - setSuccess(false); - - try { - const res = await requestServer(`${CONFIRM_ROAD_SAFETY_FORM}/${rowId}`, "post", { - data: { - expert_description: description, - }, - }); - - setSuccess(true); - mutate(); - setDescription(""); - handleClose(); - } catch (err) { - setError(err.message); - } finally { - setLoading(false); - } - }; - - return ( - - - {error && {error}} - {success && با موفقیت ثبت شد} - - setDescription(e.target.value)} - fullWidth - /> - - - - - ); -}; - -export default ConfirmRoadSafetyFormContext; +import { useState } from "react"; +import { Box, TextField, Button, CircularProgress, Alert, DialogContent } from "@mui/material"; +import useRequest from "@/lib/hooks/useRequest"; +import { CONFIRM_ROAD_SAFETY_FORM } from "@/core/utils/routes"; + +const ConfirmRoadSafetyFormContext = ({ rowId, mutate, handleClose }) => { + const requestServer = useRequest({ notificationShow: true, notificationSuccess: true }); + const [description, setDescription] = useState(""); + const [loading, setLoading] = useState(false); + const [error, setError] = useState(null); + const [success, setSuccess] = useState(false); + + const handleSubmit = async () => { + if (!description.trim()) { + setError("لطفاً توضیحات را وارد کنید"); + return; + } + + setLoading(true); + setError(null); + setSuccess(false); + + try { + const res = await requestServer(`${CONFIRM_ROAD_SAFETY_FORM}/${rowId}`, "post", { + data: { + expert_description: description, + }, + }); + + setSuccess(true); + mutate(); + setDescription(""); + handleClose(); + } catch (err) { + setError(err.message); + } finally { + setLoading(false); + } + }; + + return ( + + + {error && {error}} + {success && با موفقیت ثبت شد} + + setDescription(e.target.value)} + fullWidth + /> + + + + + ); +}; + +export default ConfirmRoadSafetyFormContext; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/DescriptionForm.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/DescriptionForm.jsx index a7099e7..c2dcd5b 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/DescriptionForm.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/DescriptionForm.jsx @@ -1,29 +1,29 @@ -import { Stack, TextField } from "@mui/material"; -import { Controller } from "react-hook-form"; - -const DescriptionForm = ({ control }) => { - return ( - - ( - - )} - /> - - ); -}; -export default DescriptionForm; +import { Stack, TextField } from "@mui/material"; +import { Controller } from "react-hook-form"; + +const DescriptionForm = ({ control }) => { + return ( + + ( + + )} + /> + + ); +}; +export default DescriptionForm; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/QuestionVerifyNeedRoadForm.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/QuestionVerifyNeedRoadForm.jsx index 747d178..a79b636 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/QuestionVerifyNeedRoadForm.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/QuestionVerifyNeedRoadForm.jsx @@ -1,29 +1,29 @@ -import { Card, CardContent, Stack, Typography } from "@mui/material"; - -const QuestionVerifyNeedRoadForm = ({ row }) => { - return ( - - - - - آیا نیاز به راه دسترسی است؟ - - - دفتر حریم راه : - - {row.original.need_road_access == 1 ? "بله" : "خیر"} - - - - - - ); -}; -export default QuestionVerifyNeedRoadForm; +import { Card, CardContent, Stack, Typography } from "@mui/material"; + +const QuestionVerifyNeedRoadForm = ({ row }) => { + return ( + + + + + آیا نیاز به راه دسترسی است؟ + + + دفتر حریم راه : + + {row.original.need_road_access == 1 ? "بله" : "خیر"} + + + + + + ); +}; +export default QuestionVerifyNeedRoadForm; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/QuestionVerifyRoadSafetyForm.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/QuestionVerifyRoadSafetyForm.jsx index 3da9f78..27ace40 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/QuestionVerifyRoadSafetyForm.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/QuestionVerifyRoadSafetyForm.jsx @@ -1,29 +1,29 @@ -import { Card, CardContent, Stack, Typography } from "@mui/material"; - -const QuestionVerifyRoadSafetyForm = ({ row }) => { - return ( - - - - - آیا ایمنی راه این طرح مورد تایید است؟ - - - دفتر حریم راه : - - {row.original.is_possible == 1 ? "بله" : "خیر"} - - - - - - ); -}; -export default QuestionVerifyRoadSafetyForm; +import { Card, CardContent, Stack, Typography } from "@mui/material"; + +const QuestionVerifyRoadSafetyForm = ({ row }) => { + return ( + + + + + آیا ایمنی راه این طرح مورد تایید است؟ + + + دفتر حریم راه : + + {row.original.is_possible == 1 ? "بله" : "خیر"} + + + + + + ); +}; +export default QuestionVerifyRoadSafetyForm; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/Refer/Form.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/Refer/Form.jsx index 3dfc3ee..d956718 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/Refer/Form.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/Refer/Form.jsx @@ -1,78 +1,78 @@ -import StyledForm from "@/core/components/StyledForm"; -import { REFER_INQUIRY_PRIVACY_ZAMIN_GOV_ASSISTANT } from "@/core/utils/routes"; -import useRequest from "@/lib/hooks/useRequest"; -import { yupResolver } from "@hookform/resolvers/yup"; -import { Button, DialogActions, DialogContent, Stack, TextField } from "@mui/material"; -import { Controller, useForm } from "react-hook-form"; -import { object, string } from "yup"; - -const validationSchema = object({ - description: string().required("وارد کردن توضیحات الزامیست!"), -}); - -const defaultValues = { - description: "", -}; - -const ReferForm = ({ rowId, mutate, handleClose, setOpenReferDialog }) => { - const requestServer = useRequest({ notificationSuccess: true }); - const { - control, - handleSubmit, - formState: { isSubmitting }, - } = useForm({ defaultValues, resolver: yupResolver(validationSchema), mode: "all" }); - - const onSubmit = async (data) => { - await requestServer(`${REFER_INQUIRY_PRIVACY_ZAMIN_GOV_ASSISTANT}/${rowId}`, "post", { - data: { - expert_description: data.description, - }, - }) - .then(() => { - handleClose(); - setOpenReferDialog(false); - mutate(); - }) - .catch(() => {}); - }; - - return ( - <> - - - ( - - )} - /> - - - - - - - ); -}; -export default ReferForm; +import StyledForm from "@/core/components/StyledForm"; +import { REFER_INQUIRY_PRIVACY_ZAMIN_GOV_ASSISTANT } from "@/core/utils/routes"; +import useRequest from "@/lib/hooks/useRequest"; +import { yupResolver } from "@hookform/resolvers/yup"; +import { Button, DialogActions, DialogContent, Stack, TextField } from "@mui/material"; +import { Controller, useForm } from "react-hook-form"; +import { object, string } from "yup"; + +const validationSchema = object({ + description: string().required("وارد کردن توضیحات الزامیست!"), +}); + +const defaultValues = { + description: "", +}; + +const ReferForm = ({ rowId, mutate, handleClose, setOpenReferDialog }) => { + const requestServer = useRequest({ notificationSuccess: true }); + const { + control, + handleSubmit, + formState: { isSubmitting }, + } = useForm({ defaultValues, resolver: yupResolver(validationSchema), mode: "all" }); + + const onSubmit = async (data) => { + await requestServer(`${REFER_INQUIRY_PRIVACY_ZAMIN_GOV_ASSISTANT}/${rowId}`, "post", { + data: { + expert_description: data.description, + }, + }) + .then(() => { + handleClose(); + setOpenReferDialog(false); + mutate(); + }) + .catch(() => {}); + }; + + return ( + <> + + + ( + + )} + /> + + + + + + + ); +}; +export default ReferForm; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/Refer/index.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/Refer/index.jsx index e18024f..a629609 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/Refer/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/Refer/index.jsx @@ -1,54 +1,54 @@ -import { Close } from "@mui/icons-material"; -import { Button, Dialog, DialogTitle, IconButton } from "@mui/material"; -import { useState } from "react"; -import ReferForm from "./Form"; - -const Refer = ({ rowId, mutate, handleClose, isSubmitting }) => { - const [openReferDialog, setOpenReferDialog] = useState(false); - - return ( - <> - - { - setOpenReferDialog(false); - }} - maxWidth="xs" - fullWidth - > - setOpenReferDialog(false)} - sx={{ - position: "absolute", - right: 8, - top: 8, - zIndex: 10, - color: (theme) => theme.palette.grey[500], - }} - > - - - مخالفت و ارجاع به دفتر حریم - {openReferDialog && ( - - )} - - - ); -}; -export default Refer; +import { Close } from "@mui/icons-material"; +import { Button, Dialog, DialogTitle, IconButton } from "@mui/material"; +import { useState } from "react"; +import ReferForm from "./Form"; + +const Refer = ({ rowId, mutate, handleClose, isSubmitting }) => { + const [openReferDialog, setOpenReferDialog] = useState(false); + + return ( + <> + + { + setOpenReferDialog(false); + }} + maxWidth="xs" + fullWidth + > + setOpenReferDialog(false)} + sx={{ + position: "absolute", + right: 8, + top: 8, + zIndex: 10, + color: (theme) => theme.palette.grey[500], + }} + > + + + مخالفت و ارجاع به دفتر حریم + {openReferDialog && ( + + )} + + + ); +}; +export default Refer; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/index.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/index.jsx index c35313e..4b5a677 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/Questions/index.jsx @@ -1,72 +1,72 @@ -import StyledForm from "@/core/components/StyledForm"; -import { CONFIRM_INQUIRY_PRIVACY_ZAMIN_GOV_ASSISTANT } from "@/core/utils/routes"; -import useRequest from "@/lib/hooks/useRequest"; -import { yupResolver } from "@hookform/resolvers/yup"; -import { Button, DialogActions, DialogContent, Stack } from "@mui/material"; -import { useForm } from "react-hook-form"; -import { object, string } from "yup"; -import QuestionVerifyNeedRoadForm from "./QuestionVerifyNeedRoadForm"; -import QuestionVerifyRoadSafetyForm from "./QuestionVerifyRoadSafetyForm"; -import Refer from "./Refer"; -import DescriptionForm from "./DescriptionForm"; - -const validationSchema = object({ - description: string().required("وارد کردن توضیحات الزامیست!"), -}); - -const defaultValues = { - description: "", -}; - -const Questions = ({ row, rowId, mutate, handleClose, handlePrev }) => { - const requestServer = useRequest({ notificationSuccess: true }); - - const { - control, - handleSubmit, - formState: { isSubmitting }, - } = useForm({ defaultValues, resolver: yupResolver(validationSchema), mode: "all" }); - - const onSubmit = async (data) => { - await requestServer(`${CONFIRM_INQUIRY_PRIVACY_ZAMIN_GOV_ASSISTANT}/${rowId}`, "post", { - data: { - expert_description: data.description, - }, - }) - .then(() => { - handleClose(); - mutate(); - }) - .catch(() => {}); - }; - - return ( - - - - - - - - - - - - - - - - - ); -}; -export default Questions; +import StyledForm from "@/core/components/StyledForm"; +import { CONFIRM_INQUIRY_PRIVACY_ZAMIN_GOV_ASSISTANT } from "@/core/utils/routes"; +import useRequest from "@/lib/hooks/useRequest"; +import { yupResolver } from "@hookform/resolvers/yup"; +import { Button, DialogActions, DialogContent, Stack } from "@mui/material"; +import { useForm } from "react-hook-form"; +import { object, string } from "yup"; +import QuestionVerifyNeedRoadForm from "./QuestionVerifyNeedRoadForm"; +import QuestionVerifyRoadSafetyForm from "./QuestionVerifyRoadSafetyForm"; +import Refer from "./Refer"; +import DescriptionForm from "./DescriptionForm"; + +const validationSchema = object({ + description: string().required("وارد کردن توضیحات الزامیست!"), +}); + +const defaultValues = { + description: "", +}; + +const Questions = ({ row, rowId, mutate, handleClose, handlePrev }) => { + const requestServer = useRequest({ notificationSuccess: true }); + + const { + control, + handleSubmit, + formState: { isSubmitting }, + } = useForm({ defaultValues, resolver: yupResolver(validationSchema), mode: "all" }); + + const onSubmit = async (data) => { + await requestServer(`${CONFIRM_INQUIRY_PRIVACY_ZAMIN_GOV_ASSISTANT}/${rowId}`, "post", { + data: { + expert_description: data.description, + }, + }) + .then(() => { + handleClose(); + mutate(); + }) + .catch(() => {}); + }; + + return ( + + + + + + + + + + + + + + + + + ); +}; +export default Questions; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/index.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/index.jsx index 8104adc..a27fa35 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmRoadSafetyForm/index.jsx @@ -1,51 +1,51 @@ -import { Close, Engineering } from "@mui/icons-material"; -import { Dialog, IconButton, Stack, Tooltip } from "@mui/material"; -import { useState } from "react"; -import ConfirmRoadSafetyDialog from "./ConfirmRoadSafetyDialog"; - -const ConfirmRoadSafetyForm = ({ row, rowId, mutate }) => { - const [openConfirmRoadSafetyForm, setOpenConfirmRoadSafetyForm] = useState(false); - - const openRoadSafetyDialog = () => { - setOpenConfirmRoadSafetyForm(true); - }; - - const handleClose = () => { - setOpenConfirmRoadSafetyForm(false); - }; - - return ( - - - { - openRoadSafetyDialog(); - }} - > - - - - - handleClose()} - sx={{ - position: "absolute", - right: 8, - top: 8, - zIndex: 10, - color: (theme) => theme.palette.grey[500], - }} - > - - - {openConfirmRoadSafetyForm && ( - - )} - - - ); -}; -export default ConfirmRoadSafetyForm; +import { Close, Engineering } from "@mui/icons-material"; +import { Dialog, IconButton, Stack, Tooltip } from "@mui/material"; +import { useState } from "react"; +import ConfirmRoadSafetyDialog from "./ConfirmRoadSafetyDialog"; + +const ConfirmRoadSafetyForm = ({ row, rowId, mutate }) => { + const [openConfirmRoadSafetyForm, setOpenConfirmRoadSafetyForm] = useState(false); + + const openRoadSafetyDialog = () => { + setOpenConfirmRoadSafetyForm(true); + }; + + const handleClose = () => { + setOpenConfirmRoadSafetyForm(false); + }; + + return ( + + + { + openRoadSafetyDialog(); + }} + > + + + + + handleClose()} + sx={{ + position: "absolute", + right: 8, + top: 8, + zIndex: 10, + color: (theme) => theme.palette.grey[500], + }} + > + + + {openConfirmRoadSafetyForm && ( + + )} + + + ); +}; +export default ConfirmRoadSafetyForm; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/ConfirmRoadSafetyDialog.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/ConfirmRoadSafetyDialog.jsx index b0beb30..7e5e76a 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/ConfirmRoadSafetyDialog.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/ConfirmRoadSafetyDialog.jsx @@ -1,43 +1,43 @@ -import DialogLoading from "@/core/components/DialogLoading"; -import { GET_REQUEST_INQUIRY_PRIVACY } from "@/core/utils/routes"; -import useRequest from "@/lib/hooks/useRequest"; -import { DialogContent, DialogTitle, Typography } from "@mui/material"; -import { useEffect, useState } from "react"; -import ConfirmRoadSafetyFormContext from "./ConfirmRoadSafetyFormContext"; - -const ConfirmRoadSafetyDialog = ({ handleClose, rowId, mutate }) => { - 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_REQUEST_INQUIRY_PRIVACY}/${rowId}`); - setData(response.data.data); - } catch (error) { - } finally { - setLoading(false); - } - }; - - fetchData(); - }, [rowId]); - - return ( - <> - تاییدیه ضمانت نامه ها - {loading ? ( - - ) : data ? ( - - ) : ( - - اطلاعات درخواست در سامانه یافت نشد - - )} - - ); -}; -export default ConfirmRoadSafetyDialog; +import DialogLoading from "@/core/components/DialogLoading"; +import { GET_REQUEST_INQUIRY_PRIVACY } from "@/core/utils/routes"; +import useRequest from "@/lib/hooks/useRequest"; +import { DialogContent, DialogTitle, Typography } from "@mui/material"; +import { useEffect, useState } from "react"; +import ConfirmRoadSafetyFormContext from "./ConfirmRoadSafetyFormContext"; + +const ConfirmRoadSafetyDialog = ({ handleClose, rowId, mutate }) => { + 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_REQUEST_INQUIRY_PRIVACY}/${rowId}`); + setData(response.data.data); + } catch (error) { + } finally { + setLoading(false); + } + }; + + fetchData(); + }, [rowId]); + + return ( + <> + تاییدیه ضمانت نامه ها + {loading ? ( + + ) : data ? ( + + ) : ( + + اطلاعات درخواست در سامانه یافت نشد + + )} + + ); +}; +export default ConfirmRoadSafetyDialog; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/ConfirmRoadSafetyFormContext.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/ConfirmRoadSafetyFormContext.jsx index 98c2d55..7531b60 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/ConfirmRoadSafetyFormContext.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/ConfirmRoadSafetyFormContext.jsx @@ -1,63 +1,63 @@ -import { Alert, Box, Button, CircularProgress, DialogContent, TextField } from "@mui/material"; -import { CONFIRM_VERIFY_LICENSE_FORM } from "@/core/utils/routes"; -import useRequest from "@/lib/hooks/useRequest"; -import { useState } from "react"; - -const ConfirmRoadSafetyFormContext = ({ rowId, mutate, handleClose }) => { - const requestServer = useRequest({ notificationShow: true, notificationSuccess: true }); - const [description, setDescription] = useState(""); - const [loading, setLoading] = useState(false); - const [error, setError] = useState(null); - const [success, setSuccess] = useState(false); - - const handleSubmit = async () => { - if (!description.trim()) { - setError("لطفاً توضیحات را وارد کنید"); - return; - } - - setLoading(true); - setError(null); - setSuccess(false); - - try { - const res = await requestServer(`${CONFIRM_VERIFY_LICENSE_FORM}/${rowId}`, "post", { - data: { - expert_description: description, - }, - }); - - setSuccess(true); - mutate(); - setDescription(""); - handleClose(); - } catch (err) { - setError(err.message); - } finally { - setLoading(false); - } - }; - - return ( - - - {error && {error}} - {success && با موفقیت ثبت شد} - - setDescription(e.target.value)} - fullWidth - /> - - - - - ); -}; -export default ConfirmRoadSafetyFormContext; +import { Alert, Box, Button, CircularProgress, DialogContent, TextField } from "@mui/material"; +import { CONFIRM_VERIFY_LICENSE_FORM } from "@/core/utils/routes"; +import useRequest from "@/lib/hooks/useRequest"; +import { useState } from "react"; + +const ConfirmRoadSafetyFormContext = ({ rowId, mutate, handleClose }) => { + const requestServer = useRequest({ notificationShow: true, notificationSuccess: true }); + const [description, setDescription] = useState(""); + const [loading, setLoading] = useState(false); + const [error, setError] = useState(null); + const [success, setSuccess] = useState(false); + + const handleSubmit = async () => { + if (!description.trim()) { + setError("لطفاً توضیحات را وارد کنید"); + return; + } + + setLoading(true); + setError(null); + setSuccess(false); + + try { + const res = await requestServer(`${CONFIRM_VERIFY_LICENSE_FORM}/${rowId}`, "post", { + data: { + expert_description: description, + }, + }); + + setSuccess(true); + mutate(); + setDescription(""); + handleClose(); + } catch (err) { + setError(err.message); + } finally { + setLoading(false); + } + }; + + return ( + + + {error && {error}} + {success && با موفقیت ثبت شد} + + setDescription(e.target.value)} + fullWidth + /> + + + + + ); +}; +export default ConfirmRoadSafetyFormContext; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/index.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/index.jsx index d1548ed..8587703 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyLicenseForm/index.jsx @@ -1,51 +1,51 @@ -import { Close, ThumbUp } from "@mui/icons-material"; -import { Dialog, IconButton, Stack, Tooltip } from "@mui/material"; -import { useState } from "react"; -import ConfirmRoadSafetyDialog from "./ConfirmRoadSafetyDialog"; - -const ConfirmVerifyLicenseForm = ({ row, rowId, mutate }) => { - const [openConfirmVerifyLicenseForm, setOpenConfirmVerifyLicenseForm] = useState(false); - - const openConfirmVerifyLicenseFormDialog = () => { - setOpenConfirmVerifyLicenseForm(true); - }; - - const handleClose = () => { - setOpenConfirmVerifyLicenseForm(false); - }; - - return ( - - - { - openConfirmVerifyLicenseFormDialog(); - }} - > - - - - - handleClose()} - sx={{ - position: "absolute", - right: 8, - top: 8, - zIndex: 10, - color: (theme) => theme.palette.grey[500], - }} - > - - - {openConfirmVerifyLicenseForm && ( - - )} - - - ); -}; -export default ConfirmVerifyLicenseForm; +import { Close, ThumbUp } from "@mui/icons-material"; +import { Dialog, IconButton, Stack, Tooltip } from "@mui/material"; +import { useState } from "react"; +import ConfirmRoadSafetyDialog from "./ConfirmRoadSafetyDialog"; + +const ConfirmVerifyLicenseForm = ({ row, rowId, mutate }) => { + const [openConfirmVerifyLicenseForm, setOpenConfirmVerifyLicenseForm] = useState(false); + + const openConfirmVerifyLicenseFormDialog = () => { + setOpenConfirmVerifyLicenseForm(true); + }; + + const handleClose = () => { + setOpenConfirmVerifyLicenseForm(false); + }; + + return ( + + + { + openConfirmVerifyLicenseFormDialog(); + }} + > + + + + + handleClose()} + sx={{ + position: "absolute", + right: 8, + top: 8, + zIndex: 10, + color: (theme) => theme.palette.grey[500], + }} + > + + + {openConfirmVerifyLicenseForm && ( + + )} + + + ); +}; +export default ConfirmVerifyLicenseForm; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/ConfirmRoadSafetyDialog.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/ConfirmRoadSafetyDialog.jsx index 933dda4..c7444f3 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/ConfirmRoadSafetyDialog.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/ConfirmRoadSafetyDialog.jsx @@ -1,43 +1,43 @@ -import DialogLoading from "@/core/components/DialogLoading"; -import { GET_REQUEST_INQUIRY_PRIVACY } from "@/core/utils/routes"; -import useRequest from "@/lib/hooks/useRequest"; -import { DialogContent, DialogTitle, Typography } from "@mui/material"; -import { useEffect, useState } from "react"; -import ConfirmRoadSafetyFormContext from "./ConfirmRoadSafetyFormContext"; - -const ConfirmRoadSafetyDialog = ({ row, handleClose, rowId, mutate }) => { - 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_REQUEST_INQUIRY_PRIVACY}/${rowId}`); - setData(response.data.data); - } catch (error) { - } finally { - setLoading(false); - } - }; - - fetchData(); - }, [rowId]); - - return ( - <> - تاییدیه دسترسی راه - {loading ? ( - - ) : data ? ( - - ) : ( - - اطلاعات درخواست در سامانه یافت نشد - - )} - - ); -}; -export default ConfirmRoadSafetyDialog; +import DialogLoading from "@/core/components/DialogLoading"; +import { GET_REQUEST_INQUIRY_PRIVACY } from "@/core/utils/routes"; +import useRequest from "@/lib/hooks/useRequest"; +import { DialogContent, DialogTitle, Typography } from "@mui/material"; +import { useEffect, useState } from "react"; +import ConfirmRoadSafetyFormContext from "./ConfirmRoadSafetyFormContext"; + +const ConfirmRoadSafetyDialog = ({ row, handleClose, rowId, mutate }) => { + 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_REQUEST_INQUIRY_PRIVACY}/${rowId}`); + setData(response.data.data); + } catch (error) { + } finally { + setLoading(false); + } + }; + + fetchData(); + }, [rowId]); + + return ( + <> + تاییدیه دسترسی راه + {loading ? ( + + ) : data ? ( + + ) : ( + + اطلاعات درخواست در سامانه یافت نشد + + )} + + ); +}; +export default ConfirmRoadSafetyDialog; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/ConfirmRoadSafetyFormContext.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/ConfirmRoadSafetyFormContext.jsx index 79c8e46..c1bc2e2 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/ConfirmRoadSafetyFormContext.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/ConfirmRoadSafetyFormContext.jsx @@ -1,63 +1,63 @@ -import useRequest from "@/lib/hooks/useRequest"; -import { useState } from "react"; -import { CONFIRM_VERIFY_ROAD_SAFETY_FORM } from "@/core/utils/routes"; -import { Alert, Box, Button, CircularProgress, DialogContent, TextField } from "@mui/material"; - -const ConfirmRoadSafetyFormContext = ({ rowId, mutate, handleClose }) => { - const requestServer = useRequest({ notificationShow: true, notificationSuccess: true }); - const [description, setDescription] = useState(""); - const [loading, setLoading] = useState(false); - const [error, setError] = useState(null); - const [success, setSuccess] = useState(false); - - const handleSubmit = async () => { - if (!description.trim()) { - setError("لطفاً توضیحات را وارد کنید"); - return; - } - - setLoading(true); - setError(null); - setSuccess(false); - - try { - const res = await requestServer(`${CONFIRM_VERIFY_ROAD_SAFETY_FORM}/${rowId}`, "post", { - data: { - expert_description: description, - }, - }); - - setSuccess(true); - mutate(); - setDescription(""); - handleClose(); - } catch (err) { - setError(err.message); - } finally { - setLoading(false); - } - }; - - return ( - - - {error && {error}} - {success && با موفقیت ثبت شد} - - setDescription(e.target.value)} - fullWidth - /> - - - - - ); -}; -export default ConfirmRoadSafetyFormContext; +import useRequest from "@/lib/hooks/useRequest"; +import { useState } from "react"; +import { CONFIRM_VERIFY_ROAD_SAFETY_FORM } from "@/core/utils/routes"; +import { Alert, Box, Button, CircularProgress, DialogContent, TextField } from "@mui/material"; + +const ConfirmRoadSafetyFormContext = ({ rowId, mutate, handleClose }) => { + const requestServer = useRequest({ notificationShow: true, notificationSuccess: true }); + const [description, setDescription] = useState(""); + const [loading, setLoading] = useState(false); + const [error, setError] = useState(null); + const [success, setSuccess] = useState(false); + + const handleSubmit = async () => { + if (!description.trim()) { + setError("لطفاً توضیحات را وارد کنید"); + return; + } + + setLoading(true); + setError(null); + setSuccess(false); + + try { + const res = await requestServer(`${CONFIRM_VERIFY_ROAD_SAFETY_FORM}/${rowId}`, "post", { + data: { + expert_description: description, + }, + }); + + setSuccess(true); + mutate(); + setDescription(""); + handleClose(); + } catch (err) { + setError(err.message); + } finally { + setLoading(false); + } + }; + + return ( + + + {error && {error}} + {success && با موفقیت ثبت شد} + + setDescription(e.target.value)} + fullWidth + /> + + + + + ); +}; +export default ConfirmRoadSafetyFormContext; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/index.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/index.jsx index 213d593..2ad643d 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/ConfirmVerifyRoadSafetyForm/index.jsx @@ -1,51 +1,51 @@ -import { Close, DoneAll } from "@mui/icons-material"; -import { Dialog, IconButton, Stack, Tooltip } from "@mui/material"; -import { useState } from "react"; -import ConfirmRoadSafetyDialog from "./ConfirmRoadSafetyDialog"; - -const ConfirmVerifyRoadSafetyForm = ({ row, rowId, mutate }) => { - const [openConfirmVerifyRoadSafetyForm, setOpenConfirmVerifyRoadSafetyForm] = useState(false); - - const openConfirmVerifyRoadSafetyDialog = () => { - setOpenConfirmVerifyRoadSafetyForm(true); - }; - - const handleClose = () => { - setOpenConfirmVerifyRoadSafetyForm(false); - }; - - return ( - - - { - openConfirmVerifyRoadSafetyDialog(); - }} - > - - - - - handleClose()} - sx={{ - position: "absolute", - right: 8, - top: 8, - zIndex: 10, - color: (theme) => theme.palette.grey[500], - }} - > - - - {openConfirmVerifyRoadSafetyForm && ( - - )} - - - ); -}; -export default ConfirmVerifyRoadSafetyForm; +import { Close, DoneAll } from "@mui/icons-material"; +import { Dialog, IconButton, Stack, Tooltip } from "@mui/material"; +import { useState } from "react"; +import ConfirmRoadSafetyDialog from "./ConfirmRoadSafetyDialog"; + +const ConfirmVerifyRoadSafetyForm = ({ row, rowId, mutate }) => { + const [openConfirmVerifyRoadSafetyForm, setOpenConfirmVerifyRoadSafetyForm] = useState(false); + + const openConfirmVerifyRoadSafetyDialog = () => { + setOpenConfirmVerifyRoadSafetyForm(true); + }; + + const handleClose = () => { + setOpenConfirmVerifyRoadSafetyForm(false); + }; + + return ( + + + { + openConfirmVerifyRoadSafetyDialog(); + }} + > + + + + + handleClose()} + sx={{ + position: "absolute", + right: 8, + top: 8, + zIndex: 10, + color: (theme) => theme.palette.grey[500], + }} + > + + + {openConfirmVerifyRoadSafetyForm && ( + + )} + + + ); +}; +export default ConfirmVerifyRoadSafetyForm; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/History/HistoryContent.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/History/HistoryContent.jsx index 71f59c1..76fcbf0 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/History/HistoryContent.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/History/HistoryContent.jsx @@ -1,17 +1,17 @@ -import { Button, DialogActions, DialogContent } from "@mui/material"; -import TableContent from "./TableContent"; -const HistoryContent = ({ setOpenReferReasonDialog, rowId }) => { - return ( - <> - - - - - - - - ); -}; -export default HistoryContent; +import { Button, DialogActions, DialogContent } from "@mui/material"; +import TableContent from "./TableContent"; +const HistoryContent = ({ setOpenReferReasonDialog, rowId }) => { + return ( + <> + + + + + + + + ); +}; +export default HistoryContent; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/History/TableContent.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/History/TableContent.jsx index b405a41..be6e82b 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/History/TableContent.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/History/TableContent.jsx @@ -1,66 +1,66 @@ -import { - Box, - Table, - TableBody, - TableCell, - TableContainer, - TableHead, - TableRow, - CircularProgress, - Typography, -} from "@mui/material"; -import "moment/locale/fa"; -import { useHistory } from "@/lib/hooks/useHistory"; - -const TableContent = ({ rowId }) => { - const { historyData, loading, error } = useHistory(rowId); - - if (loading) { - return ( - - - - ); - } - - if (error) { - return ( - - {error} - - ); - } - - if (!historyData.length) { - return ( - - اطلاعاتی وجود ندارد - - ); - } - - return ( - - - - - - وضعیت - توضیحات کارشناس - - - - {historyData.map((row) => ( - - {row.previous_state_name} - {row.expert_description} - - ))} - -
-
-
- ); -}; - -export default TableContent; +import { + Box, + Table, + TableBody, + TableCell, + TableContainer, + TableHead, + TableRow, + CircularProgress, + Typography, +} from "@mui/material"; +import "moment/locale/fa"; +import { useHistory } from "@/lib/hooks/useHistory"; + +const TableContent = ({ rowId }) => { + const { historyData, loading, error } = useHistory(rowId); + + if (loading) { + return ( + + + + ); + } + + if (error) { + return ( + + {error} + + ); + } + + if (!historyData.length) { + return ( + + اطلاعاتی وجود ندارد + + ); + } + + return ( + + + + + + وضعیت + توضیحات کارشناس + + + + {historyData.map((row) => ( + + {row.previous_state_name} + {row.expert_description} + + ))} + +
+
+
+ ); +}; + +export default TableContent; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/History/index.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/History/index.jsx index 234ac15..cc3df74 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/History/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/History/index.jsx @@ -1,33 +1,33 @@ -import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; -import { RestorePage } from "@mui/icons-material"; -import HistoryContent from "./HistoryContent"; -import { useState } from "react"; - -const History = ({ rowId }) => { - const [openReferReasonDialog, setOpenReferReasonDialog] = useState(false); - - return ( - <> - - setOpenReferReasonDialog(true)}> - - - - - تاریخچه - - - - ); -}; - -export default History; +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { RestorePage } from "@mui/icons-material"; +import HistoryContent from "./HistoryContent"; +import { useState } from "react"; + +const History = ({ rowId }) => { + const [openReferReasonDialog, setOpenReferReasonDialog] = useState(false); + + return ( + <> + + setOpenReferReasonDialog(true)}> + + + + + تاریخچه + + + + ); +}; + +export default History; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/index.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/index.jsx index 757d292..d10ff67 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/index.jsx @@ -1,23 +1,23 @@ -import { Box } from "@mui/material"; -import ConfirmRoadSafetyForm from "./ConfirmRoadSafetyForm"; -import ConfirmVerifyRoadSafetyForm from "./ConfirmVerifyRoadSafetyForm"; -import ConfirmVerifyLicenseForm from "./ConfirmVerifyLicenseForm"; -import History from "./History"; - -const RowActions = ({ row, mutate }) => { - return ( - - - {row.original.state_id == 3 && ( - - )} - {row.original.state_id == 6 && ( - - )} - {row.original.state_id == 14 && ( - - )} - - ); -}; -export default RowActions; +import { Box } from "@mui/material"; +import ConfirmRoadSafetyForm from "./ConfirmRoadSafetyForm"; +import ConfirmVerifyRoadSafetyForm from "./ConfirmVerifyRoadSafetyForm"; +import ConfirmVerifyLicenseForm from "./ConfirmVerifyLicenseForm"; +import History from "./History"; + +const RowActions = ({ row, mutate }) => { + return ( + + + {row.original.state_id == 3 && ( + + )} + {row.original.state_id == 6 && ( + + )} + {row.original.state_id == 14 && ( + + )} + + ); +}; +export default RowActions; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/ShowProjectArea/ShowBound.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/ShowProjectArea/ShowBound.jsx index 24db476..43dd0b8 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/ShowProjectArea/ShowBound.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/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/dashboard/inquiryPrivacy/technical-deputy/ShowProjectArea/ShowForbiddenBound.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/ShowProjectArea/ShowForbiddenBound.jsx index c8d28d1..6631907 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/ShowProjectArea/ShowForbiddenBound.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/ShowProjectArea/ShowForbiddenBound.jsx @@ -1,29 +1,29 @@ -import { useEffect, useRef } from "react"; -import { FeatureGroup, useMap } from "react-leaflet"; - -const ShowForbiddenBound = ({ 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 ShowForbiddenBound; +import { useEffect, useRef } from "react"; +import { FeatureGroup, useMap } from "react-leaflet"; + +const ShowForbiddenBound = ({ 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 ShowForbiddenBound; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/ShowProjectArea/index.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/ShowProjectArea/index.jsx index e7386fc..e7dc4d2 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/ShowProjectArea/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/ShowProjectArea/index.jsx @@ -1,71 +1,71 @@ -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"; -import ShowForbiddenBound from "./ShowForbiddenBound"; - -const ShowProjectArea = ({ primaryArea, forbiddenArea }) => { - const [openShowAreaDialog, setOpenShowAreaDialog] = useState(false); - const bound = useMemo(() => { - const latLngCoords = primaryArea.coordinates.map((coord) => [coord[1], coord[0]]); - return primaryArea.type === "polygon" - ? L.polygon(latLngCoords, { - color: "#ff5555", - }) - : L.polyline(latLngCoords); - }, [primaryArea]); - - const forbiddenBound = useMemo(() => { - const latLngCoords = forbiddenArea.coordinates.map((coord) => [coord[1], coord[0]]); - return forbiddenArea.type === "polygon" ? L.polygon(latLngCoords) : L.polyline(latLngCoords); - }, [forbiddenArea]); - - return ( - - - setOpenShowAreaDialog(true)}> - - - - setOpenShowAreaDialog(false)} - PaperProps={{ - sx: { - transition: "all .3s", - boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px", - borderRadius: 2, - padding: 1, - }, - }} - maxWidth="sm" - fullWidth - dir="rtl" - > - - - محدوده طرح - - setOpenShowAreaDialog(false)} size="small"> - - - - - - - - - - - - - - - - ); -}; - -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"; +import ShowForbiddenBound from "./ShowForbiddenBound"; + +const ShowProjectArea = ({ primaryArea, forbiddenArea }) => { + const [openShowAreaDialog, setOpenShowAreaDialog] = useState(false); + const bound = useMemo(() => { + const latLngCoords = primaryArea.coordinates.map((coord) => [coord[1], coord[0]]); + return primaryArea.type === "polygon" + ? L.polygon(latLngCoords, { + color: "#ff5555", + }) + : L.polyline(latLngCoords); + }, [primaryArea]); + + const forbiddenBound = useMemo(() => { + const latLngCoords = forbiddenArea.coordinates.map((coord) => [coord[1], coord[0]]); + return forbiddenArea.type === "polygon" ? L.polygon(latLngCoords) : L.polyline(latLngCoords); + }, [forbiddenArea]); + + return ( + + + setOpenShowAreaDialog(true)}> + + + + setOpenShowAreaDialog(false)} + PaperProps={{ + sx: { + transition: "all .3s", + boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px", + borderRadius: 2, + padding: 1, + }, + }} + maxWidth="sm" + fullWidth + dir="rtl" + > + + + محدوده طرح + + setOpenShowAreaDialog(false)} size="small"> + + + + + + + + + + + + + + + + ); +}; + +export default ShowProjectArea; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/TechnicalDeputyList.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/TechnicalDeputyList.jsx index cb3a82f..f84de98 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/TechnicalDeputyList.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/TechnicalDeputyList.jsx @@ -1,216 +1,216 @@ -"use client"; - -import DataTableWithAuth from "@/core/components/DataTableWithAuth"; -import { GET_INQUIRY_PRIVACY_TABLE_LIST } from "@/core/utils/routes"; -import { Box, Stack } from "@mui/material"; -import moment from "jalali-moment"; -import { useMemo } from "react"; -import RowActions from "./RowActions"; -import ShowProjectArea from "./ShowProjectArea"; - -const TechnicalDeputyList = () => { - const columns = useMemo( - () => [ - { - accessorKey: "id", - header: "کد یکتا", - id: "id", - enableColumnFilter: false, - datatype: "text", - filterMode: "notEquals", - size: 100, - }, - { - accessorKey: "panjare_vahed_id", - header: "کدرهگیری پنجره واحد", - id: "panjare_vahed_id", - enableColumnFilter: true, - datatype: "text", - filterMode: "equals", - sortDescFirst: false, - columnFilterModeOptions: ["equals", "contains"], - grow: false, - size: 150, - }, - { - accessorKey: "national_id", - header: "کد ملی", - id: "national_id", - enableColumnFilter: true, - datatype: "text", - filterMode: "equals", - sortDescFirst: false, - columnFilterModeOptions: ["equals", "contains"], - size: 120, - }, - { - accessorKey: "phone_number", - header: "تلفن", - id: "phone_number", - enableColumnFilter: true, - datatype: "text", - filterMode: "equals", - size: 120, - }, - { - accessorKey: "state_name", - header: "وضعیت درخواست", - id: "state_name", - enableColumnFilter: false, - datatype: "text", - filterMode: "equals", - }, - { - accessorKey: "payment_amount", - header: "مبلغ پرداختی", - id: "payment_amount", - enableColumnFilter: true, - datatype: "text", - filterMode: "between", - Cell: ({ row }) => <>{row.original.payment_amount || "-"}, - }, - { - accessorKey: "requested_organization", - header: "دستگاه صادر کننده", - id: "requested_organization", - enableColumnFilter: true, - datatype: "text", - filterMode: "equals", - sortDescFirst: false, - columnFilterModeOptions: ["equals", "contains"], - }, - { - accessorKey: "province_name", - header: "استان", - id: "province_name", - enableColumnFilter: false, - datatype: "text", - filterMode: "equals", - }, - { - accessorKey: "city_name", - header: "شهر", - id: "city_name", - enableColumnFilter: false, - datatype: "text", - filterMode: "equals", - }, - { - accessorKey: "plan_group", - header: "گروه طرح", - id: "plan_group", - enableColumnFilter: true, - datatype: "text", - filterMode: "equals", - sortDescFirst: false, - columnFilterModeOptions: ["equals", "contains"], - }, - { - accessorKey: "plan_title", - header: "عنوان طرح", - id: "plan_title", - enableColumnFilter: true, - datatype: "text", - filterMode: "equals", - sortDescFirst: false, - columnFilterModeOptions: ["equals", "contains"], - }, - { - accessorKey: "primary_area", - header: "نمایش محدوده طرح", - id: "primary_area", - enableColumnFilter: true, - datatype: "text", - filterMode: "equals", - sortDescFirst: false, - columnFilterModeOptions: ["equals", "contains"], - grow: false, - size: 100, - Cell: ({ row }) => - row.original.primary_area && row.original.forbidden_area ? ( - - - - ) : ( - "-" - ), - }, - { - accessorKey: "final_area", - header: "نمایش محدوده عرصه و اعیان", - id: "final_area", - enableColumnFilter: true, - datatype: "text", - filterMode: "equals", - sortDescFirst: false, - columnFilterModeOptions: ["equals", "contains"], - grow: false, - size: 100, - Cell: ({ row }) => - row.original.final_area && row.original.final_plan ? ( - - - - ) : ( - "-" - ), - }, - { - accessorKey: "worksheet_id", - header: "شناسه کاربرگ", - id: "worksheet_id", - enableColumnFilter: true, - datatype: "text", - filterMode: "equals", - sortDescFirst: false, - columnFilterModeOptions: ["equals", "contains"], - }, - { - accessorKey: "isic", - header: "کد آیسیک", - id: "isic", - enableColumnFilter: true, - datatype: "text", - filterMode: "equals", - sortDescFirst: false, - columnFilterModeOptions: ["equals", "contains"], - }, - { - accessorFn: (row) => moment(row.request_date).locale("fa").format("YYYY/MM/DD"), - header: "تاریخ درخواست", - id: "request_date", - enableColumnFilter: true, - datatype: "date", - filterMode: "between", - grow: false, - size: 120, - }, - ], - [] - ); - - return ( - <> - - - - - ); -}; -export default TechnicalDeputyList; +"use client"; + +import DataTableWithAuth from "@/core/components/DataTableWithAuth"; +import { GET_INQUIRY_PRIVACY_TABLE_LIST } from "@/core/utils/routes"; +import { Box, Stack } from "@mui/material"; +import moment from "jalali-moment"; +import { useMemo } from "react"; +import RowActions from "./RowActions"; +import ShowProjectArea from "./ShowProjectArea"; + +const TechnicalDeputyList = () => { + const columns = useMemo( + () => [ + { + accessorKey: "id", + header: "کد یکتا", + id: "id", + enableColumnFilter: false, + datatype: "text", + filterMode: "notEquals", + size: 100, + }, + { + accessorKey: "panjare_vahed_id", + header: "کدرهگیری پنجره واحد", + id: "panjare_vahed_id", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 150, + }, + { + accessorKey: "national_id", + header: "کد ملی", + id: "national_id", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + size: 120, + }, + { + accessorKey: "phone_number", + header: "تلفن", + id: "phone_number", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + size: 120, + }, + { + accessorKey: "state_name", + header: "وضعیت درخواست", + id: "state_name", + enableColumnFilter: false, + datatype: "text", + filterMode: "equals", + }, + { + accessorKey: "payment_amount", + header: "مبلغ پرداختی", + id: "payment_amount", + enableColumnFilter: true, + datatype: "text", + filterMode: "between", + Cell: ({ row }) => <>{row.original.payment_amount || "-"}, + }, + { + accessorKey: "requested_organization", + header: "دستگاه صادر کننده", + id: "requested_organization", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + }, + { + accessorKey: "province_name", + header: "استان", + id: "province_name", + enableColumnFilter: false, + datatype: "text", + filterMode: "equals", + }, + { + accessorKey: "city_name", + header: "شهر", + id: "city_name", + enableColumnFilter: false, + datatype: "text", + filterMode: "equals", + }, + { + accessorKey: "plan_group", + header: "گروه طرح", + id: "plan_group", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + }, + { + accessorKey: "plan_title", + header: "عنوان طرح", + id: "plan_title", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + }, + { + accessorKey: "primary_area", + header: "نمایش محدوده طرح", + id: "primary_area", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ row }) => + row.original.primary_area && row.original.forbidden_area ? ( + + + + ) : ( + "-" + ), + }, + { + accessorKey: "final_area", + header: "نمایش محدوده عرصه و اعیان", + id: "final_area", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + Cell: ({ row }) => + row.original.final_area && row.original.final_plan ? ( + + + + ) : ( + "-" + ), + }, + { + accessorKey: "worksheet_id", + header: "شناسه کاربرگ", + id: "worksheet_id", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + }, + { + accessorKey: "isic", + header: "کد آیسیک", + id: "isic", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + }, + { + accessorFn: (row) => moment(row.request_date).locale("fa").format("YYYY/MM/DD"), + header: "تاریخ درخواست", + id: "request_date", + enableColumnFilter: true, + datatype: "date", + filterMode: "between", + grow: false, + size: 120, + }, + ], + [] + ); + + return ( + <> + + + + + ); +}; +export default TechnicalDeputyList; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/index.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/index.jsx index 2b9a26a..17fdafd 100644 --- a/src/components/dashboard/inquiryPrivacy/technical-deputy/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/index.jsx @@ -1,15 +1,15 @@ -"use client"; - -import PageTitle from "@/core/components/PageTitle"; -import { Stack } from "@mui/material"; -import TechnicalDeputyList from "./TechnicalDeputyList"; - -const TechnicalDeputy = () => { - return ( - - - - - ); -}; -export default TechnicalDeputy; +"use client"; + +import PageTitle from "@/core/components/PageTitle"; +import { Stack } from "@mui/material"; +import TechnicalDeputyList from "./TechnicalDeputyList"; + +const TechnicalDeputy = () => { + return ( + + + + + ); +}; +export default TechnicalDeputy; diff --git a/src/components/dashboard/rahdaran/Actions/Create/Form/CityContent.jsx b/src/components/dashboard/rahdaran/Actions/Create/Form/CityContent.jsx index dda1d0e..c70f208 100644 --- a/src/components/dashboard/rahdaran/Actions/Create/Form/CityContent.jsx +++ b/src/components/dashboard/rahdaran/Actions/Create/Form/CityContent.jsx @@ -1,39 +1,39 @@ -import SelectBox from "@/core/components/SelectBox"; -import useEdaratLists from "@/lib/hooks/useEdaratLists"; -import { useEffect, useState } from "react"; - -const CityContent = ({ provinceID, field, fieldState: { error } }) => { - const { edaratList, loadingEdaratList, errorEdaratList } = useEdaratLists(provinceID); - const [prevDependency, setPrevDependency] = useState(provinceID); - - useEffect(() => { - if (prevDependency === provinceID) return; - field.onChange(null); - setPrevDependency(provinceID); - }, [provinceID]); - - return ( - - ); -}; -export default CityContent; +import SelectBox from "@/core/components/SelectBox"; +import useEdaratLists from "@/lib/hooks/useEdaratLists"; +import { useEffect, useState } from "react"; + +const CityContent = ({ provinceID, field, fieldState: { error } }) => { + const { edaratList, loadingEdaratList, errorEdaratList } = useEdaratLists(provinceID); + const [prevDependency, setPrevDependency] = useState(provinceID); + + useEffect(() => { + if (prevDependency === provinceID) return; + field.onChange(null); + setPrevDependency(provinceID); + }, [provinceID]); + + return ( + + ); +}; +export default CityContent; diff --git a/src/components/dashboard/rahdaran/Actions/Create/Form/CityController.jsx b/src/components/dashboard/rahdaran/Actions/Create/Form/CityController.jsx index cd9bc1c..c05d2c0 100644 --- a/src/components/dashboard/rahdaran/Actions/Create/Form/CityController.jsx +++ b/src/components/dashboard/rahdaran/Actions/Create/Form/CityController.jsx @@ -1,14 +1,14 @@ -import { Controller, useWatch } from "react-hook-form"; -import CityContent from "./CityContent"; - -const CityController = ({ control }) => { - const provinceID = useWatch({ control, name: "provinceId" }); - return ( - } - /> - ); -}; -export default CityController; +import { Controller, useWatch } from "react-hook-form"; +import CityContent from "./CityContent"; + +const CityController = ({ control }) => { + const provinceID = useWatch({ control, name: "provinceId" }); + return ( + } + /> + ); +}; +export default CityController; diff --git a/src/components/dashboard/rahdaran/Actions/Create/Form/CreateFormContent.jsx b/src/components/dashboard/rahdaran/Actions/Create/Form/CreateFormContent.jsx index f5a6bb1..b42727e 100644 --- a/src/components/dashboard/rahdaran/Actions/Create/Form/CreateFormContent.jsx +++ b/src/components/dashboard/rahdaran/Actions/Create/Form/CreateFormContent.jsx @@ -1,183 +1,183 @@ -import PersianTextField from "@/core/components/PersianTextField"; -import StyledForm from "@/core/components/StyledForm"; -import validateNationalCode from "@/core/utils/nationalCodeValidation"; -import { yupResolver } from "@hookform/resolvers/yup"; -import { Beenhere, ExitToApp } from "@mui/icons-material"; -import { - Button, - DialogActions, - DialogContent, - Grid, - Stack, - TextField, - ToggleButton, - ToggleButtonGroup, -} from "@mui/material"; -import { Controller, useForm } from "react-hook-form"; -import { object, string } from "yup"; -import LogesticController from "./LogesticController"; - -const validationSchema = object({ - provinceId: string().required("لطفا استان را وارد کنید!!!"), - edarehShahriId: string().required("لطفا اداره را وارد کنید!!!"), - name: string().required("وارد کردن نام و نام خانوادگی الزامیست!"), - code: string() - .required("لطفا کد ملی را وارد کنید!!!") - .test("max", "کد ملی باید شامل 10 رقم باشد", (value) => value.toString().length === 10) - .test("validation", "کد ملی صحیح نمی باشد", (value) => validateNationalCode(value)), - phone_number: string() - .matches(/^09\d{9}$/, "شماره موبایل باید با 09 شروع شده و 11 رقم باشد") - .required("لطفا تلفن همراه را وارد کنید!!!"), -}); - -const CreateFormContent = ({ setOpen, defaultValues, onSubmitBase }) => { - const { - control, - handleSubmit, - formState: { isSubmitting }, - } = useForm({ - defaultValues, - resolver: yupResolver(validationSchema), - mode: "all", - }); - const handleOnSubmit = async (data) => { - await onSubmitBase(data); - }; - - return ( - <> - - - - {/* - ( - { - if (newAlignment !== null) { - field.onChange(newAlignment); - } - }} - > - - راهدار - - - راننده - - - )} - /> - */} - - - - - ( - - )} - /> - - - - - - - ( - - )} - /> - - - - - - - ( - { - const inputValue = event.target.value; - if (isNaN(Number(inputValue))) { - return; - } - field.onChange(inputValue); - }} - label="شماره همراه" - placeholder={"شماره همراه را وارد کنید"} - fullWidth - size="small" - error={error} - helperText={error?.message} - InputLabelProps={{ shrink: true }} - /> - )} - /> - - - - - - - - - - - - ); -}; -export default CreateFormContent; +import PersianTextField from "@/core/components/PersianTextField"; +import StyledForm from "@/core/components/StyledForm"; +import validateNationalCode from "@/core/utils/nationalCodeValidation"; +import { yupResolver } from "@hookform/resolvers/yup"; +import { Beenhere, ExitToApp } from "@mui/icons-material"; +import { + Button, + DialogActions, + DialogContent, + Grid, + Stack, + TextField, + ToggleButton, + ToggleButtonGroup, +} from "@mui/material"; +import { Controller, useForm } from "react-hook-form"; +import { object, string } from "yup"; +import LogesticController from "./LogesticController"; + +const validationSchema = object({ + provinceId: string().required("لطفا استان را وارد کنید!!!"), + edarehShahriId: string().required("لطفا اداره را وارد کنید!!!"), + name: string().required("وارد کردن نام و نام خانوادگی الزامیست!"), + code: string() + .required("لطفا کد ملی را وارد کنید!!!") + .test("max", "کد ملی باید شامل 10 رقم باشد", (value) => value.toString().length === 10) + .test("validation", "کد ملی صحیح نمی باشد", (value) => validateNationalCode(value)), + phone_number: string() + .matches(/^09\d{9}$/, "شماره موبایل باید با 09 شروع شده و 11 رقم باشد") + .required("لطفا تلفن همراه را وارد کنید!!!"), +}); + +const CreateFormContent = ({ setOpen, defaultValues, onSubmitBase }) => { + const { + control, + handleSubmit, + formState: { isSubmitting }, + } = useForm({ + defaultValues, + resolver: yupResolver(validationSchema), + mode: "all", + }); + const handleOnSubmit = async (data) => { + await onSubmitBase(data); + }; + + return ( + <> + + + + {/* + ( + { + if (newAlignment !== null) { + field.onChange(newAlignment); + } + }} + > + + راهدار + + + راننده + + + )} + /> + */} + + + + + ( + + )} + /> + + + + + + + ( + + )} + /> + + + + + + + ( + { + const inputValue = event.target.value; + if (isNaN(Number(inputValue))) { + return; + } + field.onChange(inputValue); + }} + label="شماره همراه" + placeholder={"شماره همراه را وارد کنید"} + fullWidth + size="small" + error={error} + helperText={error?.message} + InputLabelProps={{ shrink: true }} + /> + )} + /> + + + + + + + + + + + + ); +}; +export default CreateFormContent; diff --git a/src/components/dashboard/rahdaran/Actions/Create/Form/LogesticController.jsx b/src/components/dashboard/rahdaran/Actions/Create/Form/LogesticController.jsx index c05aab3..69ea8ca 100644 --- a/src/components/dashboard/rahdaran/Actions/Create/Form/LogesticController.jsx +++ b/src/components/dashboard/rahdaran/Actions/Create/Form/LogesticController.jsx @@ -1,42 +1,42 @@ -import { Grid, Stack } from "@mui/material"; -import CityController from "./CityController"; -import useProvinces from "@/lib/hooks/useProvince"; -import { Controller, useWatch } from "react-hook-form"; -import SelectBox from "@/core/components/SelectBox"; - -const LogesticController = ({ control }) => { - const { provinces, errorProvinces, loadingProvinces } = useProvinces(); - const isProvince = useWatch({ control, name: "isProvince" }); - return ( - <> - {!isProvince ? ( - - { - return ( - - ); - }} - /> - - ) : null} - - - - - ); -}; -export default LogesticController; +import { Grid, Stack } from "@mui/material"; +import CityController from "./CityController"; +import useProvinces from "@/lib/hooks/useProvince"; +import { Controller, useWatch } from "react-hook-form"; +import SelectBox from "@/core/components/SelectBox"; + +const LogesticController = ({ control }) => { + const { provinces, errorProvinces, loadingProvinces } = useProvinces(); + const isProvince = useWatch({ control, name: "isProvince" }); + return ( + <> + {!isProvince ? ( + + { + return ( + + ); + }} + /> + + ) : null} + + + + + ); +}; +export default LogesticController; diff --git a/src/components/dashboard/rahdaran/Actions/Create/Form/index.jsx b/src/components/dashboard/rahdaran/Actions/Create/Form/index.jsx index 79ef047..08fbd66 100644 --- a/src/components/dashboard/rahdaran/Actions/Create/Form/index.jsx +++ b/src/components/dashboard/rahdaran/Actions/Create/Form/index.jsx @@ -1,72 +1,72 @@ -import { CREATE_RAHDARAN_ITEM } from "@/core/utils/routes"; -import { useAuth } from "@/lib/contexts/auth"; -import { usePermissions } from "@/lib/hooks/usePermissions"; -import useRequest from "@/lib/hooks/useRequest"; -import CloseIcon from "@mui/icons-material/Close"; -import { Dialog, DialogTitle, IconButton } from "@mui/material"; -import { DialogHeader } from "next/dist/client/components/react-dev-overlay/internal/components/Dialog"; -import CreateFormContent from "./CreateFormContent"; - -const CreateForm = ({ open, setOpen, mutate }) => { - const requestServer = useRequest({ notificationSuccess: true }); - const { data: userPermissions } = usePermissions(); - const { user } = useAuth(); - const hasCountryPermission = userPermissions?.includes("manage-rahdaran-country"); - - const defaultValues = { - isDriver: "0", - isProvince: !hasCountryPermission, - provinceId: !hasCountryPermission ? user.province_id : "", - edarehShahriId: "", - name: "", - code: "", - phone_number: "", - }; - const onSubmit = async (result) => { - const formData = new FormData(); - formData.append("is_driver", result.isDriver); - formData.append("province_id", result.provinceId); - formData.append("edareh_shahri_id", result.edarehShahriId); - formData.append("name", result.name); - formData.append("code", result.code); - formData.append("mobile", result.phone_number); - - await requestServer(CREATE_RAHDARAN_ITEM, "post", { - data: formData, - }) - .then(() => { - mutate(); - setOpen(false); - }) - .catch(() => {}); - }; - return ( - - setOpen(false)} - sx={(theme) => ({ - position: "absolute", - right: 8, - top: 8, - zIndex: 50, - color: theme.palette.grey[500], - })} - > - - - - ثبت راهدار جدید - - {open && ( - - )} - - ); -}; -export default CreateForm; +import { CREATE_RAHDARAN_ITEM } from "@/core/utils/routes"; +import { useAuth } from "@/lib/contexts/auth"; +import { usePermissions } from "@/lib/hooks/usePermissions"; +import useRequest from "@/lib/hooks/useRequest"; +import CloseIcon from "@mui/icons-material/Close"; +import { Dialog, DialogTitle, IconButton } from "@mui/material"; +import { DialogHeader } from "next/dist/client/components/react-dev-overlay/internal/components/Dialog"; +import CreateFormContent from "./CreateFormContent"; + +const CreateForm = ({ open, setOpen, mutate }) => { + const requestServer = useRequest({ notificationSuccess: true }); + const { data: userPermissions } = usePermissions(); + const { user } = useAuth(); + const hasCountryPermission = userPermissions?.includes("manage-rahdaran-country"); + + const defaultValues = { + isDriver: "0", + isProvince: !hasCountryPermission, + provinceId: !hasCountryPermission ? user.province_id : "", + edarehShahriId: "", + name: "", + code: "", + phone_number: "", + }; + const onSubmit = async (result) => { + const formData = new FormData(); + formData.append("is_driver", result.isDriver); + formData.append("province_id", result.provinceId); + formData.append("edareh_shahri_id", result.edarehShahriId); + formData.append("name", result.name); + formData.append("code", result.code); + formData.append("mobile", result.phone_number); + + await requestServer(CREATE_RAHDARAN_ITEM, "post", { + data: formData, + }) + .then(() => { + mutate(); + setOpen(false); + }) + .catch(() => {}); + }; + return ( + + setOpen(false)} + sx={(theme) => ({ + position: "absolute", + right: 8, + top: 8, + zIndex: 50, + color: theme.palette.grey[500], + })} + > + + + + ثبت راهدار جدید + + {open && ( + + )} + + ); +}; +export default CreateForm; diff --git a/src/components/dashboard/rahdaran/Actions/Create/index.jsx b/src/components/dashboard/rahdaran/Actions/Create/index.jsx index 8417fd5..0c75cdc 100644 --- a/src/components/dashboard/rahdaran/Actions/Create/index.jsx +++ b/src/components/dashboard/rahdaran/Actions/Create/index.jsx @@ -1,36 +1,36 @@ -import { AddCircle } from "@mui/icons-material"; -import { Button, IconButton, useMediaQuery, useTheme } from "@mui/material"; -import CreateForm from "./Form"; -import { useState } from "react"; - -const CreateRahdar = ({ mutate }) => { - const theme = useTheme(); - const isMobile = useMediaQuery(theme.breakpoints.down("sm")); - const [open, setOpen] = useState(false); - - const handleOpen = () => { - setOpen(true); - }; - - return ( - <> - {isMobile ? ( - - - - ) : ( - - )} - - - ); -}; -export default CreateRahdar; +import { AddCircle } from "@mui/icons-material"; +import { Button, IconButton, useMediaQuery, useTheme } from "@mui/material"; +import CreateForm from "./Form"; +import { useState } from "react"; + +const CreateRahdar = ({ mutate }) => { + const theme = useTheme(); + const isMobile = useMediaQuery(theme.breakpoints.down("sm")); + const [open, setOpen] = useState(false); + + const handleOpen = () => { + setOpen(true); + }; + + return ( + <> + {isMobile ? ( + + + + ) : ( + + )} + + + ); +}; +export default CreateRahdar; diff --git a/src/components/dashboard/rahdaran/Actions/Edit/EditController.jsx b/src/components/dashboard/rahdaran/Actions/Edit/EditController.jsx index 8d6903e..0813975 100644 --- a/src/components/dashboard/rahdaran/Actions/Edit/EditController.jsx +++ b/src/components/dashboard/rahdaran/Actions/Edit/EditController.jsx @@ -1,45 +1,45 @@ -import { UPDATE_RAHDARAN_ITEM } from "@/core/utils/routes"; -import useRequest from "@/lib/hooks/useRequest"; -import { DialogTitle } from "@mui/material"; -import { DialogHeader } from "next/dist/client/components/react-dev-overlay/internal/components/Dialog"; -import CreateFormContent from "../Create/Form/CreateFormContent"; - -const EditController = ({ rowId, mutate, setOpen, row }) => { - const requestServer = useRequest({ notificationSuccess: true }); - - const defaultData = { - isDriver: `${row.original?.is_driver}` || "0", - provinceId: row.original?.province_id || "", - edarehShahriId: row.original?.edareh_shahri_id || "", - name: row.original?.name || "", - code: row.original?.code || "", - phone_number: row.original?.mobile || "", - }; - const handleSubmit = async (result) => { - const formData = new FormData(); - formData.append("is_driver", result.isDriver); - formData.append("province_id", result.provinceId); - formData.append("edareh_shahri_id", result.edarehShahriId); - formData.append("name", result.name); - formData.append("code", result.code); - formData.append("mobile", result.phone_number); - - await requestServer(`${UPDATE_RAHDARAN_ITEM}/${rowId}`, "post", { - data: formData, - }) - .then(() => { - mutate(); - setOpen(false); - }) - .catch(() => {}); - }; - return ( - <> - - ویرایش راهدار - - - - ); -}; -export default EditController; +import { UPDATE_RAHDARAN_ITEM } from "@/core/utils/routes"; +import useRequest from "@/lib/hooks/useRequest"; +import { DialogTitle } from "@mui/material"; +import { DialogHeader } from "next/dist/client/components/react-dev-overlay/internal/components/Dialog"; +import CreateFormContent from "../Create/Form/CreateFormContent"; + +const EditController = ({ rowId, mutate, setOpen, row }) => { + const requestServer = useRequest({ notificationSuccess: true }); + + const defaultData = { + isDriver: `${row.original?.is_driver}` || "0", + provinceId: row.original?.province_id || "", + edarehShahriId: row.original?.edareh_shahri_id || "", + name: row.original?.name || "", + code: row.original?.code || "", + phone_number: row.original?.mobile || "", + }; + const handleSubmit = async (result) => { + const formData = new FormData(); + formData.append("is_driver", result.isDriver); + formData.append("province_id", result.provinceId); + formData.append("edareh_shahri_id", result.edarehShahriId); + formData.append("name", result.name); + formData.append("code", result.code); + formData.append("mobile", result.phone_number); + + await requestServer(`${UPDATE_RAHDARAN_ITEM}/${rowId}`, "post", { + data: formData, + }) + .then(() => { + mutate(); + setOpen(false); + }) + .catch(() => {}); + }; + return ( + <> + + ویرایش راهدار + + + + ); +}; +export default EditController; diff --git a/src/components/dashboard/rahdaran/Actions/Edit/index.jsx b/src/components/dashboard/rahdaran/Actions/Edit/index.jsx index 2a47c4c..eb86d89 100644 --- a/src/components/dashboard/rahdaran/Actions/Edit/index.jsx +++ b/src/components/dashboard/rahdaran/Actions/Edit/index.jsx @@ -1,51 +1,51 @@ -import BorderColorIcon from "@mui/icons-material/BorderColor"; -import CloseIcon from "@mui/icons-material/Close"; -import { Dialog, IconButton, Tooltip } from "@mui/material"; -import { useState } from "react"; -import EditController from "./EditController"; - -const EditRahdar = ({ mutate, row, rowId }) => { - const [open, setOpen] = useState(false); - - return ( - <> - - { - setOpen(true); - }} - > - - - - - setOpen(false)} - sx={(theme) => ({ - position: "absolute", - right: 8, - top: 8, - zIndex: 50, - color: theme.palette.grey[500], - })} - > - - - {open && } - - - ); -}; -export default EditRahdar; +import BorderColorIcon from "@mui/icons-material/BorderColor"; +import CloseIcon from "@mui/icons-material/Close"; +import { Dialog, IconButton, Tooltip } from "@mui/material"; +import { useState } from "react"; +import EditController from "./EditController"; + +const EditRahdar = ({ mutate, row, rowId }) => { + const [open, setOpen] = useState(false); + + return ( + <> + + { + setOpen(true); + }} + > + + + + + setOpen(false)} + sx={(theme) => ({ + position: "absolute", + right: 8, + top: 8, + zIndex: 50, + color: theme.palette.grey[500], + })} + > + + + {open && } + + + ); +}; +export default EditRahdar; diff --git a/src/components/dashboard/rahdaran/RahdaranList.jsx b/src/components/dashboard/rahdaran/RahdaranList.jsx index ad24f23..9373aa9 100644 --- a/src/components/dashboard/rahdaran/RahdaranList.jsx +++ b/src/components/dashboard/rahdaran/RahdaranList.jsx @@ -1,181 +1,181 @@ -"use client"; -import DataTableWithAuth from "@/core/components/DataTableWithAuth"; -import { GET_RAHDARAN_TABLE_LIST } from "@/core/utils/routes"; -import { Box } from "@mui/material"; -import { useEffect, useMemo, useState } from "react"; -import RowActions from "./RowActions"; -import Toolbar from "./Toolbar"; -import { useAuth } from "@/lib/contexts/auth"; -import useProvinces from "@/lib/hooks/useProvince"; -import CustomSelectByDependency from "@/core/components/DataTable/filter/fieldsType/CustomSelectByDependency"; -import useEdaratLists from "@/lib/hooks/useEdaratLists"; -import { usePermissions } from "@/lib/hooks/usePermissions"; - -const RahdaranList = () => { - const { data: userPermissions } = usePermissions(); - const { user } = useAuth(); - const hasCountryPermission = userPermissions?.includes("manage-rahdaran-country"); - const columns = useMemo(() => { - const provinceColumn = { - accessorKey: "province_id", - header: "استان", - id: "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_name}, - }; - return [ - { - accessorKey: "id", - header: "کد یکتا", - id: "id", - enableColumnFilter: true, - datatype: "text", - filterMode: "equals", - sortDescFirst: false, - columnFilterModeOptions: ["equals", "contains"], - grow: false, - size: 100, - }, - ...(hasCountryPermission ? [provinceColumn] : []), - { - header: "اداره", - id: "edareh_shahri_id", - enableColumnFilter: true, - datatype: "numeric", - filterMode: "equals", - dependencyId: hasCountryPermission ? "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: ({ renderedCellValue, row }) => <>{row.original.edareh_shahri_name}, - }, - { - accessorKey: "name", - header: "نام و نام خانوادگی", - id: "name", - enableColumnFilter: true, - datatype: "text", - filterMode: "equals", - columnFilterModeOptions: ["equals", "contains"], - grow: false, - size: 100, - }, - { - accessorKey: "code", - header: "کد ملی", - id: "code", - enableColumnFilter: true, - datatype: "text", - filterMode: "equals", - columnFilterModeOptions: ["equals", "contains"], - grow: false, - size: 100, - }, - { - accessorKey: "mobile", - header: "شماره همراه", - id: "mobile", - enableColumnFilter: true, - datatype: "text", - filterMode: "equals", - columnFilterModeOptions: ["equals", "contains"], - grow: false, - size: 100, - }, - ]; - }, []); - - return ( - <> - - - - - ); -}; -export default RahdaranList; +"use client"; +import DataTableWithAuth from "@/core/components/DataTableWithAuth"; +import { GET_RAHDARAN_TABLE_LIST } from "@/core/utils/routes"; +import { Box } from "@mui/material"; +import { useEffect, useMemo, useState } from "react"; +import RowActions from "./RowActions"; +import Toolbar from "./Toolbar"; +import { useAuth } from "@/lib/contexts/auth"; +import useProvinces from "@/lib/hooks/useProvince"; +import CustomSelectByDependency from "@/core/components/DataTable/filter/fieldsType/CustomSelectByDependency"; +import useEdaratLists from "@/lib/hooks/useEdaratLists"; +import { usePermissions } from "@/lib/hooks/usePermissions"; + +const RahdaranList = () => { + const { data: userPermissions } = usePermissions(); + const { user } = useAuth(); + const hasCountryPermission = userPermissions?.includes("manage-rahdaran-country"); + const columns = useMemo(() => { + const provinceColumn = { + accessorKey: "province_id", + header: "استان", + id: "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_name}, + }; + return [ + { + accessorKey: "id", + header: "کد یکتا", + id: "id", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + }, + ...(hasCountryPermission ? [provinceColumn] : []), + { + header: "اداره", + id: "edareh_shahri_id", + enableColumnFilter: true, + datatype: "numeric", + filterMode: "equals", + dependencyId: hasCountryPermission ? "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: ({ renderedCellValue, row }) => <>{row.original.edareh_shahri_name}, + }, + { + accessorKey: "name", + header: "نام و نام خانوادگی", + id: "name", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + }, + { + accessorKey: "code", + header: "کد ملی", + id: "code", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + }, + { + accessorKey: "mobile", + header: "شماره همراه", + id: "mobile", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + }, + ]; + }, []); + + return ( + <> + + + + + ); +}; +export default RahdaranList; diff --git a/src/components/dashboard/rahdaran/RowActions/DeleteDialog/DeleteContent.jsx b/src/components/dashboard/rahdaran/RowActions/DeleteDialog/DeleteContent.jsx index ef1c300..49c112d 100644 --- a/src/components/dashboard/rahdaran/RowActions/DeleteDialog/DeleteContent.jsx +++ b/src/components/dashboard/rahdaran/RowActions/DeleteDialog/DeleteContent.jsx @@ -1,39 +1,39 @@ -import { Button, DialogActions, DialogContent, Stack, Typography } from "@mui/material"; -import React, { useState } from "react"; -import useRequest from "@/lib/hooks/useRequest"; -import { DELETE_RAHDARAN_ITEM } from "@/core/utils/routes"; - -const DeleteContent = ({ rowId, mutate, setOpenDeleteDialog }) => { - const [submitting, setSubmitting] = useState(false); - const requestServer = useRequest({ notificationSuccess: true }); - const handleClick = () => { - setSubmitting(true); - requestServer(`${DELETE_RAHDARAN_ITEM}/${rowId}`, "delete") - .then(() => { - mutate(); - setSubmitting(false); - setOpenDeleteDialog(false); - }) - .catch(() => { - setSubmitting(false); - }); - }; - return ( - <> - - - آیا از حذف راهدار اطمینان دارید؟ - - - - - - - - ); -}; -export default DeleteContent; +import { Button, DialogActions, DialogContent, Stack, Typography } from "@mui/material"; +import React, { useState } from "react"; +import useRequest from "@/lib/hooks/useRequest"; +import { DELETE_RAHDARAN_ITEM } from "@/core/utils/routes"; + +const DeleteContent = ({ rowId, mutate, setOpenDeleteDialog }) => { + const [submitting, setSubmitting] = useState(false); + const requestServer = useRequest({ notificationSuccess: true }); + const handleClick = () => { + setSubmitting(true); + requestServer(`${DELETE_RAHDARAN_ITEM}/${rowId}`, "delete") + .then(() => { + mutate(); + setSubmitting(false); + setOpenDeleteDialog(false); + }) + .catch(() => { + setSubmitting(false); + }); + }; + return ( + <> + + + آیا از حذف راهدار اطمینان دارید؟ + + + + + + + + ); +}; +export default DeleteContent; diff --git a/src/components/dashboard/rahdaran/RowActions/DeleteDialog/index.jsx b/src/components/dashboard/rahdaran/RowActions/DeleteDialog/index.jsx index 3cf143b..6b3efd4 100644 --- a/src/components/dashboard/rahdaran/RowActions/DeleteDialog/index.jsx +++ b/src/components/dashboard/rahdaran/RowActions/DeleteDialog/index.jsx @@ -1,34 +1,34 @@ -import DeleteIcon from "@mui/icons-material/Delete"; -import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; -import { useState } from "react"; -import DeleteContent from "./DeleteContent"; -const DeleteDialog = ({ rowId, mutate }) => { - const [openDeleteDialog, setOpenDeleteDialog] = useState(false); - - return ( - <> - - setOpenDeleteDialog(true)}> - - - - setOpenDeleteDialog(false)} - PaperProps={{ - sx: { - boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px", - }, - }} - dir="rtl" - maxWidth={"md"} - > - حذف راهدار - {openDeleteDialog && ( - - )} - - - ); -}; -export default DeleteDialog; +import DeleteIcon from "@mui/icons-material/Delete"; +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { useState } from "react"; +import DeleteContent from "./DeleteContent"; +const DeleteDialog = ({ rowId, mutate }) => { + const [openDeleteDialog, setOpenDeleteDialog] = useState(false); + + return ( + <> + + setOpenDeleteDialog(true)}> + + + + setOpenDeleteDialog(false)} + PaperProps={{ + sx: { + boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px", + }, + }} + dir="rtl" + maxWidth={"md"} + > + حذف راهدار + {openDeleteDialog && ( + + )} + + + ); +}; +export default DeleteDialog; diff --git a/src/components/dashboard/rahdaran/RowActions/index.jsx b/src/components/dashboard/rahdaran/RowActions/index.jsx index 88602aa..116a7d2 100644 --- a/src/components/dashboard/rahdaran/RowActions/index.jsx +++ b/src/components/dashboard/rahdaran/RowActions/index.jsx @@ -1,12 +1,12 @@ -import { Box } from "@mui/material"; -import EditRahdar from "../Actions/Edit"; -import DeleteDialog from "./DeleteDialog"; -const RowActions = ({ row, mutate }) => { - return ( - - - - - ); -}; -export default RowActions; +import { Box } from "@mui/material"; +import EditRahdar from "../Actions/Edit"; +import DeleteDialog from "./DeleteDialog"; +const RowActions = ({ row, mutate }) => { + return ( + + + + + ); +}; +export default RowActions; diff --git a/src/components/dashboard/rahdaran/Toolbar.jsx b/src/components/dashboard/rahdaran/Toolbar.jsx index 18b0315..2f9b92f 100644 --- a/src/components/dashboard/rahdaran/Toolbar.jsx +++ b/src/components/dashboard/rahdaran/Toolbar.jsx @@ -1,9 +1,9 @@ -import CreateRahdar from "./Actions/Create"; -const Toolbar = ({ mutate }) => { - return ( - <> - - - ); -}; -export default Toolbar; +import CreateRahdar from "./Actions/Create"; +const Toolbar = ({ mutate }) => { + return ( + <> + + + ); +}; +export default Toolbar; diff --git a/src/components/dashboard/rahdaran/index.jsx b/src/components/dashboard/rahdaran/index.jsx index bfcce4d..47e5d89 100644 --- a/src/components/dashboard/rahdaran/index.jsx +++ b/src/components/dashboard/rahdaran/index.jsx @@ -1,13 +1,13 @@ -import PageTitle from "@/core/components/PageTitle"; -import { Stack } from "@mui/material"; -import RahdaranList from "./RahdaranList"; - -const RahdaranTablePage = () => { - return ( - - - - - ); -}; -export default RahdaranTablePage; +import PageTitle from "@/core/components/PageTitle"; +import { Stack } from "@mui/material"; +import RahdaranList from "./RahdaranList"; + +const RahdaranTablePage = () => { + return ( + + + + + ); +}; +export default RahdaranTablePage; diff --git a/src/components/dashboard/roadItems/operator/Actions/Create/Forms/GetItemInfo/ImageUpload.jsx b/src/components/dashboard/roadItems/operator/Actions/Create/Forms/GetItemInfo/ImageUpload.jsx index 8c23c76..6e33e99 100644 --- a/src/components/dashboard/roadItems/operator/Actions/Create/Forms/GetItemInfo/ImageUpload.jsx +++ b/src/components/dashboard/roadItems/operator/Actions/Create/Forms/GetItemInfo/ImageUpload.jsx @@ -1,173 +1,173 @@ -import { FormControl, FormHelperText, Grid } from "@mui/material"; -import UploadSystem from "@/core/components/UploadSystem"; -import { Controller } from "react-hook-form"; -import React, { useEffect, useState } from "react"; - -const ImageUpload = ({ control, setValue, errors, getValues, beforeImage = null, afterImage = null }) => { - const [beforeImg, setBeforeImg] = useState(beforeImage ? beforeImage : null); - const [beforeFileType, setBeforeFileType] = useState(beforeImage ? "image/" : null); - const [beforeFileName, setBeforeFileName] = useState(null); - const [showBeforeImage, setShowBeforeImage] = useState(!beforeImage); - - const [afterImg, setAfterImg] = useState(afterImage ? afterImage : null); - const [afterFileType, setAfterFileType] = useState(afterImage ? "image/" : null); - const [afterFileName, setAfterFileName] = useState(null); - const [showAfterImage, setShowAfterImage] = useState(!afterImage); - - useEffect(() => { - const beforeImage = getValues("before_image"); - const afterImage = getValues("after_image"); - - if (beforeImage) { - setShowBeforeImage(false); - - if (typeof beforeImage === "string") { - setBeforeImg(beforeImage); - setBeforeFileType("image/"); - } else if (beforeImage instanceof File) { - setBeforeImg(URL.createObjectURL(beforeImage)); - setBeforeFileType(beforeImage.type); - } - } - - if (afterImage) { - setShowAfterImage(false); - - if (typeof afterImage === "string") { - setAfterImg(afterImage); - setAfterFileType("image/"); - } else if (afterImage instanceof File) { - setAfterImg(URL.createObjectURL(afterImage)); - setAfterFileType(afterImage.type); - } - } - }, [getValues]); - - const handleBeforeFileChange = (event) => { - const uploadedFile = event.target?.files?.[0]; - if (uploadedFile) { - const fileType = event.target?.files?.[0].type; - const fileName = event.target?.files?.[0].name; - setBeforeImg(URL.createObjectURL(uploadedFile)); - setBeforeFileType(fileType); - setBeforeFileName(fileName); - setValue("before_image", uploadedFile); - setShowBeforeImage(false); - } - }; - const handleAfterFileChange = (event) => { - const uploadedFile = event.target?.files?.[0]; - if (uploadedFile) { - const fileType = event.target?.files?.[0].type; - const fileName = event.target?.files?.[0].name; - setAfterImg(URL.createObjectURL(uploadedFile)); - setAfterFileType(fileType); - setAfterFileName(fileName); - setValue("after_image", uploadedFile); - setShowAfterImage(false); - } - }; - return ( - - - { - return ( - - - عکس قبل از اقدام - - - - {errors.before_image ? errors.before_image.message : null} - - - ); - }} - /> - - - { - return ( - - - عکس بعد از اقدام - - - - {errors.after_image ? errors.after_image.message : null} - - - ); - }} - /> - - - ); -}; -export default ImageUpload; +import { FormControl, FormHelperText, Grid } from "@mui/material"; +import UploadSystem from "@/core/components/UploadSystem"; +import { Controller } from "react-hook-form"; +import React, { useEffect, useState } from "react"; + +const ImageUpload = ({ control, setValue, errors, getValues, beforeImage = null, afterImage = null }) => { + const [beforeImg, setBeforeImg] = useState(beforeImage ? beforeImage : null); + const [beforeFileType, setBeforeFileType] = useState(beforeImage ? "image/" : null); + const [beforeFileName, setBeforeFileName] = useState(null); + const [showBeforeImage, setShowBeforeImage] = useState(!beforeImage); + + const [afterImg, setAfterImg] = useState(afterImage ? afterImage : null); + const [afterFileType, setAfterFileType] = useState(afterImage ? "image/" : null); + const [afterFileName, setAfterFileName] = useState(null); + const [showAfterImage, setShowAfterImage] = useState(!afterImage); + + useEffect(() => { + const beforeImage = getValues("before_image"); + const afterImage = getValues("after_image"); + + if (beforeImage) { + setShowBeforeImage(false); + + if (typeof beforeImage === "string") { + setBeforeImg(beforeImage); + setBeforeFileType("image/"); + } else if (beforeImage instanceof File) { + setBeforeImg(URL.createObjectURL(beforeImage)); + setBeforeFileType(beforeImage.type); + } + } + + if (afterImage) { + setShowAfterImage(false); + + if (typeof afterImage === "string") { + setAfterImg(afterImage); + setAfterFileType("image/"); + } else if (afterImage instanceof File) { + setAfterImg(URL.createObjectURL(afterImage)); + setAfterFileType(afterImage.type); + } + } + }, [getValues]); + + const handleBeforeFileChange = (event) => { + const uploadedFile = event.target?.files?.[0]; + if (uploadedFile) { + const fileType = event.target?.files?.[0].type; + const fileName = event.target?.files?.[0].name; + setBeforeImg(URL.createObjectURL(uploadedFile)); + setBeforeFileType(fileType); + setBeforeFileName(fileName); + setValue("before_image", uploadedFile); + setShowBeforeImage(false); + } + }; + const handleAfterFileChange = (event) => { + const uploadedFile = event.target?.files?.[0]; + if (uploadedFile) { + const fileType = event.target?.files?.[0].type; + const fileName = event.target?.files?.[0].name; + setAfterImg(URL.createObjectURL(uploadedFile)); + setAfterFileType(fileType); + setAfterFileName(fileName); + setValue("after_image", uploadedFile); + setShowAfterImage(false); + } + }; + return ( + + + { + return ( + + + عکس قبل از اقدام + + + + {errors.before_image ? errors.before_image.message : null} + + + ); + }} + /> + + + { + return ( + + + عکس بعد از اقدام + + + + {errors.after_image ? errors.after_image.message : null} + + + ); + }} + /> + + + ); +}; +export default ImageUpload; diff --git a/src/components/dashboard/roadItems/operator/Actions/Create/Forms/GetItemInfo/MissionsDialog/MissionsList/RowActions/Allocate/index.jsx b/src/components/dashboard/roadItems/operator/Actions/Create/Forms/GetItemInfo/MissionsDialog/MissionsList/RowActions/Allocate/index.jsx index bb44050..68ff25b 100644 --- a/src/components/dashboard/roadItems/operator/Actions/Create/Forms/GetItemInfo/MissionsDialog/MissionsList/RowActions/Allocate/index.jsx +++ b/src/components/dashboard/roadItems/operator/Actions/Create/Forms/GetItemInfo/MissionsDialog/MissionsList/RowActions/Allocate/index.jsx @@ -1,23 +1,23 @@ -import { Done } from "@mui/icons-material"; -import { Button } from "@mui/material"; - -const Allocate = ({ row, setMission, setOpenDialog }) => { - const handleClick = () => { - setMission(row.original); - setOpenDialog(false); - }; - - return ( - <> - - - ); -}; -export default Allocate; +import { Done } from "@mui/icons-material"; +import { Button } from "@mui/material"; + +const Allocate = ({ row, setMission, setOpenDialog }) => { + const handleClick = () => { + setMission(row.original); + setOpenDialog(false); + }; + + return ( + <> + + + ); +}; +export default Allocate; diff --git a/src/components/dashboard/roadItems/operator/Actions/Create/Forms/GetItemInfo/MissionsDialog/MissionsList/RowActions/index.jsx b/src/components/dashboard/roadItems/operator/Actions/Create/Forms/GetItemInfo/MissionsDialog/MissionsList/RowActions/index.jsx index 31e8824..3615fa3 100644 --- a/src/components/dashboard/roadItems/operator/Actions/Create/Forms/GetItemInfo/MissionsDialog/MissionsList/RowActions/index.jsx +++ b/src/components/dashboard/roadItems/operator/Actions/Create/Forms/GetItemInfo/MissionsDialog/MissionsList/RowActions/index.jsx @@ -1,6 +1,6 @@ -import Allocate from "./Allocate"; - -const RowActions = ({ row, setMission, setOpenDialog }) => { - return ; -}; -export default RowActions; +import Allocate from "./Allocate"; + +const RowActions = ({ row, setMission, setOpenDialog }) => { + return ; +}; +export default RowActions; diff --git a/src/components/dashboard/roadItems/operator/Actions/Create/Forms/GetItemInfo/MissionsDialog/MissionsList/index.jsx b/src/components/dashboard/roadItems/operator/Actions/Create/Forms/GetItemInfo/MissionsDialog/MissionsList/index.jsx index 9bd2061..9d52581 100644 --- a/src/components/dashboard/roadItems/operator/Actions/Create/Forms/GetItemInfo/MissionsDialog/MissionsList/index.jsx +++ b/src/components/dashboard/roadItems/operator/Actions/Create/Forms/GetItemInfo/MissionsDialog/MissionsList/index.jsx @@ -1,105 +1,105 @@ -import DataTableWithAuth from "@/core/components/DataTableWithAuth"; -import { GET_ROAD_MISSIONS_OPERATOR_LIST } from "@/core/utils/routes"; -import { Box } from "@mui/material"; -import { useMemo } from "react"; -import RowActions from "./RowActions"; -import moment from "jalali-moment"; - -const MissionList = ({ setMission, setOpenDialog }) => { - const columns = useMemo( - () => [ - { - accessorKey: "id", - header: "کد یکتا", - id: "id", - enableColumnFilter: true, - datatype: "text", - filterMode: "equals", - columnFilterModeOptions: ["equals", "contains"], - grow: false, - size: 100, - }, - { - accessorKey: "explanation", - header: "موضوع", - id: "explanation", - enableColumnFilter: false, - datatype: "numeric", - filterMode: "equals", - grow: false, - size: 100, - }, - { - accessorKey: "zone", - header: "محدوده", - id: "zone", - enableColumnFilter: true, - datatype: "numeric", - filterMode: "equals", - sortDescFirst: true, - grow: false, - size: 100, - columnSelectOption: () => { - return missionRegions.map((region) => ({ - value: region.id, - label: region.name_fa, - })); - }, - Cell: ({ row }) => row.original.zone_fa, - }, - { - accessorFn: (row) => moment(row.start_time).locale("fa").format("HH:mm | yyyy/MM/DD"), - header: "تاریخ خروج", - id: "start_time", - enableColumnFilter: true, - datatype: "date", - filterMode: "between", - grow: false, - size: 100, - }, - { - accessorFn: (row) => moment(row.finish_time).locale("fa").format("HH:mm | yyyy/MM/DD"), - header: "تاریخ ورود", - id: "finish_time", - enableColumnFilter: true, - datatype: "date", - filterMode: "between", - grow: false, - size: 100, - }, - { - accessorKey: "end_point", - header: "مقصد", - id: "end_point", - enableColumnFilter: false, - datatype: "numeric", - filterMode: "equals", - grow: false, - size: 100, - }, - ], - [] - ); - - return ( - <> - - ( - - )} - /> - - - ); -}; -export default MissionList; +import DataTableWithAuth from "@/core/components/DataTableWithAuth"; +import { GET_ROAD_MISSIONS_OPERATOR_LIST } from "@/core/utils/routes"; +import { Box } from "@mui/material"; +import { useMemo } from "react"; +import RowActions from "./RowActions"; +import moment from "jalali-moment"; + +const MissionList = ({ setMission, setOpenDialog }) => { + const columns = useMemo( + () => [ + { + accessorKey: "id", + header: "کد یکتا", + id: "id", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + }, + { + accessorKey: "explanation", + header: "موضوع", + id: "explanation", + enableColumnFilter: false, + datatype: "numeric", + filterMode: "equals", + grow: false, + size: 100, + }, + { + accessorKey: "zone", + header: "محدوده", + id: "zone", + enableColumnFilter: true, + datatype: "numeric", + filterMode: "equals", + sortDescFirst: true, + grow: false, + size: 100, + columnSelectOption: () => { + return missionRegions.map((region) => ({ + value: region.id, + label: region.name_fa, + })); + }, + Cell: ({ row }) => row.original.zone_fa, + }, + { + accessorFn: (row) => moment(row.start_time).locale("fa").format("HH:mm | yyyy/MM/DD"), + header: "تاریخ خروج", + id: "start_time", + enableColumnFilter: true, + datatype: "date", + filterMode: "between", + grow: false, + size: 100, + }, + { + accessorFn: (row) => moment(row.finish_time).locale("fa").format("HH:mm | yyyy/MM/DD"), + header: "تاریخ ورود", + id: "finish_time", + enableColumnFilter: true, + datatype: "date", + filterMode: "between", + grow: false, + size: 100, + }, + { + accessorKey: "end_point", + header: "مقصد", + id: "end_point", + enableColumnFilter: false, + datatype: "numeric", + filterMode: "equals", + grow: false, + size: 100, + }, + ], + [] + ); + + return ( + <> + + ( + + )} + /> + + + ); +}; +export default MissionList; diff --git a/src/components/dashboard/roadItems/operator/Actions/Create/Forms/GetItemInfo/MissionsDialog/index.jsx b/src/components/dashboard/roadItems/operator/Actions/Create/Forms/GetItemInfo/MissionsDialog/index.jsx index e3efea4..3e25b0a 100644 --- a/src/components/dashboard/roadItems/operator/Actions/Create/Forms/GetItemInfo/MissionsDialog/index.jsx +++ b/src/components/dashboard/roadItems/operator/Actions/Create/Forms/GetItemInfo/MissionsDialog/index.jsx @@ -1,38 +1,38 @@ -import { Close, Edit } from "@mui/icons-material"; -import { Button, Dialog, IconButton } from "@mui/material"; -import { useState } from "react"; -import MissionList from "./MissionsList"; - -const MissionsDialog = ({ setMission, mode }) => { - const [open, setOpen] = useState(false); - return ( - <> - {mode == "edit" ? ( - setOpen(true)}> - - - ) : ( - - )} - - setOpen(false)} - sx={(theme) => ({ - position: "absolute", - right: 8, - top: 8, - zIndex: 50, - color: theme.palette.grey[500], - })} - > - - - {open && } - - - ); -}; -export default MissionsDialog; +import { Close, Edit } from "@mui/icons-material"; +import { Button, Dialog, IconButton } from "@mui/material"; +import { useState } from "react"; +import MissionList from "./MissionsList"; + +const MissionsDialog = ({ setMission, mode }) => { + const [open, setOpen] = useState(false); + return ( + <> + {mode == "edit" ? ( + setOpen(true)}> + + + ) : ( + + )} + + setOpen(false)} + sx={(theme) => ({ + position: "absolute", + right: 8, + top: 8, + zIndex: 50, + color: theme.palette.grey[500], + })} + > + + + {open && } + + + ); +}; +export default MissionsDialog; diff --git a/src/components/dashboard/roadItems/operator/Actions/Create/Forms/GetItemInfo/PreviousStatesInfo.jsx b/src/components/dashboard/roadItems/operator/Actions/Create/Forms/GetItemInfo/PreviousStatesInfo.jsx index 51fac42..a944ccd 100644 --- a/src/components/dashboard/roadItems/operator/Actions/Create/Forms/GetItemInfo/PreviousStatesInfo.jsx +++ b/src/components/dashboard/roadItems/operator/Actions/Create/Forms/GetItemInfo/PreviousStatesInfo.jsx @@ -1,43 +1,43 @@ -import { Box, Chip, Divider, Grid, Typography } from "@mui/material"; -import InsertDriveFileIcon from "@mui/icons-material/InsertDriveFile"; -import FileCopyIcon from "@mui/icons-material/FileCopy"; - -const PreviousStatesInfo = ({ itemsList, subItemsList }) => { - return ( - - - - } - label={ - - آیتم انتخاب ‌شده - - } - /> - - - - {itemsList.name || "هیچ آیتمی انتخاب نشده است"} - - - - - } - label={ - - اقدام انجام شده - - } - /> - - - - {subItemsList?.name || "هیچ اقدامی انتخاب نشده است"} - - - - ); -}; -export default PreviousStatesInfo; +import { Box, Chip, Divider, Grid, Typography } from "@mui/material"; +import InsertDriveFileIcon from "@mui/icons-material/InsertDriveFile"; +import FileCopyIcon from "@mui/icons-material/FileCopy"; + +const PreviousStatesInfo = ({ itemsList, subItemsList }) => { + return ( + + + + } + label={ + + آیتم انتخاب ‌شده + + } + /> + + + + {itemsList.name || "هیچ آیتمی انتخاب نشده است"} + + + + + } + label={ + + اقدام انجام شده + + } + /> + + + + {subItemsList?.name || "هیچ اقدامی انتخاب نشده است"} + + + + ); +}; +export default PreviousStatesInfo; diff --git a/src/components/dashboard/roadItems/operator/Actions/Create/Forms/GetItemInfo/index.jsx b/src/components/dashboard/roadItems/operator/Actions/Create/Forms/GetItemInfo/index.jsx index 6aab3ec..19e58f2 100644 --- a/src/components/dashboard/roadItems/operator/Actions/Create/Forms/GetItemInfo/index.jsx +++ b/src/components/dashboard/roadItems/operator/Actions/Create/Forms/GetItemInfo/index.jsx @@ -1,109 +1,109 @@ -import MapInfoOneMarker from "@/core/components/MapInfoOneMarker"; -import MapInfoTwoMarker from "@/core/components/MapInfoTwoMarker"; -import MuiDatePicker from "@/core/components/MuiDatePicker"; -import MuiTimePicker from "@/core/components/MuiTimePicker"; -import NumberField from "@/core/components/NumberField"; -import { Chip, Divider, FormHelperText, Grid, Stack, Typography } from "@mui/material"; -import ImageUpload from "./ImageUpload"; -import MissionsDialog from "./MissionsDialog"; -import PreviousStatesInfo from "./PreviousStatesInfo"; -import { Controller } from "react-hook-form"; - -const GetItemInfo = ({ register, itemsList, subItemsList, control, setValue, errors, watch, getValues, is_gasht }) => { - return ( - - - - - { - return value ? ( - - - - - onChange(m)} mode={"edit"} /> - - {error ? error.message : null} - - ) : ( - - onChange(m)} /> - {error ? error.message : null} - - ); - }} - /> - - { - if (!isNaN(event.target.value)) { - setValue("amount", event.target.value); - } else { - setValue("amount", watch("amount")); - } - }} - helperText={errors.amount ? errors.amount.message : null} - variant="outlined" - fullWidth - /> - - {!is_gasht ? ( - - - - - - - - - - - ) : null} - - {subItemsList.needs_image ? ( - - ) : null} - - - {subItemsList?.needs_end_point === 1 ? ( - - ) : ( - - )} - - - ); -}; -export default GetItemInfo; +import MapInfoOneMarker from "@/core/components/MapInfoOneMarker"; +import MapInfoTwoMarker from "@/core/components/MapInfoTwoMarker"; +import MuiDatePicker from "@/core/components/MuiDatePicker"; +import MuiTimePicker from "@/core/components/MuiTimePicker"; +import NumberField from "@/core/components/NumberField"; +import { Chip, Divider, FormHelperText, Grid, Stack, Typography } from "@mui/material"; +import ImageUpload from "./ImageUpload"; +import MissionsDialog from "./MissionsDialog"; +import PreviousStatesInfo from "./PreviousStatesInfo"; +import { Controller } from "react-hook-form"; + +const GetItemInfo = ({ register, itemsList, subItemsList, control, setValue, errors, watch, getValues, is_gasht }) => { + return ( + + + + + { + return value ? ( + + + + + onChange(m)} mode={"edit"} /> + + {error ? error.message : null} + + ) : ( + + onChange(m)} /> + {error ? error.message : null} + + ); + }} + /> + + { + if (!isNaN(event.target.value)) { + setValue("amount", event.target.value); + } else { + setValue("amount", watch("amount")); + } + }} + helperText={errors.amount ? errors.amount.message : null} + variant="outlined" + fullWidth + /> + + {!is_gasht ? ( + + + + + + + + + + + ) : null} + + {subItemsList.needs_image ? ( + + ) : null} + + + {subItemsList?.needs_end_point === 1 ? ( + + ) : ( + + )} + + + ); +}; +export default GetItemInfo; diff --git a/src/components/dashboard/roadMissions/control/RowActions/Machines/MachinesContent.jsx b/src/components/dashboard/roadMissions/control/RowActions/Machines/MachinesContent.jsx index 3ee5a3c..7465d53 100644 --- a/src/components/dashboard/roadMissions/control/RowActions/Machines/MachinesContent.jsx +++ b/src/components/dashboard/roadMissions/control/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/control/RowActions/Machines/index.jsx b/src/components/dashboard/roadMissions/control/RowActions/Machines/index.jsx index 395b276..0fa8a07 100644 --- a/src/components/dashboard/roadMissions/control/RowActions/Machines/index.jsx +++ b/src/components/dashboard/roadMissions/control/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)}> - - - - setOpenMachinesDialog(false)} - PaperProps={{ - sx: { - boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px", - }, - }} - dir="rtl" - maxWidth={"sm"} - > - اطلاعات خودرو - {openMachinesDialog && } - - - - - - ); -}; -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)}> + + + + setOpenMachinesDialog(false)} + PaperProps={{ + sx: { + boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px", + }, + }} + dir="rtl" + maxWidth={"sm"} + > + اطلاعات خودرو + {openMachinesDialog && } + + + + + + ); +}; +export default MachinesDialog; diff --git a/src/components/dashboard/roadMissions/control/RowActions/Rahdaran/RahdaranContent.jsx b/src/components/dashboard/roadMissions/control/RowActions/Rahdaran/RahdaranContent.jsx index 46001aa..74622a0 100644 --- a/src/components/dashboard/roadMissions/control/RowActions/Rahdaran/RahdaranContent.jsx +++ b/src/components/dashboard/roadMissions/control/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/control/RowActions/Rahdaran/index.jsx b/src/components/dashboard/roadMissions/control/RowActions/Rahdaran/index.jsx index b27009d..47a99e9 100644 --- a/src/components/dashboard/roadMissions/control/RowActions/Rahdaran/index.jsx +++ b/src/components/dashboard/roadMissions/control/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)}> - - - - setOpenRahdaranDialog(false)} - PaperProps={{ - sx: { - boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px", - }, - }} - dir="rtl" - maxWidth={"sm"} - > - لیست افراد - {openRahdaranDialog && } - - - - - - ); -}; -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)}> + + + + setOpenRahdaranDialog(false)} + PaperProps={{ + sx: { + boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px", + }, + }} + dir="rtl" + maxWidth={"sm"} + > + لیست افراد + {openRahdaranDialog && } + + + + + + ); +}; +export default RahdaranDialog; diff --git a/src/components/dashboard/roadMissions/operator/Actions/Create/Form/Area/MapControlPolygon/DrawBound/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/Create/Form/Area/MapControlPolygon/DrawBound/index.jsx index a2134c5..5a253a9 100644 --- a/src/components/dashboard/roadMissions/operator/Actions/Create/Form/Area/MapControlPolygon/DrawBound/index.jsx +++ b/src/components/dashboard/roadMissions/operator/Actions/Create/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/Actions/Create/Form/Area/MapControlPolygon/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/Create/Form/Area/MapControlPolygon/index.jsx index 186a0b6..718600c 100644 --- a/src/components/dashboard/roadMissions/operator/Actions/Create/Form/Area/MapControlPolygon/index.jsx +++ b/src/components/dashboard/roadMissions/operator/Actions/Create/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/Actions/Create/Form/Area/MapControlPolyline/DrawBound/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/Create/Form/Area/MapControlPolyline/DrawBound/index.jsx index 682be24..5456d12 100644 --- a/src/components/dashboard/roadMissions/operator/Actions/Create/Form/Area/MapControlPolyline/DrawBound/index.jsx +++ b/src/components/dashboard/roadMissions/operator/Actions/Create/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/Actions/Create/Form/Area/MapControlPolyline/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/Create/Form/Area/MapControlPolyline/index.jsx index edd6cac..8d9b5d0 100644 --- a/src/components/dashboard/roadMissions/operator/Actions/Create/Form/Area/MapControlPolyline/index.jsx +++ b/src/components/dashboard/roadMissions/operator/Actions/Create/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/Actions/Create/Form/Area/SelectBoundType/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/Create/Form/Area/SelectBoundType/index.jsx index a69a0ba..ebb3c69 100644 --- a/src/components/dashboard/roadMissions/operator/Actions/Create/Form/Area/SelectBoundType/index.jsx +++ b/src/components/dashboard/roadMissions/operator/Actions/Create/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/Actions/Create/Form/GetDateTime/MissionDates/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/Create/Form/GetDateTime/MissionDates/index.jsx index 8414a10..ccee5fe 100644 --- a/src/components/dashboard/roadMissions/operator/Actions/Create/Form/GetDateTime/MissionDates/index.jsx +++ b/src/components/dashboard/roadMissions/operator/Actions/Create/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 type = useWatch({ control, name: "type" }); - 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 ( - type && ( - <> - - { - return ( - field.onChange(value || [])} - helperText={error ? error.message : null} - /> - ); - }} - /> - - {type == 1 && ( - - { - return ( - field.onChange(value || null)} - helperText={error ? error.message : null} - /> - ); - }} - /> - - )} - - { - 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 { makeDateTime } from "@/core/utils/makeDateTime"; +import { Grid } from "@mui/material"; +import { Controller, useWatch } from "react-hook-form"; + +const MissionDates = ({ control }) => { + const type = useWatch({ control, name: "type" }); + 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 ( + type && ( + <> + + { + return ( + field.onChange(value || [])} + helperText={error ? error.message : null} + /> + ); + }} + /> + + {type == 1 && ( + + { + return ( + field.onChange(value || null)} + helperText={error ? error.message : null} + /> + ); + }} + /> + + )} + + { + 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/Actions/Create/Form/GetDateTime/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/Create/Form/GetDateTime/index.jsx index 00da610..c077b6b 100644 --- a/src/components/dashboard/roadMissions/operator/Actions/Create/Form/GetDateTime/index.jsx +++ b/src/components/dashboard/roadMissions/operator/Actions/Create/Form/GetDateTime/index.jsx @@ -1,86 +1,86 @@ -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({ - type: string().required("نوع ماموریت را مشخص کنید!"), - start_date: string().required("تاریخ شروع ماموریت را مشخص کنید!"), - start_time: string().when("type", { - is: "1", - then: (schema) => schema.required("زمان شروع ماموریت را مشخص کنید!"), - otherwise: (schema) => schema.notRequired(), - }), - 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, - 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({ + type: string().required("نوع ماموریت را مشخص کنید!"), + start_date: string().required("تاریخ شروع ماموریت را مشخص کنید!"), + start_time: string().when("type", { + is: "1", + then: (schema) => schema.required("زمان شروع ماموریت را مشخص کنید!"), + otherwise: (schema) => schema.notRequired(), + }), + 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, + 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/operator/Actions/Create/Form/GetItemInfo/FastReactCode/Dialog/List/RowActions/SelectId/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/Create/Form/GetItemInfo/FastReactCode/Dialog/List/RowActions/SelectId/index.jsx index 1e7e881..e3e14c0 100644 --- a/src/components/dashboard/roadMissions/operator/Actions/Create/Form/GetItemInfo/FastReactCode/Dialog/List/RowActions/SelectId/index.jsx +++ b/src/components/dashboard/roadMissions/operator/Actions/Create/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/Actions/Create/Form/GetItemInfo/FastReactCode/Dialog/List/RowActions/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/Create/Form/GetItemInfo/FastReactCode/Dialog/List/RowActions/index.jsx index 3d0b958..646104b 100644 --- a/src/components/dashboard/roadMissions/operator/Actions/Create/Form/GetItemInfo/FastReactCode/Dialog/List/RowActions/index.jsx +++ b/src/components/dashboard/roadMissions/operator/Actions/Create/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/Actions/Create/Form/GetItemInfo/FastReactCode/Dialog/List/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/Create/Form/GetItemInfo/FastReactCode/Dialog/List/index.jsx index 82a0472..8940335 100644 --- a/src/components/dashboard/roadMissions/operator/Actions/Create/Form/GetItemInfo/FastReactCode/Dialog/List/index.jsx +++ b/src/components/dashboard/roadMissions/operator/Actions/Create/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/Actions/Create/Form/GetItemInfo/FastReactCode/Dialog/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/Create/Form/GetItemInfo/FastReactCode/Dialog/index.jsx index 013f73f..d7af56d 100644 --- a/src/components/dashboard/roadMissions/operator/Actions/Create/Form/GetItemInfo/FastReactCode/Dialog/index.jsx +++ b/src/components/dashboard/roadMissions/operator/Actions/Create/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)} - /> - )} - - - setOpenFastReactDialog(false)} - sx={(theme) => ({ - position: "absolute", - right: 8, - top: 8, - zIndex: 50, - color: theme.palette.grey[500], - })} - > - - - {openFastReactDialog && ( - - )} - - - ); -}); - -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)} + /> + )} + + + setOpenFastReactDialog(false)} + sx={(theme) => ({ + position: "absolute", + right: 8, + top: 8, + zIndex: 50, + color: theme.palette.grey[500], + })} + > + + + {openFastReactDialog && ( + + )} + + + ); +}); + +FastReactDialog.displayName = "FastReactDialog"; + +export default FastReactDialog; diff --git a/src/components/dashboard/roadMissions/operator/Actions/Create/Form/GetItemInfo/FastReactCode/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/Create/Form/GetItemInfo/FastReactCode/index.jsx index 1545046..1f507c9 100644 --- a/src/components/dashboard/roadMissions/operator/Actions/Create/Form/GetItemInfo/FastReactCode/index.jsx +++ b/src/components/dashboard/roadMissions/operator/Actions/Create/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/Actions/Create/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/Create/index.jsx index f956b94..ab705c4 100644 --- a/src/components/dashboard/roadMissions/operator/Actions/Create/index.jsx +++ b/src/components/dashboard/roadMissions/operator/Actions/Create/index.jsx @@ -22,17 +22,8 @@ const Create = ({ mutate }) => { 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 - ] - )); + ? 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) { diff --git a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/Area/MapControlPolygon/DrawBound/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/Area/MapControlPolygon/DrawBound/index.jsx index a2134c5..5a253a9 100644 --- a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/Area/MapControlPolygon/DrawBound/index.jsx +++ b/src/components/dashboard/roadMissions/operator/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/operator/Actions/CreateWithoutProcess/Form/Area/MapControlPolygon/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/Area/MapControlPolygon/index.jsx index 186a0b6..718600c 100644 --- a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/Area/MapControlPolygon/index.jsx +++ b/src/components/dashboard/roadMissions/operator/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/operator/Actions/CreateWithoutProcess/Form/Area/MapControlPolyline/DrawBound/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/Area/MapControlPolyline/DrawBound/index.jsx index 682be24..5456d12 100644 --- a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/Area/MapControlPolyline/DrawBound/index.jsx +++ b/src/components/dashboard/roadMissions/operator/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/operator/Actions/CreateWithoutProcess/Form/Area/MapControlPolyline/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/Area/MapControlPolyline/index.jsx index edd6cac..8d9b5d0 100644 --- a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/Area/MapControlPolyline/index.jsx +++ b/src/components/dashboard/roadMissions/operator/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/operator/Actions/CreateWithoutProcess/Form/Area/SelectBoundType/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/Area/SelectBoundType/index.jsx index a69a0ba..ebb3c69 100644 --- a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/Area/SelectBoundType/index.jsx +++ b/src/components/dashboard/roadMissions/operator/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/operator/Actions/CreateWithoutProcess/Form/Area/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/Area/index.jsx index 91dd0d3..3d666fd 100644 --- a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/Area/index.jsx +++ b/src/components/dashboard/roadMissions/operator/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/operator/Actions/CreateWithoutProcess/Form/GetDateTime/MissionDates/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/GetDateTime/MissionDates/index.jsx index c002df3..56752de 100644 --- a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/GetDateTime/MissionDates/index.jsx +++ b/src/components/dashboard/roadMissions/operator/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/operator/Actions/CreateWithoutProcess/Form/GetDateTime/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/GetDateTime/index.jsx index 9e35f41..1b096e9 100644 --- a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/GetDateTime/index.jsx +++ b/src/components/dashboard/roadMissions/operator/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/operator/Actions/CreateWithoutProcess/Form/GetItemInfo/FastReactCode/Dialog/List/RowActions/SelectId/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/GetItemInfo/FastReactCode/Dialog/List/RowActions/SelectId/index.jsx index 1e7e881..e3e14c0 100644 --- a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/GetItemInfo/FastReactCode/Dialog/List/RowActions/SelectId/index.jsx +++ b/src/components/dashboard/roadMissions/operator/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/operator/Actions/CreateWithoutProcess/Form/GetItemInfo/FastReactCode/Dialog/List/RowActions/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/GetItemInfo/FastReactCode/Dialog/List/RowActions/index.jsx index 3d0b958..646104b 100644 --- a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/GetItemInfo/FastReactCode/Dialog/List/RowActions/index.jsx +++ b/src/components/dashboard/roadMissions/operator/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/operator/Actions/CreateWithoutProcess/Form/GetItemInfo/FastReactCode/Dialog/List/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/GetItemInfo/FastReactCode/Dialog/List/index.jsx index 82a0472..8940335 100644 --- a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/GetItemInfo/FastReactCode/Dialog/List/index.jsx +++ b/src/components/dashboard/roadMissions/operator/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/operator/Actions/CreateWithoutProcess/Form/GetItemInfo/FastReactCode/Dialog/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/GetItemInfo/FastReactCode/Dialog/index.jsx index 013f73f..d7af56d 100644 --- a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/GetItemInfo/FastReactCode/Dialog/index.jsx +++ b/src/components/dashboard/roadMissions/operator/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)} - /> - )} - - - setOpenFastReactDialog(false)} - sx={(theme) => ({ - position: "absolute", - right: 8, - top: 8, - zIndex: 50, - color: theme.palette.grey[500], - })} - > - - - {openFastReactDialog && ( - - )} - - - ); -}); - -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)} + /> + )} + + + setOpenFastReactDialog(false)} + sx={(theme) => ({ + position: "absolute", + right: 8, + top: 8, + zIndex: 50, + color: theme.palette.grey[500], + })} + > + + + {openFastReactDialog && ( + + )} + + + ); +}); + +FastReactDialog.displayName = "FastReactDialog"; + +export default FastReactDialog; diff --git a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/GetItemInfo/FastReactCode/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/GetItemInfo/FastReactCode/index.jsx index 1545046..1f507c9 100644 --- a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/GetItemInfo/FastReactCode/index.jsx +++ b/src/components/dashboard/roadMissions/operator/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/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"> - - - ) : ( - - )} - - setOpenDriversDialog(false)} - sx={(theme) => ({ - position: "absolute", - right: 8, - top: 8, - zIndex: 50, - color: theme.palette.grey[500], - })} - > - - - انتخاب راننده - {openDriversDialog && ( - - )} - - - ); -}; -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"> + + + ) : ( + + )} + + setOpenDriversDialog(false)} + sx={(theme) => ({ + position: "absolute", + right: 8, + top: 8, + zIndex: 50, + color: theme.palette.grey[500], + })} + > + + + انتخاب راننده + {openDriversDialog && ( + + )} + + + ); +}; +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"> - - - ) : ( - - )} - - setOpenMachinesDialog(false)} - sx={(theme) => ({ - position: "absolute", - right: 8, - top: 8, - zIndex: 50, - color: theme.palette.grey[500], - })} - > - - - {openMachinesDialog && ( - - )} - - - ); -}; -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"> + + + ) : ( + + )} + + setOpenMachinesDialog(false)} + sx={(theme) => ({ + position: "absolute", + right: 8, + top: 8, + zIndex: 50, + color: theme.palette.grey[500], + })} + > + + + {openMachinesDialog && ( + + )} + + + ); +}; +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 ( - - ); -} - -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 ( + + ); +} + +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/showArea/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/showArea/index.jsx index f2d9f4b..ef25c6b 100644 --- a/src/components/dashboard/roadMissions/operator/Actions/showArea/index.jsx +++ b/src/components/dashboard/roadMissions/operator/Actions/showArea/index.jsx @@ -59,5 +59,5 @@ const ShowArea = ({ area }) => { ); -};; +}; export default ShowArea; 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)} - /> - )} - - - setOpenFastReactDialog(false)} - sx={(theme) => ({ - position: "absolute", - right: 8, - top: 8, - zIndex: 50, - color: theme.palette.grey[500], - })} - > - - - {openFastReactDialog && ( - - )} - - - ); -}); - -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)} + /> + )} + + + setOpenFastReactDialog(false)} + sx={(theme) => ({ + position: "absolute", + right: 8, + top: 8, + zIndex: 50, + color: theme.palette.grey[500], + })} + > + + + {openFastReactDialog && ( + + )} + + + ); +}); + +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 ( - - ); -} - -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 ( + + ); +} + +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 25ff1c3..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,88 +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.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; +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); - }} - > - - - - - setOpenAddDialog(false)} - sx={(theme) => ({ - position: "absolute", - right: 8, - top: 8, - zIndex: 50, - color: theme.palette.grey[500], - })} - > - - - {openAddDialog && } - - - ); -}; -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); + }} + > + + + + + setOpenAddDialog(false)} + sx={(theme) => ({ + position: "absolute", + right: 8, + top: 8, + zIndex: 50, + color: theme.palette.grey[500], + })} + > + + + {openAddDialog && } + + + ); +}; +export default AddDialog; 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)}> - - - - setOpenMachinesDialog(false)} - PaperProps={{ - sx: { - boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px", - }, - }} - dir="rtl" - maxWidth={"sm"} - > - اطلاعات خودرو - {openMachinesDialog && } - - - - - - ); -}; -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)}> + + + + setOpenMachinesDialog(false)} + PaperProps={{ + sx: { + boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px", + }, + }} + dir="rtl" + maxWidth={"sm"} + > + اطلاعات خودرو + {openMachinesDialog && } + + + + + + ); +}; +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)}> - - - - setOpenRahdaranDialog(false)} - PaperProps={{ - sx: { - boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px", - }, - }} - dir="rtl" - maxWidth={"sm"} - > - لیست افراد - {openRahdaranDialog && } - - - - - - ); -}; -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)}> + + + + setOpenRahdaranDialog(false)} + PaperProps={{ + sx: { + boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px", + }, + }} + dir="rtl" + maxWidth={"sm"} + > + لیست افراد + {openRahdaranDialog && } + + + + + + ); +}; +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 f2d9f4b..ef25c6b 100644 --- a/src/components/dashboard/roadMissions/transportation/Actions/showArea/index.jsx +++ b/src/components/dashboard/roadMissions/transportation/Actions/showArea/index.jsx @@ -59,5 +59,5 @@ const ShowArea = ({ area }) => { ); -};; +}; export default ShowArea; 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"> - - - ) : ( - - )} - - setOpenDriversDialog(false)} - sx={(theme) => ({ - position: "absolute", - right: 8, - top: 8, - zIndex: 50, - color: theme.palette.grey[500], - })} - > - - - انتخاب راننده - {openDriversDialog && ( - - )} - - - ); -}; -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"> + + + ) : ( + + )} + + setOpenDriversDialog(false)} + sx={(theme) => ({ + position: "absolute", + right: 8, + top: 8, + zIndex: 50, + color: theme.palette.grey[500], + })} + > + + + انتخاب راننده + {openDriversDialog && ( + + )} + + + ); +}; +export default DriversDialog; 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)} - /> - )} - - - setOpenFastReactDialog(false)} - sx={(theme) => ({ - position: "absolute", - right: 8, - top: 8, - zIndex: 50, - color: theme.palette.grey[500], - })} - > - - - {openFastReactDialog && ( - - )} - - - ); -}); - -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)} + /> + )} + + + setOpenFastReactDialog(false)} + sx={(theme) => ({ + position: "absolute", + right: 8, + top: 8, + zIndex: 50, + color: theme.palette.grey[500], + })} + > + + + {openFastReactDialog && ( + + )} + + + ); +}); + +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"> - - - ) : ( - - )} - - setOpenDriversDialog(false)} - sx={(theme) => ({ - position: "absolute", - right: 8, - top: 8, - zIndex: 50, - color: theme.palette.grey[500], - })} - > - - - انتخاب راننده - {openDriversDialog && ( - - )} - - - ); -}; -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"> + + + ) : ( + + )} + + setOpenDriversDialog(false)} + sx={(theme) => ({ + position: "absolute", + right: 8, + top: 8, + zIndex: 50, + color: theme.palette.grey[500], + })} + > + + + انتخاب راننده + {openDriversDialog && ( + + )} + + + ); +}; +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"> - - - ) : ( - - )} - - setOpenMachinesDialog(false)} - sx={(theme) => ({ - position: "absolute", - right: 8, - top: 8, - zIndex: 50, - color: theme.palette.grey[500], - })} - > - - - {openMachinesDialog && ( - - )} - - - ); -}; -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"> + + + ) : ( + + )} + + setOpenMachinesDialog(false)} + sx={(theme) => ({ + position: "absolute", + right: 8, + top: 8, + zIndex: 50, + color: theme.palette.grey[500], + })} + > + + + {openMachinesDialog && ( + + )} + + + ); +}; +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 ( - - ); -} - -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 ( + + ); +} + +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 ? ( - - - - ) : ( - - )} - - setOpen(false)} - sx={(theme) => ({ - position: "absolute", - right: 8, - top: 8, - zIndex: 50, - color: theme.palette.grey[500], - })} - > - - - {open && ( - - )} - - - ); -}; -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 ? ( + + + + ) : ( + + )} + + setOpen(false)} + sx={(theme) => ({ + position: "absolute", + right: 8, + top: 8, + zIndex: 50, + color: theme.palette.grey[500], + })} + > + + + {open && ( + + )} + + + ); +}; +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 ? ( - - - - ) : ( - - )} - - ); -}; -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 ? ( + + + + ) : ( + + )} + + ); +}; +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 ? ( - - - - ) : ( - - )} - - ); -}; -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 ? ( + + + + ) : ( + + )} + + ); +}; +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 ? ( - - - - ) : ( - - )} - - ); -}; -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 ? ( + + + + ) : ( + + )} + + ); +}; +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} - /> - - - - ))} - - - - - - - - - ); -}; -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} + /> + + + + ))} + + + + + + + + + ); +}; +export default TollHouseArea; 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)}> - - - - setOpenShowAreaDialog(false)} - PaperProps={{ - sx: { - transition: "all .3s", - boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px", - borderRadius: 2, - padding: 1, - }, - }} - maxWidth="sm" - fullWidth - dir="rtl" - > - - - محدوده طرح - - setOpenShowAreaDialog(false)} size="small"> - - - - - - - - - - - - - - - ); -}; - -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)}> + + + + setOpenShowAreaDialog(false)} + PaperProps={{ + sx: { + transition: "all .3s", + boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px", + borderRadius: 2, + padding: 1, + }, + }} + maxWidth="sm" + fullWidth + dir="rtl" + > + + + محدوده طرح + + setOpenShowAreaDialog(false)} size="small"> + + + + + + + + + + + + + + + ); +}; + +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" ? "فعال" : "غیرفعال"} - - - - - - - recognize_picture - - - - - - recognize_picture_second - - - - - ); -}; -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" ? "فعال" : "غیرفعال"} + + + + + + + recognize_picture + + + + + + recognize_picture_second + + + + + ); +}; +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 - )} - - {open && } - - - ); -}; -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 + )} + + {open && } + + + ); +}; +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 ( - - ); -}; -export default TabPanel; +import { Box } from "@mui/material"; + +const TabPanel = (props) => { + const { children, value, index } = props; + return ( + + ); +}; +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; From 9cf37a72a1f9cd4b0603e2a1b20506c9409945b0 Mon Sep 17 00:00:00 2001 From: baslani Date: Sat, 20 Dec 2025 16:18:46 +0330 Subject: [PATCH 50/61] implemented implemented violations edit action --- .../Form/MachinesDialog/MachineList/index.jsx | 10 ++++- .../RowActions/Allocation/Form/index.jsx | 15 +++---- .../Form/GetItemInfo/index.jsx | 3 -- .../MachineAndDriver/DriversDialog/index.jsx | 2 +- .../Form/MachineAndDriver/index.jsx | 43 +++---------------- .../Form/Verify/index.jsx | 11 +---- .../CreateWithoutProcess/Form/index.jsx | 4 +- .../Actions/CreateWithoutProcess/index.jsx | 32 +++----------- .../violations/Actions/showBound/index.jsx | 29 +++++++++++++ .../violations/RowActions/index.jsx | 5 ++- src/core/utils/routes.js | 2 +- 11 files changed, 69 insertions(+), 87 deletions(-) create mode 100644 src/components/dashboard/roadMissions/violations/Actions/showBound/index.jsx diff --git a/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/MachinesDialog/MachineList/index.jsx b/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/MachinesDialog/MachineList/index.jsx index 07e8983..cfd1ed6 100644 --- a/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/MachinesDialog/MachineList/index.jsx +++ b/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/MachinesDialog/MachineList/index.jsx @@ -3,8 +3,12 @@ import { Box } from "@mui/material"; import { useMemo } from "react"; import RowActions from "./RowActions"; import { GET_MACHINES_TABLE_LIST } from "@/core/utils/routes"; +import { useAuth } from "@/lib/contexts/auth"; const MachinesList = ({ machineType, setMachine, setOpenMachinesDialog }) => { + const { + user: { city_id }, + } = useAuth(); const columns = useMemo( () => [ { @@ -40,7 +44,11 @@ const MachinesList = ({ machineType, setMachine, setOpenMachinesDialog }) => { need_filter={true} table_title="لیست خودرو ها" columns={columns} - specialFilter={[{ value: machineType, datatype: "text", id: "car_type", fn: "equals" }]} + specialFilter={[ + { value: machineType, datatype: "text", id: "car_type", fn: "equals" }, + { value: 1, datatype: "numeric", id: "status", fn: "equals" }, + { value: city_id, datatype: "numeric", id: "city_id", fn: "equals" }, + ]} sorting={[{ id: "id", desc: true }]} table_url={GET_MACHINES_TABLE_LIST} page_name={"roadMissionsTransportation"} diff --git a/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/index.jsx b/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/index.jsx index 4c2d1fe..eed66c8 100644 --- a/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/index.jsx +++ b/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/index.jsx @@ -1,18 +1,17 @@ import MapLayer from "@/core/components/MapLayer"; +import { machineType } from "@/core/utils/machineTypes"; +import { missionRegions } from "@/core/utils/missionRegions"; +import { missionTypes } from "@/core/utils/missionTypes"; import { ALLOCATE_REQUEST_MISSION } from "@/core/utils/routes"; import useRequest from "@/lib/hooks/useRequest"; import { Box, Button, Chip, DialogActions, DialogContent, Divider, Paper, Typography } from "@mui/material"; import { Stack } from "@mui/system"; +import moment from "jalali-moment"; import { useMemo, useState } from "react"; import ShowBound from "../../../Actions/showBound"; -import Reject from "./Reject"; -import { missionRegions } from "@/core/utils/missionRegions"; -import { machineType } from "@/core/utils/machineTypes"; -import { missionTypes } from "@/core/utils/missionTypes"; -import moment from "jalali-moment"; -import MachinesDialog from "./MachinesDialog"; import DriversDialog from "./DriversDialog"; -import LtrTextField from "@/core/components/LtrTextField"; +import MachinesDialog from "./MachinesDialog"; +import Reject from "./Reject"; const AllocationForm = ({ row, mutate, setOpenAllocationDialog }) => { const bound = useMemo( () => @@ -56,7 +55,7 @@ const AllocationForm = ({ row, mutate, setOpenAllocationDialog }) => { mt.id == row.requested_machines[0]).name_fa} + label={machineType.find((mt) => mt.id == row.requested_machines?.[0])?.name_fa} /> 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 7610a5b..666b1f9 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 @@ -103,9 +103,6 @@ const GetItemInfo = ({ allData, setAllData, handlePrev, setTabState }) => { )} /> - - - { +const DriversDialog = ({ setDriver, mode = "" }) => { const [openDriversDialog, setOpenDriversDialog] = useState(false); return ( <> 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 951fd83..912eb63 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,10 +1,8 @@ import { Box, Button, Chip, DialogActions, DialogContent, Divider, Stack, Typography } from "@mui/material"; -import DriversDialog from "./DriversDialog"; import { useState } from "react"; -import MachinesDialog from "./MachinesDialog"; +import DriversDialog from "./DriversDialog"; const MachineAndDriver = ({ setTabState, allData, setAllData, handlePrev }) => { - const [machine, setMachine] = useState(allData.machine); const [driver, setDriver] = useState(allData.driver); const handleNext = (data) => { @@ -18,43 +16,21 @@ const MachineAndDriver = ({ setTabState, allData, setAllData, handlePrev }) => { - {machine ? ( + {driver ? ( <> - خودرو + راننده - + ) : ( - + )} - {machine && ( - - {driver ? ( - <> - راننده - - - - - - ) : ( - - )} - - )} @@ -62,12 +38,7 @@ const MachineAndDriver = ({ setTabState, allData, setAllData, handlePrev }) => { - 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 039ff75..805e5d2 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 @@ -79,16 +79,9 @@ const Verify = ({ allData, handlePrev, submitForm, submitting }) => { - + - - خودرو - - - + راننده 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 00c4297..45ec88e 100644 --- a/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/index.jsx +++ b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/index.jsx @@ -1,4 +1,4 @@ -import { AccessTime, Engineering, InsertDriveFile, LocalShipping, Route, Verified } from "@mui/icons-material"; +import { AccessTime, Engineering, InsertDriveFile, Route, Verified, Person } from "@mui/icons-material"; import { Box, Tab, Tabs } from "@mui/material"; import { useReducer, useState } from "react"; import Area from "./Area"; @@ -62,7 +62,7 @@ const CreateForm = ({ defaultValues, submitForm, setOpen, submitting }) => { } label="مشخصات" /> } label="زمانبندی" /> } label="منطقه عملیاتی" /> - } label="خودرو و راننده" /> + } label="راننده" /> } label="همراهان" /> } label="بررسی نهایی" /> diff --git a/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/index.jsx b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/index.jsx index 4159027..5bc7492 100644 --- a/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/index.jsx +++ b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/index.jsx @@ -1,16 +1,14 @@ 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 { AddCircleOutline, Close } from "@mui/icons-material"; +import { Dialog, IconButton, Tooltip } from "@mui/material"; import moment from "jalali-moment"; import { useState } from "react"; import CreateForm from "./Form"; -const CreateWithoutProcess = ({ mutate }) => { +const CreateWithoutProcess = ({ row, 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 = () => { @@ -25,15 +23,10 @@ const CreateWithoutProcess = ({ mutate }) => { ? 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", { + await requestServer(`${REQUEST_MISSION_WITHOUT_PROCESS}/${row.original.id}`, "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, @@ -43,7 +36,6 @@ const CreateWithoutProcess = ({ mutate }) => { 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, @@ -60,21 +52,12 @@ const CreateWithoutProcess = ({ mutate }) => { return ( <> - {isMobile ? ( + - ) : ( - - )} + + { end_time: null, end_point: "", region: "", - machine: null, driver: null, }} submitForm={submitForm} diff --git a/src/components/dashboard/roadMissions/violations/Actions/showBound/index.jsx b/src/components/dashboard/roadMissions/violations/Actions/showBound/index.jsx new file mode 100644 index 0000000..24db476 --- /dev/null +++ b/src/components/dashboard/roadMissions/violations/Actions/showBound/index.jsx @@ -0,0 +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; diff --git a/src/components/dashboard/roadMissions/violations/RowActions/index.jsx b/src/components/dashboard/roadMissions/violations/RowActions/index.jsx index 0687f1d..0451883 100644 --- a/src/components/dashboard/roadMissions/violations/RowActions/index.jsx +++ b/src/components/dashboard/roadMissions/violations/RowActions/index.jsx @@ -1,4 +1,7 @@ +import CreateWithoutProcess from "../Actions/CreateWithoutProcess"; + const RowActions = ({ row, mutate }) => { - return <>; + const canEdit = row.original.status === 0 && row.original.type === 1; + return canEdit && ; }; export default RowActions; diff --git a/src/core/utils/routes.js b/src/core/utils/routes.js index 6bf7001..f22a48a 100644 --- a/src/core/utils/routes.js +++ b/src/core/utils/routes.js @@ -217,7 +217,7 @@ export const GET_ROAD_MISSIONS_OPERATOR_LIST = api + "/api/v3/missions/request_p export const GET_ROAD_MISSIONS_TRANSPORTATION_LIST = api + "/api/v3/missions/transportation_unit"; export const GET_ROAD_MISSIONS_CONTROL_LIST = api + "/api/v3/missions/control_unit"; export const REQUEST_MISSION = api + "/api/v3/missions/request_portal"; -export const REQUEST_MISSION_WITHOUT_PROCESS = api + "/api/v3/missions/request_portal/no_process"; +export const REQUEST_MISSION_WITHOUT_PROCESS = api + "/api/v3/missions/violation_management/no_process"; export const REQUEST_MISSION_CONTINUE_MISSION = api + "/api/v3/missions/request_portal/continue"; export const UPDATE_REQUEST_MISSION = api + "/api/v3/missions/request_portal"; export const DELETE_REQUEST_MISSION = api + "/api/v3/missions/request_portal"; From 484ebb1797c48ca190cf54043b65b96ae7e25e30 Mon Sep 17 00:00:00 2001 From: AminGhasempoor Date: Sun, 21 Dec 2025 08:56:17 +0330 Subject: [PATCH 51/61] mission reports --- .../dashboard/road-missions/reports/page.js | 18 +++ .../MissionsDialog/MissionsList/index.jsx | 4 + .../GetItemInfo/MissionsDialog/index.jsx | 2 +- .../roadMissions/reports/ExcelPrint/index.jsx | 72 ++++++++++ .../roadMissions/reports/ReportLists.jsx | 84 +++++++++++ .../reports/Search/FromDateController.jsx | 28 ++++ .../reports/Search/SearchReportField.jsx | 45 ++++++ .../reports/Search/SelectProvince.jsx | 47 ++++++ .../reports/Search/ToDateController.jsx | 30 ++++ .../roadMissions/reports/Search/index.jsx | 13 ++ .../roadMissions/reports/Toolbar.jsx | 11 ++ .../dashboard/roadMissions/reports/index.jsx | 134 ++++++++++++++++++ src/core/utils/pageMenu.js | 17 +++ src/core/utils/pageMenuDev.js | 17 +++ src/core/utils/routes.js | 2 + 15 files changed, 523 insertions(+), 1 deletion(-) create mode 100644 src/app/(withAuth)/(dashboardLayout)/dashboard/road-missions/reports/page.js create mode 100644 src/components/dashboard/roadMissions/reports/ExcelPrint/index.jsx create mode 100644 src/components/dashboard/roadMissions/reports/ReportLists.jsx create mode 100644 src/components/dashboard/roadMissions/reports/Search/FromDateController.jsx create mode 100644 src/components/dashboard/roadMissions/reports/Search/SearchReportField.jsx create mode 100644 src/components/dashboard/roadMissions/reports/Search/SelectProvince.jsx create mode 100644 src/components/dashboard/roadMissions/reports/Search/ToDateController.jsx create mode 100644 src/components/dashboard/roadMissions/reports/Search/index.jsx create mode 100644 src/components/dashboard/roadMissions/reports/Toolbar.jsx create mode 100644 src/components/dashboard/roadMissions/reports/index.jsx diff --git a/src/app/(withAuth)/(dashboardLayout)/dashboard/road-missions/reports/page.js b/src/app/(withAuth)/(dashboardLayout)/dashboard/road-missions/reports/page.js new file mode 100644 index 0000000..8b51a44 --- /dev/null +++ b/src/app/(withAuth)/(dashboardLayout)/dashboard/road-missions/reports/page.js @@ -0,0 +1,18 @@ +import WithPermission from "@/core/middlewares/withPermission"; +import ReportPage from "@/components/dashboard/roadMissions/reports"; +export const metadata = { + title: "کارتابل گزارش ماموریت", +}; +const Page = () => { + return ( + + + + ); +}; + +export default Page; diff --git a/src/components/dashboard/roadItems/operator/Actions/Create/Forms/GetItemInfo/MissionsDialog/MissionsList/index.jsx b/src/components/dashboard/roadItems/operator/Actions/Create/Forms/GetItemInfo/MissionsDialog/MissionsList/index.jsx index 9d52581..f4f5c49 100644 --- a/src/components/dashboard/roadItems/operator/Actions/Create/Forms/GetItemInfo/MissionsDialog/MissionsList/index.jsx +++ b/src/components/dashboard/roadItems/operator/Actions/Create/Forms/GetItemInfo/MissionsDialog/MissionsList/index.jsx @@ -4,8 +4,11 @@ import { Box } from "@mui/material"; import { useMemo } from "react"; import RowActions from "./RowActions"; import moment from "jalali-moment"; +import { useAuth } from "@/lib/contexts/auth"; +import { missionRegions } from "@/core/utils/missionRegions"; const MissionList = ({ setMission, setOpenDialog }) => { + const {user} = useAuth() const columns = useMemo( () => [ { @@ -88,6 +91,7 @@ const MissionList = ({ setMission, setOpenDialog }) => { need_filter={true} table_title="لیست ماموریت ها" columns={columns} + specialFilter={[{ value: user.id, datatype: "text", id: "user_id", fn: "equals" }]} sorting={[{ id: "id", desc: true }]} table_url={GET_ROAD_MISSIONS_OPERATOR_LIST} page_name={"roadItemsOperator"} diff --git a/src/components/dashboard/roadItems/operator/Actions/Create/Forms/GetItemInfo/MissionsDialog/index.jsx b/src/components/dashboard/roadItems/operator/Actions/Create/Forms/GetItemInfo/MissionsDialog/index.jsx index 3e25b0a..667845b 100644 --- a/src/components/dashboard/roadItems/operator/Actions/Create/Forms/GetItemInfo/MissionsDialog/index.jsx +++ b/src/components/dashboard/roadItems/operator/Actions/Create/Forms/GetItemInfo/MissionsDialog/index.jsx @@ -13,7 +13,7 @@ const MissionsDialog = ({ setMission, mode }) => { ) : ( )} diff --git a/src/components/dashboard/roadMissions/reports/ExcelPrint/index.jsx b/src/components/dashboard/roadMissions/reports/ExcelPrint/index.jsx new file mode 100644 index 0000000..5a514fb --- /dev/null +++ b/src/components/dashboard/roadMissions/reports/ExcelPrint/index.jsx @@ -0,0 +1,72 @@ +"use client"; +import { Button, CircularProgress, IconButton, useMediaQuery } from "@mui/material"; +import { useMemo, useState } from "react"; +import moment from "jalali-moment"; +import FileSaver from "file-saver"; +import DescriptionIcon from "@mui/icons-material/Description"; +import useRequest from "@/lib/hooks/useRequest"; +import { useTheme } from "@emotion/react"; +import { EXPORT_COUNTRY_ROAD_PATROL_REPORTS, EXPORT_PROVINCE_ROAD_PATROL_REPORTS } from "@/core/utils/routes"; + +const PrintExcel = ({ table, filterData }) => { + const theme = useTheme(); + const isMobile = useMediaQuery(theme.breakpoints.down("sm")); + const [loading, setLoading] = useState(false); + const requestServer = useRequest({ notificationSuccess: true }); + const activeFilters = Object.entries(filterData).reduce((acc, [key, filter]) => { + if (filter.value) { + acc.push({ id: filter.id, value: filter.value }); + } + return acc; + }, []); + + const filterParams = useMemo(() => { + const params = new URLSearchParams(); + activeFilters.length > 0 && + activeFilters.map((filter, index) => { + params.set(`${filter.id}`, filter.value); + }); + return params; + }, [activeFilters]); + + const clickHandler = () => { + setLoading(true); + const CountryOrProvince = activeFilters.find((item) => item.id === "province_id"); + const requestUrl = + CountryOrProvince.value === "-1" ? EXPORT_COUNTRY_ROAD_PATROL_REPORTS : EXPORT_PROVINCE_ROAD_PATROL_REPORTS; + requestServer(`${requestUrl}?${filterParams}`, "get", { + requestOptions: { responseType: "blob" }, + }) + .then((response) => { + const filename = `خروجی کارتابل گزارشات گشت راهداری تاریخ_${moment().format("jYYYY_jMM_jDD")}.xlsx`; + FileSaver.saveAs(response.data, filename); + }) + .catch(() => {}) + .finally(() => { + setLoading(false); + }); + }; + + return ( + <> + {isMobile ? ( + + + + ) : ( + + )} + + ); +}; +export default PrintExcel; diff --git a/src/components/dashboard/roadMissions/reports/ReportLists.jsx b/src/components/dashboard/roadMissions/reports/ReportLists.jsx new file mode 100644 index 0000000..19b5e71 --- /dev/null +++ b/src/components/dashboard/roadMissions/reports/ReportLists.jsx @@ -0,0 +1,84 @@ +"use client"; +import DataTableWithAuth from "@/core/components/DataTableWithAuth"; +import { Box } from "@mui/material"; +import { useMemo } from "react"; +import Toolbar from "./Toolbar"; + +const ReportLists = ({ data, specialFilter }) => { + const columns = useMemo(() => { + return [ + { + accessorKey: "province_name", + header: "اداره کل", + id: "province_name", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + grow: false, + size: 50, + }, + { + accessorKey: "no_mission_count", + header: "تردد بدون ماموریت", + id: "no_mission_count", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + grow: false, + size: 50, + muiTableBodyCellProps: { + sx: { + textAlign: "center", + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", + }, + }, + }, + Cell: ({ renderedCellValue }) => { + return renderedCellValue; + }, + }, + { + accessorKey: "out_of_aria_count", + header: "تردد خارج محدوده", + id: "out_of_aria_count", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + grow: false, + size: 50, + muiTableBodyCellProps: { + sx: { + textAlign: "center", + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", + }, + }, + }, + Cell: ({ renderedCellValue }) => { + return renderedCellValue; + }, + }, + ]; + }, []); + + return ( + + + + ); +}; + +export default ReportLists; diff --git a/src/components/dashboard/roadMissions/reports/Search/FromDateController.jsx b/src/components/dashboard/roadMissions/reports/Search/FromDateController.jsx new file mode 100644 index 0000000..45002e1 --- /dev/null +++ b/src/components/dashboard/roadMissions/reports/Search/FromDateController.jsx @@ -0,0 +1,28 @@ +import { Controller } from "react-hook-form"; +import MuiDatePicker from "@/core/components/MuiDatePicker"; +import React from "react"; +import moment from "jalali-moment"; + +const FromDateController = ({ control }) => { + return ( + ( + { + const formattedDate = moment(new Date(newValue)).locale("en").format("YYYY-MM-DD"); + onChange(formattedDate); // Update the field value in react-hook-form + }} + helperText={error ? error.message : null} + /> + )} + /> + ); +}; +export default FromDateController; diff --git a/src/components/dashboard/roadMissions/reports/Search/SearchReportField.jsx b/src/components/dashboard/roadMissions/reports/Search/SearchReportField.jsx new file mode 100644 index 0000000..5c6aa23 --- /dev/null +++ b/src/components/dashboard/roadMissions/reports/Search/SearchReportField.jsx @@ -0,0 +1,45 @@ +import { Button, Grid, LinearProgress, Typography } from "@mui/material"; +import SearchIcon from "@mui/icons-material/Search"; +import React from "react"; +import FromDateController from "./FromDateController"; +import ToDateController from "./ToDateController"; +import SelectProvince from "./SelectProvince"; +import { Controller } from "react-hook-form"; + +const SearchReportField = ({ control, hasProvincesPermission }) => { + return ( + + + + + + + + {hasProvincesPermission && ( + + + + )} + + ( + + )} + /> + + + ); +}; + +export default SearchReportField; diff --git a/src/components/dashboard/roadMissions/reports/Search/SelectProvince.jsx b/src/components/dashboard/roadMissions/reports/Search/SelectProvince.jsx new file mode 100644 index 0000000..7f738bc --- /dev/null +++ b/src/components/dashboard/roadMissions/reports/Search/SelectProvince.jsx @@ -0,0 +1,47 @@ +import { Controller } from "react-hook-form"; +import MuiDatePicker from "@/core/components/MuiDatePicker"; +import React from "react"; +import { FormControl, FormHelperText, InputLabel, LinearProgress, MenuItem, Select, Typography } from "@mui/material"; +import useProvinces from "@/lib/hooks/useProvince"; + +const SelectProvince = ({ control }) => { + const { provinces, loadingProvinces, errorProvinces } = useProvinces(); + return ( + ( + + استان + + {error && {error.message}} + + )} + /> + ); +}; +export default SelectProvince; diff --git a/src/components/dashboard/roadMissions/reports/Search/ToDateController.jsx b/src/components/dashboard/roadMissions/reports/Search/ToDateController.jsx new file mode 100644 index 0000000..4b5f2a8 --- /dev/null +++ b/src/components/dashboard/roadMissions/reports/Search/ToDateController.jsx @@ -0,0 +1,30 @@ +import { Controller, useWatch } from "react-hook-form"; +import MuiDatePicker from "@/core/components/MuiDatePicker"; +import React from "react"; +import moment from "jalali-moment"; + +const ToDateController = ({ control }) => { + const minDate = useWatch({ control, name: "from_date" }); + return ( + ( + { + const formattedDate = moment(new Date(newValue)).locale("en").format("YYYY-MM-DD"); + onChange(formattedDate); // Update the field value in react-hook-form + }} + helperText={error ? error.message : null} + /> + )} + /> + ); +}; +export default ToDateController; diff --git a/src/components/dashboard/roadMissions/reports/Search/index.jsx b/src/components/dashboard/roadMissions/reports/Search/index.jsx new file mode 100644 index 0000000..9d504f2 --- /dev/null +++ b/src/components/dashboard/roadMissions/reports/Search/index.jsx @@ -0,0 +1,13 @@ +import StyledForm from "@/core/components/StyledForm"; +import SearchReportField from "./SearchReportField"; + +const SearchReportList = ({ handleSubmit, onSearchSubmit, control, hasProvincesPermission }) => { + return ( + <> + + + + + ); +}; +export default SearchReportList; diff --git a/src/components/dashboard/roadMissions/reports/Toolbar.jsx b/src/components/dashboard/roadMissions/reports/Toolbar.jsx new file mode 100644 index 0000000..3e5ab8c --- /dev/null +++ b/src/components/dashboard/roadMissions/reports/Toolbar.jsx @@ -0,0 +1,11 @@ +import PrintExcel from "./ExcelPrint"; +import { Box } from "@mui/material"; + +const Toolbar = ({ table, filterData, mutate }) => { + return ( + + + + ); +}; +export default Toolbar; diff --git a/src/components/dashboard/roadMissions/reports/index.jsx b/src/components/dashboard/roadMissions/reports/index.jsx new file mode 100644 index 0000000..63b25e3 --- /dev/null +++ b/src/components/dashboard/roadMissions/reports/index.jsx @@ -0,0 +1,134 @@ +"use client"; +import PageTitle from "@/core/components/PageTitle"; +import { LinearProgress, Stack } from "@mui/material"; +import SearchReportList from "./Search"; +import { useEffect, useState } from "react"; +import ReportLists from "./ReportLists"; +import useRequest from "@/lib/hooks/useRequest"; +import { GET_CITY_ACTIVITY_REPORT, GET_MISSION_CITY_ACTIVITY_REPORT } from "@/core/utils/routes"; +import moment from "jalali-moment"; +import * as yup from "yup"; +import { useForm } from "react-hook-form"; +import { yupResolver } from "@hookform/resolvers/yup"; +import { usePermissions } from "@/lib/hooks/usePermissions"; +import { useAuth } from "@/lib/contexts/auth"; + +const ReportPage = () => { + const [data, setData] = useState(null); + const { data: userPermissions } = usePermissions(); + const { user } = useAuth(); + const requestServer = useRequest(); + const hasProvincesPermission = userPermissions?.includes("all"); // TODO : change permission + + const defaultValues = { + from_date: moment(new Date()).format("YYYY-MM-DD"), + date_to: moment(new Date()).format("YYYY-MM-DD"), + province_id: hasProvincesPermission ? "-1" : user.province_id, + }; + const defaultFilter = [ + { value: `${defaultValues.province_id}`, datatype: "numeric", id: "province_id", fn: "equals" }, + { value: `${defaultValues.from_date}`, datatype: "date", id: "from_date", fn: "between" }, + { value: `${defaultValues.date_to}`, datatype: "date", id: "date_to", fn: "between" }, + ]; + const [specialFilter, setSpecialFilter] = useState(defaultFilter); + + const onSearchSubmit = async (data) => { + const params = new URLSearchParams(); + params.set("from_date", `${data.from_date}`); + params.set("date_to", `${data.date_to}`); + setSpecialFilter([ + { value: `${data.province_id}`, datatype: "numeric", id: "province_id", fn: "equals" }, + { value: `${data.from_date}`, datatype: "date", id: "from_date", fn: "between" }, + { value: `${data.date_to}`, datatype: "date", id: "date_to", fn: "between" }, + ]); + if (data.province_id === "-1") { + try { + const response = await requestServer(`${GET_CITY_ACTIVITY_REPORT}?${params}`); + const result = response.data.data; + const nationalReportForItem = result.activities.find((report) => report.province_id === -1); + const nationalReport = { + edare_name: "کل کشور", + ...nationalReportForItem, + }; + + setData({ + data: [ + nationalReport, + ...result.provinces.map((province) => { + const filteredReports = result.activities.find( + (report) => report.province_id === province.id + ); + return { + ...filteredReports, + edare_name: province.name_fa, + }; + }), + ], + filters: data, + }); + } catch (e) {} + } else { + try { + params.set("province_id", `${data.province_id}`); + const response = await requestServer(`${GET_MISSION_CITY_ACTIVITY_REPORT}?${params}`); + const result = response.data.data; + const nationalReportForItem = result.activities.find((report) => report.edare_id === "-1"); + const nationalReport = { + ...nationalReportForItem, + edare_name: "کل استان", + }; + setData({ + data: [ + nationalReport, + ...result.edarateShahri.map((edare) => { + const filteredReports = result.activities.find((report) => report.edare_id == edare.id); + return { + edare_name: edare.name_fa, + ...filteredReports, + }; + }), + ], + filters: data, + }); + } catch (e) {} + } + }; + + useEffect(() => { + if (!userPermissions) return; + onSearchSubmit(defaultValues); + }, [userPermissions]); + + const validationSchema = yup.object().shape({ + from_date: yup + .string() + .required("تاریخ شروع الزامی است!") + .matches(/^\d{4}-\d{2}-\d{2}$/, "تاریخ شروع الزامی است!") + .test("is-valid-date", "تاریخ شروع معتبر نیست!", (value) => moment(value, "YYYY-MM-DD", true).isValid()), + date_to: yup + .string() + .required("تاریخ پایان الزامی است!") + .matches(/^\d{4}-\d{2}-\d{2}$/, "تاریخ پایان الزامی است!") + .test("is-valid-date", "تاریخ پایان معتبر نیست!", (value) => moment(value, "YYYY-MM-DD", true).isValid()), + province_id: yup.string().nullable(), + }); + + const { control, handleSubmit } = useForm({ + defaultValues, + resolver: yupResolver(validationSchema), + mode: "all", + }); + return ( + + + + {!data ? : } + + ); +}; +export default ReportPage; diff --git a/src/core/utils/pageMenu.js b/src/core/utils/pageMenu.js index f812b52..b66bd39 100644 --- a/src/core/utils/pageMenu.js +++ b/src/core/utils/pageMenu.js @@ -29,6 +29,10 @@ import ScienceIcon from "@mui/icons-material/Science"; import SecurityIcon from "@mui/icons-material/Security"; import SpaceDashboardIcon from "@mui/icons-material/SpaceDashboard"; import SpeedIcon from "@mui/icons-material/Speed"; +import ContactPageIcon from "@mui/icons-material/ContactPage"; +import DirectionsBusIcon from "@mui/icons-material/DirectionsBus"; +import SupervisedUserCircleIcon from "@mui/icons-material/SupervisedUserCircle"; +import RemoveRoadIcon from "@mui/icons-material/RemoveRoad"; export const pageMenu = [ { @@ -107,6 +111,7 @@ export const pageMenu = [ { id: "roadMissionsManagemnetRequests", label: "کارتابل", + icon: , type: "page", route: "/dashboard/road-missions/operator", badges: [{ key: "mission.request_portal" }], @@ -120,6 +125,7 @@ export const pageMenu = [ id: "roadMissionsManagemnetNaqlie", label: "نقلیه", type: "page", + icon: , route: "/dashboard/road-missions/transportation", badges: [{ key: "mission.transportation" }], permissions: ["manage-transportation-unit"], @@ -128,6 +134,7 @@ export const pageMenu = [ id: "roadMissionsManagemnetControl", label: "کنترل", type: "page", + icon: , route: "/dashboard/road-missions/control", badges: [{ key: "mission.control" }], permissions: ["manage-control-unit"], @@ -136,10 +143,20 @@ export const pageMenu = [ id: "roadMissionsViolations", label: "تخلفات", type: "page", + icon: , route: "/dashboard/road-missions/violation", // badges: [{ key: "mission.control" }], // TODO: add badge and permission permissions: ["all"], }, + { + id: "roadMissionsReports", + label: "گزارشات", + type: "page", + route: "/dashboard/road-missions/reports", + icon: , + // badges: [{ key: "mission.control" }], // TODO: add badge and permission + permissions: ["all"], + }, ], }, { diff --git a/src/core/utils/pageMenuDev.js b/src/core/utils/pageMenuDev.js index 41e811d..3ec7adc 100644 --- a/src/core/utils/pageMenuDev.js +++ b/src/core/utils/pageMenuDev.js @@ -28,6 +28,10 @@ import PsychologyAltIcon from "@mui/icons-material/PsychologyAlt"; import MapsHomeWorkIcon from "@mui/icons-material/MapsHomeWork"; import SecurityIcon from "@mui/icons-material/Security"; import ManageAccountsIcon from "@mui/icons-material/ManageAccounts"; +import DirectionsBusIcon from "@mui/icons-material/DirectionsBus"; +import ContactPageIcon from "@mui/icons-material/ContactPage"; +import SupervisedUserCircleIcon from "@mui/icons-material/SupervisedUserCircle"; +import RemoveRoadIcon from "@mui/icons-material/RemoveRoad"; export const pageMenuDev = [ { @@ -106,6 +110,7 @@ export const pageMenuDev = [ { id: "roadMissionsManagemnetRequests", label: "کارتابل", + icon: , type: "page", route: "/dashboard/road-missions/operator", badges: [{ key: "mission.request_portal" }], @@ -119,6 +124,7 @@ export const pageMenuDev = [ id: "roadMissionsManagemnetNaqlie", label: "نقلیه", type: "page", + icon: , route: "/dashboard/road-missions/transportation", badges: [{ key: "mission.transportation" }], permissions: ["manage-transportation-unit"], @@ -127,6 +133,7 @@ export const pageMenuDev = [ id: "roadMissionsManagemnetControl", label: "کنترل", type: "page", + icon: , route: "/dashboard/road-missions/control", badges: [{ key: "mission.control" }], permissions: ["manage-control-unit"], @@ -135,10 +142,20 @@ export const pageMenuDev = [ id: "roadMissionsViolations", label: "تخلفات", type: "page", + icon: , route: "/dashboard/road-missions/violation", // badges: [{ key: "mission.control" }], // TODO: add badge and permission permissions: ["all"], }, + { + id: "roadMissionsReports", + label: "گزارشات", + type: "page", + route: "/dashboard/road-missions/reports", + icon: , + // badges: [{ key: "mission.control" }], // TODO: add badge and permission + permissions: ["all"], + }, ], }, { diff --git a/src/core/utils/routes.js b/src/core/utils/routes.js index 6bf7001..02fe030 100644 --- a/src/core/utils/routes.js +++ b/src/core/utils/routes.js @@ -228,6 +228,8 @@ export const DEALLOCATE_REQUEST_MISSION = api + "/api/v3/missions/transportation export const START_MISSION = api + "/api/v3/missions/control_unit/start"; export const FINISH_MISSION = api + "/api/v3/missions/control_unit/finish"; export const GET_ROAD_MISSIONS_VIOLATIONS_LIST = api + "/api/v3/missions/violation_management"; +export const GET_MISSION_PROVINCE_ACTIVITY_REPORT = api + "/api/v3/missions/report/country_activity"; +export const GET_MISSION_CITY_ACTIVITY_REPORT = api + "/api/v3/missions/report/country_activity"; export const GET_MACHINES_TABLE_LIST = api + "/api/v3/cmms_machines"; From 6e00f8c9994f025a4c3383238114cd032491d322 Mon Sep 17 00:00:00 2001 From: AminGhasempoor Date: Sun, 21 Dec 2025 09:48:44 +0330 Subject: [PATCH 52/61] pre mission reports page --- .../dashboard/roadMissions/reports/index.jsx | 54 ++++++++++--------- src/core/utils/pageMenu.js | 18 +++---- src/core/utils/pageMenuDev.js | 18 +++---- 3 files changed, 46 insertions(+), 44 deletions(-) diff --git a/src/components/dashboard/roadMissions/reports/index.jsx b/src/components/dashboard/roadMissions/reports/index.jsx index 63b25e3..9ce0a90 100644 --- a/src/components/dashboard/roadMissions/reports/index.jsx +++ b/src/components/dashboard/roadMissions/reports/index.jsx @@ -41,10 +41,12 @@ const ReportPage = () => { { value: `${data.from_date}`, datatype: "date", id: "from_date", fn: "between" }, { value: `${data.date_to}`, datatype: "date", id: "date_to", fn: "between" }, ]); - if (data.province_id === "-1") { + // if (data.province_id === "-1") { try { + params.set("province_id", `${data.province_id}`); const response = await requestServer(`${GET_CITY_ACTIVITY_REPORT}?${params}`); const result = response.data.data; + console.log(result); const nationalReportForItem = result.activities.find((report) => report.province_id === -1); const nationalReport = { edare_name: "کل کشور", @@ -67,31 +69,31 @@ const ReportPage = () => { filters: data, }); } catch (e) {} - } else { - try { - params.set("province_id", `${data.province_id}`); - const response = await requestServer(`${GET_MISSION_CITY_ACTIVITY_REPORT}?${params}`); - const result = response.data.data; - const nationalReportForItem = result.activities.find((report) => report.edare_id === "-1"); - const nationalReport = { - ...nationalReportForItem, - edare_name: "کل استان", - }; - setData({ - data: [ - nationalReport, - ...result.edarateShahri.map((edare) => { - const filteredReports = result.activities.find((report) => report.edare_id == edare.id); - return { - edare_name: edare.name_fa, - ...filteredReports, - }; - }), - ], - filters: data, - }); - } catch (e) {} - } + // } else { + // try { + // params.set("province_id", `${data.province_id}`); + // const response = await requestServer(`${GET_MISSION_CITY_ACTIVITY_REPORT}?${params}`); + // const result = response.data.data; + // const nationalReportForItem = result.activities.find((report) => report.edare_id === "-1"); + // const nationalReport = { + // ...nationalReportForItem, + // edare_name: "کل استان", + // }; + // setData({ + // data: [ + // nationalReport, + // ...result.edarateShahri.map((edare) => { + // const filteredReports = result.activities.find((report) => report.edare_id == edare.id); + // return { + // edare_name: edare.name_fa, + // ...filteredReports, + // }; + // }), + // ], + // filters: data, + // }); + // } catch (e) {} + // } }; useEffect(() => { diff --git a/src/core/utils/pageMenu.js b/src/core/utils/pageMenu.js index b66bd39..1388709 100644 --- a/src/core/utils/pageMenu.js +++ b/src/core/utils/pageMenu.js @@ -148,15 +148,15 @@ export const pageMenu = [ // badges: [{ key: "mission.control" }], // TODO: add badge and permission permissions: ["all"], }, - { - id: "roadMissionsReports", - label: "گزارشات", - type: "page", - route: "/dashboard/road-missions/reports", - icon: , - // badges: [{ key: "mission.control" }], // TODO: add badge and permission - permissions: ["all"], - }, + // { + // id: "roadMissionsReports", + // label: "گزارشات", + // type: "page", + // route: "/dashboard/road-missions/reports", + // icon: , + // // badges: [{ key: "mission.control" }], // TODO: add badge and permission + // permissions: ["all"], + // }, ], }, { diff --git a/src/core/utils/pageMenuDev.js b/src/core/utils/pageMenuDev.js index 3ec7adc..27b37c1 100644 --- a/src/core/utils/pageMenuDev.js +++ b/src/core/utils/pageMenuDev.js @@ -147,15 +147,15 @@ export const pageMenuDev = [ // badges: [{ key: "mission.control" }], // TODO: add badge and permission permissions: ["all"], }, - { - id: "roadMissionsReports", - label: "گزارشات", - type: "page", - route: "/dashboard/road-missions/reports", - icon: , - // badges: [{ key: "mission.control" }], // TODO: add badge and permission - permissions: ["all"], - }, + // { + // id: "roadMissionsReports", + // label: "گزارشات", + // type: "page", + // route: "/dashboard/road-missions/reports", + // icon: , + // // badges: [{ key: "mission.control" }], // TODO: add badge and permission + // permissions: ["all"], + // }, ], }, { From 4aeca6983f76450ff5cfc0f42ea8552d28a6d105 Mon Sep 17 00:00:00 2001 From: AminGhasempoor Date: Sun, 21 Dec 2025 09:50:10 +0330 Subject: [PATCH 53/61] build and format --- .../MissionsDialog/MissionsList/index.jsx | 2 +- .../dashboard/roadMissions/reports/index.jsx | 50 ++++++++-------- .../violations/Actions/showBound/index.jsx | 58 +++++++++---------- 3 files changed, 54 insertions(+), 56 deletions(-) diff --git a/src/components/dashboard/roadItems/operator/Actions/Create/Forms/GetItemInfo/MissionsDialog/MissionsList/index.jsx b/src/components/dashboard/roadItems/operator/Actions/Create/Forms/GetItemInfo/MissionsDialog/MissionsList/index.jsx index f4f5c49..278aa0e 100644 --- a/src/components/dashboard/roadItems/operator/Actions/Create/Forms/GetItemInfo/MissionsDialog/MissionsList/index.jsx +++ b/src/components/dashboard/roadItems/operator/Actions/Create/Forms/GetItemInfo/MissionsDialog/MissionsList/index.jsx @@ -8,7 +8,7 @@ import { useAuth } from "@/lib/contexts/auth"; import { missionRegions } from "@/core/utils/missionRegions"; const MissionList = ({ setMission, setOpenDialog }) => { - const {user} = useAuth() + const { user } = useAuth(); const columns = useMemo( () => [ { diff --git a/src/components/dashboard/roadMissions/reports/index.jsx b/src/components/dashboard/roadMissions/reports/index.jsx index 9ce0a90..5dfd3a7 100644 --- a/src/components/dashboard/roadMissions/reports/index.jsx +++ b/src/components/dashboard/roadMissions/reports/index.jsx @@ -42,33 +42,31 @@ const ReportPage = () => { { value: `${data.date_to}`, datatype: "date", id: "date_to", fn: "between" }, ]); // if (data.province_id === "-1") { - try { - params.set("province_id", `${data.province_id}`); - const response = await requestServer(`${GET_CITY_ACTIVITY_REPORT}?${params}`); - const result = response.data.data; - console.log(result); - const nationalReportForItem = result.activities.find((report) => report.province_id === -1); - const nationalReport = { - edare_name: "کل کشور", - ...nationalReportForItem, - }; + try { + params.set("province_id", `${data.province_id}`); + const response = await requestServer(`${GET_CITY_ACTIVITY_REPORT}?${params}`); + const result = response.data.data; + console.log(result); + const nationalReportForItem = result.activities.find((report) => report.province_id === -1); + const nationalReport = { + edare_name: "کل کشور", + ...nationalReportForItem, + }; - setData({ - data: [ - nationalReport, - ...result.provinces.map((province) => { - const filteredReports = result.activities.find( - (report) => report.province_id === province.id - ); - return { - ...filteredReports, - edare_name: province.name_fa, - }; - }), - ], - filters: data, - }); - } catch (e) {} + setData({ + data: [ + nationalReport, + ...result.provinces.map((province) => { + const filteredReports = result.activities.find((report) => report.province_id === province.id); + return { + ...filteredReports, + edare_name: province.name_fa, + }; + }), + ], + filters: data, + }); + } catch (e) {} // } else { // try { // params.set("province_id", `${data.province_id}`); diff --git a/src/components/dashboard/roadMissions/violations/Actions/showBound/index.jsx b/src/components/dashboard/roadMissions/violations/Actions/showBound/index.jsx index 24db476..43dd0b8 100644 --- a/src/components/dashboard/roadMissions/violations/Actions/showBound/index.jsx +++ b/src/components/dashboard/roadMissions/violations/Actions/showBound/index.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; From 6713c97dc73993ea44b9ce9f0b601eeed2272ae5 Mon Sep 17 00:00:00 2001 From: AminGhasempoor Date: Mon, 22 Dec 2025 09:24:29 +0330 Subject: [PATCH 54/61] show map in lng lat format --- .../dashboard/roadMissions/control/index.jsx | 2 +- .../Actions/Create/Form/GetItemInfo/index.jsx | 4 ---- .../operator/Actions/Create/index.jsx | 2 +- .../Form/GetItemInfo/index.jsx | 4 ---- .../Actions/CreateWithoutProcess/index.jsx | 2 +- .../AddController/Dialog/Form/Area/index.jsx | 1 - .../Dialog/Form/GetItemInfo/index.jsx | 4 ---- .../Add/AddController/Dialog/index.jsx | 2 +- .../RowActions/Add/AddController/index.jsx | 12 ++++++++-- .../RowActions/Edit/EditController/index.jsx | 13 +++++----- .../dashboard/roadMissions/operator/index.jsx | 2 +- .../roadMissions/reports/ReportLists.jsx | 4 ++-- .../dashboard/roadMissions/reports/index.jsx | 6 ++--- .../RowActions/Allocation/Form/index.jsx | 10 +++++--- .../roadMissions/transportation/index.jsx | 2 +- src/core/utils/pageMenu.js | 24 +++++++++---------- src/core/utils/pageMenuDev.js | 24 +++++++++---------- src/core/utils/routes.js | 2 +- 18 files changed, 60 insertions(+), 60 deletions(-) diff --git a/src/components/dashboard/roadMissions/control/index.jsx b/src/components/dashboard/roadMissions/control/index.jsx index ac96845..00b0931 100644 --- a/src/components/dashboard/roadMissions/control/index.jsx +++ b/src/components/dashboard/roadMissions/control/index.jsx @@ -5,7 +5,7 @@ import ControlList from "./ControlList"; const ControlPage = () => { return ( - + ); diff --git a/src/components/dashboard/roadMissions/operator/Actions/Create/Form/GetItemInfo/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/Create/Form/GetItemInfo/index.jsx index b49ede0..f4e66e5 100644 --- a/src/components/dashboard/roadMissions/operator/Actions/Create/Form/GetItemInfo/index.jsx +++ b/src/components/dashboard/roadMissions/operator/Actions/Create/Form/GetItemInfo/index.jsx @@ -9,7 +9,6 @@ import { ExitToApp } from "@mui/icons-material"; import { Box, Button, DialogActions, DialogContent, Grid, Stack } from "@mui/material"; import { Controller, useForm } from "react-hook-form"; import { array, object, string } from "yup"; -import FastReactCode from "./FastReactCode"; const validationSchema = object({ explanation: string().required("موضوع را مشخص کنید!"), @@ -106,9 +105,6 @@ const GetItemInfo = ({ allData, setAllData, handlePrev, setTabState }) => { )} /> - - - { rahdaran: [], requested_machines: [], bound: null, - bound_type: "polygon", + bound_type: "polyline", type: "", start_date: "", start_time: null, 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 7610a5b..6e3afa0 100644 --- a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/GetItemInfo/index.jsx +++ b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/GetItemInfo/index.jsx @@ -8,7 +8,6 @@ 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("موضوع را مشخص کنید!"), @@ -103,9 +102,6 @@ const GetItemInfo = ({ allData, setAllData, handlePrev, setTabState }) => { )} /> - - - { road_observed_id: "", rahdaran: [], bound: null, - bound_type: "polygon", + bound_type: "polyline", start_date: "", start_time: null, end_date: "", 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 d47f840..c8feef7 100644 --- a/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/Area/index.jsx +++ b/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/Area/index.jsx @@ -19,7 +19,6 @@ const Area = ({ allData, setAllData, handlePrev, setTabState, oldBound }) => { setAllData({ bound: bound }); setTabState((s) => s + 1); }, [bound]); - return ( <> 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 7610a5b..6e3afa0 100644 --- a/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/GetItemInfo/index.jsx +++ b/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/Form/GetItemInfo/index.jsx @@ -8,7 +8,6 @@ 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("موضوع را مشخص کنید!"), @@ -103,9 +102,6 @@ const GetItemInfo = ({ allData, setAllData, handlePrev, setTabState }) => { )} /> - - - { category_id: "", bound: null, rahdaran: rahdaran.filter((r) => !r.is_driver), - bound_type: "polygon", + bound_type: "polyline", type: "", end_date: "", end_time: null, 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 2842239..a2e6ff0 100644 --- a/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/index.jsx +++ b/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/index.jsx @@ -1,7 +1,6 @@ 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"; @@ -36,13 +35,22 @@ const AddController = ({ row, mutate, setOpenAddDialog }) => { }); }, [row.original.id]); + const convertedArea = useMemo(() => { + if (!row.original.area) return null; + + return { + ...row.original.area, + coordinates: row.original.area.coordinates.map(([lng, lat]) => [lat, lng]), + }; + }, [row.original.area]); + return rahdaranLoading || machineLoading ? ( ) : ( { + const latLngs = useMemo(() => { + return row.original.area.coordinates.map(([lng, lat]) => [lat, lng]); + }, [row.original.area.coordinates]); + const bound = useMemo( - () => - row.original.area.type == "polygon" - ? L.polygon([...row.original.area.coordinates]) - : L.polyline([...row.original.area.coordinates]), - [row.original.area] + () => (row.original.area.type === "polygon" ? L.polygon(latLngs) : L.polyline(latLngs)), + [row.original.area.type, latLngs] ); + const [submitting, setSubmitting] = useState(false); const [rahdaran, setRahdaran] = useState(null); const [rahdaranLoading, setRahdaranLoading] = useState(true); @@ -35,7 +37,6 @@ const EditController = ({ row, mutate, openEditDialog, setOpenEditDialog }) => { setSubmitting(true); const bound = result.bound.getLatLngs(); let area = bound.map((ring) => ring.map((latlng) => [latlng.lat, latlng.lng])); - await requestServer(`${UPDATE_REQUEST_MISSION}/${row.original.id}`, "post", { data: { explanation: result.explanation, diff --git a/src/components/dashboard/roadMissions/operator/index.jsx b/src/components/dashboard/roadMissions/operator/index.jsx index 148167b..20b08f1 100644 --- a/src/components/dashboard/roadMissions/operator/index.jsx +++ b/src/components/dashboard/roadMissions/operator/index.jsx @@ -6,7 +6,7 @@ import OperatorList from "./OperatorList"; const OperatorPage = () => { return ( - + ); diff --git a/src/components/dashboard/roadMissions/reports/ReportLists.jsx b/src/components/dashboard/roadMissions/reports/ReportLists.jsx index 19b5e71..fd7d606 100644 --- a/src/components/dashboard/roadMissions/reports/ReportLists.jsx +++ b/src/components/dashboard/roadMissions/reports/ReportLists.jsx @@ -41,9 +41,9 @@ const ReportLists = ({ data, specialFilter }) => { }, }, { - accessorKey: "out_of_aria_count", + accessorKey: "out_of_area_count", header: "تردد خارج محدوده", - id: "out_of_aria_count", + id: "out_of_area_count", enableColumnFilter: false, enableSorting: false, datatype: "text", diff --git a/src/components/dashboard/roadMissions/reports/index.jsx b/src/components/dashboard/roadMissions/reports/index.jsx index 5dfd3a7..83daf1a 100644 --- a/src/components/dashboard/roadMissions/reports/index.jsx +++ b/src/components/dashboard/roadMissions/reports/index.jsx @@ -46,8 +46,7 @@ const ReportPage = () => { params.set("province_id", `${data.province_id}`); const response = await requestServer(`${GET_CITY_ACTIVITY_REPORT}?${params}`); const result = response.data.data; - console.log(result); - const nationalReportForItem = result.activities.find((report) => report.province_id === -1); + const nationalReportForItem = result.activities.find((report) => report.province_id === "-1"); const nationalReport = { edare_name: "کل کشور", ...nationalReportForItem, @@ -57,7 +56,8 @@ const ReportPage = () => { data: [ nationalReport, ...result.provinces.map((province) => { - const filteredReports = result.activities.find((report) => report.province_id === province.id); + const filteredReports = result.activities.find((report) => report.province_id == province.id); + console.log(filteredReports); return { ...filteredReports, edare_name: province.name_fa, 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 eed66c8..099b4aa 100644 --- a/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/index.jsx +++ b/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/index.jsx @@ -13,10 +13,14 @@ import DriversDialog from "./DriversDialog"; import MachinesDialog from "./MachinesDialog"; import Reject from "./Reject"; const AllocationForm = ({ row, mutate, setOpenAllocationDialog }) => { + + const latLngs = useMemo(() => { + return row.area.coordinates.map(([lng, lat]) => [lat, lng]); + }, [row.area.coordinates]); + const bound = useMemo( - () => - row.area.type == "polygon" ? L.polygon([...row.area.coordinates]) : L.polyline([...row.area.coordinates]), - [row.area] + () => (row.area.type === "polygon" ? L.polygon(latLngs) : L.polyline(latLngs)), + [row.area.type, latLngs] ); const requestServer = useRequest({ notificationSuccess: true }); const [machine, setMachine] = useState(); diff --git a/src/components/dashboard/roadMissions/transportation/index.jsx b/src/components/dashboard/roadMissions/transportation/index.jsx index ca0db36..f42676e 100644 --- a/src/components/dashboard/roadMissions/transportation/index.jsx +++ b/src/components/dashboard/roadMissions/transportation/index.jsx @@ -6,7 +6,7 @@ import TransportationList from "./TransportationList"; const TransportationPage = () => { return ( - + ); diff --git a/src/core/utils/pageMenu.js b/src/core/utils/pageMenu.js index 1388709..663de96 100644 --- a/src/core/utils/pageMenu.js +++ b/src/core/utils/pageMenu.js @@ -110,7 +110,7 @@ export const pageMenu = [ Subitems: [ { id: "roadMissionsManagemnetRequests", - label: "کارتابل", + label: "درخواست کننده", icon: , type: "page", route: "/dashboard/road-missions/operator", @@ -123,7 +123,7 @@ export const pageMenu = [ }, { id: "roadMissionsManagemnetNaqlie", - label: "نقلیه", + label: "تایید کننده", type: "page", icon: , route: "/dashboard/road-missions/transportation", @@ -132,7 +132,7 @@ export const pageMenu = [ }, { id: "roadMissionsManagemnetControl", - label: "کنترل", + label: "کنترل تردد", type: "page", icon: , route: "/dashboard/road-missions/control", @@ -148,15 +148,15 @@ export const pageMenu = [ // badges: [{ key: "mission.control" }], // TODO: add badge and permission permissions: ["all"], }, - // { - // id: "roadMissionsReports", - // label: "گزارشات", - // type: "page", - // route: "/dashboard/road-missions/reports", - // icon: , - // // badges: [{ key: "mission.control" }], // TODO: add badge and permission - // permissions: ["all"], - // }, + { + id: "roadMissionsReports", + label: "گزارشات", + type: "page", + route: "/dashboard/road-missions/reports", + icon: , + // badges: [{ key: "mission.control" }], // TODO: add badge and permission + permissions: ["all"], + }, ], }, { diff --git a/src/core/utils/pageMenuDev.js b/src/core/utils/pageMenuDev.js index 27b37c1..f4546fc 100644 --- a/src/core/utils/pageMenuDev.js +++ b/src/core/utils/pageMenuDev.js @@ -109,7 +109,7 @@ export const pageMenuDev = [ Subitems: [ { id: "roadMissionsManagemnetRequests", - label: "کارتابل", + label: "درخواست کننده", icon: , type: "page", route: "/dashboard/road-missions/operator", @@ -122,7 +122,7 @@ export const pageMenuDev = [ }, { id: "roadMissionsManagemnetNaqlie", - label: "نقلیه", + label: "تایید کننده", type: "page", icon: , route: "/dashboard/road-missions/transportation", @@ -131,7 +131,7 @@ export const pageMenuDev = [ }, { id: "roadMissionsManagemnetControl", - label: "کنترل", + label: "کنترل تردد", type: "page", icon: , route: "/dashboard/road-missions/control", @@ -147,15 +147,15 @@ export const pageMenuDev = [ // badges: [{ key: "mission.control" }], // TODO: add badge and permission permissions: ["all"], }, - // { - // id: "roadMissionsReports", - // label: "گزارشات", - // type: "page", - // route: "/dashboard/road-missions/reports", - // icon: , - // // badges: [{ key: "mission.control" }], // TODO: add badge and permission - // permissions: ["all"], - // }, + { + id: "roadMissionsReports", + label: "گزارشات", + type: "page", + route: "/dashboard/road-missions/reports", + icon: , + // badges: [{ key: "mission.control" }], // TODO: add badge and permission + permissions: ["all"], + }, ], }, { diff --git a/src/core/utils/routes.js b/src/core/utils/routes.js index 411ef1b..1c9160d 100644 --- a/src/core/utils/routes.js +++ b/src/core/utils/routes.js @@ -43,7 +43,7 @@ export const GET_FMS_DATA = api + "/api/v3/fms_vehicle/get_activity"; export const GET_OTP_TOKEN = api + "/api/v3/otp/get_token"; export const GET_PROVINCE_ACTIVITY_REPORT = api + "/api/v3/road_patrols/report/country_activity"; -export const GET_CITY_ACTIVITY_REPORT = api + "/api/v3/road_patrols/report/province_activity"; +export const GET_CITY_ACTIVITY_REPORT = api + "/api/v3/missions/report/country_activity"; export const EXPORT_COUNTRY_ROAD_PATROL_REPORTS = api + "/api/v3/road_patrols/report/country_activity_excel"; export const EXPORT_PROVINCE_ROAD_PATROL_REPORTS = api + "/api/v3/road_patrols/report/province_activity_excel"; From 36a0ab518ccee5aa6f883ccda34d09e04792f66b Mon Sep 17 00:00:00 2001 From: AminGhasempoor Date: Mon, 22 Dec 2025 09:26:59 +0330 Subject: [PATCH 55/61] build and format --- .../transportation/RowActions/Allocation/Form/index.jsx | 1 - 1 file changed, 1 deletion(-) 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 099b4aa..1702622 100644 --- a/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/index.jsx +++ b/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/index.jsx @@ -13,7 +13,6 @@ import DriversDialog from "./DriversDialog"; import MachinesDialog from "./MachinesDialog"; import Reject from "./Reject"; const AllocationForm = ({ row, mutate, setOpenAllocationDialog }) => { - const latLngs = useMemo(() => { return row.area.coordinates.map(([lng, lat]) => [lat, lng]); }, [row.area.coordinates]); From 95e1fc342736e03bc99ba9b2cd00c3114d50f69e Mon Sep 17 00:00:00 2001 From: AminGhasempoor Date: Mon, 22 Dec 2025 13:07:09 +0330 Subject: [PATCH 56/61] change permissions --- .../dashboard/road-missions/control/page.js | 9 ++++- .../dashboard/road-missions/operator/page.js | 1 + .../road-missions/transportation/page.js | 9 ++++- .../RowActions/Allocation/Form/index.jsx | 39 +++++++++++++------ src/core/utils/pageMenu.js | 15 ++++++- src/core/utils/pageMenuDev.js | 15 ++++++- 6 files changed, 71 insertions(+), 17 deletions(-) diff --git a/src/app/(withAuth)/(dashboardLayout)/dashboard/road-missions/control/page.js b/src/app/(withAuth)/(dashboardLayout)/dashboard/road-missions/control/page.js index e22ce33..708e125 100644 --- a/src/app/(withAuth)/(dashboardLayout)/dashboard/road-missions/control/page.js +++ b/src/app/(withAuth)/(dashboardLayout)/dashboard/road-missions/control/page.js @@ -7,7 +7,14 @@ export const metadata = { const Page = () => { return ( <> - + {/* */} diff --git a/src/app/(withAuth)/(dashboardLayout)/dashboard/road-missions/operator/page.js b/src/app/(withAuth)/(dashboardLayout)/dashboard/road-missions/operator/page.js index 417937a..4328d12 100644 --- a/src/app/(withAuth)/(dashboardLayout)/dashboard/road-missions/operator/page.js +++ b/src/app/(withAuth)/(dashboardLayout)/dashboard/road-missions/operator/page.js @@ -12,6 +12,7 @@ const Page = () => { "manage-request-portal-country", "manage-request-portal-province", "manage-request-portal-city", + "manage-request-portal-station", ]} > diff --git a/src/app/(withAuth)/(dashboardLayout)/dashboard/road-missions/transportation/page.js b/src/app/(withAuth)/(dashboardLayout)/dashboard/road-missions/transportation/page.js index ff62cff..5644851 100644 --- a/src/app/(withAuth)/(dashboardLayout)/dashboard/road-missions/transportation/page.js +++ b/src/app/(withAuth)/(dashboardLayout)/dashboard/road-missions/transportation/page.js @@ -7,7 +7,14 @@ export const metadata = { const Page = () => { return ( <> - + {/* */} 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 1702622..7affee2 100644 --- a/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/index.jsx +++ b/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/index.jsx @@ -12,6 +12,9 @@ import ShowBound from "../../../Actions/showBound"; import DriversDialog from "./DriversDialog"; import MachinesDialog from "./MachinesDialog"; import Reject from "./Reject"; +import SelectBox from "@/core/components/SelectBox"; +import { Controller, useForm } from "react-hook-form"; + const AllocationForm = ({ row, mutate, setOpenAllocationDialog }) => { const latLngs = useMemo(() => { return row.area.coordinates.map(([lng, lat]) => [lat, lng]); @@ -25,6 +28,12 @@ const AllocationForm = ({ row, mutate, setOpenAllocationDialog }) => { const [machine, setMachine] = useState(); const [driver, setDriver] = useState(); const [isSubmitting, setIsSubmitting] = useState(false); + const { control, watch } = useForm({ + defaultValues: { + machine_type: row.requested_machines?.[0] ? [row.requested_machines[0]] : [], + }, + }); + const handleSubmit = async (_machine, _driver) => { setIsSubmitting(true); @@ -45,6 +54,7 @@ const AllocationForm = ({ row, mutate, setOpenAllocationDialog }) => { }); }; + const selectedMachineType = watch("machine_type")?.[0]; return ( <> @@ -53,12 +63,22 @@ const AllocationForm = ({ row, mutate, setOpenAllocationDialog }) => { - - نوع خودرو درخواستی - - - mt.id == row.requested_machines?.[0])?.name_fa} + ( + { + field.onChange([newValue]); + }} + /> + )} /> @@ -76,16 +96,13 @@ const AllocationForm = ({ row, mutate, setOpenAllocationDialog }) => { /> ) : ( - + )} {machine && ( diff --git a/src/core/utils/pageMenu.js b/src/core/utils/pageMenu.js index 663de96..08f09f0 100644 --- a/src/core/utils/pageMenu.js +++ b/src/core/utils/pageMenu.js @@ -119,6 +119,7 @@ export const pageMenu = [ "manage-request-portal-country", "manage-request-portal-province", "manage-request-portal-city", + "manage-request-portal-station", ], }, { @@ -128,7 +129,12 @@ export const pageMenu = [ icon: , route: "/dashboard/road-missions/transportation", badges: [{ key: "mission.transportation" }], - permissions: ["manage-transportation-unit"], + permissions: [ + "manage-transportation-unit-city", + "manage-transportation-unit-province", + "manage-transportation-unit-country", + "manage-transportation-unit-station", + ], }, { id: "roadMissionsManagemnetControl", @@ -137,7 +143,12 @@ export const pageMenu = [ icon: , route: "/dashboard/road-missions/control", badges: [{ key: "mission.control" }], - permissions: ["manage-control-unit"], + permissions: [ + "manage-control-unit-province", + "manage-control-unit-city", + "manage-control-unit-country", + "manage-control-unit-station", + ], }, { id: "roadMissionsViolations", diff --git a/src/core/utils/pageMenuDev.js b/src/core/utils/pageMenuDev.js index f4546fc..f78fffe 100644 --- a/src/core/utils/pageMenuDev.js +++ b/src/core/utils/pageMenuDev.js @@ -118,6 +118,7 @@ export const pageMenuDev = [ "manage-request-portal-country", "manage-request-portal-province", "manage-request-portal-city", + "manage-request-portal-station", ], }, { @@ -127,7 +128,12 @@ export const pageMenuDev = [ icon: , route: "/dashboard/road-missions/transportation", badges: [{ key: "mission.transportation" }], - permissions: ["manage-transportation-unit"], + permissions: [ + "manage-transportation-unit-province", + "manage-transportation-unit-city", + "manage-transportation-unit-country", + "manage-transportation-unit-station", + ], }, { id: "roadMissionsManagemnetControl", @@ -136,7 +142,12 @@ export const pageMenuDev = [ icon: , route: "/dashboard/road-missions/control", badges: [{ key: "mission.control" }], - permissions: ["manage-control-unit"], + permissions: [ + "manage-control-unit-province", + "manage-control-unit-city", + "manage-control-unit-country", + "manage-control-unit-station", + ], }, { id: "roadMissionsViolations", From f43629766be34e807e23f48f76d36ec58079a04c Mon Sep 17 00:00:00 2001 From: AminGhasempoor Date: Mon, 22 Dec 2025 13:08:24 +0330 Subject: [PATCH 57/61] build and format --- .../transportation/RowActions/Allocation/Form/index.jsx | 1 - 1 file changed, 1 deletion(-) 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 7affee2..c35018d 100644 --- a/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/index.jsx +++ b/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/index.jsx @@ -34,7 +34,6 @@ const AllocationForm = ({ row, mutate, setOpenAllocationDialog }) => { }, }); - const handleSubmit = async (_machine, _driver) => { setIsSubmitting(true); await requestServer(`${ALLOCATE_REQUEST_MISSION}/${row.id}`, "post", { From 4a733811a530bf92a3bcc3444928fbd4bc26af3f Mon Sep 17 00:00:00 2001 From: baslani Date: Mon, 22 Dec 2025 14:47:20 +0330 Subject: [PATCH 58/61] updated violations and no_process actions --- .../Form/GetItemInfo/index.jsx | 3 - .../MachineAndDriver/MachinesDialog/index.jsx | 40 ++++++++++-- .../Form/MachineAndDriver/index.jsx | 62 ++++++++++--------- .../Form/Verify/index.jsx | 28 +++------ .../CreateWithoutProcess/Form/index.jsx | 26 +++----- .../Actions/CreateWithoutProcess/index.jsx | 26 +------- .../Form/Verify/index.jsx | 5 -- .../CreateWithoutProcess/Form/index.jsx | 26 +++----- .../Actions/CreateWithoutProcess/index.jsx | 15 +---- src/core/utils/routes.js | 3 +- 10 files changed, 97 insertions(+), 137 deletions(-) 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 7610a5b..666b1f9 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 @@ -103,9 +103,6 @@ const GetItemInfo = ({ allData, setAllData, handlePrev, setTabState }) => { )} /> - - - { +const MachinesDialog = ({ setMachine, mode, machineCode, setShowMachineCodeDialog }) => { const [openMachinesDialog, setOpenMachinesDialog] = useState(false); + return ( <> {mode == "edit" ? ( @@ -13,7 +14,7 @@ const MachinesDialog = ({ setMachine, mode }) => { ) : ( )} @@ -31,7 +32,36 @@ const MachinesDialog = ({ setMachine, mode }) => { {openMachinesDialog && ( - + + { + setMachine(event.target.value); + }} + variant="outlined" + fullWidth + /> + + )} 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 951fd83..03ce25e 100644 --- a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/MachineAndDriver/index.jsx +++ b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/MachineAndDriver/index.jsx @@ -1,10 +1,11 @@ import { Box, Button, Chip, DialogActions, DialogContent, Divider, Stack, Typography } from "@mui/material"; -import DriversDialog from "./DriversDialog"; import { useState } from "react"; +import DriversDialog from "./DriversDialog"; import MachinesDialog from "./MachinesDialog"; const MachineAndDriver = ({ setTabState, allData, setAllData, handlePrev }) => { - const [machine, setMachine] = useState(allData.machine); + const [showMachineCodeDialog, setShowMachineCodeDialog] = useState(allData.machine_code ? true : false); + const [machineCode, setMachineCode] = useState(allData.machine_code); const [driver, setDriver] = useState(allData.driver); const handleNext = (data) => { @@ -18,43 +19,44 @@ const MachineAndDriver = ({ setTabState, allData, setAllData, handlePrev }) => { - {machine ? ( + {showMachineCodeDialog ? ( <> خودرو + + + + + ) : ( + + )} + + + + {driver ? ( + <> + راننده + - + ) : ( - + )} - {machine && ( - - {driver ? ( - <> - راننده - - - - - - ) : ( - - )} - - )} @@ -64,9 +66,9 @@ const MachineAndDriver = ({ setTabState, allData, setAllData, handlePrev }) => { 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 039ff75..48516b0 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,15 +1,8 @@ -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(() => { @@ -21,11 +14,6 @@ const Verify = ({ allData, handlePrev, submitForm, submitting }) => { - - - - - @@ -79,16 +67,20 @@ const Verify = ({ allData, handlePrev, submitForm, submitting }) => { - + + - خودرو + کد خودرو - + + + + + + + راننده 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 00c4297..0d60270 100644 --- a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/index.jsx +++ b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/index.jsx @@ -1,12 +1,11 @@ -import { AccessTime, Engineering, InsertDriveFile, LocalShipping, Route, Verified } from "@mui/icons-material"; +import { AccessTime, Engineering, InsertDriveFile, LocalShipping, 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 MachineAndDriver from "./MachineAndDriver"; import Rahdaran from "./Rahdaran"; import Verify from "./Verify"; -import MachineAndDriver from "./MachineAndDriver"; function TabPanel(props) { const { children, value, index } = props; @@ -61,10 +60,9 @@ const CreateForm = ({ defaultValues, submitForm, setOpen, submitting }) => { > } label="مشخصات" /> } label="زمانبندی" /> - } label="منطقه عملیاتی" /> - } label="خودرو و راننده" /> - } label="همراهان" /> - } label="بررسی نهایی" /> + } label="خودرو و راننده" /> + } label="همراهان" /> + } label="بررسی نهایی" /> { /> - { - dispatch({ type: "changeData", data }); - }} - handlePrev={handlePrev} - setTabState={setTabState} - /> - - { @@ -106,7 +94,7 @@ const CreateForm = ({ defaultValues, submitForm, setOpen, submitting }) => { setTabState={setTabState} /> - + { @@ -116,7 +104,7 @@ const CreateForm = ({ defaultValues, submitForm, setOpen, submitting }) => { setTabState={setTabState} /> - + diff --git a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/index.jsx index 277a63d..f5a4a8a 100644 --- a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/index.jsx +++ b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/index.jsx @@ -19,38 +19,18 @@ const CreateWithoutProcess = ({ mutate }) => { 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, + machine_code: result.machine_code, }, hasSidebarUpdate: true, }) @@ -102,16 +82,14 @@ const CreateWithoutProcess = ({ mutate }) => { category_id: "", road_observed_id: "", rahdaran: [], - bound: null, - bound_type: "polygon", start_date: "", start_time: null, end_date: "", end_time: null, end_point: "", region: "", - machine: null, driver: null, + machine_code: "", }} submitForm={submitForm} submitting={submitting} 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 805e5d2..09f865f 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 @@ -21,11 +21,6 @@ const Verify = ({ allData, handlePrev, submitForm, submitting }) => { - - - - - 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 45ec88e..96de65d 100644 --- a/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/index.jsx +++ b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/index.jsx @@ -1,12 +1,11 @@ -import { AccessTime, Engineering, InsertDriveFile, Route, Verified, Person } from "@mui/icons-material"; +import { AccessTime, Engineering, InsertDriveFile, Person, 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 MachineAndDriver from "./MachineAndDriver"; import Rahdaran from "./Rahdaran"; import Verify from "./Verify"; -import MachineAndDriver from "./MachineAndDriver"; function TabPanel(props) { const { children, value, index } = props; @@ -61,10 +60,9 @@ const CreateForm = ({ defaultValues, submitForm, setOpen, submitting }) => { > } label="مشخصات" /> } label="زمانبندی" /> - } label="منطقه عملیاتی" /> - } label="راننده" /> - } label="همراهان" /> - } label="بررسی نهایی" /> + } label="راننده" /> + } label="همراهان" /> + } label="بررسی نهایی" /> { /> - { - dispatch({ type: "changeData", data }); - }} - handlePrev={handlePrev} - setTabState={setTabState} - /> - - { @@ -106,7 +94,7 @@ const CreateForm = ({ defaultValues, submitForm, setOpen, submitting }) => { setTabState={setTabState} /> - + { @@ -116,7 +104,7 @@ const CreateForm = ({ defaultValues, submitForm, setOpen, submitting }) => { setTabState={setTabState} /> - + diff --git a/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/index.jsx b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/index.jsx index 5bc7492..0e1f42b 100644 --- a/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/index.jsx +++ b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/index.jsx @@ -1,4 +1,4 @@ -import { REQUEST_MISSION_WITHOUT_PROCESS } from "@/core/utils/routes"; +import { REQUEST_MISSION_VIOLATIONS_PROCESS } from "@/core/utils/routes"; import useRequest from "@/lib/hooks/useRequest"; import { AddCircleOutline, Close } from "@mui/icons-material"; import { Dialog, IconButton, Tooltip } from "@mui/material"; @@ -17,20 +17,11 @@ const CreateWithoutProcess = ({ row, mutate }) => { 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}/${row.original.id}`, "post", { + await requestServer(`${REQUEST_MISSION_VIOLATIONS_PROCESS}/${row.original.id}`, "post", { data: { explanation: result.explanation, category_id: result.category_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, @@ -79,8 +70,6 @@ const CreateWithoutProcess = ({ row, mutate }) => { category_id: "", road_observed_id: "", rahdaran: [], - bound: null, - bound_type: "polygon", start_date: "", start_time: null, end_date: "", diff --git a/src/core/utils/routes.js b/src/core/utils/routes.js index 411ef1b..ea82259 100644 --- a/src/core/utils/routes.js +++ b/src/core/utils/routes.js @@ -217,7 +217,8 @@ export const GET_ROAD_MISSIONS_OPERATOR_LIST = api + "/api/v3/missions/request_p export const GET_ROAD_MISSIONS_TRANSPORTATION_LIST = api + "/api/v3/missions/transportation_unit"; export const GET_ROAD_MISSIONS_CONTROL_LIST = api + "/api/v3/missions/control_unit"; export const REQUEST_MISSION = api + "/api/v3/missions/request_portal"; -export const REQUEST_MISSION_WITHOUT_PROCESS = api + "/api/v3/missions/violation_management/no_process"; +export const REQUEST_MISSION_WITHOUT_PROCESS = api + "/api/v3/missions/request_portal/no_process"; +export const REQUEST_MISSION_VIOLATIONS_PROCESS = api + "/api/v3/missions/violation_management/no_process"; export const REQUEST_MISSION_CONTINUE_MISSION = api + "/api/v3/missions/request_portal/continue"; export const UPDATE_REQUEST_MISSION = api + "/api/v3/missions/request_portal"; export const DELETE_REQUEST_MISSION = api + "/api/v3/missions/request_portal"; From bcf52b301d495a6af27d0700c5ca9d277d48dafa Mon Sep 17 00:00:00 2001 From: baslani Date: Mon, 22 Dec 2025 14:52:04 +0330 Subject: [PATCH 59/61] commented sidebar reports button --- src/core/utils/pageMenu.js | 18 +++++++++--------- src/core/utils/pageMenuDev.js | 18 +++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/core/utils/pageMenu.js b/src/core/utils/pageMenu.js index 08f09f0..97c7001 100644 --- a/src/core/utils/pageMenu.js +++ b/src/core/utils/pageMenu.js @@ -159,15 +159,15 @@ export const pageMenu = [ // badges: [{ key: "mission.control" }], // TODO: add badge and permission permissions: ["all"], }, - { - id: "roadMissionsReports", - label: "گزارشات", - type: "page", - route: "/dashboard/road-missions/reports", - icon: , - // badges: [{ key: "mission.control" }], // TODO: add badge and permission - permissions: ["all"], - }, + // { + // id: "roadMissionsReports", + // label: "گزارشات", + // type: "page", + // route: "/dashboard/road-missions/reports", + // icon: , + // // badges: [{ key: "mission.control" }], // TODO: add badge and permission + // permissions: ["all"], + // }, ], }, { diff --git a/src/core/utils/pageMenuDev.js b/src/core/utils/pageMenuDev.js index f78fffe..90ae25f 100644 --- a/src/core/utils/pageMenuDev.js +++ b/src/core/utils/pageMenuDev.js @@ -158,15 +158,15 @@ export const pageMenuDev = [ // badges: [{ key: "mission.control" }], // TODO: add badge and permission permissions: ["all"], }, - { - id: "roadMissionsReports", - label: "گزارشات", - type: "page", - route: "/dashboard/road-missions/reports", - icon: , - // badges: [{ key: "mission.control" }], // TODO: add badge and permission - permissions: ["all"], - }, + // { + // id: "roadMissionsReports", + // label: "گزارشات", + // type: "page", + // route: "/dashboard/road-missions/reports", + // icon: , + // // badges: [{ key: "mission.control" }], // TODO: add badge and permission + // permissions: ["all"], + // }, ], }, { From cc9b052b960453bfdd3f6ae14a97134daf7de3cb Mon Sep 17 00:00:00 2001 From: AminGhasempoor Date: Mon, 22 Dec 2025 15:12:42 +0330 Subject: [PATCH 60/61] add area to no process --- .../CreateWithoutProcess/Form/Verify/index.jsx | 13 +++++++++++++ .../Actions/CreateWithoutProcess/Form/index.jsx | 14 +++++++++++++- .../Actions/CreateWithoutProcess/index.jsx | 17 +++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) 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 48516b0..d55de17 100644 --- a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/Verify/index.jsx +++ b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/Verify/index.jsx @@ -3,6 +3,14 @@ import { missionRegions } from "@/core/utils/missionRegions"; import { Box, Button, Chip, DialogActions, DialogContent, Divider, Stack, Typography } from "@mui/material"; import moment from "jalali-moment"; import { useCallback } from "react"; +// import ShowBound from "../../../showBound"; +// import MapLoading from "@/core/components/MapLayer/Loading"; +// import dynamic from "next/dynamic"; +// +// const MapLayer = dynamic(() => import("@/core/components/MapLayer"), { +// loading: () => , +// ssr: false, +// }); const Verify = ({ allData, handlePrev, submitForm, submitting }) => { const handleNext = useCallback(() => { @@ -14,6 +22,11 @@ const Verify = ({ allData, handlePrev, submitForm, submitting }) => { + {/**/} + {/* */} + {/* */} + {/* */} + {/**/} 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 0d60270..a36981c 100644 --- a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/index.jsx +++ b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/index.jsx @@ -1,4 +1,4 @@ -import { AccessTime, Engineering, InsertDriveFile, LocalShipping, Verified } from "@mui/icons-material"; +import { AccessTime, Engineering, InsertDriveFile, LocalShipping, Route, Verified } from "@mui/icons-material"; import { Box, Tab, Tabs } from "@mui/material"; import { useReducer, useState } from "react"; import GetDateTime from "./GetDateTime"; @@ -6,6 +6,7 @@ import GetItemInfo from "./GetItemInfo"; import MachineAndDriver from "./MachineAndDriver"; import Rahdaran from "./Rahdaran"; import Verify from "./Verify"; +import Area from "@/components/dashboard/roadMissions/operator/Actions/Create/Form/Area"; function TabPanel(props) { const { children, value, index } = props; @@ -60,6 +61,7 @@ const CreateForm = ({ defaultValues, submitForm, setOpen, submitting }) => { > } label="مشخصات" /> } label="زمانبندی" /> + {/*} label="منطقه عملیاتی" />*/} } label="خودرو و راننده" /> } label="همراهان" /> } label="بررسی نهایی" /> @@ -84,6 +86,16 @@ const CreateForm = ({ defaultValues, submitForm, setOpen, submitting }) => { setTabState={setTabState} /> + {/**/} + {/* {*/} + {/* dispatch({ type: "changeData", data });*/} + {/* }}*/} + {/* handlePrev={handlePrev}*/} + {/* setTabState={setTabState}*/} + {/* />*/} + {/**/} { 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: { @@ -27,6 +38,10 @@ const CreateWithoutProcess = ({ mutate }) => { ...(result.rahdaran.length != 0 ? { rahdaran: result.rahdaran.map((r) => r.id) } : {}), zone: result.region, end_point: result.end_point, + // area: { + // type: result.bound_type, + // coordinates: area, + // }, start_date: `${result.start_date} ${moment(result.start_time).format("HH:mm")}`, end_date: `${result.end_date} ${moment(result.end_time).format("HH:mm")}`, driver: result.driver.id, @@ -85,6 +100,8 @@ const CreateWithoutProcess = ({ mutate }) => { start_date: "", start_time: null, end_date: "", + // bound: null, + // bound_type: "polyline", end_time: null, end_point: "", region: "", From 5d0c8307c129ca8710b9307feeed061f27ed4f80 Mon Sep 17 00:00:00 2001 From: AminGhasempoor Date: Mon, 22 Dec 2025 15:17:08 +0330 Subject: [PATCH 61/61] release v1.8.4 --- .env.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.example b/.env.example index d6c1f1b..406a907 100644 --- a/.env.example +++ b/.env.example @@ -1,5 +1,5 @@ HOST="rms.witel.ir" HOST_RMTO="rms.rmto.ir" -NEXT_PUBLIC_VERSION="1.8.3" +NEXT_PUBLIC_VERSION="1.8.4" NEXT_PUBLIC_API_URL="https://rms.witel.ir" NEXT_PUBLIC_MAPTILE_ENDPOINT="https://rmsmap.rmto.ir/141map" \ No newline at end of file