From 4a733811a530bf92a3bcc3444928fbd4bc26af3f Mon Sep 17 00:00:00 2001 From: baslani Date: Mon, 22 Dec 2025 14:47:20 +0330 Subject: [PATCH] updated violations and no_process actions --- .../Form/GetItemInfo/index.jsx | 3 - .../MachineAndDriver/MachinesDialog/index.jsx | 40 ++++++++++-- .../Form/MachineAndDriver/index.jsx | 62 ++++++++++--------- .../Form/Verify/index.jsx | 28 +++------ .../CreateWithoutProcess/Form/index.jsx | 26 +++----- .../Actions/CreateWithoutProcess/index.jsx | 26 +------- .../Form/Verify/index.jsx | 5 -- .../CreateWithoutProcess/Form/index.jsx | 26 +++----- .../Actions/CreateWithoutProcess/index.jsx | 15 +---- src/core/utils/routes.js | 3 +- 10 files changed, 97 insertions(+), 137 deletions(-) diff --git a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/GetItemInfo/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/GetItemInfo/index.jsx index 7610a5b..666b1f9 100644 --- a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/GetItemInfo/index.jsx +++ b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/GetItemInfo/index.jsx @@ -103,9 +103,6 @@ const GetItemInfo = ({ allData, setAllData, handlePrev, setTabState }) => { )} /> - - - { +const MachinesDialog = ({ setMachine, mode, machineCode, setShowMachineCodeDialog }) => { const [openMachinesDialog, setOpenMachinesDialog] = useState(false); + return ( <> {mode == "edit" ? ( @@ -13,7 +14,7 @@ const MachinesDialog = ({ setMachine, mode }) => { ) : ( )} @@ -31,7 +32,36 @@ const MachinesDialog = ({ setMachine, mode }) => { {openMachinesDialog && ( - + + { + setMachine(event.target.value); + }} + variant="outlined" + fullWidth + /> + + )} diff --git a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/MachineAndDriver/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/MachineAndDriver/index.jsx index 951fd83..03ce25e 100644 --- a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/MachineAndDriver/index.jsx +++ b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/MachineAndDriver/index.jsx @@ -1,10 +1,11 @@ import { Box, Button, Chip, DialogActions, DialogContent, Divider, Stack, Typography } from "@mui/material"; -import DriversDialog from "./DriversDialog"; import { useState } from "react"; +import DriversDialog from "./DriversDialog"; import MachinesDialog from "./MachinesDialog"; const MachineAndDriver = ({ setTabState, allData, setAllData, handlePrev }) => { - const [machine, setMachine] = useState(allData.machine); + const [showMachineCodeDialog, setShowMachineCodeDialog] = useState(allData.machine_code ? true : false); + const [machineCode, setMachineCode] = useState(allData.machine_code); const [driver, setDriver] = useState(allData.driver); const handleNext = (data) => { @@ -18,43 +19,44 @@ const MachineAndDriver = ({ setTabState, allData, setAllData, handlePrev }) => { - {machine ? ( + {showMachineCodeDialog ? ( <> خودرو + + + + + ) : ( + + )} + + + + {driver ? ( + <> + راننده + - + ) : ( - + )} - {machine && ( - - {driver ? ( - <> - راننده - - - - - - ) : ( - - )} - - )} @@ -64,9 +66,9 @@ const MachineAndDriver = ({ setTabState, allData, setAllData, handlePrev }) => { diff --git a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/Verify/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/Verify/index.jsx index 039ff75..48516b0 100644 --- a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/Verify/index.jsx +++ b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/Verify/index.jsx @@ -1,15 +1,8 @@ -import MapLoading from "@/core/components/MapLayer/Loading"; import { missionCategoryTypes } from "@/core/utils/missionCategoryTypes"; import { missionRegions } from "@/core/utils/missionRegions"; import { Box, Button, Chip, DialogActions, DialogContent, Divider, Stack, Typography } from "@mui/material"; import moment from "jalali-moment"; -import dynamic from "next/dynamic"; import { useCallback } from "react"; -import ShowBound from "../../../showBound"; -const MapLayer = dynamic(() => import("@/core/components/MapLayer"), { - loading: () => , - ssr: false, -}); const Verify = ({ allData, handlePrev, submitForm, submitting }) => { const handleNext = useCallback(() => { @@ -21,11 +14,6 @@ const Verify = ({ allData, handlePrev, submitForm, submitting }) => { - - - - - @@ -79,16 +67,20 @@ const Verify = ({ allData, handlePrev, submitForm, submitting }) => { - + + - خودرو + کد خودرو - + + + + + + + راننده diff --git a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/index.jsx index 00c4297..0d60270 100644 --- a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/index.jsx +++ b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/index.jsx @@ -1,12 +1,11 @@ -import { AccessTime, Engineering, InsertDriveFile, LocalShipping, Route, Verified } from "@mui/icons-material"; +import { AccessTime, Engineering, InsertDriveFile, LocalShipping, Verified } from "@mui/icons-material"; import { Box, Tab, Tabs } from "@mui/material"; import { useReducer, useState } from "react"; -import Area from "./Area"; import GetDateTime from "./GetDateTime"; import GetItemInfo from "./GetItemInfo"; +import MachineAndDriver from "./MachineAndDriver"; import Rahdaran from "./Rahdaran"; import Verify from "./Verify"; -import MachineAndDriver from "./MachineAndDriver"; function TabPanel(props) { const { children, value, index } = props; @@ -61,10 +60,9 @@ const CreateForm = ({ defaultValues, submitForm, setOpen, submitting }) => { > } label="مشخصات" /> } label="زمانبندی" /> - } label="منطقه عملیاتی" /> - } label="خودرو و راننده" /> - } label="همراهان" /> - } label="بررسی نهایی" /> + } label="خودرو و راننده" /> + } label="همراهان" /> + } label="بررسی نهایی" /> { /> - { - dispatch({ type: "changeData", data }); - }} - handlePrev={handlePrev} - setTabState={setTabState} - /> - - { @@ -106,7 +94,7 @@ const CreateForm = ({ defaultValues, submitForm, setOpen, submitting }) => { setTabState={setTabState} /> - + { @@ -116,7 +104,7 @@ const CreateForm = ({ defaultValues, submitForm, setOpen, submitting }) => { setTabState={setTabState} /> - + diff --git a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/index.jsx index 277a63d..f5a4a8a 100644 --- a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/index.jsx +++ b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/index.jsx @@ -19,38 +19,18 @@ const CreateWithoutProcess = ({ mutate }) => { const submitForm = async (result) => { setSubmitting(true); - const bound = result.bound.getLatLngs(); - let area = - result.bound_type === "polygon" - ? bound.map((ring) => ring.map((latlng) => [latlng.lng, latlng.lat]))[0] - : bound.map((latlng) => [latlng.lng, latlng.lat]); - - // بستن polygon - if (result.bound_type === "polygon" && area.length > 0) { - const firstPoint = area[0]; - area.push({ ...firstPoint }); - } await requestServer(REQUEST_MISSION_WITHOUT_PROCESS, "post", { data: { explanation: result.explanation, category_id: result.category_id, - ...(result.category_id == 3 - ? { - road_observed_id: result.road_observed_id, - } - : {}), - area: { - type: result.bound_type, - coordinates: area, - }, ...(result.rahdaran.length != 0 ? { rahdaran: result.rahdaran.map((r) => r.id) } : {}), zone: result.region, end_point: result.end_point, start_date: `${result.start_date} ${moment(result.start_time).format("HH:mm")}`, end_date: `${result.end_date} ${moment(result.end_time).format("HH:mm")}`, - machines: [result.machine.id], driver: result.driver.id, + machine_code: result.machine_code, }, hasSidebarUpdate: true, }) @@ -102,16 +82,14 @@ const CreateWithoutProcess = ({ mutate }) => { category_id: "", road_observed_id: "", rahdaran: [], - bound: null, - bound_type: "polygon", start_date: "", start_time: null, end_date: "", end_time: null, end_point: "", region: "", - machine: null, driver: null, + machine_code: "", }} submitForm={submitForm} submitting={submitting} diff --git a/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/Verify/index.jsx b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/Verify/index.jsx index 805e5d2..09f865f 100644 --- a/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/Verify/index.jsx +++ b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/Verify/index.jsx @@ -21,11 +21,6 @@ const Verify = ({ allData, handlePrev, submitForm, submitting }) => { - - - - - diff --git a/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/index.jsx b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/index.jsx index 45ec88e..96de65d 100644 --- a/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/index.jsx +++ b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/index.jsx @@ -1,12 +1,11 @@ -import { AccessTime, Engineering, InsertDriveFile, Route, Verified, Person } from "@mui/icons-material"; +import { AccessTime, Engineering, InsertDriveFile, Person, Verified } from "@mui/icons-material"; import { Box, Tab, Tabs } from "@mui/material"; import { useReducer, useState } from "react"; -import Area from "./Area"; import GetDateTime from "./GetDateTime"; import GetItemInfo from "./GetItemInfo"; +import MachineAndDriver from "./MachineAndDriver"; import Rahdaran from "./Rahdaran"; import Verify from "./Verify"; -import MachineAndDriver from "./MachineAndDriver"; function TabPanel(props) { const { children, value, index } = props; @@ -61,10 +60,9 @@ const CreateForm = ({ defaultValues, submitForm, setOpen, submitting }) => { > } label="مشخصات" /> } label="زمانبندی" /> - } label="منطقه عملیاتی" /> - } label="راننده" /> - } label="همراهان" /> - } label="بررسی نهایی" /> + } label="راننده" /> + } label="همراهان" /> + } label="بررسی نهایی" /> { /> - { - dispatch({ type: "changeData", data }); - }} - handlePrev={handlePrev} - setTabState={setTabState} - /> - - { @@ -106,7 +94,7 @@ const CreateForm = ({ defaultValues, submitForm, setOpen, submitting }) => { setTabState={setTabState} /> - + { @@ -116,7 +104,7 @@ const CreateForm = ({ defaultValues, submitForm, setOpen, submitting }) => { setTabState={setTabState} /> - + diff --git a/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/index.jsx b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/index.jsx index 5bc7492..0e1f42b 100644 --- a/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/index.jsx +++ b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/index.jsx @@ -1,4 +1,4 @@ -import { REQUEST_MISSION_WITHOUT_PROCESS } from "@/core/utils/routes"; +import { REQUEST_MISSION_VIOLATIONS_PROCESS } from "@/core/utils/routes"; import useRequest from "@/lib/hooks/useRequest"; import { AddCircleOutline, Close } from "@mui/icons-material"; import { Dialog, IconButton, Tooltip } from "@mui/material"; @@ -17,20 +17,11 @@ const CreateWithoutProcess = ({ row, mutate }) => { const submitForm = async (result) => { setSubmitting(true); - const bound = result.bound.getLatLngs(); - let area = - result.bound_type == "polygon" - ? bound.map((ring) => ring.map((latlng) => [latlng.lat, latlng.lng]))[0] - : bound.map((latlng) => [latlng.lat, latlng.lng]); - await requestServer(`${REQUEST_MISSION_WITHOUT_PROCESS}/${row.original.id}`, "post", { + await requestServer(`${REQUEST_MISSION_VIOLATIONS_PROCESS}/${row.original.id}`, "post", { data: { explanation: result.explanation, category_id: result.category_id, - area: { - type: result.bound_type, - coordinates: area, - }, ...(result.rahdaran.length != 0 ? { rahdaran: result.rahdaran.map((r) => r.id) } : {}), zone: result.region, end_point: result.end_point, @@ -79,8 +70,6 @@ const CreateWithoutProcess = ({ row, mutate }) => { category_id: "", road_observed_id: "", rahdaran: [], - bound: null, - bound_type: "polygon", start_date: "", start_time: null, end_date: "", diff --git a/src/core/utils/routes.js b/src/core/utils/routes.js index 411ef1b..ea82259 100644 --- a/src/core/utils/routes.js +++ b/src/core/utils/routes.js @@ -217,7 +217,8 @@ export const GET_ROAD_MISSIONS_OPERATOR_LIST = api + "/api/v3/missions/request_p export const GET_ROAD_MISSIONS_TRANSPORTATION_LIST = api + "/api/v3/missions/transportation_unit"; export const GET_ROAD_MISSIONS_CONTROL_LIST = api + "/api/v3/missions/control_unit"; export const REQUEST_MISSION = api + "/api/v3/missions/request_portal"; -export const REQUEST_MISSION_WITHOUT_PROCESS = api + "/api/v3/missions/violation_management/no_process"; +export const REQUEST_MISSION_WITHOUT_PROCESS = api + "/api/v3/missions/request_portal/no_process"; +export const REQUEST_MISSION_VIOLATIONS_PROCESS = api + "/api/v3/missions/violation_management/no_process"; export const REQUEST_MISSION_CONTINUE_MISSION = api + "/api/v3/missions/request_portal/continue"; export const UPDATE_REQUEST_MISSION = api + "/api/v3/missions/request_portal"; export const DELETE_REQUEST_MISSION = api + "/api/v3/missions/request_portal";