diff --git a/src/components/dashboard/roadMissions/control/Actions/showArea/index.jsx b/src/components/dashboard/roadMissions/control/Actions/showArea/index.jsx index be4ee7a..ef25c6b 100644 --- a/src/components/dashboard/roadMissions/control/Actions/showArea/index.jsx +++ b/src/components/dashboard/roadMissions/control/Actions/showArea/index.jsx @@ -6,10 +6,15 @@ import ShowBound from "../showBound"; import L from "leaflet"; const ShowArea = ({ area }) => { + const latLngs = useMemo(() => { + return area.coordinates.map(([lng, lat]) => [lat, lng]); + }, [area.coordinates]); + const bound = useMemo( - () => (area.type == "polygon" ? L.polygon([...area.coordinates]) : L.polyline([...area.coordinates])), - [area] + () => (area.type === "polygon" ? L.polygon(latLngs) : L.polyline(latLngs)), + [area.type, latLngs] ); + const [openAreaDialog, setOpenAreaDialog] = useState(false); return ( diff --git a/src/components/dashboard/roadMissions/operator/Actions/Create/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/Create/index.jsx index e48ab26..f956b94 100644 --- a/src/components/dashboard/roadMissions/operator/Actions/Create/index.jsx +++ b/src/components/dashboard/roadMissions/operator/Actions/Create/index.jsx @@ -21,10 +21,24 @@ const Create = ({ mutate }) => { 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]); + 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, "post", { data: { explanation: result.explanation, diff --git a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/index.jsx index ab64c85..277a63d 100644 --- a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/index.jsx +++ b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/index.jsx @@ -1,121 +1,127 @@ -import { REQUEST_MISSION_WITHOUT_PROCESS } from "@/core/utils/routes"; -import useRequest from "@/lib/hooks/useRequest"; -import { AddCircle, AddCircleOutline, Close } from "@mui/icons-material"; -import { Button, Dialog, IconButton, useMediaQuery, useTheme } from "@mui/material"; -import moment from "jalali-moment"; -import { useState } from "react"; -import CreateForm from "./Form"; - -const CreateWithoutProcess = ({ mutate }) => { - const [submitting, setSubmitting] = useState(false); - const requestServer = useRequest({ notificationSuccess: true }); - const theme = useTheme(); - const isMobile = useMediaQuery(theme.breakpoints.down("sm")); - const [open, setOpen] = useState(false); - - const handleOpen = () => { - setOpen(true); - }; - - 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, "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, - }, - hasSidebarUpdate: true, - }) - .then((response) => { - mutate(); - setOpen(false); - }) - .catch((error) => {}) - .finally(() => { - setSubmitting(false); - }); - }; - - return ( - <> - {isMobile ? ( - - - - ) : ( - - )} - - setOpen(false)} - sx={(theme) => ({ - position: "absolute", - right: 8, - top: 8, - zIndex: 50, - color: theme.palette.grey[500], - })} - > - - - {open && ( - - )} - - - ); -}; -export default CreateWithoutProcess; +import { REQUEST_MISSION_WITHOUT_PROCESS } from "@/core/utils/routes"; +import useRequest from "@/lib/hooks/useRequest"; +import { AddCircle, AddCircleOutline, Close } from "@mui/icons-material"; +import { Button, Dialog, IconButton, useMediaQuery, useTheme } from "@mui/material"; +import moment from "jalali-moment"; +import { useState } from "react"; +import CreateForm from "./Form"; + +const CreateWithoutProcess = ({ mutate }) => { + const [submitting, setSubmitting] = useState(false); + const requestServer = useRequest({ notificationSuccess: true }); + const theme = useTheme(); + const isMobile = useMediaQuery(theme.breakpoints.down("sm")); + const [open, setOpen] = useState(false); + + const handleOpen = () => { + setOpen(true); + }; + + 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, + }, + hasSidebarUpdate: true, + }) + .then((response) => { + mutate(); + setOpen(false); + }) + .catch((error) => {}) + .finally(() => { + setSubmitting(false); + }); + }; + + return ( + <> + {isMobile ? ( + + + + ) : ( + + )} + + setOpen(false)} + sx={(theme) => ({ + position: "absolute", + right: 8, + top: 8, + zIndex: 50, + color: theme.palette.grey[500], + })} + > + + + {open && ( + + )} + + + ); +}; +export default CreateWithoutProcess; diff --git a/src/components/dashboard/roadMissions/operator/Actions/showArea/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/showArea/index.jsx index be4ee7a..f2d9f4b 100644 --- a/src/components/dashboard/roadMissions/operator/Actions/showArea/index.jsx +++ b/src/components/dashboard/roadMissions/operator/Actions/showArea/index.jsx @@ -6,10 +6,15 @@ import ShowBound from "../showBound"; import L from "leaflet"; const ShowArea = ({ area }) => { + const latLngs = useMemo(() => { + return area.coordinates.map(([lng, lat]) => [lat, lng]); + }, [area.coordinates]); + const bound = useMemo( - () => (area.type == "polygon" ? L.polygon([...area.coordinates]) : L.polyline([...area.coordinates])), - [area] + () => (area.type === "polygon" ? L.polygon(latLngs) : L.polyline(latLngs)), + [area.type, latLngs] ); + const [openAreaDialog, setOpenAreaDialog] = useState(false); return ( @@ -54,5 +59,5 @@ const ShowArea = ({ area }) => { ); -}; +};; export default ShowArea; diff --git a/src/components/dashboard/roadMissions/operator/OperatorList.jsx b/src/components/dashboard/roadMissions/operator/OperatorList.jsx index 9625838..c393619 100644 --- a/src/components/dashboard/roadMissions/operator/OperatorList.jsx +++ b/src/components/dashboard/roadMissions/operator/OperatorList.jsx @@ -12,6 +12,7 @@ import RowActions from "./RowActions"; import MachinesDialog from "./RowActions/Machines"; import Toolbar from "./Toolbar"; import RahdaranDialog from "./RowActions/Rahdaran"; +import DescriptionDialog from "@/components/dashboard/roadMissions/operator/RowActions/DescriptionDialog"; const OperatorList = () => { const columns = useMemo( @@ -219,7 +220,7 @@ const OperatorList = () => { }, }, }, - Cell: ({ renderedCellValue, row }) => { + Cell: ({ row }) => { return ( @@ -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 ( + + + + ); + }, + }, { accessorFn: (row) => row.start_time ? moment(row.start_time).locale("fa").format("HH:mm | yyyy/MM/DD") : null, diff --git a/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/index.jsx b/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/index.jsx index 440c4e9..25ff1c3 100644 --- a/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/index.jsx +++ b/src/components/dashboard/roadMissions/operator/RowActions/Add/AddController/Dialog/index.jsx @@ -12,14 +12,19 @@ const DialogAdd = ({ mutate, setOpen, oldBound, rahdaran, machine, row }) => { 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]); + 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_CONTINUE_MISSION}/${row.original.id}`, "post", { data: { ...(result.rahdaran.length != 0 ? { rahdaran: result.rahdaran.map((r) => r.id) } : {}), - machines: [result.machine.id], + machine_id: result.machine.id, driver: result.driver.id, zone: result.region, type: result.type, diff --git a/src/components/dashboard/roadMissions/operator/RowActions/DescriptionDialog/index.jsx b/src/components/dashboard/roadMissions/operator/RowActions/DescriptionDialog/index.jsx new file mode 100644 index 0000000..3941b37 --- /dev/null +++ b/src/components/dashboard/roadMissions/operator/RowActions/DescriptionDialog/index.jsx @@ -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 ( + <> + + setOpenDescriptionDialog(true)}> + + + + 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"} + > + دلیل رد درخواست + + + + {description || "هیچ توضیحی موجود نیست"} + + + + + + + + + ); +}; +export default DescriptionDialog; diff --git a/src/components/dashboard/roadMissions/transportation/Actions/showArea/index.jsx b/src/components/dashboard/roadMissions/transportation/Actions/showArea/index.jsx index be4ee7a..f2d9f4b 100644 --- a/src/components/dashboard/roadMissions/transportation/Actions/showArea/index.jsx +++ b/src/components/dashboard/roadMissions/transportation/Actions/showArea/index.jsx @@ -6,10 +6,15 @@ import ShowBound from "../showBound"; import L from "leaflet"; const ShowArea = ({ area }) => { + const latLngs = useMemo(() => { + return area.coordinates.map(([lng, lat]) => [lat, lng]); + }, [area.coordinates]); + const bound = useMemo( - () => (area.type == "polygon" ? L.polygon([...area.coordinates]) : L.polyline([...area.coordinates])), - [area] + () => (area.type === "polygon" ? L.polygon(latLngs) : L.polyline(latLngs)), + [area.type, latLngs] ); + const [openAreaDialog, setOpenAreaDialog] = useState(false); return ( @@ -54,5 +59,5 @@ const ShowArea = ({ area }) => { ); -}; +};; export default ShowArea; diff --git a/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/index.jsx b/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/index.jsx index 70d8cfb..4c2d1fe 100644 --- a/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/index.jsx +++ b/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/index.jsx @@ -28,7 +28,7 @@ const AllocationForm = ({ row, mutate, setOpenAllocationDialog }) => { setIsSubmitting(true); await requestServer(`${ALLOCATE_REQUEST_MISSION}/${row.id}`, "post", { data: { - machines: _machine.id, + machine_id: _machine.id, driver: _driver.id, }, hasSidebarUpdate: true, diff --git a/src/components/infrastructure/tollHouse/Form/CreateTollHouse/index.jsx b/src/components/infrastructure/tollHouse/Form/CreateTollHouse/index.jsx index a9cb7cf..5a6ffe1 100644 --- a/src/components/infrastructure/tollHouse/Form/CreateTollHouse/index.jsx +++ b/src/components/infrastructure/tollHouse/Form/CreateTollHouse/index.jsx @@ -53,10 +53,12 @@ const CreateTollHouse = ({ mutate }) => { formData.append("lng", result.start_point.lng); formData.append("area[type]", "polygon"); result.area.map((point, pointIndex) => { - formData.append(`area[coordinates][${pointIndex}][0]`, point.lat); - formData.append(`area[coordinates][${pointIndex}][1]`, point.lon); + formData.append(`area[coordinates][${pointIndex}][0]`, 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", { data: formData, })