merge mohammad changes

This commit is contained in:
2023-12-18 09:30:46 +03:30
parent 7b8497b2b8
commit ea2be91094
3 changed files with 67 additions and 29 deletions

View File

@@ -9,6 +9,7 @@ import {useRequest, useUser} from "@witel/webapp-builder";
import useProvince from "@/lib/app/hooks/useProvince";
import useCities from "@/lib/app/hooks/useCities";
import PlateNumber from "@/core/components/PlateNumber";
import MuiDatePicker from "@/core/MuiDatePicker";
const AddFormComponent = () => {
const t = useTranslations();
@@ -25,13 +26,14 @@ const AddFormComponent = () => {
city_id: "",
navgan_id: "",
national_code: "",
shenasname_id: "",
shenasname_serial: "",
postal_code: "",
navgan_type: "",
plate_part1 : "",
plate_part2 : "",
plate_part3 : "",
plate_part4 : "",
address : "",
};
const validationSchema = Yup.object().shape({
@@ -44,6 +46,9 @@ const AddFormComponent = () => {
navgan_type: Yup.string().required(
t("LoanRequest.error_message_navgan_type")
),
address: Yup.string().required(
t("LoanRequest.error_message_address")
),
postal_code : Yup.mixed()
.test("max", `${t("LoanRequest.postal_code_max")}`, (value) => value.toString().length === 10)
.required(
@@ -77,8 +82,9 @@ const AddFormComponent = () => {
.test("positive", `${t("LoanRequest.national_code_positive")}`, (value) => value >= 0)
.test("max", `${t("LoanRequest.national_code_max")}`, (value) => value.toString().length === 10)
.required(t("LoanRequest.error_message_national_id")),
shenasname_id: Yup.string().required(
t("LoanRequest.error_message_shenasname_id")
shenasname_serial: Yup.mixed()
.test("max", `${t("LoanRequest.shenasname_serial_max")}`, (value) => value.toString().length === 11)
.required(t("LoanRequest.error_message_shenasname_serial")
),
});
@@ -92,9 +98,10 @@ const AddFormComponent = () => {
formData.append("plate_number", values.plate_number);
formData.append("province_id", values.province_id);
formData.append("city_id", values.city_id);
formData.append("address", values.address);
formData.append("navgan_id", values.navgan_id);
formData.append("national_code", values.national_code);
formData.append("shenasname_id", values.shenasname_id);
formData.append("shenasname_serial", values.shenasname_serial);
requestServer(SEND_LOAN_REQUEST_NAVGAN, "post", {auth : true, notification : true}).then().catch(() => {
props.setSubmitting(false)
@@ -131,19 +138,17 @@ const AddFormComponent = () => {
>
<TextField
sx={{width: "100%"}}
name="tel_number"
name="postal_code"
variant="outlined"
type={'number'}
size="small"
onChange={formik.handleChange}
label={t("LoanRequest.text_field_tel_number")}
placeholder={t(
"LoanRequest.text_field_enter_your_tel_number"
)}
size="small"
label={t("LoanRequest.text_field_postal_code")}
placeholder={t("LoanRequest.text_field_enter_your_postal_code")}
fullWidth
onBlur={formik.handleBlur("tel_number")}
error={formik.touched.tel_number && Boolean(formik.errors.tel_number)}
helperText={formik.touched.tel_number && formik.errors.tel_number}
onBlur={formik.handleBlur("postal_code")}
error={formik.touched.postal_code && Boolean(formik.errors.postal_code)}
helperText={formik.touched.postal_code && formik.errors.postal_code}
/>
</Grid>
</Grid>
@@ -184,17 +189,19 @@ const AddFormComponent = () => {
<Grid item xs={12} sm={6}>
<TextField
sx={{width: "100%"}}
name="postal_code"
name="tel_number"
variant="outlined"
type={'number'}
onChange={formik.handleChange}
size="small"
label={t("LoanRequest.text_field_postal_code")}
placeholder={t("LoanRequest.text_field_enter_your_postal_code")}
onChange={formik.handleChange}
label={t("LoanRequest.text_field_tel_number")}
placeholder={t(
"LoanRequest.text_field_enter_your_tel_number"
)}
fullWidth
onBlur={formik.handleBlur("postal_code")}
error={formik.touched.postal_code && Boolean(formik.errors.postal_code)}
helperText={formik.touched.postal_code && formik.errors.postal_code}
onBlur={formik.handleBlur("tel_number")}
error={formik.touched.tel_number && Boolean(formik.errors.tel_number)}
helperText={formik.touched.tel_number && formik.errors.tel_number}
/>
</Grid>
<Grid item xs={12} sm={6}>
@@ -255,19 +262,21 @@ const AddFormComponent = () => {
<Grid item xs={12} sm={6}>
<TextField
sx={{width: "100%"}}
name="shenasname_id"
name="shenasname_serial"
variant="outlined"
size="small"
label={t("LoanRequest.text_field_shenasname_id")}
label={t("LoanRequest.text_field_shenasname_serial")}
placeholder={t(
"LoanRequest.text_field_enter_your_shenasname_id")}
"LoanRequest.text_field_enter_your_shenasname_serial")}
fullWidth
onBlur={formik.handleBlur("shenasname_id")}
error={formik.touched.shenasname_id && Boolean(formik.errors.shenasname_id)}
helperText={formik.touched.shenasname_id && formik.errors.shenasname_id}
onChange={formik.handleChange}
onBlur={formik.handleBlur("shenasname_serial")}
error={formik.touched.shenasname_serial && Boolean(formik.errors.shenasname_serial)}
helperText={formik.touched.shenasname_serial && formik.errors.shenasname_serial}
/>
</Grid>
<Grid item xs={12} sm={6}>
{/*<MuiDatePicker />*/}
</Grid>
</Grid>
<Grid container spacing={2} sx={{padding : 2}}>
@@ -275,6 +284,25 @@ const AddFormComponent = () => {
<PlateNumber formik={formik} />
</Grid>
</Grid>
<Grid container spacing={2} sx={{padding : 2}}>
<Grid item xs={12}>
<TextField
multiline
rows={8}
sx={{width: "100%"}}
name="address"
variant="outlined"
size="small"
label={t("LoanRequest.text_field_address")}
placeholder={t("LoanRequest.text_field_enter_your_address")}
fullWidth
onChange={formik.handleChange}
onBlur={formik.handleBlur("address")}
error={formik.touched.address && Boolean(formik.errors.address)}
helperText={formik.touched.address && formik.errors.address}
/>
</Grid>
</Grid>
<Box
sx={{
display: "flex",