From f78ee620cde0f1b4df4cf6d27255afaaf4c14d76 Mon Sep 17 00:00:00 2001 From: AminGhasempoor Date: Wed, 17 Dec 2025 14:53:19 +0330 Subject: [PATCH] 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;