added end_km, fixed time picker & typos
- road missions table
This commit is contained in:
@@ -14,6 +14,7 @@ import useCities from "@/lib/hooks/useCities";
|
||||
const ControlList = () => {
|
||||
const columns = useMemo(() => {
|
||||
const dynamicColumns = {
|
||||
accessorKey: "province_id",
|
||||
header: "استان",
|
||||
id: "province_id",
|
||||
enableColumnFilter: true,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import LtrTextField from "@/core/components/LtrTextField";
|
||||
import MuiDatePicker from "@/core/components/MuiDatePicker";
|
||||
import MuiTimePicker from "@/core/components/MuiTimePicker";
|
||||
import { FINISH_MISSION } from "@/core/utils/routes";
|
||||
@@ -14,6 +15,7 @@ const FinishMissionContent = ({ rowId, mutate, setOpenFinishMissionDialog }) =>
|
||||
const requestServer = useRequest({ notificationSuccess: true });
|
||||
|
||||
const validationSchema = object().shape({
|
||||
end_km: string().required("لطفاً کیلومتر را وارد کنید."),
|
||||
start_date: mixed().required("تاریخ خروج خودرو را مشخص کنید."),
|
||||
start_time: mixed().required("ساعت خروج خودرو را مشخص کنید."),
|
||||
});
|
||||
@@ -24,6 +26,7 @@ const FinishMissionContent = ({ rowId, mutate, setOpenFinishMissionDialog }) =>
|
||||
formState: { isSubmitting },
|
||||
} = useForm({
|
||||
defaultValues: {
|
||||
end_km: "",
|
||||
start_date: null,
|
||||
start_time: null,
|
||||
},
|
||||
@@ -36,6 +39,7 @@ const FinishMissionContent = ({ rowId, mutate, setOpenFinishMissionDialog }) =>
|
||||
const formattedTime = format(values.start_time, "HH:mm");
|
||||
requestServer(`${FINISH_MISSION}/${rowId}`, "post", {
|
||||
data: {
|
||||
end_km: values.end_km,
|
||||
time: `${formattedDate} ${formattedTime}`,
|
||||
},
|
||||
hasSidebarUpdate: true,
|
||||
@@ -55,6 +59,27 @@ const FinishMissionContent = ({ rowId, mutate, setOpenFinishMissionDialog }) =>
|
||||
<DialogContent>
|
||||
<Stack alignItems="center" spacing={2}>
|
||||
<Typography mt={2}>آیا از ورود خودرو و پایان ماموریت اطمینان دارید؟</Typography>
|
||||
<Stack>
|
||||
<Controller
|
||||
control={control}
|
||||
name={"end_km"}
|
||||
render={({ field, fieldState: { error } }) => (
|
||||
<LtrTextField
|
||||
autoComplete="off"
|
||||
type="tel"
|
||||
value={field.value}
|
||||
onChange={(e) => {
|
||||
if (isNaN(Number(e.target.value))) return;
|
||||
field.onChange(e.target.value);
|
||||
}}
|
||||
size="small"
|
||||
fullWidth
|
||||
label="کیلومتر خودرو / ساعت کار"
|
||||
InputLabelProps={{ shrink: true }}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</Stack>
|
||||
<Stack>
|
||||
<Controller
|
||||
control={control}
|
||||
@@ -65,8 +90,8 @@ const FinishMissionContent = ({ rowId, mutate, setOpenFinishMissionDialog }) =>
|
||||
error={error}
|
||||
value={field.value || null}
|
||||
disableFuture={false}
|
||||
placeholder={"تاریخ شروع ماموریت را وارد کنید"}
|
||||
label={"تاریخ شروع ماموریت"}
|
||||
placeholder={"تاریخ پایان ماموریت را وارد کنید"}
|
||||
label={"تاریخ پایان ماموریت"}
|
||||
setFieldValue={(name, value) => field.onChange(value || null)}
|
||||
helperText={error ? error.message : null}
|
||||
/>
|
||||
@@ -83,8 +108,8 @@ const FinishMissionContent = ({ rowId, mutate, setOpenFinishMissionDialog }) =>
|
||||
error={error}
|
||||
value={field.value || null}
|
||||
views={["hours", "minutes"]}
|
||||
placeholder={"زمان شروع ماموریت را وارد کنید"}
|
||||
label={"زمان شروع ماموریت"}
|
||||
placeholder={"زمان پایان ماموریت را وارد کنید"}
|
||||
label={"زمان پایان ماموریت"}
|
||||
setFieldValue={(name, value) => field.onChange(value || null)}
|
||||
helperText={error ? error.message : null}
|
||||
/>
|
||||
|
||||
@@ -51,7 +51,6 @@ const MissionDates = ({ control }) => {
|
||||
name="start_time"
|
||||
error={error}
|
||||
value={field.value}
|
||||
views={["hours"]}
|
||||
minTime={
|
||||
start_date && new Date(start_date).toDateString() === now.toDateString()
|
||||
? now
|
||||
@@ -100,7 +99,6 @@ const MissionDates = ({ control }) => {
|
||||
name="end_time"
|
||||
error={error}
|
||||
value={field.value}
|
||||
views={["hours"]}
|
||||
minTime={startDateTime ?? null}
|
||||
placeholder={"زمان پایان ماموریت را وارد کنید"}
|
||||
label={"زمان پایان ماموریت"}
|
||||
|
||||
@@ -15,7 +15,7 @@ const ToDateController = ({ control }) => {
|
||||
maxDate={new Date()}
|
||||
error={!!error}
|
||||
value={value}
|
||||
label={"تاریخ شروع (تا تاریخ)"}
|
||||
label={"تاریخ پایان (تا تاریخ)"}
|
||||
placeholder={"تا تاریخ"}
|
||||
setFieldValue={(name, newValue) => {
|
||||
const formattedDate = moment(new Date(newValue)).locale("en").format("YYYY-MM-DD");
|
||||
|
||||
Reference in New Issue
Block a user