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 { missionCategoryTypes } from "@/core/utils/missionCategoryTypes";
|
||||||
import { missionRegions } from "@/core/utils/missionRegions";
|
import { missionRegions } from "@/core/utils/missionRegions";
|
||||||
import { Box, Button, Chip, DialogActions, DialogContent, Divider, Stack, Typography } from "@mui/material";
|
import { Box, Button, Chip, DialogActions, DialogContent, Divider, Stack, Typography } from "@mui/material";
|
||||||
import moment from "jalali-moment";
|
import moment from "jalali-moment";
|
||||||
|
import dynamic from "next/dynamic";
|
||||||
import { useCallback } from "react";
|
import { useCallback } from "react";
|
||||||
// import ShowBound from "../../../showBound";
|
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 />,
|
||||||
// const MapLayer = dynamic(() => import("@/core/components/MapLayer"), {
|
ssr: false,
|
||||||
// loading: () => <MapLoading />,
|
});
|
||||||
// ssr: false,
|
|
||||||
// });
|
|
||||||
|
|
||||||
const Verify = ({ allData, handlePrev, submitForm, submitting }) => {
|
const Verify = ({ allData, handlePrev, submitForm, submitting }) => {
|
||||||
const handleNext = useCallback(() => {
|
const handleNext = useCallback(() => {
|
||||||
@@ -22,11 +22,11 @@ const Verify = ({ allData, handlePrev, submitForm, submitting }) => {
|
|||||||
<DialogContent dividers>
|
<DialogContent dividers>
|
||||||
<Box sx={{ flex: 1 }}>
|
<Box sx={{ flex: 1 }}>
|
||||||
<Stack spacing={2}>
|
<Stack spacing={2}>
|
||||||
{/*<Box sx={{ width: "100%", height: "200px" }}>*/}
|
<Box sx={{ width: "100%", height: "200px" }}>
|
||||||
{/* <MapLayer style={{ borderRadius: "4px" }}>*/}
|
<MapLayer style={{ borderRadius: "4px" }}>
|
||||||
{/* <ShowBound bound={allData.bound} />*/}
|
<ShowBound bound={allData.bound} />
|
||||||
{/* </MapLayer>*/}
|
</MapLayer>
|
||||||
{/*</Box>*/}
|
</Box>
|
||||||
<Stack spacing={1}>
|
<Stack spacing={1}>
|
||||||
<Divider>
|
<Divider>
|
||||||
<Chip color="primary" variant="outlined" label="مشخصات ماموریت" />
|
<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 { AccessTime, Engineering, InsertDriveFile, LocalShipping, Route, Verified } from "@mui/icons-material";
|
||||||
import { Box, Tab, Tabs } from "@mui/material";
|
import { Box, Tab, Tabs } from "@mui/material";
|
||||||
import { useReducer, useState } from "react";
|
import { useReducer, useState } from "react";
|
||||||
@@ -6,7 +7,6 @@ import GetItemInfo from "./GetItemInfo";
|
|||||||
import MachineAndDriver from "./MachineAndDriver";
|
import MachineAndDriver from "./MachineAndDriver";
|
||||||
import Rahdaran from "./Rahdaran";
|
import Rahdaran from "./Rahdaran";
|
||||||
import Verify from "./Verify";
|
import Verify from "./Verify";
|
||||||
import Area from "@/components/dashboard/roadMissions/operator/Actions/Create/Form/Area";
|
|
||||||
|
|
||||||
function TabPanel(props) {
|
function TabPanel(props) {
|
||||||
const { children, value, index } = props;
|
const { children, value, index } = props;
|
||||||
@@ -61,10 +61,10 @@ const CreateForm = ({ defaultValues, submitForm, setOpen, submitting }) => {
|
|||||||
>
|
>
|
||||||
<Tab icon={<InsertDriveFile />} label="مشخصات" />
|
<Tab icon={<InsertDriveFile />} label="مشخصات" />
|
||||||
<Tab disabled={tabState < 1} icon={<AccessTime />} label="زمانبندی" />
|
<Tab disabled={tabState < 1} icon={<AccessTime />} label="زمانبندی" />
|
||||||
{/*<Tab disabled={tabState < 2} icon={<Route />} label="منطقه عملیاتی" />*/}
|
<Tab disabled={tabState < 2} icon={<Route />} label="منطقه عملیاتی" />
|
||||||
<Tab disabled={tabState < 2} icon={<LocalShipping />} label="خودرو و راننده" />
|
<Tab disabled={tabState < 3} icon={<LocalShipping />} label="خودرو و راننده" />
|
||||||
<Tab disabled={tabState < 3} icon={<Engineering />} label="همراهان" />
|
<Tab disabled={tabState < 4} icon={<Engineering />} label="همراهان" />
|
||||||
<Tab disabled={tabState < 4} icon={<Verified />} label="بررسی نهایی" />
|
<Tab disabled={tabState < 5} icon={<Verified />} label="بررسی نهایی" />
|
||||||
</Tabs>
|
</Tabs>
|
||||||
<TabPanel value={tabState} index={0}>
|
<TabPanel value={tabState} index={0}>
|
||||||
<GetItemInfo
|
<GetItemInfo
|
||||||
@@ -86,18 +86,8 @@ const CreateForm = ({ defaultValues, submitForm, setOpen, submitting }) => {
|
|||||||
setTabState={setTabState}
|
setTabState={setTabState}
|
||||||
/>
|
/>
|
||||||
</TabPanel>
|
</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}>
|
<TabPanel value={tabState} index={2}>
|
||||||
<MachineAndDriver
|
<Area
|
||||||
allData={allData}
|
allData={allData}
|
||||||
setAllData={(data) => {
|
setAllData={(data) => {
|
||||||
dispatch({ type: "changeData", data });
|
dispatch({ type: "changeData", data });
|
||||||
@@ -107,7 +97,7 @@ const CreateForm = ({ defaultValues, submitForm, setOpen, submitting }) => {
|
|||||||
/>
|
/>
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
<TabPanel value={tabState} index={3}>
|
<TabPanel value={tabState} index={3}>
|
||||||
<Rahdaran
|
<MachineAndDriver
|
||||||
allData={allData}
|
allData={allData}
|
||||||
setAllData={(data) => {
|
setAllData={(data) => {
|
||||||
dispatch({ type: "changeData", data });
|
dispatch({ type: "changeData", data });
|
||||||
@@ -117,6 +107,16 @@ const CreateForm = ({ defaultValues, submitForm, setOpen, submitting }) => {
|
|||||||
/>
|
/>
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
<TabPanel value={tabState} index={4}>
|
<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} />
|
<Verify allData={allData} handlePrev={handlePrev} submitForm={submitForm} submitting={submitting} />
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -19,17 +19,17 @@ const CreateWithoutProcess = ({ mutate }) => {
|
|||||||
|
|
||||||
const submitForm = async (result) => {
|
const submitForm = async (result) => {
|
||||||
setSubmitting(true);
|
setSubmitting(true);
|
||||||
// const bound = result.bound.getLatLngs();
|
const bound = result.bound.getLatLngs();
|
||||||
// let area =
|
let area =
|
||||||
// result.bound_type === "polygon"
|
result.bound_type === "polygon"
|
||||||
// ? bound.map((ring) => ring.map((latlng) => [latlng.lng, latlng.lat]))[0]
|
? bound.map((ring) => ring.map((latlng) => [latlng.lng, latlng.lat]))[0]
|
||||||
// : bound.map((latlng) => [latlng.lng, latlng.lat]);
|
: bound.map((latlng) => [latlng.lng, latlng.lat]);
|
||||||
//
|
|
||||||
// // بستن polygon
|
// بستن polygon
|
||||||
// if (result.bound_type === "polygon" && area.length > 0) {
|
if (result.bound_type === "polygon" && area.length > 0) {
|
||||||
// const firstPoint = area[0];
|
const firstPoint = area[0];
|
||||||
// area.push({ ...firstPoint });
|
area.push({ ...firstPoint });
|
||||||
// }
|
}
|
||||||
|
|
||||||
await requestServer(REQUEST_MISSION_WITHOUT_PROCESS, "post", {
|
await requestServer(REQUEST_MISSION_WITHOUT_PROCESS, "post", {
|
||||||
data: {
|
data: {
|
||||||
@@ -38,10 +38,10 @@ const CreateWithoutProcess = ({ mutate }) => {
|
|||||||
...(result.rahdaran.length != 0 ? { rahdaran: result.rahdaran.map((r) => r.id) } : {}),
|
...(result.rahdaran.length != 0 ? { rahdaran: result.rahdaran.map((r) => r.id) } : {}),
|
||||||
zone: result.region,
|
zone: result.region,
|
||||||
end_point: result.end_point,
|
end_point: result.end_point,
|
||||||
// area: {
|
area: {
|
||||||
// type: result.bound_type,
|
type: result.bound_type,
|
||||||
// coordinates: area,
|
coordinates: area,
|
||||||
// },
|
},
|
||||||
start_date: `${result.start_date} ${moment(result.start_time).format("HH:mm")}`,
|
start_date: `${result.start_date} ${moment(result.start_time).format("HH:mm")}`,
|
||||||
end_date: `${result.end_date} ${moment(result.end_time).format("HH:mm")}`,
|
end_date: `${result.end_date} ${moment(result.end_time).format("HH:mm")}`,
|
||||||
driver: result.driver.id,
|
driver: result.driver.id,
|
||||||
@@ -100,8 +100,8 @@ const CreateWithoutProcess = ({ mutate }) => {
|
|||||||
start_date: "",
|
start_date: "",
|
||||||
start_time: null,
|
start_time: null,
|
||||||
end_date: "",
|
end_date: "",
|
||||||
// bound: null,
|
bound: null,
|
||||||
// bound_type: "polyline",
|
bound_type: "polyline",
|
||||||
end_time: null,
|
end_time: null,
|
||||||
end_point: "",
|
end_point: "",
|
||||||
region: "",
|
region: "",
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { useAuth } from "@/lib/contexts/auth";
|
|||||||
|
|
||||||
const MachinesList = ({ machineType, setMachine, setOpenMachinesDialog }) => {
|
const MachinesList = ({ machineType, setMachine, setOpenMachinesDialog }) => {
|
||||||
const {
|
const {
|
||||||
user: { city_id },
|
user: { city_id, province_id },
|
||||||
} = useAuth();
|
} = useAuth();
|
||||||
const columns = useMemo(
|
const columns = useMemo(
|
||||||
() => [
|
() => [
|
||||||
@@ -47,7 +47,12 @@ const MachinesList = ({ machineType, setMachine, setOpenMachinesDialog }) => {
|
|||||||
specialFilter={[
|
specialFilter={[
|
||||||
{ value: machineType, datatype: "text", id: "car_type", fn: "equals" },
|
{ value: machineType, datatype: "text", id: "car_type", fn: "equals" },
|
||||||
{ value: 1, datatype: "numeric", id: "status", 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 }]}
|
sorting={[{ id: "id", desc: true }]}
|
||||||
table_url={GET_MACHINES_TABLE_LIST}
|
table_url={GET_MACHINES_TABLE_LIST}
|
||||||
|
|||||||
Reference in New Issue
Block a user