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 eca6626..86fb936 100644 --- a/src/components/dashboard/roadMissions/violations/Actions/CreateViolation/Form/CreateForm.jsx +++ b/src/components/dashboard/roadMissions/violations/Actions/CreateViolation/Form/CreateForm.jsx @@ -1,11 +1,13 @@ +import CarCode from "@/core/components/CarCode"; +import LtrTextField from "@/core/components/LtrTextField"; +import StyledForm from "@/core/components/StyledForm"; +import { yupResolver } from "@hookform/resolvers/yup"; import { Button, DialogActions, DialogContent, Stack } from "@mui/material"; import { Controller, useForm } from "react-hook-form"; -import CarCode from "@/core/components/CarCode"; -import { yupResolver } from "@hookform/resolvers/yup"; import * as yup from "yup"; -import StyledForm from "@/core/components/StyledForm"; const schema = yup.object().shape({ machinesId: yup.object().required("کد خودرو الزامی است."), + km: yup.string(), }); const CreateViolationForm = ({ setOpenMachinesDialog, defaultValues, onSubmitBase }) => { @@ -22,20 +24,43 @@ const CreateViolationForm = ({ setOpenMachinesDialog, defaultValues, onSubmitBas <> - - { - return ( - field.onChange(value)} - error={error} + + + { + return ( + field.onChange(value)} + error={error} + /> + ); + }} + name={"machinesId"} + /> + + + ( + { + if (isNaN(Number(e.target.value))) return; + field.onChange(e.target.value); + }} + size="small" + fullWidth + label="کیلومتر خودرو / ساعت کار" + InputLabelProps={{ shrink: true }} /> - ); - }} - name={"machinesId"} - /> + )} + /> + 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 260b0d9..2b70d5b 100644 --- a/src/components/dashboard/roadMissions/violations/Actions/CreateViolation/Form/index.jsx +++ b/src/components/dashboard/roadMissions/violations/Actions/CreateViolation/Form/index.jsx @@ -9,12 +9,14 @@ const ViolationForm = ({ setOpenMachinesDialog, mutate, openMachinesDialog }) => const defaultValues = { machinesId: null, + km: "", }; const submitForm = async (result) => { await requestServer(CREATE_VIOLATION, "post", { data: { machine_code: result.machinesId.machine_code, + km: result.km, }, }) .then((response) => { diff --git a/src/components/dashboard/roadMissions/violations/ViolationsList.jsx b/src/components/dashboard/roadMissions/violations/ViolationsList.jsx index dfbc013..bf9566d 100644 --- a/src/components/dashboard/roadMissions/violations/ViolationsList.jsx +++ b/src/components/dashboard/roadMissions/violations/ViolationsList.jsx @@ -33,12 +33,21 @@ const ViolationsList = () => { }, { accessorKey: "machine_code", - header: "خودرو", + header: "کد خودرو", id: "machine_code", datatype: "text", columnFilterModeOptions: ["equals", "contains"], grow: false, }, + { + accessorKey: "machine", + header: "نام خودرو", + id: "machine", + datatype: "text", + columnFilterModeOptions: ["equals", "contains"], + grow: false, + Cell: ({ row }) => row.original.machine?.car_name || "-", + }, { accessorKey: "mission_id", header: "کد ماموریت",