diff --git a/src/components/dashboard/roadItems/operator/Actions/Create/Forms/index.jsx b/src/components/dashboard/roadItems/operator/Actions/Create/Forms/index.jsx
index b2d73b5..c9921bf 100644
--- a/src/components/dashboard/roadItems/operator/Actions/Create/Forms/index.jsx
+++ b/src/components/dashboard/roadItems/operator/Actions/Create/Forms/index.jsx
@@ -18,13 +18,11 @@ const OperatorCreateForm = ({ open, setOpen, mutate, rowId }) => {
mutate();
setOpen(false);
})
- .catch((error) => { });
+ .catch((error) => {});
};
return (
);
};
diff --git a/src/components/dashboard/roadItems/operator/OperatorList.jsx b/src/components/dashboard/roadItems/operator/OperatorList.jsx
index 2cb64e1..52913cc 100644
--- a/src/components/dashboard/roadItems/operator/OperatorList.jsx
+++ b/src/components/dashboard/roadItems/operator/OperatorList.jsx
@@ -120,8 +120,8 @@ const OperatorList = () => {
props.dependencyFieldValue.value === ""
? "empty"
: loadingSubItemsList
- ? "loading"
- : props.filterParameters.value
+ ? "loading"
+ : props.filterParameters.value
}
columnSelectOption={getColumnSelectOptions}
/>
diff --git a/src/components/dashboard/roadItems/supervisor/SupervisorList.jsx b/src/components/dashboard/roadItems/supervisor/SupervisorList.jsx
index 10c4d72..84a48c9 100644
--- a/src/components/dashboard/roadItems/supervisor/SupervisorList.jsx
+++ b/src/components/dashboard/roadItems/supervisor/SupervisorList.jsx
@@ -127,8 +127,8 @@ const SupervisorList = () => {
props.dependencyFieldValue?.value === ""
? "empty"
: loadingEdaratList
- ? "loading"
- : props.filterParameters.value
+ ? "loading"
+ : props.filterParameters.value
}
columnSelectOption={getColumnSelectOptions}
/>
@@ -221,8 +221,8 @@ const SupervisorList = () => {
props.dependencyFieldValue.value === ""
? "empty"
: loadingSubItemsList
- ? "loading"
- : props.filterParameters.value
+ ? "loading"
+ : props.filterParameters.value
}
columnSelectOption={getColumnSelectOptions}
/>
diff --git a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/ActionInfo.jsx b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/ActionInfo.jsx
index 3dee248..ae935b3 100644
--- a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/ActionInfo.jsx
+++ b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/ActionInfo.jsx
@@ -1,27 +1,20 @@
"use client";
import DeleteIcon from "@mui/icons-material/Delete";
-import DesignServicesIcon from "@mui/icons-material/DesignServices";
-import DirectionsCarIcon from "@mui/icons-material/DirectionsCar";
import HandymanIcon from "@mui/icons-material/Handyman";
-import PersonIcon from "@mui/icons-material/Person";
-import {
- Box,
- Card,
- CardActions,
- CardContent,
- CardHeader,
- Chip,
- Divider,
- IconButton,
- Stack,
- Typography,
-} from "@mui/material";
+import { Box, Card, CardActions, CardHeader, IconButton, Typography } from "@mui/material";
import EditActionDuringPatrol from "./EditActionDuringPatrol";
const ActionInfo = ({ action, setActionsList, index, deleteAction }) => {
return (
-
+
}
title={{action.data.item_name}}
diff --git a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/ActionsDurigPatrol.jsx b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/ActionsDurigPatrol.jsx
index 4efd9a1..304391a 100644
--- a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/ActionsDurigPatrol.jsx
+++ b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/ActionsDurigPatrol.jsx
@@ -20,7 +20,7 @@ const ActionsDuringPatrol = ({ allData, setAllData, handlePrev, setTabState }) =
const handleNext = (data) => {
setAllData({ observed_items: data });
- setTabState(s => s + 1);
+ setTabState((s) => s + 1);
};
return (
@@ -28,19 +28,14 @@ const ActionsDuringPatrol = ({ allData, setAllData, handlePrev, setTabState }) =
- }
- variant="outlined"
- sx={{ mb: 1 }}
- >
+ } variant="outlined" sx={{ mb: 1 }}>
ثبت اقدام انجام شده
@@ -78,7 +73,7 @@ const ActionsDuringPatrol = ({ allData, setAllData, handlePrev, setTabState }) =
)}
-
+
-
diff --git a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/CompeleteRequest.jsx b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/CompeleteRequest.jsx
index 77d2862..78a9496 100644
--- a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/CompeleteRequest.jsx
+++ b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/CompeleteRequest.jsx
@@ -1,7 +1,9 @@
"use client";
+import ShowPlak from "@/core/components/ShowPlak";
import StyledForm from "@/core/components/StyledForm";
import { formatCounter } from "@/core/utils/formatCounter";
+import { formatSecondsToHHMMSS } from "@/core/utils/formatSecondsToHHMMSS";
import { CREATE_PATROL, GET_OTP_TOKEN } from "@/core/utils/routes";
import useRequest from "@/lib/hooks/useRequest";
import { yupResolver } from "@hookform/resolvers/yup";
@@ -39,10 +41,7 @@ const schemaSend = yup.object().shape({
.string()
.matches(/^09\d{9}$/, "شماره تماس باید با 09 شروع شود و 11 رقم باشد.")
.required("شماره تماس الزامی است."),
- code: yup
- .string()
- .length(6)
- .required("شماره تماس الزامی است."),
+ code: yup.string().length(6).required("شماره تماس الزامی است."),
});
const CompeleteRequest = ({ allData, handlePrev, mutate, setOpen }) => {
@@ -52,17 +51,26 @@ const CompeleteRequest = ({ allData, handlePrev, mutate, setOpen }) => {
const [otpSended, setOtpSended] = useState(false);
const defaultValuesOtp = {
- phoneNumber: ''
- }
+ phoneNumber: "",
+ };
const defaultValuesSend = {
- phoneNumber: '',
- code: ''
- }
+ phoneNumber: "",
+ code: "",
+ };
- const { handleSubmit: handleSubmitOtp, register: registerOtp, formState: { isSubmitting: isSubmittingOtp, isValid: isValidOtp } } = useForm({ defaultValues: defaultValuesOtp, resolver: yupResolver(schemaOtp), mode: 'onBlur' })
+ const {
+ handleSubmit: handleSubmitOtp,
+ register: registerOtp,
+ formState: { isSubmitting: isSubmittingOtp, isValid: isValidOtp },
+ } = useForm({ defaultValues: defaultValuesOtp, resolver: yupResolver(schemaOtp), mode: "onBlur" });
- const { handleSubmit: handleSubmitSend, setValue: setValueSend, register: registerSend, formState: { isSubmitting: isSubmittingSend, isValid: isValidSend } } = useForm({ defaultValues: defaultValuesSend, resolver: yupResolver(schemaSend), mode: 'onBlur' })
+ const {
+ handleSubmit: handleSubmitSend,
+ setValue: setValueSend,
+ register: registerSend,
+ formState: { isSubmitting: isSubmittingSend, isValid: isValidSend },
+ } = useForm({ defaultValues: defaultValuesSend, resolver: yupResolver(schemaSend), mode: "onBlur" });
useEffect(() => {
if (counter === 0) {
@@ -80,82 +88,102 @@ const CompeleteRequest = ({ allData, handlePrev, mutate, setOpen }) => {
const sendOtp = async (data) => {
try {
- const response = await requestServer(`${GET_OTP_TOKEN}?phone_number=${data.phoneNumber}`, "get")
- setOtpSended(true)
+ const response = await requestServer(`${GET_OTP_TOKEN}?phone_number=${data.phoneNumber}`, "get");
+ setOtpSended(true);
setDelayPerRequest(true);
- setValueSend("phoneNumber", data.phoneNumber)
- } catch (error) {
-
- }
+ setValueSend("phoneNumber", data.phoneNumber);
+ } catch (error) {}
};
- const sendData = useCallback(async (data) => {
- console.log(allData);
-
- const formData = new FormData();
- allData.road_patrol_rahdaran_id.forEach((rahdar, index) => formData.append(`road_patrol_rahdaran_id[${index}]`, rahdar.id));
- formData.append(`road_patrol_machines_id[0]`, allData.roadPatrolMachinesId.id)
- allData.stopPoints.forEach((stop_point, index) => formData.append(`stop_points[${index}]`, stop_point))
- allData.observed_items.forEach((observed_item, index) => {
- formData.append(`observed_items[${index}][instant_action]`, 1);
- formData.append(`observed_items[${index}][local_name]`, "");
- formData.append(`observed_items[${index}][start_point]`, observed_item.result.start_point);
- formData.append(`observed_items[${index}][end_point]`, observed_item.result.end_point);
- formData.append(`observed_items[${index}][amount]`, observed_item.result.amount);
- formData.append(`observed_items[${index}][before_image]`, observed_item.result.before_image);
- formData.append(`observed_items[${index}][after_image]`, observed_item.result.after_image);
- formData.append(`observed_items[${index}][item_id]`, observed_item.result.item_id);
- formData.append(`observed_items[${index}][sub_item_id]`, observed_item.result.sub_item_id);
- formData.append(`observed_items[${index}][road_item_machines_id][]`, allData.roadPatrolMachinesId.id)
- allData.road_patrol_rahdaran_id.forEach((rahdar, index) => formData.append(`observed_items[${index}][road_item_rahdaran_id][]`, rahdar.id));
- })
- formData.append("start_time", allData.start_time);
- formData.append("end_time", allData.end_time);
- formData.append("vehicle_runtime", allData.accOnDuration);
- formData.append("fuel_consumption", +allData.fuelConsumption);
- formData.append("distance", allData.mileage);
- // formData.append("description", "");
- formData.append("phone_number", data.phoneNumber);
- formData.append("verification_code", data.code);
- try {
- await requestServer(CREATE_PATROL, "post", {
- data: formData,
+ const sendData = useCallback(
+ async (data) => {
+ const formData = new FormData();
+ allData.road_patrol_rahdaran_id.forEach((rahdar, index) =>
+ formData.append(`road_patrol_rahdaran_id[${index}]`, rahdar.id)
+ );
+ formData.append(`road_patrol_machines_id[0]`, allData.roadPatrolMachinesId.id);
+ allData.stopPoints.forEach((stop_point, index) => {
+ formData.append(`stop_points[${index}][duration]`, stop_point.duration);
+ formData.append(`stop_points[${index}][latitude]`, stop_point.latitude);
+ formData.append(`stop_points[${index}][longitude]`, stop_point.longitude);
+ formData.append(`stop_points[${index}][startDT]`, stop_point.startDT);
});
- mutate();
- setOpen(false);
- } catch (error) {
- console.log(error);
-
- }
- }, [allData])
+ allData.observed_items.forEach((observed_item, index) => {
+ formData.append(`observed_items[${index}][instant_action]`, 1);
+ formData.append(`observed_items[${index}][local_name]`, "");
+ formData.append(`observed_items[${index}][start_point]`, observed_item.result.start_point);
+ formData.append(`observed_items[${index}][end_point]`, observed_item.result.end_point);
+ formData.append(`observed_items[${index}][amount]`, observed_item.result.amount);
+ formData.append(`observed_items[${index}][before_image]`, observed_item.result.before_image);
+ formData.append(`observed_items[${index}][after_image]`, observed_item.result.after_image);
+ formData.append(`observed_items[${index}][item_id]`, observed_item.result.item_id);
+ formData.append(`observed_items[${index}][sub_item_id]`, observed_item.result.sub_item_id);
+ formData.append(`observed_items[${index}][road_item_machines_id][]`, allData.roadPatrolMachinesId.id);
+ allData.road_patrol_rahdaran_id.forEach((rahdar, index) =>
+ formData.append(`observed_items[${index}][road_item_rahdaran_id][]`, rahdar.id)
+ );
+ });
+ formData.append("start_time", allData.start_time);
+ formData.append("end_time", allData.end_time);
+ formData.append("vehicle_runtime", allData.accOnDuration);
+ formData.append("fuel_consumption", +allData.fuelConsumption);
+ formData.append("distance", allData.mileage);
+ // formData.append("description", "");
+ formData.append("phone_number", data.phoneNumber);
+ formData.append("verification_code", data.code);
+ try {
+ await requestServer(CREATE_PATROL, "post", {
+ data: formData,
+ });
+ mutate();
+ setOpen(false);
+ } catch (error) {
+ console.log(error);
+ }
+ },
+ [allData]
+ );
return (
<>
-
-
-
- {allData.start_time !== '' && moment(allData.start_time).locale("fa").format("YYYY/MM/DD | HH:mm")}
+
+
+
+
+
+
+
+
+ {allData.start_time !== "" &&
+ moment(allData.start_time).locale("fa").format("YYYY/MM/DD | HH:mm")}
-
-
-
- {allData.end_time !== '' && moment(allData.end_time).locale("fa").format("YYYY/MM/DD | HH:mm")}
+
+
+
+
+
+ {allData.start_time !== "" &&
+ moment(allData.start_time).locale("fa").format("YYYY/MM/DD | HH:mm")}
-
-
+
+
- {allData.accOnDuration && allData.accOnDuration}
+
+ {allData.accOnDuration && formatSecondsToHHMMSS(allData.accOnDuration)}
+
- {allData.fuelConsumption && allData.fuelConsumption}
+
+ {allData.fuelConsumption && Math.round(allData.fuelConsumption * 10) / 10} لیتر
+
@@ -165,7 +193,9 @@ const CompeleteRequest = ({ allData, handlePrev, mutate, setOpen }) => {
- {allData.mileage && allData.mileage}
+
+ {allData.mileage && (allData.mileage / 1000).toFixed(1)} کیلومتر
+
@@ -178,38 +208,58 @@ const CompeleteRequest = ({ allData, handlePrev, mutate, setOpen }) => {
-
- کد
+
+
- {allData.roadPatrolMachinesId && allData.roadPatrolMachinesId.machine_code}
-
-
- نام
+
+ {allData.roadPatrolMachinesId && allData.roadPatrolMachinesId.machine_code}
+
+
+
+
- {allData.roadPatrolMachinesId && allData.roadPatrolMachinesId.car_name}
-
-
- پلاک
+
+ {allData.roadPatrolMachinesId && allData.roadPatrolMachinesId.car_name}
+
+
+
+
- {allData.roadPatrolMachinesId && allData.roadPatrolMachinesId.plak_number}
-
+
+ {allData.roadPatrolMachinesId.plak_number &&
+ ShowPlak({ plak_number: allData.roadPatrolMachinesId.plak_number })}
+
+
{allData.road_patrol_rahdaran_id.map((rahdar, index) => (
-
- نام و کد راهدار
+
+
-
- {rahdar.name} | {rahdar.code}
-
-
+
+
+ {rahdar.name} | {rahdar.code}
+
+
+
))}
-
+
+
+
+
@@ -235,7 +285,11 @@ const CompeleteRequest = ({ allData, handlePrev, mutate, setOpen }) => {
sx={{ textWrap: "nowrap", width: 200 }}
endIcon={}
>
- {delayPerRequest ? formatCounter(counter) : isSubmittingOtp ? 'درحال دریافت کد ...' : "دریافت کد"}
+ {delayPerRequest
+ ? formatCounter(counter)
+ : isSubmittingOtp
+ ? "درحال دریافت کد ..."
+ : "دریافت کد"}
@@ -269,7 +323,7 @@ const CompeleteRequest = ({ allData, handlePrev, mutate, setOpen }) => {
-
+
{
- const startTime = useWatch({ control, name: "start_time" })
+ const startTime = useWatch({ control, name: "start_time" });
return (
{
size: "small",
placeholder: "تاریخ و ساعت وارد کنید",
InputLabelProps: { shrink: true },
- sx: { width: { xs: '100%', md: 200 } },
+ sx: { width: { xs: "100%", md: 200 } },
InputProps: {
endAdornment: (
@@ -50,5 +50,5 @@ const DatePickerForEndTime = ({ field, fieldState: { error }, control }) => {
label="تاریخ و ساعت پایان گشت"
/>
);
-}
-export default DatePickerForEndTime
\ No newline at end of file
+};
+export default DatePickerForEndTime;
diff --git a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/DatePickerForStartTime.jsx b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/DatePickerForStartTime.jsx
index a777733..927ad13 100644
--- a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/DatePickerForStartTime.jsx
+++ b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/DatePickerForStartTime.jsx
@@ -4,7 +4,7 @@ import moment from "jalali-moment";
import { useWatch } from "react-hook-form";
const DatePickerForStartTime = ({ field, fieldState: { error }, control }) => {
- const endTime = useWatch({ control, name: "end_time" })
+ const endTime = useWatch({ control, name: "end_time" });
return (
{
size: "small",
placeholder: "تاریخ و ساعت وارد کنید",
InputLabelProps: { shrink: true },
- sx: { width: { xs: '100%', md: 200 } },
+ sx: { width: { xs: "100%", md: 200 } },
InputProps: {
endAdornment: (
@@ -50,5 +50,5 @@ const DatePickerForStartTime = ({ field, fieldState: { error }, control }) => {
label="تاریخ و ساعت شروع گشت"
/>
);
-}
-export default DatePickerForStartTime
\ No newline at end of file
+};
+export default DatePickerForStartTime;
diff --git a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/EditActionDuringPatrol.jsx b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/EditActionDuringPatrol.jsx
index 01bb3bc..46875ce 100644
--- a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/EditActionDuringPatrol.jsx
+++ b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/EditActionDuringPatrol.jsx
@@ -48,7 +48,12 @@ const EditActionDuringPatrol = ({ action, index, setActionsList }) => {
}}
>
ویرایش اطلاعات
-
+
>
);
diff --git a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolDetail.jsx b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolDetail.jsx
index 36cc8bd..75515aa 100644
--- a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolDetail.jsx
+++ b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolDetail.jsx
@@ -21,15 +21,9 @@ import PatrolDetailInfo from "./PatrolDetailInfo";
import PatrolResultCodeErrors from "./PatrolResultCodeErrors";
const schema = yup.object().shape({
- roadPatrolMachinesId: yup
- .object()
- .required("خودرو الزامی است."),
- start_time: yup
- .string()
- .required("زمان شروع الزامی است."),
- end_time: yup
- .string()
- .required("زمان پایان الزامی است.")
+ roadPatrolMachinesId: yup.object().required("خودرو الزامی است."),
+ start_time: yup.string().required("زمان شروع الزامی است."),
+ end_time: yup.string().required("زمان پایان الزامی است."),
});
const PatrolDetail = ({ allData, setAllData, handlePrev, setTabState }) => {
@@ -47,12 +41,16 @@ const PatrolDetail = ({ allData, setAllData, handlePrev, setTabState }) => {
const [patrolResultStatus, setPatrolResultStatus] = useState(allData.resultCode);
const [patrolData, setPatrolData] = useState(defaultValues);
-
- const { control, handleSubmit, setValue, formState: { isSubmitting, isValid } } = useForm({ defaultValues, resolver: yupResolver(schema), mode: 'onBlur' })
+ const {
+ control,
+ handleSubmit,
+ setValue,
+ formState: { isSubmitting, isValid },
+ } = useForm({ defaultValues, resolver: yupResolver(schema), mode: "onBlur" });
const requestPatrolInfo = async (data) => {
- setPatrolResultStatus(1)
- setPatrolData(pd => ({ ...pd, has_vehicle_operation: false }))
+ setPatrolResultStatus(1);
+ setPatrolData((pd) => ({ ...pd, has_vehicle_operation: false }));
const formData = new FormData();
formData.append("machineCode", data.roadPatrolMachinesId.machine_code);
formData.append("startDT", moment(data.start_time).format("YYYY-MM-DDTHH:mm"));
@@ -60,46 +58,51 @@ const PatrolDetail = ({ allData, setAllData, handlePrev, setTabState }) => {
try {
const response = await requestServer(GET_VAHICLE_OPRATION, "post", {
data: formData,
- })
+ });
const result = response.data.data;
setPatrolData({
...result,
roadPatrolMachinesId: data.roadPatrolMachinesId,
start_time: data.start_time,
end_time: data.end_time,
- has_vehicle_operation: result.resultCode == 0
+ has_vehicle_operation: result.resultCode == 0,
});
- setValue('stopPoints', result.stopPoints)
- setValue('accOnDuration', result.accOnDuration)
- setValue('fuelConsumption', result.fuelConsumption)
- setValue('mileage', result.mileage)
- setValue('has_vehicle_operation', true)
+ setValue("stopPoints", result.stopPoints);
+ setValue("accOnDuration", result.accOnDuration);
+ setValue("fuelConsumption", result.fuelConsumption);
+ setValue("mileage", result.mileage);
+ setValue("has_vehicle_operation", true);
setPatrolResultStatus(result.resultCode);
- } catch (error) {
-
- }
+ } catch (error) {}
};
const handleNext = (data) => {
setAllData(data);
- setTabState(s => s + 1)
- }
+ setTabState((s) => s + 1);
+ };
return (
<>
-
+
-
+
{
disabled={isSubmitting || !isValid}
endIcon={}
>
- {isSubmitting ? "درحال دریافت عملکرد خودرو ..." : 'دریافت عملکرد خوردو'}
+ {isSubmitting ? "درحال دریافت عملکرد خودرو ..." : "دریافت عملکرد خوردو"}
- {patrolResultStatus !== 0 && (
-
- )}
-
+ {patrolResultStatus !== 0 && }
+
diff --git a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolDetailInfo.jsx b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolDetailInfo.jsx
index 3fb6a6e..f67f322 100644
--- a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolDetailInfo.jsx
+++ b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolDetailInfo.jsx
@@ -1,6 +1,18 @@
"use client";
-import { Box, Button, Card, CardActions, CardContent, Chip, Divider, Fade, Slide, Stack, Typography } from "@mui/material";
+import {
+ Box,
+ Button,
+ Card,
+ CardActions,
+ CardContent,
+ Chip,
+ Divider,
+ Fade,
+ Slide,
+ Stack,
+ Typography,
+} from "@mui/material";
import React, { useEffect } from "react";
import dynamic from "next/dynamic";
import MapLoading from "@/core/components/MapLayer/Loading";
@@ -16,6 +28,8 @@ import QrCode2Icon from "@mui/icons-material/QrCode2";
import moment from "jalali-moment";
import PatrolMapFeatures from "./PatrolMapFeatures";
import { useMap } from "react-leaflet";
+import { formatSecondsToHHMMSS } from "@/core/utils/formatSecondsToHHMMSS";
+import ShowPlak from "@/core/components/ShowPlak";
const MapLayer = dynamic(() => import("@/core/components/MapLayer"), {
loading: () => ,
@@ -33,17 +47,20 @@ const MapItemViewBound = ({ patrolData, bound }) => {
return (
<>
- {patrolData?.stopPoints && patrolData.stopPoints.map((stopPoint, index) => (
-
-
-
- ))}
+ {patrolData?.stopPoints &&
+ patrolData.stopPoints.map((stopPoint, index) => (
+
+
+
+ ))}
>
);
};
const PatrolDetailInfo = ({ patrolData }) => {
- const bound = patrolData?.stopPoints ? patrolData?.stopPoints.map((point) => [point.latitude, point.longitude]) : []
+ const bound = patrolData?.stopPoints
+ ? patrolData?.stopPoints.map((point) => [point.latitude, point.longitude])
+ : [];
return (
@@ -57,12 +74,12 @@ const PatrolDetailInfo = ({ patrolData }) => {
gap: { xs: 2, lg: 0 },
}}
>
-
+
} />
- {Math.floor(patrolData?.accOnDuration / 60)} دقیقه
+ {formatSecondsToHHMMSS(patrolData?.accOnDuration)}
@@ -79,36 +96,39 @@ const PatrolDetailInfo = ({ patrolData }) => {
{patrolData?.roadPatrolMachinesId?.machine_code}
-
+
} />
-
- {patrolData?.roadPatrolMachinesId?.plak_number}
-
+
+ {patrolData?.roadPatrolMachinesId?.plak_number &&
+ ShowPlak({ plak_number: patrolData?.roadPatrolMachinesId?.plak_number })}
+
} />
- {patrolData?.start_time !== '' && moment(patrolData?.start_time).locale("fa").format("HH:mm | YYYY/MM/DD")}
+ {patrolData?.start_time !== "" &&
+ moment(patrolData?.start_time).locale("fa").format("HH:mm | YYYY/MM/DD")}
} />
- {patrolData?.end_time !== '' && moment(patrolData?.end_time).locale("fa").format("HH:mm | YYYY/MM/DD")}
+ {patrolData?.end_time !== "" &&
+ moment(patrolData?.end_time).locale("fa").format("HH:mm | YYYY/MM/DD")}
- } />
+ } />
{(patrolData?.mileage / 1000).toFixed(1)} کیلومتر
- } />
+ } />
{Math.round(patrolData?.fuelConsumption * 10) / 10} لیتر
@@ -150,7 +170,6 @@ const PatrolDetailInfo = ({ patrolData }) => {
-
);
diff --git a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolForms.jsx b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolForms.jsx
index ad0c721..63b877c 100644
--- a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolForms.jsx
+++ b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolForms.jsx
@@ -1,17 +1,17 @@
"use client";
-import useRequest from "@/lib/hooks/useRequest";
import { useTheme } from "@emotion/react";
-import TaxiAlertIcon from "@mui/icons-material/TaxiAlert";
import EngineeringIcon from "@mui/icons-material/Engineering";
import HandymanIcon from "@mui/icons-material/Handyman";
+import TaxiAlertIcon from "@mui/icons-material/TaxiAlert";
import VerifiedIcon from "@mui/icons-material/Verified";
import { Box, Tab, Tabs, useMediaQuery } from "@mui/material";
+import { DialogHeader } from "next/dist/client/components/react-dev-overlay/internal/components/Dialog";
import { useCallback, useEffect, useReducer, useState } from "react";
-import PatrolDetail from "./PatrolDetail";
-import SuperVisorsDetail from "./SuperVisorsDetail";
import ActionsDuringPatrol from "./ActionsDurigPatrol";
import CompeleteRequest from "./CompeleteRequest";
+import PatrolDetail from "./PatrolDetail";
+import SuperVisorsDetail from "./SuperVisorsDetail";
function TabPanel(props) {
const { children, value, index } = props;
@@ -41,17 +41,14 @@ const defaultValues = {
const reducer = (state, action) => {
switch (action.type) {
- case 'changeData':
- return { ...state, ...action.data }
+ case "changeData":
+ return { ...state, ...action.data };
default:
return state;
}
-
-
-}
+};
const PatrolForms = ({ mutate, setOpen }) => {
- const requestServer = useRequest({ notificationSuccess: true });
const [allData, dispatch] = useReducer(reducer, defaultValues);
const theme = useTheme();
const isMobile = useMediaQuery(theme.breakpoints.down("md"));
@@ -72,33 +69,36 @@ const PatrolForms = ({ mutate, setOpen }) => {
if (tabState == 0) {
setOpen(false);
}
- setTabState(s => s - 1)
- }, [tabState])
+ setTabState((s) => s - 1);
+ }, [tabState]);
return (
<>
-
- = 0)} icon={} label="مشخصات گشت">
- = 1)} icon={} label="مشخصات راهداران">
- = 2)} icon={} label="اقدامات حین گشت">
- = 3)} icon={} label="بررسی نهایی و ثبت">
-
-
+
+
+ = 0)} icon={} label="مشخصات گشت">
+ = 1)} icon={} label="مشخصات راهداران">
+ = 2)} icon={} label="اقدامات حین گشت">
+ = 3)} icon={} label="بررسی نهایی و ثبت">
+
+
{ dispatch({ type: 'changeData', data }) }}
+ setAllData={(data) => {
+ dispatch({ type: "changeData", data });
+ }}
handlePrev={handlePrev}
setTabState={setTabState}
/>
@@ -106,7 +106,9 @@ const PatrolForms = ({ mutate, setOpen }) => {
{ dispatch({ type: 'changeData', data }) }}
+ setAllData={(data) => {
+ dispatch({ type: "changeData", data });
+ }}
handlePrev={handlePrev}
setTabState={setTabState}
/>
@@ -114,18 +116,15 @@ const PatrolForms = ({ mutate, setOpen }) => {
{ dispatch({ type: 'changeData', data }) }}
+ setAllData={(data) => {
+ dispatch({ type: "changeData", data });
+ }}
handlePrev={handlePrev}
setTabState={setTabState}
/>
-
+
>
);
diff --git a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolResultCodeErrors.jsx b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolResultCodeErrors.jsx
index b3abdbf..e079d0e 100644
--- a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolResultCodeErrors.jsx
+++ b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolResultCodeErrors.jsx
@@ -15,8 +15,11 @@ const PatrolResultCodeErrors = ({ ResultCode }) => {
const message = errorMessages[ResultCode] || "ابتدا اطلاعات بالا را تکمیل نمایید";
return (
-
-
+
+
{message}
diff --git a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/SuperVisorInfo.jsx b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/SuperVisorInfo.jsx
index 703807e..d9ffef6 100644
--- a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/SuperVisorInfo.jsx
+++ b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/SuperVisorInfo.jsx
@@ -14,7 +14,7 @@ const SuperVisorInfo = ({ superVisor, deleteSuperVisor }) => {
alignItems: "center",
justifyContent: "space-between",
border: 1,
- borderColor: 'divider',
+ borderColor: "divider",
px: 1,
py: 1,
}}
diff --git a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/SuperVisorsDetail.jsx b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/SuperVisorsDetail.jsx
index e26fb11..42cd036 100644
--- a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/SuperVisorsDetail.jsx
+++ b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/SuperVisorsDetail.jsx
@@ -11,9 +11,7 @@ import { Controller, useForm } from "react-hook-form";
import * as yup from "yup";
const schema = yup.object().shape({
- road_patrol_rahdaran_id: yup
- .object()
- .required("راهدار الزامی است."),
+ road_patrol_rahdaran_id: yup.object().required("راهدار الزامی است."),
});
const SuperVisorsDetail = ({ allData, setAllData, handlePrev, setTabState }) => {
@@ -23,11 +21,17 @@ const SuperVisorsDetail = ({ allData, setAllData, handlePrev, setTabState }) =>
road_patrol_rahdaran_id: null,
};
- const { control, handleSubmit, reset, setValue, formState: { isSubmitting, isValid } } = useForm({ defaultValues, resolver: yupResolver(schema), mode: 'onBlur' })
+ const {
+ control,
+ handleSubmit,
+ reset,
+ setValue,
+ formState: { isSubmitting, isValid },
+ } = useForm({ defaultValues, resolver: yupResolver(schema), mode: "onBlur" });
const requestPatrolInfo = (data) => {
setSuperVisorList((prev) => [...prev, data.road_patrol_rahdaran_id]);
- reset()
+ reset();
};
const deleteSuperVisor = (id) => {
@@ -36,8 +40,8 @@ const SuperVisorsDetail = ({ allData, setAllData, handlePrev, setTabState }) =>
const handleNext = (data) => {
setAllData({ road_patrol_rahdaran_id: data });
- setTabState(s => s + 1)
- }
+ setTabState((s) => s + 1);
+ };
return (
<>
@@ -48,11 +52,11 @@ const SuperVisorsDetail = ({ allData, setAllData, handlePrev, setTabState }) =>
display: "flex",
flexDirection: "column",
mt: 1,
- mb: 2
+ mb: 2,
}}
>
-
+
overflowY: "auto",
}}
>
- {SuperVisorList.length !== 0 && SuperVisorList.map((superVisor) => (
-
-
-
- ))}
+ {SuperVisorList.length !== 0 &&
+ SuperVisorList.map((superVisor) => (
+
+
+
+ ))}
-
+
{
return (
);
};
diff --git a/src/components/dashboard/roadPatrols/operator/RowActions/MachinePerformanceForm/StopsInfo.jsx b/src/components/dashboard/roadPatrols/operator/RowActions/MachinePerformanceForm/StopsInfo.jsx
index 6869f7a..fa6679a 100644
--- a/src/components/dashboard/roadPatrols/operator/RowActions/MachinePerformanceForm/StopsInfo.jsx
+++ b/src/components/dashboard/roadPatrols/operator/RowActions/MachinePerformanceForm/StopsInfo.jsx
@@ -3,6 +3,7 @@ import AccessAlarmsIcon from "@mui/icons-material/AccessAlarms";
import PinDropIcon from "@mui/icons-material/PinDrop";
import LocalGasStationIcon from "@mui/icons-material/LocalGasStation";
import DirectionsCarIcon from "@mui/icons-material/DirectionsCar";
+import { formatSecondsToHHMMSS } from "@/core/utils/formatSecondsToHHMMSS";
const StopsInfo = ({ selectedPoint, staticData }) => {
return (
@@ -13,7 +14,7 @@ const StopsInfo = ({ selectedPoint, staticData }) => {
icon={}
label={
- کد ماشین
+ کد خودرو
}
/>
@@ -29,14 +30,14 @@ const StopsInfo = ({ selectedPoint, staticData }) => {
icon={}
label={
- مصرف سوخت
+ میزان سوخت مصرفی
}
/>
- {staticData.fuelConsumption || ""} لیتر
+ {Math.round(patrolData?.fuelConsumption * 10) / 10} لیتر
@@ -45,14 +46,14 @@ const StopsInfo = ({ selectedPoint, staticData }) => {
icon={}
label={
- مسافت طیشده
+ مسافت پیموده شده
}
/>
- {staticData.mileage.toLocaleString() || ""} متر
+ {(patrolData?.mileage / 1000).toFixed(1)} کیلومتر
@@ -68,7 +69,7 @@ const StopsInfo = ({ selectedPoint, staticData }) => {
- {(staticData.accOnDuration / 60)?.toFixed(2) || ""} دقیقه
+ {formatSecondsToHHMMSS(patrolData?.accOnDuration)}
diff --git a/src/components/dashboard/roadPatrols/operator/RowActions/MachinePerformanceForm/index.jsx b/src/components/dashboard/roadPatrols/operator/RowActions/MachinePerformanceForm/index.jsx
index fb267d5..8f35d4f 100644
--- a/src/components/dashboard/roadPatrols/operator/RowActions/MachinePerformanceForm/index.jsx
+++ b/src/components/dashboard/roadPatrols/operator/RowActions/MachinePerformanceForm/index.jsx
@@ -3,7 +3,7 @@ import DirectionsCarIcon from "@mui/icons-material/DirectionsCar";
import MachinePerformanceContent from "./MachinePerformanceContent";
import { useState } from "react";
-const MachinePerformanceForm = ({row}) => {
+const MachinePerformanceForm = ({ row }) => {
const [openMachinesCodeDialog, setOpenMachinesCodeDialog] = useState(false);
const machineData = {
cmms_machine_code: row.original?.cmms_machines[0]?.machine_code,
diff --git a/src/components/dashboard/roadPatrols/supervisor/RowActions/MachinePerformanceForm/StopsInfo.jsx b/src/components/dashboard/roadPatrols/supervisor/RowActions/MachinePerformanceForm/StopsInfo.jsx
index 07e6e77..8319890 100644
--- a/src/components/dashboard/roadPatrols/supervisor/RowActions/MachinePerformanceForm/StopsInfo.jsx
+++ b/src/components/dashboard/roadPatrols/supervisor/RowActions/MachinePerformanceForm/StopsInfo.jsx
@@ -3,6 +3,8 @@ import AccessAlarmsIcon from "@mui/icons-material/AccessAlarms";
import PinDropIcon from "@mui/icons-material/PinDrop";
import LocalGasStationIcon from "@mui/icons-material/LocalGasStation";
import DirectionsCarIcon from "@mui/icons-material/DirectionsCar";
+import { formatSecondsToHHMMSS } from "@/core/utils/formatSecondsToHHMMSS";
+
const StopsInfo = ({ selectedPoint, staticData }) => {
return (
@@ -12,7 +14,7 @@ const StopsInfo = ({ selectedPoint, staticData }) => {
icon={}
label={
- کد ماشین
+ کد خودرو
}
/>
@@ -28,14 +30,14 @@ const StopsInfo = ({ selectedPoint, staticData }) => {
icon={}
label={
- مصرف سوخت
+ میزان سوخت مصرفی
}
/>
- {staticData.fuelConsumption || ""} لیتر
+ {Math.round(staticData?.fuelConsumption * 10) / 10} لیتر
@@ -44,14 +46,14 @@ const StopsInfo = ({ selectedPoint, staticData }) => {
icon={}
label={
- مسافت طیشده
+ مسافت پیموده شده
}
/>
- {staticData.mileage.toLocaleString() || ""} متر
+ {(staticData?.mileage / 1000).toFixed(1)} کیلومتر
@@ -67,7 +69,7 @@ const StopsInfo = ({ selectedPoint, staticData }) => {
- {(staticData.accOnDuration / 60)?.toFixed(2) || ""} دقیقه
+ {formatSecondsToHHMMSS(staticData?.accOnDuration)}
@@ -115,7 +117,9 @@ const StopsInfo = ({ selectedPoint, staticData }) => {
- {selectedPoint ? `${selectedPoint.duration} ثانیه` : "نقطه مورد نظر را انتخاب کنید"}
+ {selectedPoint
+ ? `${formatSecondsToHHMMSS(selectedPoint.duration)} ثانیه`
+ : "نقطه مورد نظر را انتخاب کنید"}
diff --git a/src/components/dashboard/roadPatrols/supervisor/RowActions/MachinePerformanceForm/index.jsx b/src/components/dashboard/roadPatrols/supervisor/RowActions/MachinePerformanceForm/index.jsx
index fb267d5..8f35d4f 100644
--- a/src/components/dashboard/roadPatrols/supervisor/RowActions/MachinePerformanceForm/index.jsx
+++ b/src/components/dashboard/roadPatrols/supervisor/RowActions/MachinePerformanceForm/index.jsx
@@ -3,7 +3,7 @@ import DirectionsCarIcon from "@mui/icons-material/DirectionsCar";
import MachinePerformanceContent from "./MachinePerformanceContent";
import { useState } from "react";
-const MachinePerformanceForm = ({row}) => {
+const MachinePerformanceForm = ({ row }) => {
const [openMachinesCodeDialog, setOpenMachinesCodeDialog] = useState(false);
const machineData = {
cmms_machine_code: row.original?.cmms_machines[0]?.machine_code,
diff --git a/src/components/dashboard/roadPatrols/supervisor/SupervisorList.jsx b/src/components/dashboard/roadPatrols/supervisor/SupervisorList.jsx
index f33c695..b3a0b02 100644
--- a/src/components/dashboard/roadPatrols/supervisor/SupervisorList.jsx
+++ b/src/components/dashboard/roadPatrols/supervisor/SupervisorList.jsx
@@ -147,7 +147,7 @@ const SupervisorList = () => {
},
},
},
- Cell: ({row}) => (
+ Cell: ({ row }) => (
diff --git a/src/core/components/DataTable/filter/fieldsType/CustomDate/MuiDatePicker.jsx b/src/core/components/DataTable/filter/fieldsType/CustomDate/MuiDatePicker.jsx
index fafbb9b..d2d9df0 100644
--- a/src/core/components/DataTable/filter/fieldsType/CustomDate/MuiDatePicker.jsx
+++ b/src/core/components/DataTable/filter/fieldsType/CustomDate/MuiDatePicker.jsx
@@ -30,7 +30,7 @@ function MuiDatePicker({ label, value, setFieldValue, name, minDate, maxDate, he
maxDate={maxDate ? new Date(maxDate) : null}
slotProps={{
textField: {
- size: 'small',
+ size: "small",
error: error,
placeholder: placeholder,
InputProps: {
diff --git a/src/core/components/DataTable/filter/fieldsType/CustomSelect.jsx b/src/core/components/DataTable/filter/fieldsType/CustomSelect.jsx
index 135a8b6..f008c5e 100644
--- a/src/core/components/DataTable/filter/fieldsType/CustomSelect.jsx
+++ b/src/core/components/DataTable/filter/fieldsType/CustomSelect.jsx
@@ -2,10 +2,11 @@
import { FormControl, InputLabel, MenuItem, OutlinedInput, Select } from "@mui/material";
function CustomSelect({ column, filterParameters, handleChange }) {
-
return (
- {column.header}
+
+ {column.header}
+
diff --git a/src/core/components/DataTable/filter/fieldsType/CustomSelectByDependency.jsx b/src/core/components/DataTable/filter/fieldsType/CustomSelectByDependency.jsx
index 201f908..5a1f2d3 100644
--- a/src/core/components/DataTable/filter/fieldsType/CustomSelectByDependency.jsx
+++ b/src/core/components/DataTable/filter/fieldsType/CustomSelectByDependency.jsx
@@ -13,7 +13,9 @@ function CustomSelectByDependency({
}) {
return (
- {column.header}
+
+ {column.header}
+