From e94d899b299370d1f32a7d2d67d81aa91dbbc59e Mon Sep 17 00:00:00 2001 From: baslani Date: Sat, 27 Dec 2025 11:26:28 +0330 Subject: [PATCH] updated create without process flow --- .../Form/Verify/index.jsx | 26 +++++++------- .../CreateWithoutProcess/Form/index.jsx | 34 +++++++++---------- .../Actions/CreateWithoutProcess/index.jsx | 34 +++++++++---------- .../Form/MachinesDialog/MachineList/index.jsx | 9 +++-- 4 files changed, 54 insertions(+), 49 deletions(-) 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 d55de17..c348607 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,16 +1,16 @@ +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"; -// import MapLoading from "@/core/components/MapLayer/Loading"; -// import dynamic from "next/dynamic"; -// -// const MapLayer = dynamic(() => import("@/core/components/MapLayer"), { -// loading: () => , -// ssr: false, -// }); +import ShowBound from "../../../showBound"; + +const MapLayer = dynamic(() => import("@/core/components/MapLayer"), { + loading: () => , + ssr: false, +}); const Verify = ({ allData, handlePrev, submitForm, submitting }) => { const handleNext = useCallback(() => { @@ -22,11 +22,11 @@ const Verify = ({ allData, handlePrev, submitForm, submitting }) => { - {/**/} - {/* */} - {/* */} - {/* */} - {/**/} + + + + + diff --git a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/index.jsx index a36981c..0091ae2 100644 --- a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/index.jsx +++ b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/index.jsx @@ -1,3 +1,4 @@ +import Area from "@/components/dashboard/roadMissions/operator/Actions/Create/Form/Area"; import { AccessTime, Engineering, InsertDriveFile, LocalShipping, Route, Verified } from "@mui/icons-material"; import { Box, Tab, Tabs } from "@mui/material"; import { useReducer, useState } from "react"; @@ -6,7 +7,6 @@ import GetItemInfo from "./GetItemInfo"; import MachineAndDriver from "./MachineAndDriver"; import Rahdaran from "./Rahdaran"; import Verify from "./Verify"; -import Area from "@/components/dashboard/roadMissions/operator/Actions/Create/Form/Area"; function TabPanel(props) { const { children, value, index } = props; @@ -61,10 +61,10 @@ const CreateForm = ({ defaultValues, submitForm, setOpen, submitting }) => { > } label="مشخصات" /> } label="زمانبندی" /> - {/*} label="منطقه عملیاتی" />*/} - } label="خودرو و راننده" /> - } label="همراهان" /> - } label="بررسی نهایی" /> + } label="منطقه عملیاتی" /> + } label="خودرو و راننده" /> + } label="همراهان" /> + } label="بررسی نهایی" /> { setTabState={setTabState} /> - {/**/} - {/* {*/} - {/* dispatch({ type: "changeData", data });*/} - {/* }}*/} - {/* handlePrev={handlePrev}*/} - {/* setTabState={setTabState}*/} - {/* />*/} - {/**/} - { dispatch({ type: "changeData", data }); @@ -107,7 +97,7 @@ const CreateForm = ({ defaultValues, submitForm, setOpen, submitting }) => { /> - { dispatch({ type: "changeData", data }); @@ -117,6 +107,16 @@ const CreateForm = ({ defaultValues, submitForm, setOpen, submitting }) => { /> + { + dispatch({ type: "changeData", data }); + }} + handlePrev={handlePrev} + 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 5e27bec..4889489 100644 --- a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/index.jsx +++ b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/index.jsx @@ -19,17 +19,17 @@ 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 }); - // } + 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: { @@ -38,10 +38,10 @@ const CreateWithoutProcess = ({ mutate }) => { ...(result.rahdaran.length != 0 ? { rahdaran: result.rahdaran.map((r) => r.id) } : {}), zone: result.region, end_point: result.end_point, - // area: { - // type: result.bound_type, - // coordinates: area, - // }, + area: { + type: result.bound_type, + coordinates: area, + }, start_date: `${result.start_date} ${moment(result.start_time).format("HH:mm")}`, end_date: `${result.end_date} ${moment(result.end_time).format("HH:mm")}`, driver: result.driver.id, @@ -100,8 +100,8 @@ const CreateWithoutProcess = ({ mutate }) => { start_date: "", start_time: null, end_date: "", - // bound: null, - // bound_type: "polyline", + bound: null, + bound_type: "polyline", end_time: null, end_point: "", region: "", diff --git a/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/MachinesDialog/MachineList/index.jsx b/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/MachinesDialog/MachineList/index.jsx index cfd1ed6..9d9068d 100644 --- a/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/MachinesDialog/MachineList/index.jsx +++ b/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/MachinesDialog/MachineList/index.jsx @@ -7,7 +7,7 @@ import { useAuth } from "@/lib/contexts/auth"; const MachinesList = ({ machineType, setMachine, setOpenMachinesDialog }) => { const { - user: { city_id }, + user: { city_id, province_id }, } = useAuth(); const columns = useMemo( () => [ @@ -47,7 +47,12 @@ const MachinesList = ({ machineType, setMachine, setOpenMachinesDialog }) => { specialFilter={[ { value: machineType, datatype: "text", id: "car_type", fn: "equals" }, { value: 1, datatype: "numeric", id: "status", fn: "equals" }, - { value: city_id, datatype: "numeric", id: "city_id", fn: "equals" }, + { + value: city_id ? city_id : province_id, + datatype: "numeric", + id: city_id ? "city_id" : "province_id", + fn: "equals", + }, ]} sorting={[{ id: "id", desc: true }]} table_url={GET_MACHINES_TABLE_LIST}