Merge branch 'develop' into feature/violations_remove_operation_area
This commit is contained in:
@@ -5,7 +5,7 @@ import ControlList from "./ControlList";
|
||||
const ControlPage = () => {
|
||||
return (
|
||||
<Stack spacing={1}>
|
||||
<PageTitle title={"کارتابل کنترل"} />
|
||||
<PageTitle title={"کارتابل کنترل تردد"} />
|
||||
<ControlList />
|
||||
</Stack>
|
||||
);
|
||||
|
||||
@@ -9,7 +9,6 @@ import { ExitToApp } from "@mui/icons-material";
|
||||
import { Box, Button, DialogActions, DialogContent, Grid, Stack } from "@mui/material";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
import { array, object, string } from "yup";
|
||||
import FastReactCode from "./FastReactCode";
|
||||
|
||||
const validationSchema = object({
|
||||
explanation: string().required("موضوع را مشخص کنید!"),
|
||||
@@ -106,9 +105,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}
|
||||
|
||||
@@ -110,7 +110,7 @@ const Create = ({ mutate }) => {
|
||||
rahdaran: [],
|
||||
requested_machines: [],
|
||||
bound: null,
|
||||
bound_type: "polygon",
|
||||
bound_type: "polyline",
|
||||
type: "",
|
||||
start_date: "",
|
||||
start_time: null,
|
||||
|
||||
@@ -8,7 +8,6 @@ import { ExitToApp } from "@mui/icons-material";
|
||||
import { Box, Button, DialogActions, DialogContent, Grid, Stack } from "@mui/material";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
import { object, string } from "yup";
|
||||
import FastReactCode from "./FastReactCode";
|
||||
|
||||
const validationSchema = object({
|
||||
explanation: string().required("موضوع را مشخص کنید!"),
|
||||
|
||||
@@ -19,7 +19,6 @@ const Area = ({ allData, setAllData, handlePrev, setTabState, oldBound }) => {
|
||||
setAllData({ bound: bound });
|
||||
setTabState((s) => s + 1);
|
||||
}, [bound]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<DialogContent dividers>
|
||||
|
||||
@@ -8,7 +8,6 @@ import { ExitToApp } from "@mui/icons-material";
|
||||
import { Box, Button, DialogActions, DialogContent, Grid, Stack } from "@mui/material";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
import { object, string } from "yup";
|
||||
import FastReactCode from "./FastReactCode";
|
||||
|
||||
const validationSchema = object({
|
||||
explanation: string().required("موضوع را مشخص کنید!"),
|
||||
@@ -103,9 +102,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}
|
||||
|
||||
@@ -67,7 +67,7 @@ const DialogAdd = ({ mutate, setOpen, oldBound, rahdaran, machine, row }) => {
|
||||
category_id: "",
|
||||
bound: null,
|
||||
rahdaran: rahdaran.filter((r) => !r.is_driver),
|
||||
bound_type: "polygon",
|
||||
bound_type: "polyline",
|
||||
type: "",
|
||||
end_date: "",
|
||||
end_time: null,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import DialogLoading from "@/core/components/DialogLoading";
|
||||
import { GET_MACHINES_BY_ID, GET_RAHDARAN_BY_ID } from "@/core/utils/routes";
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
import L from "leaflet";
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import DialogAdd from "./Dialog";
|
||||
|
||||
@@ -36,13 +35,22 @@ const AddController = ({ row, mutate, setOpenAddDialog }) => {
|
||||
});
|
||||
}, [row.original.id]);
|
||||
|
||||
const convertedArea = useMemo(() => {
|
||||
if (!row.original.area) return null;
|
||||
|
||||
return {
|
||||
...row.original.area,
|
||||
coordinates: row.original.area.coordinates.map(([lng, lat]) => [lat, lng]),
|
||||
};
|
||||
}, [row.original.area]);
|
||||
|
||||
return rahdaranLoading || machineLoading ? (
|
||||
<DialogLoading />
|
||||
) : (
|
||||
<DialogAdd
|
||||
mutate={mutate}
|
||||
setOpen={setOpenAddDialog}
|
||||
oldBound={row.original.area}
|
||||
oldBound={convertedArea}
|
||||
rahdaran={rahdaran}
|
||||
machine={machine}
|
||||
row={row}
|
||||
|
||||
@@ -7,13 +7,15 @@ import L from "leaflet";
|
||||
import { GET_RAHDARAN_BY_ID, UPDATE_REQUEST_MISSION } from "@/core/utils/routes";
|
||||
|
||||
const EditController = ({ row, mutate, openEditDialog, setOpenEditDialog }) => {
|
||||
const latLngs = useMemo(() => {
|
||||
return row.original.area.coordinates.map(([lng, lat]) => [lat, lng]);
|
||||
}, [row.original.area.coordinates]);
|
||||
|
||||
const bound = useMemo(
|
||||
() =>
|
||||
row.original.area.type == "polygon"
|
||||
? L.polygon([...row.original.area.coordinates])
|
||||
: L.polyline([...row.original.area.coordinates]),
|
||||
[row.original.area]
|
||||
() => (row.original.area.type === "polygon" ? L.polygon(latLngs) : L.polyline(latLngs)),
|
||||
[row.original.area.type, latLngs]
|
||||
);
|
||||
|
||||
const [submitting, setSubmitting] = useState(false);
|
||||
const [rahdaran, setRahdaran] = useState(null);
|
||||
const [rahdaranLoading, setRahdaranLoading] = useState(true);
|
||||
@@ -35,7 +37,6 @@ const EditController = ({ row, mutate, openEditDialog, setOpenEditDialog }) => {
|
||||
setSubmitting(true);
|
||||
const bound = result.bound.getLatLngs();
|
||||
let area = bound.map((ring) => ring.map((latlng) => [latlng.lat, latlng.lng]));
|
||||
|
||||
await requestServer(`${UPDATE_REQUEST_MISSION}/${row.original.id}`, "post", {
|
||||
data: {
|
||||
explanation: result.explanation,
|
||||
|
||||
@@ -6,7 +6,7 @@ import OperatorList from "./OperatorList";
|
||||
const OperatorPage = () => {
|
||||
return (
|
||||
<Stack spacing={1}>
|
||||
<PageTitle title={"کارتابل عملیات ماموریت"} />
|
||||
<PageTitle title={"کارتابل درخواست کننده"} />
|
||||
<OperatorList />
|
||||
</Stack>
|
||||
);
|
||||
|
||||
@@ -41,9 +41,9 @@ const ReportLists = ({ data, specialFilter }) => {
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: "out_of_aria_count",
|
||||
accessorKey: "out_of_area_count",
|
||||
header: "تردد خارج محدوده",
|
||||
id: "out_of_aria_count",
|
||||
id: "out_of_area_count",
|
||||
enableColumnFilter: false,
|
||||
enableSorting: false,
|
||||
datatype: "text",
|
||||
|
||||
@@ -46,8 +46,7 @@ const ReportPage = () => {
|
||||
params.set("province_id", `${data.province_id}`);
|
||||
const response = await requestServer(`${GET_CITY_ACTIVITY_REPORT}?${params}`);
|
||||
const result = response.data.data;
|
||||
console.log(result);
|
||||
const nationalReportForItem = result.activities.find((report) => report.province_id === -1);
|
||||
const nationalReportForItem = result.activities.find((report) => report.province_id === "-1");
|
||||
const nationalReport = {
|
||||
edare_name: "کل کشور",
|
||||
...nationalReportForItem,
|
||||
@@ -57,7 +56,8 @@ const ReportPage = () => {
|
||||
data: [
|
||||
nationalReport,
|
||||
...result.provinces.map((province) => {
|
||||
const filteredReports = result.activities.find((report) => report.province_id === province.id);
|
||||
const filteredReports = result.activities.find((report) => report.province_id == province.id);
|
||||
console.log(filteredReports);
|
||||
return {
|
||||
...filteredReports,
|
||||
edare_name: province.name_fa,
|
||||
|
||||
@@ -12,16 +12,27 @@ import ShowBound from "../../../Actions/showBound";
|
||||
import DriversDialog from "./DriversDialog";
|
||||
import MachinesDialog from "./MachinesDialog";
|
||||
import Reject from "./Reject";
|
||||
import SelectBox from "@/core/components/SelectBox";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
|
||||
const AllocationForm = ({ row, mutate, setOpenAllocationDialog }) => {
|
||||
const latLngs = useMemo(() => {
|
||||
return row.area.coordinates.map(([lng, lat]) => [lat, lng]);
|
||||
}, [row.area.coordinates]);
|
||||
|
||||
const bound = useMemo(
|
||||
() =>
|
||||
row.area.type == "polygon" ? L.polygon([...row.area.coordinates]) : L.polyline([...row.area.coordinates]),
|
||||
[row.area]
|
||||
() => (row.area.type === "polygon" ? L.polygon(latLngs) : L.polyline(latLngs)),
|
||||
[row.area.type, latLngs]
|
||||
);
|
||||
const requestServer = useRequest({ notificationSuccess: true });
|
||||
const [machine, setMachine] = useState();
|
||||
const [driver, setDriver] = useState();
|
||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||
const { control, watch } = useForm({
|
||||
defaultValues: {
|
||||
machine_type: row.requested_machines?.[0] ? [row.requested_machines[0]] : [],
|
||||
},
|
||||
});
|
||||
|
||||
const handleSubmit = async (_machine, _driver) => {
|
||||
setIsSubmitting(true);
|
||||
@@ -42,6 +53,7 @@ const AllocationForm = ({ row, mutate, setOpenAllocationDialog }) => {
|
||||
});
|
||||
};
|
||||
|
||||
const selectedMachineType = watch("machine_type")?.[0];
|
||||
return (
|
||||
<>
|
||||
<DialogContent dividers>
|
||||
@@ -50,12 +62,22 @@ const AllocationForm = ({ row, mutate, setOpenAllocationDialog }) => {
|
||||
<Paper elevation={24}>
|
||||
<Stack spacing={2} sx={{ p: 2 }}>
|
||||
<Stack direction={"row"} alignItems={"center"} spacing={1}>
|
||||
<Typography variant="body" fontWeight={"bold"} color={"primary"}>
|
||||
نوع خودرو درخواستی
|
||||
</Typography>
|
||||
<Divider sx={{ flex: 1 }} />
|
||||
<Chip
|
||||
label={machineType.find((mt) => mt.id == row.requested_machines?.[0])?.name_fa}
|
||||
<Controller
|
||||
name="machine_type"
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => (
|
||||
<SelectBox
|
||||
value={field.value?.[0] || ""}
|
||||
label="نوع خودرو درخواستی"
|
||||
selectors={machineType}
|
||||
schema={{ name: "name_fa", value: "id" }}
|
||||
error={!!error}
|
||||
helperText={error?.message}
|
||||
onChange={(newValue) => {
|
||||
field.onChange([newValue]);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</Stack>
|
||||
<Stack direction={"row"} alignItems={"center"} spacing={1}>
|
||||
@@ -73,16 +95,13 @@ const AllocationForm = ({ row, mutate, setOpenAllocationDialog }) => {
|
||||
/>
|
||||
<Divider sx={{ flex: 1 }} />
|
||||
<MachinesDialog
|
||||
machineType={row.requested_machines[0]}
|
||||
machineType={selectedMachineType}
|
||||
setMachine={setMachine}
|
||||
mode={"edit"}
|
||||
/>
|
||||
</>
|
||||
) : (
|
||||
<MachinesDialog
|
||||
machineType={row.requested_machines[0]}
|
||||
setMachine={setMachine}
|
||||
/>
|
||||
<MachinesDialog machineType={selectedMachineType} setMachine={setMachine} />
|
||||
)}
|
||||
</Stack>
|
||||
{machine && (
|
||||
|
||||
@@ -6,7 +6,7 @@ import TransportationList from "./TransportationList";
|
||||
const TransportationPage = () => {
|
||||
return (
|
||||
<Stack spacing={1}>
|
||||
<PageTitle title={"کارتابل عملیات ماموریت"} />
|
||||
<PageTitle title={"کارتابل تایید کننده"} />
|
||||
<TransportationList />
|
||||
</Stack>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user