updated violations and no_process actions
This commit is contained in:
@@ -103,9 +103,6 @@ const GetItemInfo = ({ allData, setAllData, handlePrev, setTabState }) => {
|
||||
)}
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={12} sm={6}>
|
||||
<FastReactCode control={control} />
|
||||
</Grid>
|
||||
<Grid item xs={12} sm={6}>
|
||||
<Controller
|
||||
control={control}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import LtrTextField from "@/core/components/LtrTextField";
|
||||
import { Close, Edit } from "@mui/icons-material";
|
||||
import { Button, Dialog, IconButton } from "@mui/material";
|
||||
import { Button, Dialog, IconButton, Stack } from "@mui/material";
|
||||
import { useState } from "react";
|
||||
import MachinesList from "./MachineList";
|
||||
|
||||
const MachinesDialog = ({ setMachine, mode }) => {
|
||||
const MachinesDialog = ({ setMachine, mode, machineCode, setShowMachineCodeDialog }) => {
|
||||
const [openMachinesDialog, setOpenMachinesDialog] = useState(false);
|
||||
|
||||
return (
|
||||
<>
|
||||
{mode == "edit" ? (
|
||||
@@ -13,7 +14,7 @@ const MachinesDialog = ({ setMachine, mode }) => {
|
||||
</IconButton>
|
||||
) : (
|
||||
<Button onClick={() => setOpenMachinesDialog(true)} variant="contained" fullWidth size="large">
|
||||
انتخاب خودرو
|
||||
وارد کردن کد خودرو{" "}
|
||||
</Button>
|
||||
)}
|
||||
<Dialog open={openMachinesDialog} fullWidth maxWidth="sm">
|
||||
@@ -31,7 +32,36 @@ const MachinesDialog = ({ setMachine, mode }) => {
|
||||
<Close />
|
||||
</IconButton>
|
||||
{openMachinesDialog && (
|
||||
<MachinesList setMachine={setMachine} setOpenMachinesDialog={setOpenMachinesDialog} />
|
||||
<Stack sx={{ p: 4, mt: 2 }} spacing={2}>
|
||||
<LtrTextField
|
||||
label={`کد خودرو`}
|
||||
value={machineCode || ""}
|
||||
type="text"
|
||||
size={"small"}
|
||||
inputProps={{
|
||||
placeholder: "کد خودرو را وارد کنید",
|
||||
inputMode: "numeric",
|
||||
min: 0,
|
||||
pattern: "[0-9]*",
|
||||
}}
|
||||
onChange={(event) => {
|
||||
setMachine(event.target.value);
|
||||
}}
|
||||
variant="outlined"
|
||||
fullWidth
|
||||
/>
|
||||
<Button
|
||||
onClick={() => {
|
||||
setShowMachineCodeDialog(true);
|
||||
setOpenMachinesDialog(false);
|
||||
}}
|
||||
variant="contained"
|
||||
fullWidth
|
||||
size="large"
|
||||
>
|
||||
ثبت
|
||||
</Button>
|
||||
</Stack>
|
||||
)}
|
||||
</Dialog>
|
||||
</>
|
||||
|
||||
@@ -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 }) => {
|
||||
<Box sx={{ flex: 1 }}>
|
||||
<Stack sx={{ my: 1 }} spacing={2}>
|
||||
<Stack direction={"row"} alignItems={"center"} spacing={1}>
|
||||
{machine ? (
|
||||
{showMachineCodeDialog ? (
|
||||
<>
|
||||
<Typography variant="body2">خودرو</Typography>
|
||||
<Divider sx={{ flex: 1 }} />
|
||||
<Chip label={machineCode} size="small" />
|
||||
<Divider sx={{ flex: 1 }} />
|
||||
<MachinesDialog
|
||||
setMachine={setMachineCode}
|
||||
setShowMachineCodeDialog={setShowMachineCodeDialog}
|
||||
mode={"edit"}
|
||||
machineCode={machineCode}
|
||||
/>
|
||||
</>
|
||||
) : (
|
||||
<MachinesDialog
|
||||
setMachine={setMachineCode}
|
||||
setShowMachineCodeDialog={setShowMachineCodeDialog}
|
||||
machineCode={machineCode}
|
||||
/>
|
||||
)}
|
||||
</Stack>
|
||||
|
||||
<Stack direction={"row"} alignItems={"center"} spacing={1}>
|
||||
{driver ? (
|
||||
<>
|
||||
<Typography variant="body2">راننده</Typography>
|
||||
<Divider sx={{ flex: 1 }} />
|
||||
<Chip
|
||||
label={
|
||||
machine
|
||||
? `${machine.machine_code} | ${machine.car_name}`
|
||||
: "خودرویی انتخاب نشده"
|
||||
}
|
||||
label={driver ? `${driver.code} | ${driver.name}` : "راننده ای انتخاب نشده"}
|
||||
size="small"
|
||||
/>
|
||||
<Divider sx={{ flex: 1 }} />
|
||||
<MachinesDialog setMachine={setMachine} mode={"edit"} />
|
||||
<DriversDialog setDriver={setDriver} mode={"edit"} />
|
||||
</>
|
||||
) : (
|
||||
<MachinesDialog setMachine={setMachine} />
|
||||
<DriversDialog setDriver={setDriver} />
|
||||
)}
|
||||
</Stack>
|
||||
{machine && (
|
||||
<Stack direction={"row"} alignItems={"center"} spacing={1}>
|
||||
{driver ? (
|
||||
<>
|
||||
<Typography variant="body2">راننده</Typography>
|
||||
<Divider sx={{ flex: 1 }} />
|
||||
<Chip
|
||||
label={driver ? `${driver.code} | ${driver.name}` : "راننده ای انتخاب نشده"}
|
||||
size="small"
|
||||
/>
|
||||
<Divider sx={{ flex: 1 }} />
|
||||
<DriversDialog setDriver={setDriver} mode={"edit"} />
|
||||
</>
|
||||
) : (
|
||||
<DriversDialog setDriver={setDriver} />
|
||||
)}
|
||||
</Stack>
|
||||
)}
|
||||
</Stack>
|
||||
</Box>
|
||||
</DialogContent>
|
||||
@@ -64,9 +66,9 @@ const MachineAndDriver = ({ setTabState, allData, setAllData, handlePrev }) => {
|
||||
</Button>
|
||||
<Button
|
||||
variant="contained"
|
||||
disabled={!machine || !driver}
|
||||
disabled={!driver || !machineCode}
|
||||
size="large"
|
||||
onClick={() => handleNext({ machine, driver })}
|
||||
onClick={() => handleNext({ driver, machine_code: machineCode })}
|
||||
>
|
||||
مرحله بعد
|
||||
</Button>
|
||||
|
||||
@@ -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: () => <MapLoading />,
|
||||
ssr: false,
|
||||
});
|
||||
|
||||
const Verify = ({ allData, handlePrev, submitForm, submitting }) => {
|
||||
const handleNext = useCallback(() => {
|
||||
@@ -21,11 +14,6 @@ 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>
|
||||
<Stack spacing={1}>
|
||||
<Divider>
|
||||
<Chip color="primary" variant="outlined" label="مشخصات ماموریت" />
|
||||
@@ -79,16 +67,20 @@ const Verify = ({ allData, handlePrev, submitForm, submitting }) => {
|
||||
</Stack>
|
||||
<Stack spacing={1}>
|
||||
<Divider>
|
||||
<Chip color="primary" variant="outlined" label="خودرو و راننده" />
|
||||
<Chip color="primary" variant="outlined" label="کد خودرو" />
|
||||
</Divider>
|
||||
|
||||
<Stack direction={"row"} alignItems={"center"} spacing={1}>
|
||||
<Typography variant="body2">خودرو</Typography>
|
||||
<Typography variant="body2">کد خودرو</Typography>
|
||||
<Divider sx={{ flex: 1 }} />
|
||||
<Chip
|
||||
size="small"
|
||||
label={`${allData.machine.machine_code} | ${allData.machine.car_name}`}
|
||||
/>
|
||||
<Chip size="small" label={`${allData.machine_code}`} />
|
||||
</Stack>
|
||||
</Stack>
|
||||
<Stack spacing={1}>
|
||||
<Divider>
|
||||
<Chip color="primary" variant="outlined" label="راننده" />
|
||||
</Divider>
|
||||
|
||||
<Stack direction={"row"} alignItems={"center"} spacing={1}>
|
||||
<Typography variant="body2">راننده</Typography>
|
||||
<Divider sx={{ flex: 1 }} />
|
||||
|
||||
@@ -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 }) => {
|
||||
>
|
||||
<Tab icon={<InsertDriveFile />} label="مشخصات" />
|
||||
<Tab disabled={tabState < 1} icon={<AccessTime />} 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="بررسی نهایی" />
|
||||
<Tab disabled={tabState < 2} icon={<LocalShipping />} label="خودرو و راننده" />
|
||||
<Tab disabled={tabState < 3} icon={<Engineering />} label="همراهان" />
|
||||
<Tab disabled={tabState < 4} icon={<Verified />} label="بررسی نهایی" />
|
||||
</Tabs>
|
||||
<TabPanel value={tabState} index={0}>
|
||||
<GetItemInfo
|
||||
@@ -87,16 +85,6 @@ const CreateForm = ({ defaultValues, submitForm, setOpen, submitting }) => {
|
||||
/>
|
||||
</TabPanel>
|
||||
<TabPanel value={tabState} index={2}>
|
||||
<Area
|
||||
allData={allData}
|
||||
setAllData={(data) => {
|
||||
dispatch({ type: "changeData", data });
|
||||
}}
|
||||
handlePrev={handlePrev}
|
||||
setTabState={setTabState}
|
||||
/>
|
||||
</TabPanel>
|
||||
<TabPanel value={tabState} index={3}>
|
||||
<MachineAndDriver
|
||||
allData={allData}
|
||||
setAllData={(data) => {
|
||||
@@ -106,7 +94,7 @@ const CreateForm = ({ defaultValues, submitForm, setOpen, submitting }) => {
|
||||
setTabState={setTabState}
|
||||
/>
|
||||
</TabPanel>
|
||||
<TabPanel value={tabState} index={4}>
|
||||
<TabPanel value={tabState} index={3}>
|
||||
<Rahdaran
|
||||
allData={allData}
|
||||
setAllData={(data) => {
|
||||
@@ -116,7 +104,7 @@ const CreateForm = ({ defaultValues, submitForm, setOpen, submitting }) => {
|
||||
setTabState={setTabState}
|
||||
/>
|
||||
</TabPanel>
|
||||
<TabPanel value={tabState} index={5}>
|
||||
<TabPanel value={tabState} index={4}>
|
||||
<Verify allData={allData} handlePrev={handlePrev} submitForm={submitForm} submitting={submitting} />
|
||||
</TabPanel>
|
||||
</>
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -21,11 +21,6 @@ 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>
|
||||
<Stack spacing={1}>
|
||||
<Divider>
|
||||
<Chip color="primary" variant="outlined" label="مشخصات ماموریت" />
|
||||
|
||||
@@ -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 }) => {
|
||||
>
|
||||
<Tab icon={<InsertDriveFile />} label="مشخصات" />
|
||||
<Tab disabled={tabState < 1} icon={<AccessTime />} label="زمانبندی" />
|
||||
<Tab disabled={tabState < 2} icon={<Route />} label="منطقه عملیاتی" />
|
||||
<Tab disabled={tabState < 3} icon={<Person />} label="راننده" />
|
||||
<Tab disabled={tabState < 4} icon={<Engineering />} label="همراهان" />
|
||||
<Tab disabled={tabState < 5} icon={<Verified />} label="بررسی نهایی" />
|
||||
<Tab disabled={tabState < 2} icon={<Person />} label="راننده" />
|
||||
<Tab disabled={tabState < 3} icon={<Engineering />} label="همراهان" />
|
||||
<Tab disabled={tabState < 4} icon={<Verified />} label="بررسی نهایی" />
|
||||
</Tabs>
|
||||
<TabPanel value={tabState} index={0}>
|
||||
<GetItemInfo
|
||||
@@ -87,16 +85,6 @@ const CreateForm = ({ defaultValues, submitForm, setOpen, submitting }) => {
|
||||
/>
|
||||
</TabPanel>
|
||||
<TabPanel value={tabState} index={2}>
|
||||
<Area
|
||||
allData={allData}
|
||||
setAllData={(data) => {
|
||||
dispatch({ type: "changeData", data });
|
||||
}}
|
||||
handlePrev={handlePrev}
|
||||
setTabState={setTabState}
|
||||
/>
|
||||
</TabPanel>
|
||||
<TabPanel value={tabState} index={3}>
|
||||
<MachineAndDriver
|
||||
allData={allData}
|
||||
setAllData={(data) => {
|
||||
@@ -106,7 +94,7 @@ const CreateForm = ({ defaultValues, submitForm, setOpen, submitting }) => {
|
||||
setTabState={setTabState}
|
||||
/>
|
||||
</TabPanel>
|
||||
<TabPanel value={tabState} index={4}>
|
||||
<TabPanel value={tabState} index={3}>
|
||||
<Rahdaran
|
||||
allData={allData}
|
||||
setAllData={(data) => {
|
||||
@@ -116,7 +104,7 @@ const CreateForm = ({ defaultValues, submitForm, setOpen, submitting }) => {
|
||||
setTabState={setTabState}
|
||||
/>
|
||||
</TabPanel>
|
||||
<TabPanel value={tabState} index={5}>
|
||||
<TabPanel value={tabState} index={4}>
|
||||
<Verify allData={allData} handlePrev={handlePrev} submitForm={submitForm} submitting={submitting} />
|
||||
</TabPanel>
|
||||
</>
|
||||
|
||||
@@ -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: "",
|
||||
|
||||
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user