Merge pull request #16 from witelgroup/feature/mission_report
Feature/mission report
This commit is contained in:
@@ -7,7 +7,14 @@ export const metadata = {
|
||||
const Page = () => {
|
||||
return (
|
||||
<>
|
||||
<WithPermission permission_name={["manage-control-unit"]}>
|
||||
<WithPermission
|
||||
permission_name={[
|
||||
"manage-control-unit",
|
||||
"manage-control-unit-city",
|
||||
"manage-control-unit-country",
|
||||
"manage-control-unit-station",
|
||||
]}
|
||||
>
|
||||
<ControlPage />
|
||||
{/* <ActivityCodeLog activity_code={1152} /> */}
|
||||
</WithPermission>
|
||||
|
||||
@@ -12,6 +12,7 @@ const Page = () => {
|
||||
"manage-request-portal-country",
|
||||
"manage-request-portal-province",
|
||||
"manage-request-portal-city",
|
||||
"manage-request-portal-station",
|
||||
]}
|
||||
>
|
||||
<OperatorPage />
|
||||
|
||||
@@ -7,7 +7,14 @@ export const metadata = {
|
||||
const Page = () => {
|
||||
return (
|
||||
<>
|
||||
<WithPermission permission_name={["manage-transportation-unit"]}>
|
||||
<WithPermission
|
||||
permission_name={[
|
||||
"manage-transportation-unit-country",
|
||||
"manage-transportation-unit-city",
|
||||
"manage-transportation-unit-country",
|
||||
"manage-transportation-unit-station",
|
||||
]}
|
||||
>
|
||||
<TransportationPage />
|
||||
{/* <ActivityCodeLog activity_code={1152} /> */}
|
||||
</WithPermission>
|
||||
|
||||
@@ -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("موضوع را مشخص کنید!"),
|
||||
@@ -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}
|
||||
|
||||
@@ -103,7 +103,7 @@ const CreateWithoutProcess = ({ mutate }) => {
|
||||
road_observed_id: "",
|
||||
rahdaran: [],
|
||||
bound: null,
|
||||
bound_type: "polygon",
|
||||
bound_type: "polyline",
|
||||
start_date: "",
|
||||
start_time: null,
|
||||
end_date: "",
|
||||
|
||||
@@ -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>
|
||||
);
|
||||
|
||||
@@ -110,7 +110,7 @@ export const pageMenu = [
|
||||
Subitems: [
|
||||
{
|
||||
id: "roadMissionsManagemnetRequests",
|
||||
label: "کارتابل",
|
||||
label: "درخواست کننده",
|
||||
icon: <ContactPageIcon sx={{ width: "inherit", height: "inherit" }} />,
|
||||
type: "page",
|
||||
route: "/dashboard/road-missions/operator",
|
||||
@@ -119,25 +119,36 @@ export const pageMenu = [
|
||||
"manage-request-portal-country",
|
||||
"manage-request-portal-province",
|
||||
"manage-request-portal-city",
|
||||
"manage-request-portal-station",
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "roadMissionsManagemnetNaqlie",
|
||||
label: "نقلیه",
|
||||
label: "تایید کننده",
|
||||
type: "page",
|
||||
icon: <DirectionsBusIcon sx={{ width: "inherit", height: "inherit" }} />,
|
||||
route: "/dashboard/road-missions/transportation",
|
||||
badges: [{ key: "mission.transportation" }],
|
||||
permissions: ["manage-transportation-unit"],
|
||||
permissions: [
|
||||
"manage-transportation-unit-city",
|
||||
"manage-transportation-unit-province",
|
||||
"manage-transportation-unit-country",
|
||||
"manage-transportation-unit-station",
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "roadMissionsManagemnetControl",
|
||||
label: "کنترل",
|
||||
label: "کنترل تردد",
|
||||
type: "page",
|
||||
icon: <SupervisedUserCircleIcon sx={{ width: "inherit", height: "inherit" }} />,
|
||||
route: "/dashboard/road-missions/control",
|
||||
badges: [{ key: "mission.control" }],
|
||||
permissions: ["manage-control-unit"],
|
||||
permissions: [
|
||||
"manage-control-unit-province",
|
||||
"manage-control-unit-city",
|
||||
"manage-control-unit-country",
|
||||
"manage-control-unit-station",
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "roadMissionsViolations",
|
||||
@@ -148,15 +159,15 @@ export const pageMenu = [
|
||||
// badges: [{ key: "mission.control" }], // TODO: add badge and permission
|
||||
permissions: ["all"],
|
||||
},
|
||||
// {
|
||||
// id: "roadMissionsReports",
|
||||
// label: "گزارشات",
|
||||
// type: "page",
|
||||
// route: "/dashboard/road-missions/reports",
|
||||
// icon: <AssessmentIcon sx={{ width: "inherit", height: "inherit" }} />,
|
||||
// // badges: [{ key: "mission.control" }], // TODO: add badge and permission
|
||||
// permissions: ["all"],
|
||||
// },
|
||||
{
|
||||
id: "roadMissionsReports",
|
||||
label: "گزارشات",
|
||||
type: "page",
|
||||
route: "/dashboard/road-missions/reports",
|
||||
icon: <AssessmentIcon sx={{ width: "inherit", height: "inherit" }} />,
|
||||
// badges: [{ key: "mission.control" }], // TODO: add badge and permission
|
||||
permissions: ["all"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
@@ -109,7 +109,7 @@ export const pageMenuDev = [
|
||||
Subitems: [
|
||||
{
|
||||
id: "roadMissionsManagemnetRequests",
|
||||
label: "کارتابل",
|
||||
label: "درخواست کننده",
|
||||
icon: <ContactPageIcon sx={{ width: "inherit", height: "inherit" }} />,
|
||||
type: "page",
|
||||
route: "/dashboard/road-missions/operator",
|
||||
@@ -118,25 +118,36 @@ export const pageMenuDev = [
|
||||
"manage-request-portal-country",
|
||||
"manage-request-portal-province",
|
||||
"manage-request-portal-city",
|
||||
"manage-request-portal-station",
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "roadMissionsManagemnetNaqlie",
|
||||
label: "نقلیه",
|
||||
label: "تایید کننده",
|
||||
type: "page",
|
||||
icon: <DirectionsBusIcon sx={{ width: "inherit", height: "inherit" }} />,
|
||||
route: "/dashboard/road-missions/transportation",
|
||||
badges: [{ key: "mission.transportation" }],
|
||||
permissions: ["manage-transportation-unit"],
|
||||
permissions: [
|
||||
"manage-transportation-unit-province",
|
||||
"manage-transportation-unit-city",
|
||||
"manage-transportation-unit-country",
|
||||
"manage-transportation-unit-station",
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "roadMissionsManagemnetControl",
|
||||
label: "کنترل",
|
||||
label: "کنترل تردد",
|
||||
type: "page",
|
||||
icon: <SupervisedUserCircleIcon sx={{ width: "inherit", height: "inherit" }} />,
|
||||
route: "/dashboard/road-missions/control",
|
||||
badges: [{ key: "mission.control" }],
|
||||
permissions: ["manage-control-unit"],
|
||||
permissions: [
|
||||
"manage-control-unit-province",
|
||||
"manage-control-unit-city",
|
||||
"manage-control-unit-country",
|
||||
"manage-control-unit-station",
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "roadMissionsViolations",
|
||||
@@ -147,15 +158,15 @@ export const pageMenuDev = [
|
||||
// badges: [{ key: "mission.control" }], // TODO: add badge and permission
|
||||
permissions: ["all"],
|
||||
},
|
||||
// {
|
||||
// id: "roadMissionsReports",
|
||||
// label: "گزارشات",
|
||||
// type: "page",
|
||||
// route: "/dashboard/road-missions/reports",
|
||||
// icon: <AssessmentIcon sx={{ width: "inherit", height: "inherit" }} />,
|
||||
// // badges: [{ key: "mission.control" }], // TODO: add badge and permission
|
||||
// permissions: ["all"],
|
||||
// },
|
||||
{
|
||||
id: "roadMissionsReports",
|
||||
label: "گزارشات",
|
||||
type: "page",
|
||||
route: "/dashboard/road-missions/reports",
|
||||
icon: <AssessmentIcon sx={{ width: "inherit", height: "inherit" }} />,
|
||||
// badges: [{ key: "mission.control" }], // TODO: add badge and permission
|
||||
permissions: ["all"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
@@ -43,7 +43,7 @@ export const GET_FMS_DATA = api + "/api/v3/fms_vehicle/get_activity";
|
||||
export const GET_OTP_TOKEN = api + "/api/v3/otp/get_token";
|
||||
|
||||
export const GET_PROVINCE_ACTIVITY_REPORT = api + "/api/v3/road_patrols/report/country_activity";
|
||||
export const GET_CITY_ACTIVITY_REPORT = api + "/api/v3/road_patrols/report/province_activity";
|
||||
export const GET_CITY_ACTIVITY_REPORT = api + "/api/v3/missions/report/country_activity";
|
||||
export const EXPORT_COUNTRY_ROAD_PATROL_REPORTS = api + "/api/v3/road_patrols/report/country_activity_excel";
|
||||
export const EXPORT_PROVINCE_ROAD_PATROL_REPORTS = api + "/api/v3/road_patrols/report/province_activity_excel";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user