diff --git a/src/components/dashboard/roadMissions/violations/Actions/CreateViolation/Form/CreateForm.jsx b/src/components/dashboard/roadMissions/violations/Actions/CreateViolation/Form/CreateForm.jsx
index 86fb936..cb7dc7a 100644
--- a/src/components/dashboard/roadMissions/violations/Actions/CreateViolation/Form/CreateForm.jsx
+++ b/src/components/dashboard/roadMissions/violations/Actions/CreateViolation/Form/CreateForm.jsx
@@ -5,6 +5,7 @@ import { yupResolver } from "@hookform/resolvers/yup";
import { Button, DialogActions, DialogContent, Stack } from "@mui/material";
import { Controller, useForm } from "react-hook-form";
import * as yup from "yup";
+import MissionDates from "@/components/dashboard/roadMissions/violations/Actions/CreateViolation/Form/MissionDates";
const schema = yup.object().shape({
machinesId: yup.object().required("کد خودرو الزامی است."),
km: yup.string(),
@@ -61,6 +62,9 @@ const CreateViolationForm = ({ setOpenMachinesDialog, defaultValues, onSubmitBas
)}
/>
+
+
+
diff --git a/src/components/dashboard/roadMissions/violations/Actions/CreateViolation/Form/MissionDates/index.jsx b/src/components/dashboard/roadMissions/violations/Actions/CreateViolation/Form/MissionDates/index.jsx
new file mode 100644
index 0000000..ca84634
--- /dev/null
+++ b/src/components/dashboard/roadMissions/violations/Actions/CreateViolation/Form/MissionDates/index.jsx
@@ -0,0 +1,55 @@
+import MuiDatePicker from "@/core/components/MuiDatePicker";
+import MuiTimePicker from "@/core/components/MuiTimePicker";
+import { Grid } from "@mui/material";
+import { Controller, useWatch } from "react-hook-form";
+
+const MissionDates = ({ control }) => {
+ const start_date = useWatch({ control, name: "start_date" });
+ const now = new Date();
+
+ return (
+ <>
+
+ {
+ return (
+ field.onChange(value || [])}
+ helperText={error ? error.message : null}
+ />
+ );
+ }}
+ />
+
+
+ {
+ return (
+ field.onChange(value || null)}
+ helperText={error ? error.message : null}
+ />
+ );
+ }}
+ />
+
+ >
+ );
+};
+export default MissionDates;
diff --git a/src/components/dashboard/roadMissions/violations/Actions/CreateViolation/Form/index.jsx b/src/components/dashboard/roadMissions/violations/Actions/CreateViolation/Form/index.jsx
index 2b70d5b..ad34476 100644
--- a/src/components/dashboard/roadMissions/violations/Actions/CreateViolation/Form/index.jsx
+++ b/src/components/dashboard/roadMissions/violations/Actions/CreateViolation/Form/index.jsx
@@ -3,6 +3,7 @@ import { DialogHeader } from "next/dist/client/components/react-dev-overlay/inte
import useRequest from "@/lib/hooks/useRequest";
import { CREATE_VIOLATION } from "@/core/utils/routes";
import CreateViolationForm from "@/components/dashboard/roadMissions/violations/Actions/CreateViolation/Form/CreateForm";
+import moment from "jalali-moment";
const ViolationForm = ({ setOpenMachinesDialog, mutate, openMachinesDialog }) => {
const requestServer = useRequest({ notificationSuccess: true });
@@ -10,6 +11,8 @@ const ViolationForm = ({ setOpenMachinesDialog, mutate, openMachinesDialog }) =>
const defaultValues = {
machinesId: null,
km: "",
+ start_date: null,
+ start_time: null,
};
const submitForm = async (result) => {
@@ -17,6 +20,7 @@ const ViolationForm = ({ setOpenMachinesDialog, mutate, openMachinesDialog }) =>
data: {
machine_code: result.machinesId.machine_code,
km: result.km,
+ exit_time: `${result.start_date} ${moment(result.start_time).format("HH:mm")}`,
},
})
.then((response) => {
diff --git a/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/index.jsx b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/index.jsx
index 96de65d..76230ad 100644
--- a/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/index.jsx
+++ b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/index.jsx
@@ -59,10 +59,9 @@ const CreateForm = ({ defaultValues, submitForm, setOpen, submitting }) => {
}}
>
} label="مشخصات" />
- } label="زمانبندی" />
- } label="راننده" />
- } label="همراهان" />
- } label="بررسی نهایی" />
+ } label="راننده" />
+ } label="همراهان" />
+ } label="بررسی نهایی" />
{
setTabState={setTabState}
/>
-
- {
- dispatch({ type: "changeData", data });
- }}
- handlePrev={handlePrev}
- setTabState={setTabState}
- />
-
{
...(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")}`,
driver: result.driver.id,
},
hasSidebarUpdate: true,
@@ -70,10 +68,6 @@ const CreateWithoutProcess = ({ row, mutate }) => {
category_id: "",
road_observed_id: "",
rahdaran: [],
- start_date: "",
- start_time: null,
- end_date: "",
- end_time: null,
end_point: "",
region: "",
driver: null,
diff --git a/src/components/dashboard/roadMissions/violations/Actions/EditViolation/EditController.jsx b/src/components/dashboard/roadMissions/violations/Actions/EditViolation/EditController.jsx
index 97ae1e2..ab16760 100644
--- a/src/components/dashboard/roadMissions/violations/Actions/EditViolation/EditController.jsx
+++ b/src/components/dashboard/roadMissions/violations/Actions/EditViolation/EditController.jsx
@@ -5,24 +5,19 @@ import { DialogHeader } from "next/dist/client/components/react-dev-overlay/inte
import EditViolationForm from "./EditViolationForm";
import moment from "jalali-moment";
-const EditController = ({ rowId, mutate, setOpen }) => {
+const EditController = ({ rowId, mutate, setOpen, row }) => {
const requestServer = useRequest({ notificationSuccess: true });
+ const [endDate] = row?.original?.enter_time?.split(" ") || [null];
const defaultData = {
- start_date: null,
- start_time: null,
- end_date: null,
- end_time: null,
+ end_date: endDate,
+ end_time: row?.original?.enter_time ? new Date(row.original.enter_time) : null,
};
const handleSubmit = async (result) => {
const payload = {};
- if (result.start_date && result.start_time) {
- payload.enter_time = `${result.start_date} ${moment(result.start_time).format("HH:mm")}`;
- }
-
if (result.end_date && result.end_time) {
- payload.exit_time = `${result.end_date} ${moment(result.end_time).format("HH:mm")}`;
+ payload.enter_time = `${result.end_date} ${moment(result.end_time).format("HH:mm")}`;
}
await requestServer(`${EDIT_VIOLATION}/${rowId}`, "post", {
diff --git a/src/components/dashboard/roadMissions/violations/Actions/EditViolation/MissionDates/index.jsx b/src/components/dashboard/roadMissions/violations/Actions/EditViolation/MissionDates/index.jsx
index 493d4e2..ba07a09 100644
--- a/src/components/dashboard/roadMissions/violations/Actions/EditViolation/MissionDates/index.jsx
+++ b/src/components/dashboard/roadMissions/violations/Actions/EditViolation/MissionDates/index.jsx
@@ -5,52 +5,11 @@ import { Grid } from "@mui/material";
import { Controller, useWatch } from "react-hook-form";
const MissionDates = ({ control }) => {
- const start_date = useWatch({ control, name: "start_date" });
const end_date = useWatch({ control, name: "end_date" });
const now = new Date();
return (
<>
-
- {
- return (
- field.onChange(value || [])}
- helperText={error ? error.message : null}
- />
- );
- }}
- />
-
-
- {
- return (
- field.onChange(value || null)}
- helperText={error ? error.message : null}
- />
- );
- }}
- />
-
{
error={error}
value={field.value}
disableFuture={false}
- minDate={start_date ? start_date : now}
+ minDate={end_date ? end_date : now}
placeholder={"تاریخ پایان ماموریت را وارد کنید"}
label={"تاریخ پایان ماموریت"}
setFieldValue={(name, value) => field.onChange(value || [])}