legal person loan request part 1

This commit is contained in:
2024-04-13 16:30:33 +03:30
parent a3b409a01a
commit 1f82fc7cf8
3 changed files with 55 additions and 9 deletions

View File

@@ -48,6 +48,7 @@ const AddFormComponent = () => {
const initialValues = {
person_type: "real",
telephone_number: "",
company_tel_number: "",
vehicle_type: "",
province_id: "",
father_name: "",
@@ -72,6 +73,7 @@ const AddFormComponent = () => {
plate_part4: "",
address: "",
birthday: "",
company_date: "",
education_id: "",
occupation_id: "",
checkedBox: false,
@@ -85,6 +87,12 @@ const AddFormComponent = () => {
return stringValue.length === 11
})
.required(t("LoanRequest.error_message_tel_number")),
company_tel_number: Yup.mixed()
.test("max", `${t("LoanRequest.company_tel_number_max")}`, (value) => {
const stringValue = String(value);
return stringValue.length === 11
})
.required(t("LoanRequest.error_message_company_tel_number")),
vehicle_type: Yup.string().required(t("LoanRequest.error_message_vehicle_type")),
register_number: Yup.string().required(t("LoanRequest.error_message_register_number")),
father_name: Yup.string().required(t("LoanRequest.error_message_father_name")),
@@ -95,6 +103,7 @@ const AddFormComponent = () => {
education_id: Yup.string().required(t("LoanRequest.error_message_education_id")),
address: Yup.string().required(t("LoanRequest.error_message_address")),
birthday: Yup.string().required(t("LoanRequest.error_message_date_of_birth")),
company_date: Yup.string().required(t("LoanRequest.error_message_date_of_birth")),
postal_code: Yup.mixed()
.test("max", `${t("LoanRequest.postal_code_max")}`, (value) => value.toString().length === 10)
.required(t("LoanRequest.error_message_postal_code")),

View File

@@ -3,6 +3,9 @@ import {useTranslations} from "next-intl";
import useCities from "@/lib/app/hooks/useCities";
import UseEducations from "@/lib/app/hooks/useEducations";
import useOccupations from "@/lib/app/hooks/useOccupations";
import MuiDatePicker from "@/core/components/MuiDatePicker";
import {DatePicker} from "@mui/x-date-pickers/DatePicker";
import * as React from "react";
const LegalPersonForm = ({formik}) => {
const t = useTranslations();
@@ -86,7 +89,7 @@ const LegalPersonForm = ({formik}) => {
</Grid>
</Grid>
<Grid container spacing={2} sx={{padding: 2}}>
<Grid item xs={12} sm={6}>
<Grid item xs={12} sm={4}>
<TextField
sx={{width: "100%"}}
name="company_postal_code"
@@ -114,7 +117,7 @@ const LegalPersonForm = ({formik}) => {
helperText={formik.touched.company_postal_code && formik.errors.company_postal_code}
/>
</Grid>
<Grid item xs={12} sm={6}>
<Grid item xs={12} sm={4}>
<TextField
sx={{width: "100%"}}
name="company_tel_number"
@@ -142,6 +145,33 @@ const LegalPersonForm = ({formik}) => {
helperText={formik.touched.company_tel_number && formik.errors.company_tel_number}
/>
</Grid>
<Grid item xs={12} sm={4}>
<MuiDatePicker
formik={formik}
error={formik.touched.company_date && Boolean(formik.errors.company_date)}
helperText={formik.touched.company_date && formik.errors.company_date}
onBlur={formik.handleBlur("company_date")}
/>
<DatePicker
slots={{ field: ButtonField, ...props.slots }}
disabled={props.disabled}
slotProps={{
formik: props.formik,
field: { setOpen },
textField: {
helperText: props.formik.errors.birthday
? `${t("birthday_error")}`
: null,
},
}}
{...props}
open={open}
minDate={dateRange.min}
maxDate={dateRange.max}
onClose={() => setOpen(false)}
onOpen={() => setOpen(true)}
/>
</Grid>
</Grid>
</>
)