add postal code address and some validation

This commit is contained in:
2023-12-18 14:11:07 +03:30
parent 8cbe7a435c
commit 4b31247ca1
9 changed files with 247 additions and 175 deletions

View File

@@ -9,7 +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";
import MuiDatePicker from "@/core/components/MuiDatePicker";
const AddFormComponent = () => {
const t = useTranslations();
@@ -34,6 +34,7 @@ const AddFormComponent = () => {
plate_part3 : "",
plate_part4 : "",
address : "",
date_of_birth : "",
};
const validationSchema = Yup.object().shape({
@@ -49,6 +50,9 @@ const AddFormComponent = () => {
address: Yup.string().required(
t("LoanRequest.error_message_address")
),
date_of_birth: 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(
@@ -101,6 +105,7 @@ const AddFormComponent = () => {
formData.append("address", values.address);
formData.append("navgan_id", values.navgan_id);
formData.append("national_code", values.national_code);
formData.append("date_of_birth", values.date_of_birth);
formData.append("shenasname_serial", values.shenasname_serial);
requestServer(SEND_LOAN_REQUEST_NAVGAN, "post", {auth : true, notification : true}).then().catch(() => {
@@ -115,7 +120,7 @@ const AddFormComponent = () => {
<>
<Grid container spacing={2} sx={{padding : 2}}
>
<Grid item xs={12} sm={6}
<Grid item xs={12} sm={4}
>
<TextField
sx={{width: "100%"}}
@@ -134,8 +139,34 @@ const AddFormComponent = () => {
fullWidth
/>
</Grid>
<Grid item xs={12} sm={6}
<Grid item xs={12} sm={4}
>
<TextField
sx={{width: "100%"}}
name="shenasname_serial"
variant="outlined"
size="small"
label={t("LoanRequest.text_field_shenasname_serial")}
placeholder={t(
"LoanRequest.text_field_enter_your_shenasname_serial")}
fullWidth
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={4}>
<MuiDatePicker
formik={formik}
error={formik.touched.date_of_birth && Boolean(formik.errors.date_of_birth)}
helperText={formik.touched.date_of_birth && formik.errors.date_of_birth}
onBlur={formik.handleBlur("date_of_birth")}
/>
</Grid>
</Grid>
<Grid container spacing={2} sx={{padding : 2}}>
<Grid item xs={12} sm={6}>
<TextField
sx={{width: "100%"}}
name="postal_code"
@@ -151,41 +182,6 @@ const AddFormComponent = () => {
helperText={formik.touched.postal_code && formik.errors.postal_code}
/>
</Grid>
</Grid>
<Grid container spacing={2} sx={{padding : 2}}>
<Grid item xs={12} sm={6}>
<SelectBox
name="vehicle_type"
label={t("LoanRequest.text_field_vehicle_type")}
size="small"
selectType="vehicle_type"
selectors={[{id : 0, value : 0, name : "اتوبوس"},
{id : 1, value: 1, name : "مینی بوس"}]}
select={formik.values.vehicle_type}
setFieldValue={formik.setFieldValue}
error={formik.touched.vehicle_type && Boolean(formik.errors.vehicle_type)}
helperText={formik.touched.vehicle_type && formik.errors.vehicle_type}
onBlur={formik.handleBlur("vehicle_type")}
/>
</Grid>
<Grid item xs={12} sm={6}>
<TextField
sx={{width: "100%"}}
name="navgan_id"
variant="outlined"
type={'number'}
onChange={formik.handleChange}
size="small"
label={t("LoanRequest.text_field_navgan_id")}
placeholder={t("LoanRequest.text_field_enter_your_navgan_id")}
fullWidth
onBlur={formik.handleBlur("navgan_id")}
error={formik.touched.navgan_id && Boolean(formik.errors.navgan_id)}
helperText={formik.touched.navgan_id && formik.errors.navgan_id}
/>
</Grid>
</Grid>
<Grid container spacing={2} sx={{padding: 2}}>
<Grid item xs={12} sm={6}>
<TextField
sx={{width: "100%"}}
@@ -204,6 +200,8 @@ const AddFormComponent = () => {
helperText={formik.touched.tel_number && formik.errors.tel_number}
/>
</Grid>
</Grid>
<Grid container spacing={2} sx={{padding: 2}}>
<Grid item xs={12} sm={6}>
<SelectBox
name="navgan_type"
@@ -219,6 +217,22 @@ const AddFormComponent = () => {
onBlur={formik.handleBlur("navgan_type")}
/>
</Grid>
<Grid item xs={12} sm={6}>
<TextField
sx={{width: "100%"}}
name="navgan_id"
variant="outlined"
type={'number'}
onChange={formik.handleChange}
size="small"
label={t("LoanRequest.text_field_navgan_id")}
placeholder={t("LoanRequest.text_field_enter_your_navgan_id")}
fullWidth
onBlur={formik.handleBlur("navgan_id")}
error={formik.touched.navgan_id && Boolean(formik.errors.navgan_id)}
helperText={formik.touched.navgan_id && formik.errors.navgan_id}
/>
</Grid>
</Grid>
<Grid container spacing={2} sx={{padding : 2}}>
<Grid item xs={12} sm={6}>
@@ -244,7 +258,7 @@ const AddFormComponent = () => {
<Grid item xs={12} sm={6}>
<SelectBox
name="city_id"
label={cityTextField}
label={cityList.length === 0 ? `${t("LoanRequest.cityList_empty")}`: cityTextField}
size="small"
selectType="city_id"
disabled={cityList.length === 0}
@@ -260,28 +274,22 @@ const AddFormComponent = () => {
</Grid>
<Grid container spacing={2} sx={{padding : 2}}>
<Grid item xs={12} sm={6}>
<TextField
sx={{width: "100%"}}
name="shenasname_serial"
variant="outlined"
<SelectBox
name="vehicle_type"
label={t("LoanRequest.text_field_vehicle_type")}
size="small"
label={t("LoanRequest.text_field_shenasname_serial")}
placeholder={t(
"LoanRequest.text_field_enter_your_shenasname_serial")}
fullWidth
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}
selectType="vehicle_type"
selectors={[{id : 0, value : 0, name : "اتوبوس"},
{id : 1, value: 1, name : "مینی بوس"}]}
select={formik.values.vehicle_type}
handleChange={(event)=>formik.setFieldValue('vehicle_type', event.target.value)}
error={formik.touched.vehicle_type && Boolean(formik.errors.vehicle_type)}
helperText={formik.touched.vehicle_type && formik.errors.vehicle_type}
onBlur={formik.handleBlur("vehicle_type")}
/>
</Grid>
<Grid item xs={12} sm={6}>
{/*<MuiDatePicker />*/}
</Grid>
</Grid>
<Grid container spacing={2} sx={{padding : 2}}>
<Grid item xs={12} sm={6}>
<PlateNumber formik={formik} />
<PlateNumber formik={formik}/>
</Grid>
</Grid>
<Grid container spacing={2} sx={{padding : 2}}>

View File

@@ -1,20 +1,16 @@
import {Box, Chip, Divider} from "@mui/material";
import {useTranslations} from "next-intl";
import AddFormComponent from "@/components/dashboard/navgan/add-request-loan/forms/AddForm";
import {CenterLayout, useUser} from "@witel/webapp-builder";
const LoanRequestComponent = () => {
const t = useTranslations();
const {user} = useUser();
return (
<>
<Box>
<Divider>
<Chip
label={`${t("LoanRequest.loan_request_page")} | ${
user.type_name
}`}
label={`${t("LoanRequest.loan_request_page")} | ${t("user_navy")} `}
/>
</Divider>
</Box>