implemented ConfirmRequestForm modal
This commit is contained in:
@@ -1,3 +1,60 @@
|
||||
export default function ConfirmRequestForm({ mutate }) {
|
||||
return <div>ConfirmRequestForm</div>;
|
||||
import { Box, Button, Checkbox, DialogActions, FormControlLabel, TextField } from "@mui/material";
|
||||
import { useState } from "react";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
|
||||
export default function ConfirmRequestForm({ mutate, onClose }) {
|
||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||
const { control, handleSubmit } = useForm({
|
||||
defaultValues: {
|
||||
expert_description: "",
|
||||
need_payment: false,
|
||||
needsAccessRoad: false,
|
||||
},
|
||||
});
|
||||
|
||||
const onSubmit = (data) => {
|
||||
console.log(data);
|
||||
setIsSubmitting(true);
|
||||
mutate();
|
||||
onClose();
|
||||
};
|
||||
|
||||
return (
|
||||
<Box sx={{ display: "flex", flexDirection: "column", mt: 1 }}>
|
||||
<Controller
|
||||
name="expert_description"
|
||||
control={control}
|
||||
render={({ field }) => <TextField {...field} fullWidth multiline minRows={3} label="توضیحات" />}
|
||||
/>
|
||||
<Controller
|
||||
name="need_payment"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<FormControlLabel
|
||||
control={<Checkbox {...field} checked={field.value} />}
|
||||
label="نیاز به پرداخت وجه خزانه"
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
<Controller
|
||||
name="needsAccessRoad"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<FormControlLabel
|
||||
control={<Checkbox {...field} checked={field.value} />}
|
||||
label="نیاز به پرداخت وجه خزانه"
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
|
||||
<DialogActions>
|
||||
<Button onClick={onClose} variant="outlined" disabled={isSubmitting}>
|
||||
انصراف
|
||||
</Button>
|
||||
<Button variant="contained" onClick={handleSubmit(onSubmit)} disabled={isSubmitting}>
|
||||
انجام عملیات
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user