Merge pull request #13 from witelgroup/feature/debug_mission_cartable
debug road mission cartable area view
This commit is contained in:
@@ -6,10 +6,15 @@ import ShowBound from "../showBound";
|
|||||||
import L from "leaflet";
|
import L from "leaflet";
|
||||||
|
|
||||||
const ShowArea = ({ area }) => {
|
const ShowArea = ({ area }) => {
|
||||||
|
const latLngs = useMemo(() => {
|
||||||
|
return area.coordinates.map(([lng, lat]) => [lat, lng]);
|
||||||
|
}, [area.coordinates]);
|
||||||
|
|
||||||
const bound = useMemo(
|
const bound = useMemo(
|
||||||
() => (area.type == "polygon" ? L.polygon([...area.coordinates]) : L.polyline([...area.coordinates])),
|
() => (area.type === "polygon" ? L.polygon(latLngs) : L.polyline(latLngs)),
|
||||||
[area]
|
[area.type, latLngs]
|
||||||
);
|
);
|
||||||
|
|
||||||
const [openAreaDialog, setOpenAreaDialog] = useState(false);
|
const [openAreaDialog, setOpenAreaDialog] = useState(false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -21,10 +21,15 @@ const Create = ({ mutate }) => {
|
|||||||
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.lat, latlng.lng]))[0]
|
? bound.map((ring) => ring.map((latlng) => [latlng.lng, latlng.lat]))[0]
|
||||||
: bound.map((latlng) => [latlng.lat, latlng.lng]);
|
: 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, "post", {
|
await requestServer(REQUEST_MISSION, "post", {
|
||||||
data: {
|
data: {
|
||||||
explanation: result.explanation,
|
explanation: result.explanation,
|
||||||
|
|||||||
@@ -21,9 +21,15 @@ const CreateWithoutProcess = ({ mutate }) => {
|
|||||||
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.lat, latlng.lng]))[0]
|
? bound.map((ring) => ring.map((latlng) => [latlng.lng, latlng.lat]))[0]
|
||||||
: bound.map((latlng) => [latlng.lat, latlng.lng]);
|
: 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", {
|
await requestServer(REQUEST_MISSION_WITHOUT_PROCESS, "post", {
|
||||||
data: {
|
data: {
|
||||||
|
|||||||
@@ -6,10 +6,15 @@ import ShowBound from "../showBound";
|
|||||||
import L from "leaflet";
|
import L from "leaflet";
|
||||||
|
|
||||||
const ShowArea = ({ area }) => {
|
const ShowArea = ({ area }) => {
|
||||||
|
const latLngs = useMemo(() => {
|
||||||
|
return area.coordinates.map(([lng, lat]) => [lat, lng]);
|
||||||
|
}, [area.coordinates]);
|
||||||
|
|
||||||
const bound = useMemo(
|
const bound = useMemo(
|
||||||
() => (area.type == "polygon" ? L.polygon([...area.coordinates]) : L.polyline([...area.coordinates])),
|
() => (area.type === "polygon" ? L.polygon(latLngs) : L.polyline(latLngs)),
|
||||||
[area]
|
[area.type, latLngs]
|
||||||
);
|
);
|
||||||
|
|
||||||
const [openAreaDialog, setOpenAreaDialog] = useState(false);
|
const [openAreaDialog, setOpenAreaDialog] = useState(false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import RowActions from "./RowActions";
|
|||||||
import MachinesDialog from "./RowActions/Machines";
|
import MachinesDialog from "./RowActions/Machines";
|
||||||
import Toolbar from "./Toolbar";
|
import Toolbar from "./Toolbar";
|
||||||
import RahdaranDialog from "./RowActions/Rahdaran";
|
import RahdaranDialog from "./RowActions/Rahdaran";
|
||||||
|
import DescriptionDialog from "@/components/dashboard/roadMissions/operator/RowActions/DescriptionDialog";
|
||||||
|
|
||||||
const OperatorList = () => {
|
const OperatorList = () => {
|
||||||
const columns = useMemo(
|
const columns = useMemo(
|
||||||
@@ -219,7 +220,7 @@ const OperatorList = () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Cell: ({ renderedCellValue, row }) => {
|
Cell: ({ row }) => {
|
||||||
return (
|
return (
|
||||||
<Stack alignItems={"center"} justifyContent={"center"}>
|
<Stack alignItems={"center"} justifyContent={"center"}>
|
||||||
<RahdaranDialog rowId={row.original.id} />
|
<RahdaranDialog rowId={row.original.id} />
|
||||||
@@ -227,6 +228,33 @@ const OperatorList = () => {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
header: "دلیل رد درخواست",
|
||||||
|
id: "description",
|
||||||
|
enableColumnFilter: false,
|
||||||
|
enableSorting: false,
|
||||||
|
datatype: "text",
|
||||||
|
filterMode: "contains",
|
||||||
|
columnFilterModeOptions: ["equals", "contains"],
|
||||||
|
grow: false,
|
||||||
|
size: 100,
|
||||||
|
muiTableBodyCellProps: {
|
||||||
|
sx: {
|
||||||
|
borderLeft: "1px solid #e1e1e1",
|
||||||
|
py: 0,
|
||||||
|
"&:first-of-type": {
|
||||||
|
borderLeft: "unset",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Cell: ({ row }) => {
|
||||||
|
return (
|
||||||
|
<Stack alignItems={"center"} justifyContent={"center"}>
|
||||||
|
<DescriptionDialog description={row.original.description} />
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
accessorFn: (row) =>
|
accessorFn: (row) =>
|
||||||
row.start_time ? moment(row.start_time).locale("fa").format("HH:mm | yyyy/MM/DD") : null,
|
row.start_time ? moment(row.start_time).locale("fa").format("HH:mm | yyyy/MM/DD") : null,
|
||||||
|
|||||||
@@ -12,14 +12,19 @@ const DialogAdd = ({ mutate, setOpen, oldBound, rahdaran, machine, row }) => {
|
|||||||
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.lat, latlng.lng]))[0]
|
? bound.map((ring) => ring.map((latlng) => [latlng.lng, latlng.lat]))[0]
|
||||||
: bound.map((latlng) => [latlng.lat, latlng.lng]);
|
: 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_CONTINUE_MISSION}/${row.original.id}`, "post", {
|
await requestServer(`${REQUEST_MISSION_CONTINUE_MISSION}/${row.original.id}`, "post", {
|
||||||
data: {
|
data: {
|
||||||
...(result.rahdaran.length != 0 ? { rahdaran: result.rahdaran.map((r) => r.id) } : {}),
|
...(result.rahdaran.length != 0 ? { rahdaran: result.rahdaran.map((r) => r.id) } : {}),
|
||||||
machines: [result.machine.id],
|
machine_id: result.machine.id,
|
||||||
driver: result.driver.id,
|
driver: result.driver.id,
|
||||||
zone: result.region,
|
zone: result.region,
|
||||||
type: result.type,
|
type: result.type,
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
import {
|
||||||
|
Button,
|
||||||
|
Card,
|
||||||
|
CardContent,
|
||||||
|
Dialog,
|
||||||
|
DialogActions,
|
||||||
|
DialogContent,
|
||||||
|
DialogTitle,
|
||||||
|
IconButton,
|
||||||
|
Tooltip,
|
||||||
|
Typography,
|
||||||
|
} from "@mui/material";
|
||||||
|
import RemoveRedEyeIcon from "@mui/icons-material/RemoveRedEye";
|
||||||
|
import { useState } from "react";
|
||||||
|
|
||||||
|
const DescriptionDialog = ({ description }) => {
|
||||||
|
const [openDescriptionDialog, setOpenDescriptionDialog] = useState(false);
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Tooltip title="دلیل رد درخواست">
|
||||||
|
<IconButton color="primary" onClick={() => setOpenDescriptionDialog(true)}>
|
||||||
|
<RemoveRedEyeIcon />
|
||||||
|
</IconButton>
|
||||||
|
</Tooltip>
|
||||||
|
<Dialog
|
||||||
|
fullWidth
|
||||||
|
open={openDescriptionDialog}
|
||||||
|
onClose={() => setOpenDescriptionDialog(false)}
|
||||||
|
PaperProps={{
|
||||||
|
sx: {
|
||||||
|
boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px",
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
dir="rtl"
|
||||||
|
maxWidth={"sm"}
|
||||||
|
>
|
||||||
|
<DialogTitle sx={{ fontSize: "large" }}>دلیل رد درخواست</DialogTitle>
|
||||||
|
<DialogContent>
|
||||||
|
<Card elevation={0}>
|
||||||
|
<CardContent>
|
||||||
|
<Typography variant="body2">{description || "هیچ توضیحی موجود نیست"} </Typography>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
</DialogContent>
|
||||||
|
<DialogActions>
|
||||||
|
<Button
|
||||||
|
onClick={() => setOpenDescriptionDialog(false)}
|
||||||
|
variant="outlined"
|
||||||
|
color="secondary"
|
||||||
|
autoFocus
|
||||||
|
>
|
||||||
|
بستن
|
||||||
|
</Button>
|
||||||
|
</DialogActions>
|
||||||
|
</Dialog>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
export default DescriptionDialog;
|
||||||
@@ -6,10 +6,15 @@ import ShowBound from "../showBound";
|
|||||||
import L from "leaflet";
|
import L from "leaflet";
|
||||||
|
|
||||||
const ShowArea = ({ area }) => {
|
const ShowArea = ({ area }) => {
|
||||||
|
const latLngs = useMemo(() => {
|
||||||
|
return area.coordinates.map(([lng, lat]) => [lat, lng]);
|
||||||
|
}, [area.coordinates]);
|
||||||
|
|
||||||
const bound = useMemo(
|
const bound = useMemo(
|
||||||
() => (area.type == "polygon" ? L.polygon([...area.coordinates]) : L.polyline([...area.coordinates])),
|
() => (area.type === "polygon" ? L.polygon(latLngs) : L.polyline(latLngs)),
|
||||||
[area]
|
[area.type, latLngs]
|
||||||
);
|
);
|
||||||
|
|
||||||
const [openAreaDialog, setOpenAreaDialog] = useState(false);
|
const [openAreaDialog, setOpenAreaDialog] = useState(false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ const AllocationForm = ({ row, mutate, setOpenAllocationDialog }) => {
|
|||||||
setIsSubmitting(true);
|
setIsSubmitting(true);
|
||||||
await requestServer(`${ALLOCATE_REQUEST_MISSION}/${row.id}`, "post", {
|
await requestServer(`${ALLOCATE_REQUEST_MISSION}/${row.id}`, "post", {
|
||||||
data: {
|
data: {
|
||||||
machines: _machine.id,
|
machine_id: _machine.id,
|
||||||
driver: _driver.id,
|
driver: _driver.id,
|
||||||
},
|
},
|
||||||
hasSidebarUpdate: true,
|
hasSidebarUpdate: true,
|
||||||
|
|||||||
@@ -53,10 +53,12 @@ const CreateTollHouse = ({ mutate }) => {
|
|||||||
formData.append("lng", result.start_point.lng);
|
formData.append("lng", result.start_point.lng);
|
||||||
formData.append("area[type]", "polygon");
|
formData.append("area[type]", "polygon");
|
||||||
result.area.map((point, pointIndex) => {
|
result.area.map((point, pointIndex) => {
|
||||||
formData.append(`area[coordinates][${pointIndex}][0]`, point.lat);
|
formData.append(`area[coordinates][${pointIndex}][0]`, point.lon);
|
||||||
formData.append(`area[coordinates][${pointIndex}][1]`, point.lon);
|
formData.append(`area[coordinates][${pointIndex}][1]`, point.lat);
|
||||||
});
|
});
|
||||||
|
const repeat_first = result.area.length;
|
||||||
|
formData.append(`area[coordinates][${repeat_first}][0]`, result.area[0].lon);
|
||||||
|
formData.append(`area[coordinates][${repeat_first}][1]`, result.area[0].lat);
|
||||||
await requestServer(`${CREATE_TOLL_HOUSE}`, "post", {
|
await requestServer(`${CREATE_TOLL_HOUSE}`, "post", {
|
||||||
data: formData,
|
data: formData,
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user