add km to control panel
This commit is contained in:
@@ -11,6 +11,7 @@ const StartMissionContent = ({ rowId, mutate, setOpenStartMissionDialog }) => {
|
||||
|
||||
const validationSchema = object().shape({
|
||||
code: string().length(6, "کد خروج باید 6 رقم باشد").required("لطفاً کد خروج را وارد کنید."),
|
||||
km: string().required("لطفاً کیلومتر را وارد کنید."),
|
||||
});
|
||||
|
||||
const {
|
||||
@@ -20,6 +21,7 @@ const StartMissionContent = ({ rowId, mutate, setOpenStartMissionDialog }) => {
|
||||
} = useForm({
|
||||
defaultValues: {
|
||||
code: "",
|
||||
km : ""
|
||||
},
|
||||
resolver: yupResolver(validationSchema),
|
||||
mode: "all",
|
||||
@@ -29,6 +31,7 @@ const StartMissionContent = ({ rowId, mutate, setOpenStartMissionDialog }) => {
|
||||
requestServer(`${START_MISSION}/${rowId}`, "post", {
|
||||
data: {
|
||||
code: values.code,
|
||||
km: values.km,
|
||||
},
|
||||
hasSidebarUpdate: true,
|
||||
})
|
||||
@@ -69,6 +72,27 @@ const StartMissionContent = ({ rowId, mutate, setOpenStartMissionDialog }) => {
|
||||
)}
|
||||
/>
|
||||
</Stack>
|
||||
<Stack>
|
||||
<Controller
|
||||
control={control}
|
||||
name={"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>
|
||||
</DialogContent>
|
||||
<DialogActions sx={{ justifyContent: "center", paddingBottom: 2, width: "100%" }}>
|
||||
|
||||
@@ -22,16 +22,14 @@ const AllocationForm = ({ row, mutate, setOpenAllocationDialog }) => {
|
||||
const requestServer = useRequest({ notificationSuccess: true });
|
||||
const [machine, setMachine] = useState();
|
||||
const [driver, setDriver] = useState();
|
||||
const [kilometer, setKilometer] = useState();
|
||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||
|
||||
const handleSubmit = async (_machine, _driver, _kilometer) => {
|
||||
const handleSubmit = async (_machine, _driver) => {
|
||||
setIsSubmitting(true);
|
||||
await requestServer(`${ALLOCATE_REQUEST_MISSION}/${row.id}`, "post", {
|
||||
data: {
|
||||
machines: [_machine.id],
|
||||
machines: _machine.id,
|
||||
driver: _driver.id,
|
||||
km: kilometer,
|
||||
},
|
||||
hasSidebarUpdate: true,
|
||||
})
|
||||
@@ -110,23 +108,7 @@ const AllocationForm = ({ row, mutate, setOpenAllocationDialog }) => {
|
||||
)}
|
||||
</Stack>
|
||||
)}
|
||||
{driver && (
|
||||
<Stack direction={"row"} alignItems={"center"} spacing={1}>
|
||||
<LtrTextField
|
||||
autoComplete="off"
|
||||
type="tel"
|
||||
value={kilometer}
|
||||
onChange={(e) => {
|
||||
if (isNaN(Number(e.target.value))) return;
|
||||
setKilometer(e.target.value);
|
||||
}}
|
||||
size="small"
|
||||
fullWidth
|
||||
label="کیلومتر خودرو"
|
||||
InputLabelProps={{ shrink: true }}
|
||||
/>
|
||||
</Stack>
|
||||
)}
|
||||
|
||||
</Stack>
|
||||
</Paper>
|
||||
<Stack spacing={1}>
|
||||
@@ -208,10 +190,10 @@ const AllocationForm = ({ row, mutate, setOpenAllocationDialog }) => {
|
||||
</Stack>
|
||||
<Box>
|
||||
<Button
|
||||
onClick={() => handleSubmit(machine, driver, kilometer)}
|
||||
onClick={() => handleSubmit(machine, driver)}
|
||||
variant="contained"
|
||||
color="primary"
|
||||
disabled={!machine || !driver || !kilometer || isSubmitting}
|
||||
disabled={!machine || !driver || isSubmitting}
|
||||
autoFocus
|
||||
>
|
||||
تایید و تخصیص
|
||||
|
||||
Reference in New Issue
Block a user