updated create without process flow
This commit is contained in:
@@ -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: () => <MapLoading />,
|
||||
// ssr: false,
|
||||
// });
|
||||
import ShowBound from "../../../showBound";
|
||||
|
||||
const MapLayer = dynamic(() => import("@/core/components/MapLayer"), {
|
||||
loading: () => <MapLoading />,
|
||||
ssr: false,
|
||||
});
|
||||
|
||||
const Verify = ({ allData, handlePrev, submitForm, submitting }) => {
|
||||
const handleNext = useCallback(() => {
|
||||
@@ -22,11 +22,11 @@ const Verify = ({ allData, handlePrev, submitForm, submitting }) => {
|
||||
<DialogContent dividers>
|
||||
<Box sx={{ flex: 1 }}>
|
||||
<Stack spacing={2}>
|
||||
{/*<Box sx={{ width: "100%", height: "200px" }}>*/}
|
||||
{/* <MapLayer style={{ borderRadius: "4px" }}>*/}
|
||||
{/* <ShowBound bound={allData.bound} />*/}
|
||||
{/* </MapLayer>*/}
|
||||
{/*</Box>*/}
|
||||
<Box sx={{ width: "100%", height: "200px" }}>
|
||||
<MapLayer style={{ borderRadius: "4px" }}>
|
||||
<ShowBound bound={allData.bound} />
|
||||
</MapLayer>
|
||||
</Box>
|
||||
<Stack spacing={1}>
|
||||
<Divider>
|
||||
<Chip color="primary" variant="outlined" label="مشخصات ماموریت" />
|
||||
|
||||
@@ -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 }) => {
|
||||
>
|
||||
<Tab icon={<InsertDriveFile />} label="مشخصات" />
|
||||
<Tab disabled={tabState < 1} icon={<AccessTime />} label="زمانبندی" />
|
||||
{/*<Tab disabled={tabState < 2} icon={<Route />} label="منطقه عملیاتی" />*/}
|
||||
<Tab disabled={tabState < 2} icon={<LocalShipping />} label="خودرو و راننده" />
|
||||
<Tab disabled={tabState < 3} icon={<Engineering />} label="همراهان" />
|
||||
<Tab disabled={tabState < 4} icon={<Verified />} label="بررسی نهایی" />
|
||||
<Tab disabled={tabState < 2} icon={<Route />} label="منطقه عملیاتی" />
|
||||
<Tab disabled={tabState < 3} icon={<LocalShipping />} label="خودرو و راننده" />
|
||||
<Tab disabled={tabState < 4} icon={<Engineering />} label="همراهان" />
|
||||
<Tab disabled={tabState < 5} icon={<Verified />} label="بررسی نهایی" />
|
||||
</Tabs>
|
||||
<TabPanel value={tabState} index={0}>
|
||||
<GetItemInfo
|
||||
@@ -86,18 +86,8 @@ const CreateForm = ({ defaultValues, submitForm, setOpen, submitting }) => {
|
||||
setTabState={setTabState}
|
||||
/>
|
||||
</TabPanel>
|
||||
{/*<TabPanel value={tabState} index={2}>*/}
|
||||
{/* <Area*/}
|
||||
{/* allData={allData}*/}
|
||||
{/* setAllData={(data) => {*/}
|
||||
{/* dispatch({ type: "changeData", data });*/}
|
||||
{/* }}*/}
|
||||
{/* handlePrev={handlePrev}*/}
|
||||
{/* setTabState={setTabState}*/}
|
||||
{/* />*/}
|
||||
{/*</TabPanel>*/}
|
||||
<TabPanel value={tabState} index={2}>
|
||||
<MachineAndDriver
|
||||
<Area
|
||||
allData={allData}
|
||||
setAllData={(data) => {
|
||||
dispatch({ type: "changeData", data });
|
||||
@@ -107,7 +97,7 @@ const CreateForm = ({ defaultValues, submitForm, setOpen, submitting }) => {
|
||||
/>
|
||||
</TabPanel>
|
||||
<TabPanel value={tabState} index={3}>
|
||||
<Rahdaran
|
||||
<MachineAndDriver
|
||||
allData={allData}
|
||||
setAllData={(data) => {
|
||||
dispatch({ type: "changeData", data });
|
||||
@@ -117,6 +107,16 @@ const CreateForm = ({ defaultValues, submitForm, setOpen, submitting }) => {
|
||||
/>
|
||||
</TabPanel>
|
||||
<TabPanel value={tabState} index={4}>
|
||||
<Rahdaran
|
||||
allData={allData}
|
||||
setAllData={(data) => {
|
||||
dispatch({ type: "changeData", data });
|
||||
}}
|
||||
handlePrev={handlePrev}
|
||||
setTabState={setTabState}
|
||||
/>
|
||||
</TabPanel>
|
||||
<TabPanel value={tabState} index={5}>
|
||||
<Verify allData={allData} handlePrev={handlePrev} submitForm={submitForm} submitting={submitting} />
|
||||
</TabPanel>
|
||||
</>
|
||||
|
||||
@@ -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: "",
|
||||
|
||||
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user