use some api
This commit is contained in:
@@ -1,5 +1,14 @@
|
|||||||
import {Box, Button, Checkbox, FormControlLabel, Grid, TextField, ToggleButton, ToggleButtonGroup} from "@mui/material";
|
import {
|
||||||
import {useTranslations} from "next-intl";
|
Box,
|
||||||
|
Button,
|
||||||
|
Checkbox,
|
||||||
|
FormControlLabel,
|
||||||
|
Grid,
|
||||||
|
TextField,
|
||||||
|
ToggleButton,
|
||||||
|
ToggleButtonGroup,
|
||||||
|
} from "@mui/material";
|
||||||
|
import { useTranslations } from "next-intl";
|
||||||
import useCities from "@/lib/app/hooks/useCities";
|
import useCities from "@/lib/app/hooks/useCities";
|
||||||
import UseEducations from "@/lib/app/hooks/useEducations";
|
import UseEducations from "@/lib/app/hooks/useEducations";
|
||||||
import useOccupations from "@/lib/app/hooks/useOccupations";
|
import useOccupations from "@/lib/app/hooks/useOccupations";
|
||||||
@@ -7,29 +16,29 @@ import * as React from "react";
|
|||||||
import SelectBox from "@/core/components/SelectBox";
|
import SelectBox from "@/core/components/SelectBox";
|
||||||
import useLimitedProvince from "@/lib/app/hooks/useLimitedProvince";
|
import useLimitedProvince from "@/lib/app/hooks/useLimitedProvince";
|
||||||
import PlateNumber from "@/core/components/PlateNumber";
|
import PlateNumber from "@/core/components/PlateNumber";
|
||||||
import {useRouter} from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import {useRequest, useUser} from "@witel/webapp-builder";
|
import { useRequest, useUser } from "@witel/webapp-builder";
|
||||||
import * as Yup from "yup";
|
import * as Yup from "yup";
|
||||||
import {SEND_LOAN_REQUEST_NAVGAN} from "@/core/data/apiRoutes";
|
import { SEND_LOAN_REQUEST_NAVGAN } from "@/core/data/apiRoutes";
|
||||||
import DataSaverOnIcon from "@mui/icons-material/DataSaverOn";
|
import DataSaverOnIcon from "@mui/icons-material/DataSaverOn";
|
||||||
import {useFormik} from "formik";
|
import { useFormik } from "formik";
|
||||||
import LegalPersonDatePicker from "@/components/dashboard/navgan/add-request-loan/forms/LegalPersonDatePicker";
|
import LegalPersonDatePicker from "@/components/dashboard/navgan/add-request-loan/forms/LegalPersonDatePicker";
|
||||||
import useProjectTitle from "@/lib/app/hooks/useProjectTitle";
|
import useProjectTitle from "@/lib/app/hooks/useProjectTitle";
|
||||||
import useActivityType from "@/lib/app/hooks/useActivityType";
|
import useActivityType from "@/lib/app/hooks/useActivityType";
|
||||||
import usePriorityLists from "@/lib/app/hooks/usePriorityLists";
|
import usePriorityLists from "@/lib/app/hooks/usePriorityLists";
|
||||||
|
|
||||||
const LegalPersonForm = ({setFinishLoanRequest}) => {
|
const LegalPersonForm = ({ setFinishLoanRequest }) => {
|
||||||
const t = useTranslations();
|
const t = useTranslations();
|
||||||
const router = useRouter()
|
const router = useRouter();
|
||||||
const requestServer = useRequest()
|
const requestServer = useRequest();
|
||||||
const {getUser, changeUser} = useUser()
|
const { getUser, changeUser } = useUser();
|
||||||
const {cityTextField, cityList, setProvinceID, isLoadingCityList} = useCities()
|
const { cityTextField, cityList, setProvinceID, isLoadingCityList } = useCities();
|
||||||
const {provinceList, isLoadingProvinceList, errorProvinceList} = useLimitedProvince()
|
const { provinceList, isLoadingProvinceList, errorProvinceList } = useLimitedProvince();
|
||||||
const {educationsList, isLoadingEducationsList, errorEducationsList} = UseEducations()
|
const { educationsList, isLoadingEducationsList, errorEducationsList } = UseEducations();
|
||||||
const {occupationsList, isLoadingOccupationsList, errorOccupationsList} = useOccupations()
|
const { occupationsList, isLoadingOccupationsList, errorOccupationsList } = useOccupations();
|
||||||
const {activityType, isLoadingActivityType, errorActivityType} = useActivityType()
|
const { activityType, isLoadingActivityType, errorActivityType } = useActivityType();
|
||||||
const {priorityLists, isLoadingPriorityLists, errorPriorityLists} = usePriorityLists()
|
const { priorityLists, isLoadingPriorityLists, errorPriorityLists } = usePriorityLists();
|
||||||
const {projectTitle, isLoadingProjectTitle, errorProjectTitle} = useProjectTitle()
|
const { projectTitle, isLoadingProjectTitle, errorProjectTitle } = useProjectTitle();
|
||||||
|
|
||||||
const initialValues = {
|
const initialValues = {
|
||||||
person_type: "legal",
|
person_type: "legal",
|
||||||
@@ -40,7 +49,7 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
vehicle_type: "",
|
vehicle_type: "",
|
||||||
province_id: "",
|
province_id: "",
|
||||||
boss_father_name: "",
|
boss_father_name: "",
|
||||||
company_postal_code : "",
|
company_postal_code: "",
|
||||||
register_number: "",
|
register_number: "",
|
||||||
boss_gender: "",
|
boss_gender: "",
|
||||||
boss_first_name: "",
|
boss_first_name: "",
|
||||||
@@ -69,7 +78,7 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
company_tel_number: Yup.mixed()
|
company_tel_number: Yup.mixed()
|
||||||
.test("max", `${t("LoanRequest.company_tel_number_max")}`, (value) => {
|
.test("max", `${t("LoanRequest.company_tel_number_max")}`, (value) => {
|
||||||
const stringValue = String(value);
|
const stringValue = String(value);
|
||||||
return stringValue.length === 11
|
return stringValue.length === 11;
|
||||||
})
|
})
|
||||||
.required(t("LoanRequest.error_message_company_tel_number")),
|
.required(t("LoanRequest.error_message_company_tel_number")),
|
||||||
vehicle_type: Yup.string().required(t("LoanRequest.error_message_vehicle_type")),
|
vehicle_type: Yup.string().required(t("LoanRequest.error_message_vehicle_type")),
|
||||||
@@ -88,13 +97,15 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
company_postal_code: Yup.mixed()
|
company_postal_code: Yup.mixed()
|
||||||
.test("max", `${t("LoanRequest.company_postal_code_max")}`, (value) => value.toString().length === 10)
|
.test("max", `${t("LoanRequest.company_postal_code_max")}`, (value) => value.toString().length === 10)
|
||||||
.required(t("LoanRequest.error_message_company_postal_code")),
|
.required(t("LoanRequest.error_message_company_postal_code")),
|
||||||
plate_part1: Yup.mixed().test("max", `${t("LoanRequest.error_message_plate_number")}`, (value) => value.toString().length === 2)
|
plate_part1: Yup.mixed()
|
||||||
|
.test("max", `${t("LoanRequest.error_message_plate_number")}`, (value) => value.toString().length === 2)
|
||||||
.required(t("LoanRequest.error_message_plate_number")),
|
.required(t("LoanRequest.error_message_plate_number")),
|
||||||
plate_part2: Yup.mixed()
|
plate_part2: Yup.mixed().required(t("LoanRequest.error_message_plate_number")),
|
||||||
|
plate_part3: Yup.mixed()
|
||||||
|
.test("max", `${t("LoanRequest.error_message_plate_number")}`, (value) => value.toString().length === 3)
|
||||||
.required(t("LoanRequest.error_message_plate_number")),
|
.required(t("LoanRequest.error_message_plate_number")),
|
||||||
plate_part3: Yup.mixed().test("max", `${t("LoanRequest.error_message_plate_number")}`, (value) => value.toString().length === 3)
|
plate_part4: Yup.mixed()
|
||||||
.required(t("LoanRequest.error_message_plate_number")),
|
.test("max", `${t("LoanRequest.error_message_plate_number")}`, (value) => value.toString().length === 2)
|
||||||
plate_part4: Yup.mixed().test("max", `${t("LoanRequest.error_message_plate_number")}`, (value) => value.toString().length === 2)
|
|
||||||
.required(t("LoanRequest.error_message_plate_number")),
|
.required(t("LoanRequest.error_message_plate_number")),
|
||||||
navgan_id: Yup.mixed().required(t("LoanRequest.error_message_navgan_id")),
|
navgan_id: Yup.mixed().required(t("LoanRequest.error_message_navgan_id")),
|
||||||
province_id: Yup.string().required(t("LoanRequest.error_message_province_id")),
|
province_id: Yup.string().required(t("LoanRequest.error_message_province_id")),
|
||||||
@@ -106,35 +117,60 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
.test("positive", `${t("LoanRequest.boss_national_code_positive")}`, (value) => value >= 0)
|
.test("positive", `${t("LoanRequest.boss_national_code_positive")}`, (value) => value >= 0)
|
||||||
.test("max", `${t("LoanRequest.boss_national_code_max")}`, (value) => value.toString().length === 10)
|
.test("max", `${t("LoanRequest.boss_national_code_max")}`, (value) => value.toString().length === 10)
|
||||||
.required(t("LoanRequest.error_message_national_id")),
|
.required(t("LoanRequest.error_message_national_id")),
|
||||||
national_number: Yup.mixed().when('person_type', ([person_type], schema) => {
|
national_number: Yup.mixed().when("person_type", ([person_type], schema) => {
|
||||||
return person_type === 'legal' ? schema
|
return person_type === "legal"
|
||||||
.test("is-number", `${t("LoanRequest.national_number_number")}`, (value) => !isNaN(value))
|
? schema
|
||||||
.test("positive", `${t("LoanRequest.national_number_positive")}`, (value) => value >= 0)
|
.test("is-number", `${t("LoanRequest.national_number_number")}`, (value) => !isNaN(value))
|
||||||
.test("max", `${t("LoanRequest.national_number_max")}`, (value) => value && value.toString().length === 11)
|
.test("positive", `${t("LoanRequest.national_number_positive")}`, (value) => value >= 0)
|
||||||
.required(t("LoanRequest.error_message_national_number")) : schema;
|
.test(
|
||||||
|
"max",
|
||||||
|
`${t("LoanRequest.national_number_max")}`,
|
||||||
|
(value) => value && value.toString().length === 11
|
||||||
|
)
|
||||||
|
.required(t("LoanRequest.error_message_national_number"))
|
||||||
|
: schema;
|
||||||
}),
|
}),
|
||||||
boss_national_serial_number: Yup.string().when('national_serial_number_or_tracking_code', ([national_serial_number_or_tracking_code], schema) => {
|
boss_national_serial_number: Yup.string()
|
||||||
return national_serial_number_or_tracking_code === 'national_serial_number' ? schema.required(t("LoanRequest.error_message_boss_national_serial_number")) : schema
|
.test(
|
||||||
}),
|
"max",
|
||||||
boss_national_card_tracking_code: Yup.string().when('national_serial_number_or_tracking_code', ([national_serial_number_or_tracking_code], schema) => {
|
`${t("LoanRequest.national_serial_number_max")}`,
|
||||||
return national_serial_number_or_tracking_code === 'national_card_tracking_code' ? schema.required(t("LoanRequest.error_message_boss_national_card_tracking_code")) : schema
|
(value) => value && value.toString().length === 10
|
||||||
})
|
)
|
||||||
|
.when("national_serial_number_or_tracking_code", ([national_serial_number_or_tracking_code], schema) => {
|
||||||
|
return national_serial_number_or_tracking_code === "national_serial_number"
|
||||||
|
? schema.required(t("LoanRequest.error_message_shenasname_serial"))
|
||||||
|
: schema;
|
||||||
|
}),
|
||||||
|
boss_national_card_tracking_code: Yup.string().when(
|
||||||
|
"national_serial_number_or_tracking_code",
|
||||||
|
([national_serial_number_or_tracking_code], schema) => {
|
||||||
|
return national_serial_number_or_tracking_code === "national_card_tracking_code"
|
||||||
|
? schema.required(t("LoanRequest.error_message_boss_national_card_tracking_code"))
|
||||||
|
: schema;
|
||||||
|
}
|
||||||
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleSubmit = async (values, props) => {
|
const handleSubmit = async (values, props) => {
|
||||||
props.setSubmitting(true)
|
props.setSubmitting(true);
|
||||||
let _national_number = values.person_type === "legal" ? {
|
let _national_number =
|
||||||
shenase_meli: values.national_number
|
values.person_type === "legal"
|
||||||
} : {}
|
? {
|
||||||
|
shenase_meli: values.national_number,
|
||||||
|
}
|
||||||
|
: {};
|
||||||
|
|
||||||
const _national_card = values.national_serial_number_or_tracking_code === "national_serial_number" ? {
|
const _national_card =
|
||||||
national_serial_number: values.national_serial_number
|
values.national_serial_number_or_tracking_code === "national_serial_number"
|
||||||
} : {
|
? {
|
||||||
national_tracking_code: values.national_card_tracking_code
|
national_serial_number: values.boss_national_serial_number,
|
||||||
}
|
}
|
||||||
|
: {
|
||||||
|
national_tracking_code: values.boss_national_card_tracking_code,
|
||||||
|
};
|
||||||
|
|
||||||
let _data = {
|
let _data = {
|
||||||
is_legal_person: 1 ,
|
is_legal_person: 1,
|
||||||
telephone_number: values.company_tel_number,
|
telephone_number: values.company_tel_number,
|
||||||
register_number: values.register_number,
|
register_number: values.register_number,
|
||||||
national_id: values.boss_national_code,
|
national_id: values.boss_national_code,
|
||||||
@@ -146,38 +182,49 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
first_name: values.boss_first_name,
|
first_name: values.boss_first_name,
|
||||||
last_name: values.boss_last_name,
|
last_name: values.boss_last_name,
|
||||||
navgan_id: values.navgan_id,
|
navgan_id: values.navgan_id,
|
||||||
postal_code: values.postal_code,
|
activity_type_id: values.activity_type,
|
||||||
|
project_title: values.project_title,
|
||||||
|
activity_priority_id: values.priority_list,
|
||||||
|
postal_code: values.company_postal_code,
|
||||||
navgan_type: values.navgan_type,
|
navgan_type: values.navgan_type,
|
||||||
gender: values.gender,
|
gender: values.boss_gender,
|
||||||
plate_part1: values.plate_part1,
|
plate_part1: values.plate_part1,
|
||||||
plate_part2: values.plate_part2,
|
plate_part2: values.plate_part2,
|
||||||
plate_part3: values.plate_part3,
|
plate_part3: values.plate_part3,
|
||||||
plate_part4: values.plate_part4,
|
plate_part4: values.plate_part4,
|
||||||
address: values.address,
|
address: values.address,
|
||||||
birthday: values.birthday.locale('en').format("YYYY-MM-DD"),
|
company_register_date: values.company_date.locale("en").format("YYYY-MM-DD"),
|
||||||
education_id: values.education_id,
|
education_id: values.education_id,
|
||||||
occupation_id: values.occupation_id, ..._national_card, ..._national_number
|
occupation_id: values.occupation_id,
|
||||||
}
|
..._national_card,
|
||||||
|
..._national_number,
|
||||||
|
};
|
||||||
|
|
||||||
await requestServer(SEND_LOAN_REQUEST_NAVGAN, "post", {
|
await requestServer(SEND_LOAN_REQUEST_NAVGAN, "post", {
|
||||||
auth: true, notification: true, data: _data
|
auth: true,
|
||||||
}).then(() => {
|
notification: true,
|
||||||
router.replace('/dashboard/navgan/followUp-loan')
|
data: _data,
|
||||||
getUser((data) => {
|
|
||||||
changeUser(data);
|
|
||||||
});
|
|
||||||
}).catch(() => {
|
|
||||||
}).finally(() => {
|
|
||||||
props.setSubmitting(false)
|
|
||||||
})
|
})
|
||||||
|
.then(() => {
|
||||||
|
router.replace("/dashboard/navgan/followUp-loan");
|
||||||
|
getUser((data) => {
|
||||||
|
changeUser(data);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(() => {})
|
||||||
|
.finally(() => {
|
||||||
|
props.setSubmitting(false);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const formik = useFormik({
|
const formik = useFormik({
|
||||||
initialValues, validationSchema, onSubmit: handleSubmit
|
initialValues,
|
||||||
})
|
validationSchema,
|
||||||
|
onSubmit: handleSubmit,
|
||||||
|
});
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Grid container spacing={2} sx={{p: 2}}>
|
<Grid container spacing={2} sx={{ p: 2 }}>
|
||||||
<Grid item xs={12} sm={4}>
|
<Grid item xs={12} sm={4}>
|
||||||
<SelectBox
|
<SelectBox
|
||||||
name="project_title"
|
name="project_title"
|
||||||
@@ -187,11 +234,11 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
isLoading={isLoadingProjectTitle}
|
isLoading={isLoadingProjectTitle}
|
||||||
errorEcured={errorProjectTitle}
|
errorEcured={errorProjectTitle}
|
||||||
selectors={projectTitle}
|
selectors={projectTitle}
|
||||||
schema={{value: 'value', name: 'name'}}
|
schema={{ value: "name", name: "name" }}
|
||||||
select={formik.values.project_title}
|
select={formik.values.project_title}
|
||||||
value={formik.values.project_title}
|
value={formik.values.project_title}
|
||||||
handleChange={(event) => {
|
handleChange={(event) => {
|
||||||
formik.setFieldValue('project_title', event.target.value)
|
formik.setFieldValue("project_title", event.target.value);
|
||||||
}}
|
}}
|
||||||
setFieldTouched={formik.setFieldTouched}
|
setFieldTouched={formik.setFieldTouched}
|
||||||
error={formik.touched.project_title && Boolean(formik.errors.project_title)}
|
error={formik.touched.project_title && Boolean(formik.errors.project_title)}
|
||||||
@@ -208,11 +255,11 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
isLoading={isLoadingActivityType}
|
isLoading={isLoadingActivityType}
|
||||||
errorEcured={errorActivityType}
|
errorEcured={errorActivityType}
|
||||||
selectors={activityType}
|
selectors={activityType}
|
||||||
schema={{value: 'value', name: 'name'}}
|
schema={{ value: "value", name: "name" }}
|
||||||
select={formik.values.activity_type}
|
select={formik.values.activity_type}
|
||||||
value={formik.values.activity_type}
|
value={formik.values.activity_type}
|
||||||
handleChange={(event) => {
|
handleChange={(event) => {
|
||||||
formik.setFieldValue('activity_type', event.target.value)
|
formik.setFieldValue("activity_type", event.target.value);
|
||||||
}}
|
}}
|
||||||
setFieldTouched={formik.setFieldTouched}
|
setFieldTouched={formik.setFieldTouched}
|
||||||
error={formik.touched.activity_type && Boolean(formik.errors.activity_type)}
|
error={formik.touched.activity_type && Boolean(formik.errors.activity_type)}
|
||||||
@@ -229,11 +276,11 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
isLoading={isLoadingPriorityLists}
|
isLoading={isLoadingPriorityLists}
|
||||||
errorEcured={errorPriorityLists}
|
errorEcured={errorPriorityLists}
|
||||||
selectors={priorityLists}
|
selectors={priorityLists}
|
||||||
schema={{value: 'value', name: 'name'}}
|
schema={{ value: "value", name: "name" }}
|
||||||
select={formik.values.priority_list}
|
select={formik.values.priority_list}
|
||||||
value={formik.values.priority_list}
|
value={formik.values.priority_list}
|
||||||
handleChange={(event) => {
|
handleChange={(event) => {
|
||||||
formik.setFieldValue('priority_list', event.target.value)
|
formik.setFieldValue("priority_list", event.target.value);
|
||||||
}}
|
}}
|
||||||
setFieldTouched={formik.setFieldTouched}
|
setFieldTouched={formik.setFieldTouched}
|
||||||
error={formik.touched.priority_list && Boolean(formik.errors.priority_list)}
|
error={formik.touched.priority_list && Boolean(formik.errors.priority_list)}
|
||||||
@@ -242,16 +289,16 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid container spacing={2} sx={{p: 2}}>
|
<Grid container spacing={2} sx={{ p: 2 }}>
|
||||||
<Grid item xs={12} sm={4}>
|
<Grid item xs={12} sm={4}>
|
||||||
<TextField
|
<TextField
|
||||||
sx={{width: "100%"}}
|
sx={{ width: "100%" }}
|
||||||
name="national_number"
|
name="national_number"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
size="small"
|
size="small"
|
||||||
value={formik.values.national_number}
|
value={formik.values.national_number}
|
||||||
inputProps={{inputMode: 'numeric', pattern: '[0-9]*'}}
|
inputProps={{ inputMode: "numeric", pattern: "[0-9]*" }}
|
||||||
type={'tel'}
|
type={"tel"}
|
||||||
onChange={(event) => {
|
onChange={(event) => {
|
||||||
const inputValue = event.target.value;
|
const inputValue = event.target.value;
|
||||||
if (isNaN(Number(inputValue))) {
|
if (isNaN(Number(inputValue))) {
|
||||||
@@ -259,7 +306,8 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
}
|
}
|
||||||
formik.handleChange({
|
formik.handleChange({
|
||||||
target: {
|
target: {
|
||||||
name: "national_number", value: inputValue,
|
name: "national_number",
|
||||||
|
value: inputValue,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
@@ -273,7 +321,7 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
</Grid>
|
</Grid>
|
||||||
<Grid item xs={12} sm={4}>
|
<Grid item xs={12} sm={4}>
|
||||||
<TextField
|
<TextField
|
||||||
sx={{width: "100%"}}
|
sx={{ width: "100%" }}
|
||||||
name="company_name"
|
name="company_name"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
size="small"
|
size="small"
|
||||||
@@ -289,13 +337,13 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
</Grid>
|
</Grid>
|
||||||
<Grid item xs={12} sm={4}>
|
<Grid item xs={12} sm={4}>
|
||||||
<TextField
|
<TextField
|
||||||
sx={{width: "100%"}}
|
sx={{ width: "100%" }}
|
||||||
name="register_number"
|
name="register_number"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
size="small"
|
size="small"
|
||||||
value={formik.values.register_number}
|
value={formik.values.register_number}
|
||||||
inputProps={{inputMode: 'numeric', pattern: '[0-9]*'}}
|
inputProps={{ inputMode: "numeric", pattern: "[0-9]*" }}
|
||||||
type={'tel'}
|
type={"tel"}
|
||||||
onChange={(event) => {
|
onChange={(event) => {
|
||||||
const inputValue = event.target.value;
|
const inputValue = event.target.value;
|
||||||
if (isNaN(Number(inputValue))) {
|
if (isNaN(Number(inputValue))) {
|
||||||
@@ -303,7 +351,8 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
}
|
}
|
||||||
formik.handleChange({
|
formik.handleChange({
|
||||||
target: {
|
target: {
|
||||||
name: "register_number", value: inputValue,
|
name: "register_number",
|
||||||
|
value: inputValue,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
@@ -316,15 +365,15 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid container spacing={2} sx={{padding: 2}}>
|
<Grid container spacing={2} sx={{ padding: 2 }}>
|
||||||
<Grid item xs={12} sm={4}>
|
<Grid item xs={12} sm={4}>
|
||||||
<TextField
|
<TextField
|
||||||
sx={{width: "100%"}}
|
sx={{ width: "100%" }}
|
||||||
name="company_postal_code"
|
name="company_postal_code"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
value={formik.values.company_postal_code}
|
value={formik.values.company_postal_code}
|
||||||
inputProps={{inputMode: 'numeric', pattern: '[0-9]*'}}
|
inputProps={{ inputMode: "numeric", pattern: "[0-9]*" }}
|
||||||
type={'tel'}
|
type={"tel"}
|
||||||
onChange={(event) => {
|
onChange={(event) => {
|
||||||
const inputValue = event.target.value;
|
const inputValue = event.target.value;
|
||||||
if (isNaN(Number(inputValue))) {
|
if (isNaN(Number(inputValue))) {
|
||||||
@@ -332,7 +381,8 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
}
|
}
|
||||||
formik.handleChange({
|
formik.handleChange({
|
||||||
target: {
|
target: {
|
||||||
name: "company_postal_code", value: inputValue,
|
name: "company_postal_code",
|
||||||
|
value: inputValue,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
@@ -347,12 +397,12 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
</Grid>
|
</Grid>
|
||||||
<Grid item xs={12} sm={4}>
|
<Grid item xs={12} sm={4}>
|
||||||
<TextField
|
<TextField
|
||||||
sx={{width: "100%"}}
|
sx={{ width: "100%" }}
|
||||||
name="company_tel_number"
|
name="company_tel_number"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
value={formik.values.company_tel_number}
|
value={formik.values.company_tel_number}
|
||||||
inputProps={{inputMode: 'numeric', pattern: '[0-9]*'}}
|
inputProps={{ inputMode: "numeric", pattern: "[0-9]*" }}
|
||||||
type={'tel'}
|
type={"tel"}
|
||||||
size="small"
|
size="small"
|
||||||
onChange={(event) => {
|
onChange={(event) => {
|
||||||
const inputValue = event.target.value;
|
const inputValue = event.target.value;
|
||||||
@@ -361,7 +411,8 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
}
|
}
|
||||||
formik.handleChange({
|
formik.handleChange({
|
||||||
target: {
|
target: {
|
||||||
name: "company_tel_number", value: inputValue,
|
name: "company_tel_number",
|
||||||
|
value: inputValue,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
@@ -382,7 +433,7 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid container spacing={2} sx={{padding: 2}}>
|
<Grid container spacing={2} sx={{ padding: 2 }}>
|
||||||
<Grid item xs={12} sm={6}>
|
<Grid item xs={12} sm={6}>
|
||||||
<SelectBox
|
<SelectBox
|
||||||
name="province_id"
|
name="province_id"
|
||||||
@@ -392,14 +443,14 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
isLoading={isLoadingProvinceList}
|
isLoading={isLoadingProvinceList}
|
||||||
errorEcured={errorProvinceList}
|
errorEcured={errorProvinceList}
|
||||||
selectors={provinceList}
|
selectors={provinceList}
|
||||||
schema={{value: 'value', name: 'name'}}
|
schema={{ value: "value", name: "name" }}
|
||||||
select={formik.values.province_id}
|
select={formik.values.province_id}
|
||||||
value={formik.values.province_id}
|
value={formik.values.province_id}
|
||||||
handleChange={(event) => {
|
handleChange={(event) => {
|
||||||
formik.setFieldValue('province_id', event.target.value);
|
formik.setFieldValue("province_id", event.target.value);
|
||||||
setProvinceID(event.target.value)
|
setProvinceID(event.target.value);
|
||||||
formik.setFieldTouched("city_id", false, false);
|
formik.setFieldTouched("city_id", false, false);
|
||||||
formik.setFieldValue("city_id", "")
|
formik.setFieldValue("city_id", "");
|
||||||
}}
|
}}
|
||||||
setFieldTouched={formik.setFieldTouched}
|
setFieldTouched={formik.setFieldTouched}
|
||||||
error={formik.touched.province_id && Boolean(formik.errors.province_id)}
|
error={formik.touched.province_id && Boolean(formik.errors.province_id)}
|
||||||
@@ -410,15 +461,21 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
<Grid item xs={12} sm={6}>
|
<Grid item xs={12} sm={6}>
|
||||||
<SelectBox
|
<SelectBox
|
||||||
name="city_id"
|
name="city_id"
|
||||||
label={isLoadingCityList ? `${t("LoanRequest.cityList_loading")}` : (cityList.length === 0 ? `${t("LoanRequest.cityList_empty")}` : cityTextField)}
|
label={
|
||||||
|
isLoadingCityList
|
||||||
|
? `${t("LoanRequest.cityList_loading")}`
|
||||||
|
: cityList.length === 0
|
||||||
|
? `${t("LoanRequest.cityList_empty")}`
|
||||||
|
: cityTextField
|
||||||
|
}
|
||||||
size="small"
|
size="small"
|
||||||
selectType="city_id"
|
selectType="city_id"
|
||||||
schema={{value: 'value', name: 'name'}}
|
schema={{ value: "value", name: "name" }}
|
||||||
disabled={cityList.length === 0}
|
disabled={cityList.length === 0}
|
||||||
selectors={cityList}
|
selectors={cityList}
|
||||||
select={formik.values.city_id}
|
select={formik.values.city_id}
|
||||||
value={formik.values.city_id}
|
value={formik.values.city_id}
|
||||||
handleChange={(event) => formik.setFieldValue('city_id', event.target.value)}
|
handleChange={(event) => formik.setFieldValue("city_id", event.target.value)}
|
||||||
setFieldTouched={formik.setFieldTouched}
|
setFieldTouched={formik.setFieldTouched}
|
||||||
error={formik.touched.city_id && Boolean(formik.errors.city_id)}
|
error={formik.touched.city_id && Boolean(formik.errors.city_id)}
|
||||||
helperText={formik.touched.city_id && formik.errors.city_id}
|
helperText={formik.touched.city_id && formik.errors.city_id}
|
||||||
@@ -426,16 +483,16 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid container spacing={2} sx={{padding: 2}}>
|
<Grid container spacing={2} sx={{ padding: 2 }}>
|
||||||
<Grid item xs={12} sm={6}>
|
<Grid item xs={12} sm={6}>
|
||||||
<TextField
|
<TextField
|
||||||
sx={{width: "100%"}}
|
sx={{ width: "100%" }}
|
||||||
name="boss_national_code"
|
name="boss_national_code"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
size="small"
|
size="small"
|
||||||
value={formik.values.boss_national_code}
|
value={formik.values.boss_national_code}
|
||||||
inputProps={{inputMode: 'numeric', pattern: '[0-9]*'}}
|
inputProps={{ inputMode: "numeric", pattern: "[0-9]*" }}
|
||||||
type={'tel'}
|
type={"tel"}
|
||||||
onChange={(event) => {
|
onChange={(event) => {
|
||||||
const inputValue = event.target.value;
|
const inputValue = event.target.value;
|
||||||
if (isNaN(Number(inputValue))) {
|
if (isNaN(Number(inputValue))) {
|
||||||
@@ -443,7 +500,8 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
}
|
}
|
||||||
formik.handleChange({
|
formik.handleChange({
|
||||||
target: {
|
target: {
|
||||||
name: "boss_national_code", value: inputValue,
|
name: "boss_national_code",
|
||||||
|
value: inputValue,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
@@ -462,15 +520,22 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
size="small"
|
size="small"
|
||||||
value={formik.values.boss_gender}
|
value={formik.values.boss_gender}
|
||||||
selectType="boss_gender"
|
selectType="boss_gender"
|
||||||
selectors={[{
|
selectors={[
|
||||||
id: 1, value: 1, name: "زن"
|
{
|
||||||
}, {
|
id: 1,
|
||||||
id: 2, value: 0, name: "مرد"
|
value: 1,
|
||||||
}]}
|
name: "زن",
|
||||||
schema={{value: 'value', name: 'name'}}
|
},
|
||||||
|
{
|
||||||
|
id: 2,
|
||||||
|
value: 0,
|
||||||
|
name: "مرد",
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
schema={{ value: "value", name: "name" }}
|
||||||
select={formik.values.boss_gender}
|
select={formik.values.boss_gender}
|
||||||
handleChange={(event) => {
|
handleChange={(event) => {
|
||||||
formik.setFieldValue('boss_gender', event.target.value)
|
formik.setFieldValue("boss_gender", event.target.value);
|
||||||
}}
|
}}
|
||||||
setFieldTouched={formik.setFieldTouched}
|
setFieldTouched={formik.setFieldTouched}
|
||||||
error={formik.touched.boss_gender && Boolean(formik.errors.boss_gender)}
|
error={formik.touched.boss_gender && Boolean(formik.errors.boss_gender)}
|
||||||
@@ -479,10 +544,10 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid container spacing={2} sx={{padding: 2}}>
|
<Grid container spacing={2} sx={{ padding: 2 }}>
|
||||||
<Grid item xs={12} sm={6}>
|
<Grid item xs={12} sm={6}>
|
||||||
<TextField
|
<TextField
|
||||||
sx={{width: "100%"}}
|
sx={{ width: "100%" }}
|
||||||
name="boss_first_name"
|
name="boss_first_name"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
size="small"
|
size="small"
|
||||||
@@ -498,7 +563,7 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
</Grid>
|
</Grid>
|
||||||
<Grid item xs={12} sm={6}>
|
<Grid item xs={12} sm={6}>
|
||||||
<TextField
|
<TextField
|
||||||
sx={{width: "100%"}}
|
sx={{ width: "100%" }}
|
||||||
name="boss_last_name"
|
name="boss_last_name"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
size="small"
|
size="small"
|
||||||
@@ -513,21 +578,22 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid container spacing={2} sx={{padding: 2}}>
|
<Grid container spacing={2} sx={{ padding: 2 }}>
|
||||||
<Grid item xs={12} sm={4}>
|
<Grid item xs={12} sm={4}>
|
||||||
<ToggleButtonGroup
|
<ToggleButtonGroup
|
||||||
color="primary"
|
color="primary"
|
||||||
fullWidth
|
fullWidth
|
||||||
size={'small'}
|
size={"small"}
|
||||||
value={formik.values.national_serial_number_or_tracking_code}
|
value={formik.values.national_serial_number_or_tracking_code}
|
||||||
exclusive
|
exclusive
|
||||||
onChange={(e, value) => {
|
onChange={(e, value) => {
|
||||||
if (value === null) return
|
if (value === null) return;
|
||||||
formik.handleChange({
|
formik.handleChange({
|
||||||
target: {
|
target: {
|
||||||
name: "national_serial_number_or_tracking_code", value: value,
|
name: "national_serial_number_or_tracking_code",
|
||||||
|
value: value,
|
||||||
},
|
},
|
||||||
})
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<ToggleButton value="national_serial_number">
|
<ToggleButton value="national_serial_number">
|
||||||
@@ -538,11 +604,10 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
</ToggleButton>
|
</ToggleButton>
|
||||||
</ToggleButtonGroup>
|
</ToggleButtonGroup>
|
||||||
</Grid>
|
</Grid>
|
||||||
{formik.values.national_serial_number_or_tracking_code === 'national_serial_number' ? (
|
{formik.values.national_serial_number_or_tracking_code === "national_serial_number" ? (
|
||||||
<Grid item xs={12} sm={4}
|
<Grid item xs={12} sm={4}>
|
||||||
>
|
|
||||||
<TextField
|
<TextField
|
||||||
sx={{width: "100%"}}
|
sx={{ width: "100%" }}
|
||||||
name="boss_national_serial_number"
|
name="boss_national_serial_number"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
size="small"
|
size="small"
|
||||||
@@ -552,13 +617,19 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
fullWidth
|
fullWidth
|
||||||
onChange={formik.handleChange}
|
onChange={formik.handleChange}
|
||||||
onBlur={formik.handleBlur("boss_national_serial_number")}
|
onBlur={formik.handleBlur("boss_national_serial_number")}
|
||||||
error={formik.touched.boss_national_serial_number && Boolean(formik.errors.boss_national_serial_number)}
|
error={
|
||||||
helperText={formik.touched.boss_national_serial_number && formik.errors.boss_national_serial_number}
|
formik.touched.boss_national_serial_number &&
|
||||||
|
Boolean(formik.errors.boss_national_serial_number)
|
||||||
|
}
|
||||||
|
helperText={
|
||||||
|
formik.touched.boss_national_serial_number && formik.errors.boss_national_serial_number
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
</Grid>) : (
|
</Grid>
|
||||||
|
) : (
|
||||||
<Grid item xs={12} sm={4}>
|
<Grid item xs={12} sm={4}>
|
||||||
<TextField
|
<TextField
|
||||||
sx={{width: "100%"}}
|
sx={{ width: "100%" }}
|
||||||
name="boss_national_card_tracking_code"
|
name="boss_national_card_tracking_code"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
size="small"
|
size="small"
|
||||||
@@ -568,14 +639,20 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
fullWidth
|
fullWidth
|
||||||
onChange={formik.handleChange}
|
onChange={formik.handleChange}
|
||||||
onBlur={formik.handleBlur("boss_national_card_tracking_code")}
|
onBlur={formik.handleBlur("boss_national_card_tracking_code")}
|
||||||
error={formik.touched.boss_national_card_tracking_code && Boolean(formik.errors.boss_national_card_tracking_code)}
|
error={
|
||||||
helperText={formik.touched.boss_national_card_tracking_code && formik.errors.boss_national_card_tracking_code}
|
formik.touched.boss_national_card_tracking_code &&
|
||||||
|
Boolean(formik.errors.boss_national_card_tracking_code)
|
||||||
|
}
|
||||||
|
helperText={
|
||||||
|
formik.touched.boss_national_card_tracking_code &&
|
||||||
|
formik.errors.boss_national_card_tracking_code
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
)}
|
)}
|
||||||
<Grid item xs={12} sm={4}>
|
<Grid item xs={12} sm={4}>
|
||||||
<TextField
|
<TextField
|
||||||
sx={{width: "100%"}}
|
sx={{ width: "100%" }}
|
||||||
name="boss_father_name"
|
name="boss_father_name"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
value={formik.values.boss_father_name}
|
value={formik.values.boss_father_name}
|
||||||
@@ -590,7 +667,7 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid container spacing={2} sx={{padding: 2}}>
|
<Grid container spacing={2} sx={{ padding: 2 }}>
|
||||||
<Grid item xs={12} sm={6}>
|
<Grid item xs={12} sm={6}>
|
||||||
<SelectBox
|
<SelectBox
|
||||||
name="navgan_type"
|
name="navgan_type"
|
||||||
@@ -598,17 +675,27 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
size="small"
|
size="small"
|
||||||
value={formik.values.navgan_type}
|
value={formik.values.navgan_type}
|
||||||
selectType="navgan_type"
|
selectType="navgan_type"
|
||||||
selectors={[{
|
selectors={[
|
||||||
id: 1, value: "روستایی", name: "روستایی"
|
{
|
||||||
}, {
|
id: 1,
|
||||||
id: 2, value: "عمومی", name: "عمومی"
|
value: "روستایی",
|
||||||
}, {
|
name: "روستایی",
|
||||||
id: 3, value: "منطقه آزاد", name: "منطقه آزاد"
|
},
|
||||||
}]}
|
{
|
||||||
schema={{value: 'value', name: 'name'}}
|
id: 2,
|
||||||
|
value: "عمومی",
|
||||||
|
name: "عمومی",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 3,
|
||||||
|
value: "منطقه آزاد",
|
||||||
|
name: "منطقه آزاد",
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
schema={{ value: "value", name: "name" }}
|
||||||
select={formik.values.navgan_type}
|
select={formik.values.navgan_type}
|
||||||
handleChange={(event) => {
|
handleChange={(event) => {
|
||||||
formik.setFieldValue('navgan_type', event.target.value)
|
formik.setFieldValue("navgan_type", event.target.value);
|
||||||
}}
|
}}
|
||||||
setFieldTouched={formik.setFieldTouched}
|
setFieldTouched={formik.setFieldTouched}
|
||||||
error={formik.touched.navgan_type && Boolean(formik.errors.navgan_type)}
|
error={formik.touched.navgan_type && Boolean(formik.errors.navgan_type)}
|
||||||
@@ -618,11 +705,11 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
</Grid>
|
</Grid>
|
||||||
<Grid item xs={12} sm={6}>
|
<Grid item xs={12} sm={6}>
|
||||||
<TextField
|
<TextField
|
||||||
sx={{width: "100%"}}
|
sx={{ width: "100%" }}
|
||||||
name="navgan_id"
|
name="navgan_id"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
inputProps={{inputMode: 'numeric', pattern: '[0-9]*'}}
|
inputProps={{ inputMode: "numeric", pattern: "[0-9]*" }}
|
||||||
type={'tel'}
|
type={"tel"}
|
||||||
value={formik.values.navgan_id}
|
value={formik.values.navgan_id}
|
||||||
onChange={formik.handleChange}
|
onChange={formik.handleChange}
|
||||||
size="small"
|
size="small"
|
||||||
@@ -635,32 +722,39 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid container spacing={2} sx={{padding: 2}}>
|
<Grid container spacing={2} sx={{ padding: 2 }}>
|
||||||
<Grid item xs={12} sm={6}>
|
<Grid item xs={12} sm={6}>
|
||||||
<SelectBox
|
<SelectBox
|
||||||
name="vehicle_type"
|
name="vehicle_type"
|
||||||
label={t("LoanRequest.text_field_vehicle_type")}
|
label={t("LoanRequest.text_field_vehicle_type")}
|
||||||
size="small"
|
size="small"
|
||||||
value={formik.values.vehicle_type}
|
value={formik.values.vehicle_type}
|
||||||
schema={{value: 'value', name: 'name'}}
|
schema={{ value: "value", name: "name" }}
|
||||||
selectType="vehicle_type"
|
selectType="vehicle_type"
|
||||||
selectors={[{
|
selectors={[
|
||||||
id: 0, value: "اتوبوس", name: "اتوبوس"
|
{
|
||||||
}, {
|
id: 0,
|
||||||
id: 1, value: "مینی بوس", name: "مینی بوس"
|
value: "اتوبوس",
|
||||||
}]}
|
name: "اتوبوس",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
value: "مینی بوس",
|
||||||
|
name: "مینی بوس",
|
||||||
|
},
|
||||||
|
]}
|
||||||
select={formik.values.vehicle_type}
|
select={formik.values.vehicle_type}
|
||||||
handleChange={(event) => formik.setFieldValue('vehicle_type', event.target.value)}
|
handleChange={(event) => formik.setFieldValue("vehicle_type", event.target.value)}
|
||||||
error={formik.touched.vehicle_type && Boolean(formik.errors.vehicle_type)}
|
error={formik.touched.vehicle_type && Boolean(formik.errors.vehicle_type)}
|
||||||
helperText={formik.touched.vehicle_type && formik.errors.vehicle_type}
|
helperText={formik.touched.vehicle_type && formik.errors.vehicle_type}
|
||||||
onBlur={formik.handleBlur("vehicle_type")}
|
onBlur={formik.handleBlur("vehicle_type")}
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item xs={12} sm={6}>
|
<Grid item xs={12} sm={6}>
|
||||||
<PlateNumber formik={formik}/>
|
<PlateNumber formik={formik} />
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid container spacing={2} sx={{padding: 2}}>
|
<Grid container spacing={2} sx={{ padding: 2 }}>
|
||||||
<Grid item xs={12} sm={6}>
|
<Grid item xs={12} sm={6}>
|
||||||
<SelectBox
|
<SelectBox
|
||||||
name="education_id"
|
name="education_id"
|
||||||
@@ -672,9 +766,9 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
selectors={educationsList}
|
selectors={educationsList}
|
||||||
select={formik.values.education_id}
|
select={formik.values.education_id}
|
||||||
value={formik.values.education_id}
|
value={formik.values.education_id}
|
||||||
schema={{value: 'id', name: 'title'}}
|
schema={{ value: "id", name: "title" }}
|
||||||
handleChange={(event) => {
|
handleChange={(event) => {
|
||||||
formik.setFieldValue('education_id', event.target.value)
|
formik.setFieldValue("education_id", event.target.value);
|
||||||
}}
|
}}
|
||||||
setFieldTouched={formik.setFieldTouched}
|
setFieldTouched={formik.setFieldTouched}
|
||||||
error={formik.touched.education_id && Boolean(formik.errors.education_id)}
|
error={formik.touched.education_id && Boolean(formik.errors.education_id)}
|
||||||
@@ -690,12 +784,12 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
isLoading={isLoadingOccupationsList}
|
isLoading={isLoadingOccupationsList}
|
||||||
errorEcured={errorOccupationsList}
|
errorEcured={errorOccupationsList}
|
||||||
selectType="occupation_id"
|
selectType="occupation_id"
|
||||||
schema={{value: 'id', name: 'title'}}
|
schema={{ value: "id", name: "title" }}
|
||||||
selectors={occupationsList}
|
selectors={occupationsList}
|
||||||
select={formik.values.occupation_id}
|
select={formik.values.occupation_id}
|
||||||
value={formik.values.occupation_id}
|
value={formik.values.occupation_id}
|
||||||
handleChange={(event) => {
|
handleChange={(event) => {
|
||||||
formik.setFieldValue('occupation_id', event.target.value)
|
formik.setFieldValue("occupation_id", event.target.value);
|
||||||
}}
|
}}
|
||||||
setFieldTouched={formik.setFieldTouched}
|
setFieldTouched={formik.setFieldTouched}
|
||||||
error={formik.touched.occupation_id && Boolean(formik.errors.occupation_id)}
|
error={formik.touched.occupation_id && Boolean(formik.errors.occupation_id)}
|
||||||
@@ -704,12 +798,12 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid container spacing={2} sx={{padding: 2}}>
|
<Grid container spacing={2} sx={{ padding: 2 }}>
|
||||||
<Grid item xs={12}>
|
<Grid item xs={12}>
|
||||||
<TextField
|
<TextField
|
||||||
multiline
|
multiline
|
||||||
rows={4}
|
rows={4}
|
||||||
sx={{width: "100%"}}
|
sx={{ width: "100%" }}
|
||||||
name="address"
|
name="address"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
size="small"
|
size="small"
|
||||||
@@ -724,27 +818,29 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid container spacing={2} sx={{padding: 2}}>
|
<Grid container spacing={2} sx={{ padding: 2 }}>
|
||||||
<Grid item xs={12}>
|
<Grid item xs={12}>
|
||||||
<FormControlLabel
|
<FormControlLabel
|
||||||
color={'error.main'}
|
color={"error.main"}
|
||||||
control={<Checkbox
|
control={
|
||||||
checked={formik.values.checkedBox}
|
<Checkbox
|
||||||
onChange={(event) => {
|
checked={formik.values.checkedBox}
|
||||||
formik.setFieldValue("checkedBox", event.target.checked)
|
onChange={(event) => {
|
||||||
}}
|
formik.setFieldValue("checkedBox", event.target.checked);
|
||||||
/>}
|
}}
|
||||||
label={`${t("LoanRequest.checkbox")}`}/>
|
/>
|
||||||
|
}
|
||||||
|
label={`${t("LoanRequest.checkbox")}`}
|
||||||
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
display: "flex",
|
display: "flex",
|
||||||
flexDirection: {xs: "column", sm: "row"},
|
flexDirection: { xs: "column", sm: "row" },
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
mx: "auto",
|
mx: "auto",
|
||||||
width: {xs: "100%", sm: "30%", md: "25%"},
|
width: { xs: "100%", sm: "30%", md: "25%" },
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Button
|
<Button
|
||||||
@@ -753,14 +849,14 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
type="submit"
|
type="submit"
|
||||||
variant="contained"
|
variant="contained"
|
||||||
size="large"
|
size="large"
|
||||||
sx={{my: 4}}
|
sx={{ my: 4 }}
|
||||||
endIcon={<DataSaverOnIcon/>}
|
endIcon={<DataSaverOnIcon />}
|
||||||
disabled={formik.values.checkedBox ? (formik.isSubmitting || !formik.dirty || !formik.isValid) : true}
|
disabled={formik.values.checkedBox ? formik.isSubmitting || !formik.dirty || !formik.isValid : true}
|
||||||
>
|
>
|
||||||
{formik.isSubmitting ? t("LoanRequest.button_while_submit") : t("LoanRequest.button_submit")}
|
{formik.isSubmitting ? t("LoanRequest.button_while_submit") : t("LoanRequest.button_submit")}
|
||||||
</Button>
|
</Button>
|
||||||
</Box>
|
</Box>
|
||||||
</>
|
</>
|
||||||
)
|
);
|
||||||
}
|
};
|
||||||
export default LegalPersonForm
|
export default LegalPersonForm;
|
||||||
|
|||||||
@@ -1,15 +1,24 @@
|
|||||||
import {Box, Button, Checkbox, FormControlLabel, Grid, TextField, ToggleButton, ToggleButtonGroup} from "@mui/material";
|
import {
|
||||||
|
Box,
|
||||||
|
Button,
|
||||||
|
Checkbox,
|
||||||
|
FormControlLabel,
|
||||||
|
Grid,
|
||||||
|
TextField,
|
||||||
|
ToggleButton,
|
||||||
|
ToggleButtonGroup,
|
||||||
|
} from "@mui/material";
|
||||||
import SelectBox from "@/core/components/SelectBox";
|
import SelectBox from "@/core/components/SelectBox";
|
||||||
import MuiDatePicker from "@/core/components/MuiDatePicker";
|
import MuiDatePicker from "@/core/components/MuiDatePicker";
|
||||||
import {useTranslations} from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
import useLimitedProvince from "@/lib/app/hooks/useLimitedProvince";
|
import useLimitedProvince from "@/lib/app/hooks/useLimitedProvince";
|
||||||
import useCities from "@/lib/app/hooks/useCities";
|
import useCities from "@/lib/app/hooks/useCities";
|
||||||
import {useFormik} from "formik";
|
import { useFormik } from "formik";
|
||||||
import * as Yup from "yup";
|
import * as Yup from "yup";
|
||||||
import DataSaverOnIcon from "@mui/icons-material/DataSaverOn";
|
import DataSaverOnIcon from "@mui/icons-material/DataSaverOn";
|
||||||
import {SEND_LOAN_REQUEST_NAVGAN} from "@/core/data/apiRoutes";
|
import { SEND_LOAN_REQUEST_NAVGAN } from "@/core/data/apiRoutes";
|
||||||
import {useRequest, useUser} from "@witel/webapp-builder";
|
import { useRequest, useUser } from "@witel/webapp-builder";
|
||||||
import {useRouter} from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import PlateNumber from "@/core/components/PlateNumber";
|
import PlateNumber from "@/core/components/PlateNumber";
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import UseEducations from "@/lib/app/hooks/useEducations";
|
import UseEducations from "@/lib/app/hooks/useEducations";
|
||||||
@@ -18,22 +27,22 @@ import useActivityType from "@/lib/app/hooks/useActivityType";
|
|||||||
import usePriorityLists from "@/lib/app/hooks/usePriorityLists";
|
import usePriorityLists from "@/lib/app/hooks/usePriorityLists";
|
||||||
import useProjectTitle from "@/lib/app/hooks/useProjectTitle";
|
import useProjectTitle from "@/lib/app/hooks/useProjectTitle";
|
||||||
|
|
||||||
const RealPersonForm = ({setFinishLoanRequest}) => {
|
const RealPersonForm = ({ setFinishLoanRequest }) => {
|
||||||
const t = useTranslations();
|
const t = useTranslations();
|
||||||
const {provinceList, isLoadingProvinceList, errorProvinceList} = useLimitedProvince()
|
const { provinceList, isLoadingProvinceList, errorProvinceList } = useLimitedProvince();
|
||||||
const {cityTextField, cityList, setProvinceID, isLoadingCityList} = useCities()
|
const { cityTextField, cityList, setProvinceID, isLoadingCityList } = useCities();
|
||||||
const {educationsList, isLoadingEducationsList, errorEducationsList} = UseEducations()
|
const { educationsList, isLoadingEducationsList, errorEducationsList } = UseEducations();
|
||||||
const {occupationsList, isLoadingOccupationsList, errorOccupationsList} = useOccupations()
|
const { occupationsList, isLoadingOccupationsList, errorOccupationsList } = useOccupations();
|
||||||
const {activityType, isLoadingActivityType, errorActivityType} = useActivityType()
|
const { activityType, isLoadingActivityType, errorActivityType } = useActivityType();
|
||||||
const {priorityLists, isLoadingPriorityLists, errorPriorityLists} = usePriorityLists()
|
const { priorityLists, isLoadingPriorityLists, errorPriorityLists } = usePriorityLists();
|
||||||
const {projectTitle, isLoadingProjectTitle, errorProjectTitle} = useProjectTitle()
|
const { projectTitle, isLoadingProjectTitle, errorProjectTitle } = useProjectTitle();
|
||||||
const requestServer = useRequest()
|
const requestServer = useRequest();
|
||||||
const {getUser, changeUser} = useUser()
|
const { getUser, changeUser } = useUser();
|
||||||
const router = useRouter()
|
const router = useRouter();
|
||||||
|
|
||||||
const initialValues = {
|
const initialValues = {
|
||||||
person_type : "real",
|
person_type: "real",
|
||||||
vehicle_type : "",
|
vehicle_type: "",
|
||||||
telephone_number: "",
|
telephone_number: "",
|
||||||
activity_type: "",
|
activity_type: "",
|
||||||
project_title: "",
|
project_title: "",
|
||||||
@@ -66,7 +75,7 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
telephone_number: Yup.mixed()
|
telephone_number: Yup.mixed()
|
||||||
.test("max", `${t("LoanRequest.tel_number_max")}`, (value) => {
|
.test("max", `${t("LoanRequest.tel_number_max")}`, (value) => {
|
||||||
const stringValue = String(value);
|
const stringValue = String(value);
|
||||||
return stringValue.length === 11
|
return stringValue.length === 11;
|
||||||
})
|
})
|
||||||
.required(t("LoanRequest.error_message_tel_number")),
|
.required(t("LoanRequest.error_message_tel_number")),
|
||||||
father_name: Yup.string().required(t("LoanRequest.error_message_father_name")),
|
father_name: Yup.string().required(t("LoanRequest.error_message_father_name")),
|
||||||
@@ -88,48 +97,75 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
city_id: Yup.string().required(t("LoanRequest.error_message_city_id")),
|
city_id: Yup.string().required(t("LoanRequest.error_message_city_id")),
|
||||||
first_name: Yup.string().required(t("LoanRequest.error_message_first_name")),
|
first_name: Yup.string().required(t("LoanRequest.error_message_first_name")),
|
||||||
last_name: Yup.string().required(t("LoanRequest.error_message_last_name")),
|
last_name: Yup.string().required(t("LoanRequest.error_message_last_name")),
|
||||||
plate_part1: Yup.mixed().test("max", `${t("LoanRequest.error_message_plate_number")}`, (value) => value.toString().length === 2)
|
plate_part1: Yup.mixed()
|
||||||
|
.test("max", `${t("LoanRequest.error_message_plate_number")}`, (value) => value.toString().length === 2)
|
||||||
.required(t("LoanRequest.error_message_plate_number")),
|
.required(t("LoanRequest.error_message_plate_number")),
|
||||||
plate_part2: Yup.mixed()
|
plate_part2: Yup.mixed().required(t("LoanRequest.error_message_plate_number")),
|
||||||
|
plate_part3: Yup.mixed()
|
||||||
|
.test("max", `${t("LoanRequest.error_message_plate_number")}`, (value) => value.toString().length === 3)
|
||||||
.required(t("LoanRequest.error_message_plate_number")),
|
.required(t("LoanRequest.error_message_plate_number")),
|
||||||
plate_part3: Yup.mixed().test("max", `${t("LoanRequest.error_message_plate_number")}`, (value) => value.toString().length === 3)
|
plate_part4: Yup.mixed()
|
||||||
.required(t("LoanRequest.error_message_plate_number")),
|
.test("max", `${t("LoanRequest.error_message_plate_number")}`, (value) => value.toString().length === 2)
|
||||||
plate_part4: Yup.mixed().test("max", `${t("LoanRequest.error_message_plate_number")}`, (value) => value.toString().length === 2)
|
|
||||||
.required(t("LoanRequest.error_message_plate_number")),
|
.required(t("LoanRequest.error_message_plate_number")),
|
||||||
national_code: Yup.mixed()
|
national_code: Yup.mixed()
|
||||||
.test("is-number", `${t("LoanRequest.national_code_number")}`, (value) => !isNaN(value))
|
.test("is-number", `${t("LoanRequest.national_code_number")}`, (value) => !isNaN(value))
|
||||||
.test("positive", `${t("LoanRequest.national_code_positive")}`, (value) => value >= 0)
|
.test("positive", `${t("LoanRequest.national_code_positive")}`, (value) => value >= 0)
|
||||||
.test("max", `${t("LoanRequest.national_code_max")}`, (value) => value.toString().length === 10)
|
.test("max", `${t("LoanRequest.national_code_max")}`, (value) => value.toString().length === 10)
|
||||||
.required(t("LoanRequest.error_message_national_id")),
|
.required(t("LoanRequest.error_message_national_id")),
|
||||||
national_number: Yup.mixed().when('person_type', ([person_type], schema) => {
|
national_number: Yup.mixed().when("person_type", ([person_type], schema) => {
|
||||||
return person_type === 'legal' ? schema
|
return person_type === "legal"
|
||||||
.test("is-number", `${t("LoanRequest.national_number_number")}`, (value) => !isNaN(value))
|
? schema
|
||||||
.test("positive", `${t("LoanRequest.national_number_positive")}`, (value) => value >= 0)
|
.test("is-number", `${t("LoanRequest.national_number_number")}`, (value) => !isNaN(value))
|
||||||
.test("max", `${t("LoanRequest.national_number_max")}`, (value) => value && value.toString().length === 11)
|
.test("positive", `${t("LoanRequest.national_number_positive")}`, (value) => value >= 0)
|
||||||
.required(t("LoanRequest.error_message_national_number")) : schema;
|
.test(
|
||||||
}),
|
"max",
|
||||||
national_serial_number: Yup.string().test("max", `${t("LoanRequest.national_serial_number_max")}`, (value) => value && value.toString().length === 10).when('national_serial_number_or_tracking_code', ([national_serial_number_or_tracking_code], schema) => {
|
`${t("LoanRequest.national_number_max")}`,
|
||||||
return national_serial_number_or_tracking_code === 'national_serial_number' ? schema.required(t("LoanRequest.error_message_shenasname_serial")) : schema
|
(value) => value && value.toString().length === 11
|
||||||
}),
|
)
|
||||||
national_card_tracking_code: Yup.string().when('national_serial_number_or_tracking_code', ([national_serial_number_or_tracking_code], schema) => {
|
.required(t("LoanRequest.error_message_national_number"))
|
||||||
return national_serial_number_or_tracking_code === 'national_card_tracking_code' ? schema.required(t("LoanRequest.error_message_tracking_code")) : schema
|
: schema;
|
||||||
}),
|
}),
|
||||||
|
national_serial_number: Yup.string()
|
||||||
|
.test(
|
||||||
|
"max",
|
||||||
|
`${t("LoanRequest.national_serial_number_max")}`,
|
||||||
|
(value) => value && value.toString().length === 10
|
||||||
|
)
|
||||||
|
.when("national_serial_number_or_tracking_code", ([national_serial_number_or_tracking_code], schema) => {
|
||||||
|
return national_serial_number_or_tracking_code === "national_serial_number"
|
||||||
|
? schema.required(t("LoanRequest.error_message_shenasname_serial"))
|
||||||
|
: schema;
|
||||||
|
}),
|
||||||
|
national_card_tracking_code: Yup.string().when(
|
||||||
|
"national_serial_number_or_tracking_code",
|
||||||
|
([national_serial_number_or_tracking_code], schema) => {
|
||||||
|
return national_serial_number_or_tracking_code === "national_card_tracking_code"
|
||||||
|
? schema.required(t("LoanRequest.error_message_tracking_code"))
|
||||||
|
: schema;
|
||||||
|
}
|
||||||
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleSubmit = async (values, props) => {
|
const handleSubmit = async (values, props) => {
|
||||||
props.setSubmitting(true)
|
props.setSubmitting(true);
|
||||||
let _national_number = values.person_type === "legal" ? {
|
let _national_number =
|
||||||
shenase_meli: values.national_number
|
values.person_type === "legal"
|
||||||
} : {}
|
? {
|
||||||
|
shenase_meli: values.national_number,
|
||||||
|
}
|
||||||
|
: {};
|
||||||
|
|
||||||
const _national_card = values.national_serial_number_or_tracking_code === "national_serial_number" ? {
|
const _national_card =
|
||||||
national_serial_number: values.national_serial_number
|
values.national_serial_number_or_tracking_code === "national_serial_number"
|
||||||
} : {
|
? {
|
||||||
national_tracking_code: values.national_card_tracking_code
|
national_serial_number: values.national_serial_number,
|
||||||
}
|
}
|
||||||
|
: {
|
||||||
|
national_tracking_code: values.national_card_tracking_code,
|
||||||
|
};
|
||||||
|
|
||||||
let _data = {
|
let _data = {
|
||||||
is_legal_person: 0,
|
is_legal_person: 0,
|
||||||
telephone_number: values.telephone_number,
|
telephone_number: values.telephone_number,
|
||||||
national_id: values.national_code,
|
national_id: values.national_code,
|
||||||
vehicle_type: values.vehicle_type,
|
vehicle_type: values.vehicle_type,
|
||||||
@@ -145,32 +181,44 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
address: values.address,
|
address: values.address,
|
||||||
education_id: values.education_id,
|
education_id: values.education_id,
|
||||||
occupation_id: values.occupation_id,
|
occupation_id: values.occupation_id,
|
||||||
activity_type: values.activity_type,
|
activity_type_id: values.activity_type,
|
||||||
project_title: values.project_title,
|
project_title: values.project_title,
|
||||||
priority_list: values.priority_list,
|
activity_priority_id: values.priority_list,
|
||||||
birthday: values.birthday.locale('en').format("YYYY-MM-DD"), ..._national_card, ..._national_number
|
plate_part1: values.plate_part1,
|
||||||
}
|
plate_part2: values.plate_part2,
|
||||||
|
plate_part3: values.plate_part3,
|
||||||
|
plate_part4: values.plate_part4,
|
||||||
|
birthday: values.birthday.locale("en").format("YYYY-MM-DD"),
|
||||||
|
..._national_card,
|
||||||
|
..._national_number,
|
||||||
|
};
|
||||||
|
|
||||||
await requestServer(SEND_LOAN_REQUEST_NAVGAN, "post", {
|
await requestServer(SEND_LOAN_REQUEST_NAVGAN, "post", {
|
||||||
auth: true, notification: true, data: _data
|
auth: true,
|
||||||
}).then(() => {
|
notification: true,
|
||||||
router.replace('/dashboard/navgan/followUp-loan')
|
data: _data,
|
||||||
getUser((data) => {
|
|
||||||
changeUser(data);
|
|
||||||
});
|
|
||||||
}).catch(() => {
|
|
||||||
}).finally(() => {
|
|
||||||
props.setSubmitting(false)
|
|
||||||
})
|
})
|
||||||
|
.then(() => {
|
||||||
|
router.replace("/dashboard/navgan/followUp-loan");
|
||||||
|
getUser((data) => {
|
||||||
|
changeUser(data);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(() => {})
|
||||||
|
.finally(() => {
|
||||||
|
props.setSubmitting(false);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const formik = useFormik({
|
const formik = useFormik({
|
||||||
initialValues, validationSchema, onSubmit: handleSubmit
|
initialValues,
|
||||||
})
|
validationSchema,
|
||||||
|
onSubmit: handleSubmit,
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Grid container spacing={2} sx={{p: 2}}>
|
<Grid container spacing={2} sx={{ p: 2 }}>
|
||||||
<Grid item xs={12} sm={4}>
|
<Grid item xs={12} sm={4}>
|
||||||
<SelectBox
|
<SelectBox
|
||||||
name="project_title"
|
name="project_title"
|
||||||
@@ -180,11 +228,11 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
isLoading={isLoadingProjectTitle}
|
isLoading={isLoadingProjectTitle}
|
||||||
errorEcured={errorProjectTitle}
|
errorEcured={errorProjectTitle}
|
||||||
selectors={projectTitle}
|
selectors={projectTitle}
|
||||||
schema={{value: 'value', name: 'name'}}
|
schema={{ value: "name", name: "name" }}
|
||||||
select={formik.values.project_title}
|
select={formik.values.project_title}
|
||||||
value={formik.values.project_title}
|
value={formik.values.project_title}
|
||||||
handleChange={(event) => {
|
handleChange={(event) => {
|
||||||
formik.setFieldValue('project_title', event.target.value)
|
formik.setFieldValue("project_title", event.target.value);
|
||||||
}}
|
}}
|
||||||
setFieldTouched={formik.setFieldTouched}
|
setFieldTouched={formik.setFieldTouched}
|
||||||
error={formik.touched.project_title && Boolean(formik.errors.project_title)}
|
error={formik.touched.project_title && Boolean(formik.errors.project_title)}
|
||||||
@@ -201,11 +249,11 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
isLoading={isLoadingActivityType}
|
isLoading={isLoadingActivityType}
|
||||||
errorEcured={errorActivityType}
|
errorEcured={errorActivityType}
|
||||||
selectors={activityType}
|
selectors={activityType}
|
||||||
schema={{value: 'value', name: 'name'}}
|
schema={{ value: "value", name: "name" }}
|
||||||
select={formik.values.activity_type}
|
select={formik.values.activity_type}
|
||||||
value={formik.values.activity_type}
|
value={formik.values.activity_type}
|
||||||
handleChange={(event) => {
|
handleChange={(event) => {
|
||||||
formik.setFieldValue('activity_type', event.target.value)
|
formik.setFieldValue("activity_type", event.target.value);
|
||||||
}}
|
}}
|
||||||
setFieldTouched={formik.setFieldTouched}
|
setFieldTouched={formik.setFieldTouched}
|
||||||
error={formik.touched.activity_type && Boolean(formik.errors.activity_type)}
|
error={formik.touched.activity_type && Boolean(formik.errors.activity_type)}
|
||||||
@@ -222,11 +270,11 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
isLoading={isLoadingPriorityLists}
|
isLoading={isLoadingPriorityLists}
|
||||||
errorEcured={errorPriorityLists}
|
errorEcured={errorPriorityLists}
|
||||||
selectors={priorityLists}
|
selectors={priorityLists}
|
||||||
schema={{value: 'value', name: 'name'}}
|
schema={{ value: "value", name: "name" }}
|
||||||
select={formik.values.priority_list}
|
select={formik.values.priority_list}
|
||||||
value={formik.values.priority_list}
|
value={formik.values.priority_list}
|
||||||
handleChange={(event) => {
|
handleChange={(event) => {
|
||||||
formik.setFieldValue('priority_list', event.target.value)
|
formik.setFieldValue("priority_list", event.target.value);
|
||||||
}}
|
}}
|
||||||
setFieldTouched={formik.setFieldTouched}
|
setFieldTouched={formik.setFieldTouched}
|
||||||
error={formik.touched.priority_list && Boolean(formik.errors.priority_list)}
|
error={formik.touched.priority_list && Boolean(formik.errors.priority_list)}
|
||||||
@@ -235,21 +283,22 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid container spacing={2} sx={{padding: 2}}>
|
<Grid container spacing={2} sx={{ padding: 2 }}>
|
||||||
<Grid item xs={12} sm={4}>
|
<Grid item xs={12} sm={4}>
|
||||||
<ToggleButtonGroup
|
<ToggleButtonGroup
|
||||||
color="primary"
|
color="primary"
|
||||||
fullWidth
|
fullWidth
|
||||||
size={'small'}
|
size={"small"}
|
||||||
value={formik.values.national_serial_number_or_tracking_code}
|
value={formik.values.national_serial_number_or_tracking_code}
|
||||||
exclusive
|
exclusive
|
||||||
onChange={(e, value) => {
|
onChange={(e, value) => {
|
||||||
if (value === null) return
|
if (value === null) return;
|
||||||
formik.handleChange({
|
formik.handleChange({
|
||||||
target: {
|
target: {
|
||||||
name: "national_serial_number_or_tracking_code", value: value,
|
name: "national_serial_number_or_tracking_code",
|
||||||
|
value: value,
|
||||||
},
|
},
|
||||||
})
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<ToggleButton value="national_serial_number">
|
<ToggleButton value="national_serial_number">
|
||||||
@@ -260,11 +309,10 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
</ToggleButton>
|
</ToggleButton>
|
||||||
</ToggleButtonGroup>
|
</ToggleButtonGroup>
|
||||||
</Grid>
|
</Grid>
|
||||||
{formik.values.national_serial_number_or_tracking_code === 'national_serial_number' ? (
|
{formik.values.national_serial_number_or_tracking_code === "national_serial_number" ? (
|
||||||
<Grid item xs={12} sm={4}
|
<Grid item xs={12} sm={4}>
|
||||||
>
|
|
||||||
<TextField
|
<TextField
|
||||||
sx={{width: "100%"}}
|
sx={{ width: "100%" }}
|
||||||
name="national_serial_number"
|
name="national_serial_number"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
size="small"
|
size="small"
|
||||||
@@ -274,13 +322,16 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
fullWidth
|
fullWidth
|
||||||
onChange={formik.handleChange}
|
onChange={formik.handleChange}
|
||||||
onBlur={formik.handleBlur("national_serial_number")}
|
onBlur={formik.handleBlur("national_serial_number")}
|
||||||
error={formik.touched.national_serial_number && Boolean(formik.errors.national_serial_number)}
|
error={
|
||||||
|
formik.touched.national_serial_number && Boolean(formik.errors.national_serial_number)
|
||||||
|
}
|
||||||
helperText={formik.touched.national_serial_number && formik.errors.national_serial_number}
|
helperText={formik.touched.national_serial_number && formik.errors.national_serial_number}
|
||||||
/>
|
/>
|
||||||
</Grid>) : (
|
</Grid>
|
||||||
|
) : (
|
||||||
<Grid item xs={12} sm={4}>
|
<Grid item xs={12} sm={4}>
|
||||||
<TextField
|
<TextField
|
||||||
sx={{width: "100%"}}
|
sx={{ width: "100%" }}
|
||||||
name="national_card_tracking_code"
|
name="national_card_tracking_code"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
size="small"
|
size="small"
|
||||||
@@ -290,20 +341,25 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
fullWidth
|
fullWidth
|
||||||
onChange={formik.handleChange}
|
onChange={formik.handleChange}
|
||||||
onBlur={formik.handleBlur("national_card_tracking_code")}
|
onBlur={formik.handleBlur("national_card_tracking_code")}
|
||||||
error={formik.touched.national_card_tracking_code && Boolean(formik.errors.national_card_tracking_code)}
|
error={
|
||||||
helperText={formik.touched.national_card_tracking_code && formik.errors.national_card_tracking_code}
|
formik.touched.national_card_tracking_code &&
|
||||||
|
Boolean(formik.errors.national_card_tracking_code)
|
||||||
|
}
|
||||||
|
helperText={
|
||||||
|
formik.touched.national_card_tracking_code && formik.errors.national_card_tracking_code
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
)}
|
)}
|
||||||
<Grid item xs={12} sm={4}>
|
<Grid item xs={12} sm={4}>
|
||||||
<TextField
|
<TextField
|
||||||
sx={{width: "100%"}}
|
sx={{ width: "100%" }}
|
||||||
name="national_code"
|
name="national_code"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
size="small"
|
size="small"
|
||||||
value={formik.values.national_code}
|
value={formik.values.national_code}
|
||||||
inputProps={{inputMode: 'numeric', pattern: '[0-9]*'}}
|
inputProps={{ inputMode: "numeric", pattern: "[0-9]*" }}
|
||||||
type={'tel'}
|
type={"tel"}
|
||||||
onChange={(event) => {
|
onChange={(event) => {
|
||||||
const inputValue = event.target.value;
|
const inputValue = event.target.value;
|
||||||
if (isNaN(Number(inputValue))) {
|
if (isNaN(Number(inputValue))) {
|
||||||
@@ -311,7 +367,8 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
}
|
}
|
||||||
formik.handleChange({
|
formik.handleChange({
|
||||||
target: {
|
target: {
|
||||||
name: "national_code", value: inputValue,
|
name: "national_code",
|
||||||
|
value: inputValue,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
@@ -324,10 +381,10 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid container spacing={2} sx={{padding: 2}}>
|
<Grid container spacing={2} sx={{ padding: 2 }}>
|
||||||
<Grid item xs={12} sm={6}>
|
<Grid item xs={12} sm={6}>
|
||||||
<TextField
|
<TextField
|
||||||
sx={{width: "100%"}}
|
sx={{ width: "100%" }}
|
||||||
name="first_name"
|
name="first_name"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
size="small"
|
size="small"
|
||||||
@@ -343,7 +400,7 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
</Grid>
|
</Grid>
|
||||||
<Grid item xs={12} sm={6}>
|
<Grid item xs={12} sm={6}>
|
||||||
<TextField
|
<TextField
|
||||||
sx={{width: "100%"}}
|
sx={{ width: "100%" }}
|
||||||
name="last_name"
|
name="last_name"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
size="small"
|
size="small"
|
||||||
@@ -358,10 +415,10 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid container spacing={2} sx={{padding: 2}}>
|
<Grid container spacing={2} sx={{ padding: 2 }}>
|
||||||
<Grid item xs={12} sm={4}>
|
<Grid item xs={12} sm={4}>
|
||||||
<TextField
|
<TextField
|
||||||
sx={{width: "100%"}}
|
sx={{ width: "100%" }}
|
||||||
name="father_name"
|
name="father_name"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
value={formik.values.father_name}
|
value={formik.values.father_name}
|
||||||
@@ -382,15 +439,22 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
size="small"
|
size="small"
|
||||||
value={formik.values.gender}
|
value={formik.values.gender}
|
||||||
selectType="gender"
|
selectType="gender"
|
||||||
selectors={[{
|
selectors={[
|
||||||
id: 1, value: 1, name: "زن"
|
{
|
||||||
}, {
|
id: 1,
|
||||||
id: 2, value: 0, name: "مرد"
|
value: 1,
|
||||||
}]}
|
name: "زن",
|
||||||
schema={{value: 'value', name: 'name'}}
|
},
|
||||||
|
{
|
||||||
|
id: 2,
|
||||||
|
value: 0,
|
||||||
|
name: "مرد",
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
schema={{ value: "value", name: "name" }}
|
||||||
select={formik.values.gender}
|
select={formik.values.gender}
|
||||||
handleChange={(event) => {
|
handleChange={(event) => {
|
||||||
formik.setFieldValue('gender', event.target.value)
|
formik.setFieldValue("gender", event.target.value);
|
||||||
}}
|
}}
|
||||||
setFieldTouched={formik.setFieldTouched}
|
setFieldTouched={formik.setFieldTouched}
|
||||||
error={formik.touched.gender && Boolean(formik.errors.gender)}
|
error={formik.touched.gender && Boolean(formik.errors.gender)}
|
||||||
@@ -407,15 +471,15 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid container spacing={2} sx={{padding: 2}}>
|
<Grid container spacing={2} sx={{ padding: 2 }}>
|
||||||
<Grid item xs={12} sm={6}>
|
<Grid item xs={12} sm={6}>
|
||||||
<TextField
|
<TextField
|
||||||
sx={{width: "100%"}}
|
sx={{ width: "100%" }}
|
||||||
name="postal_code"
|
name="postal_code"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
value={formik.values.postal_code}
|
value={formik.values.postal_code}
|
||||||
inputProps={{inputMode: 'numeric', pattern: '[0-9]*'}}
|
inputProps={{ inputMode: "numeric", pattern: "[0-9]*" }}
|
||||||
type={'tel'}
|
type={"tel"}
|
||||||
onChange={(event) => {
|
onChange={(event) => {
|
||||||
const inputValue = event.target.value;
|
const inputValue = event.target.value;
|
||||||
if (isNaN(Number(inputValue))) {
|
if (isNaN(Number(inputValue))) {
|
||||||
@@ -423,7 +487,8 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
}
|
}
|
||||||
formik.handleChange({
|
formik.handleChange({
|
||||||
target: {
|
target: {
|
||||||
name: "postal_code", value: inputValue,
|
name: "postal_code",
|
||||||
|
value: inputValue,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
@@ -438,12 +503,12 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
</Grid>
|
</Grid>
|
||||||
<Grid item xs={12} sm={6}>
|
<Grid item xs={12} sm={6}>
|
||||||
<TextField
|
<TextField
|
||||||
sx={{width: "100%"}}
|
sx={{ width: "100%" }}
|
||||||
name="telephone_number"
|
name="telephone_number"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
value={formik.values.telephone_number}
|
value={formik.values.telephone_number}
|
||||||
inputProps={{inputMode: 'numeric', pattern: '[0-9]*'}}
|
inputProps={{ inputMode: "numeric", pattern: "[0-9]*" }}
|
||||||
type={'tel'}
|
type={"tel"}
|
||||||
size="small"
|
size="small"
|
||||||
onChange={(event) => {
|
onChange={(event) => {
|
||||||
const inputValue = event.target.value;
|
const inputValue = event.target.value;
|
||||||
@@ -452,7 +517,8 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
}
|
}
|
||||||
formik.handleChange({
|
formik.handleChange({
|
||||||
target: {
|
target: {
|
||||||
name: "telephone_number", value: inputValue,
|
name: "telephone_number",
|
||||||
|
value: inputValue,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
@@ -465,7 +531,7 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid container spacing={2} sx={{padding: 2}}>
|
<Grid container spacing={2} sx={{ padding: 2 }}>
|
||||||
<Grid item xs={12} sm={6}>
|
<Grid item xs={12} sm={6}>
|
||||||
<SelectBox
|
<SelectBox
|
||||||
name="navgan_type"
|
name="navgan_type"
|
||||||
@@ -473,17 +539,27 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
size="small"
|
size="small"
|
||||||
value={formik.values.navgan_type}
|
value={formik.values.navgan_type}
|
||||||
selectType="navgan_type"
|
selectType="navgan_type"
|
||||||
selectors={[{
|
selectors={[
|
||||||
id: 1, value: "روستایی", name: "روستایی"
|
{
|
||||||
}, {
|
id: 1,
|
||||||
id: 2, value: "عمومی", name: "عمومی"
|
value: "روستایی",
|
||||||
}, {
|
name: "روستایی",
|
||||||
id: 3, value: "منطقه آزاد", name: "منطقه آزاد"
|
},
|
||||||
}]}
|
{
|
||||||
schema={{value: 'value', name: 'name'}}
|
id: 2,
|
||||||
|
value: "عمومی",
|
||||||
|
name: "عمومی",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 3,
|
||||||
|
value: "منطقه آزاد",
|
||||||
|
name: "منطقه آزاد",
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
schema={{ value: "value", name: "name" }}
|
||||||
select={formik.values.navgan_type}
|
select={formik.values.navgan_type}
|
||||||
handleChange={(event) => {
|
handleChange={(event) => {
|
||||||
formik.setFieldValue('navgan_type', event.target.value)
|
formik.setFieldValue("navgan_type", event.target.value);
|
||||||
}}
|
}}
|
||||||
setFieldTouched={formik.setFieldTouched}
|
setFieldTouched={formik.setFieldTouched}
|
||||||
error={formik.touched.navgan_type && Boolean(formik.errors.navgan_type)}
|
error={formik.touched.navgan_type && Boolean(formik.errors.navgan_type)}
|
||||||
@@ -493,11 +569,11 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
</Grid>
|
</Grid>
|
||||||
<Grid item xs={12} sm={6}>
|
<Grid item xs={12} sm={6}>
|
||||||
<TextField
|
<TextField
|
||||||
sx={{width: "100%"}}
|
sx={{ width: "100%" }}
|
||||||
name="navgan_id"
|
name="navgan_id"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
inputProps={{inputMode: 'numeric', pattern: '[0-9]*'}}
|
inputProps={{ inputMode: "numeric", pattern: "[0-9]*" }}
|
||||||
type={'tel'}
|
type={"tel"}
|
||||||
value={formik.values.navgan_id}
|
value={formik.values.navgan_id}
|
||||||
onChange={formik.handleChange}
|
onChange={formik.handleChange}
|
||||||
size="small"
|
size="small"
|
||||||
@@ -510,7 +586,7 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid container spacing={2} sx={{padding: 2}}>
|
<Grid container spacing={2} sx={{ padding: 2 }}>
|
||||||
<Grid item xs={12} sm={6}>
|
<Grid item xs={12} sm={6}>
|
||||||
<SelectBox
|
<SelectBox
|
||||||
name="province_id"
|
name="province_id"
|
||||||
@@ -520,14 +596,14 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
isLoading={isLoadingProvinceList}
|
isLoading={isLoadingProvinceList}
|
||||||
errorEcured={errorProvinceList}
|
errorEcured={errorProvinceList}
|
||||||
selectors={provinceList}
|
selectors={provinceList}
|
||||||
schema={{value: 'value', name: 'name'}}
|
schema={{ value: "value", name: "name" }}
|
||||||
select={formik.values.province_id}
|
select={formik.values.province_id}
|
||||||
value={formik.values.province_id}
|
value={formik.values.province_id}
|
||||||
handleChange={(event) => {
|
handleChange={(event) => {
|
||||||
formik.setFieldValue('province_id', event.target.value);
|
formik.setFieldValue("province_id", event.target.value);
|
||||||
setProvinceID(event.target.value)
|
setProvinceID(event.target.value);
|
||||||
formik.setFieldTouched("city_id", false, false);
|
formik.setFieldTouched("city_id", false, false);
|
||||||
formik.setFieldValue("city_id", "")
|
formik.setFieldValue("city_id", "");
|
||||||
}}
|
}}
|
||||||
setFieldTouched={formik.setFieldTouched}
|
setFieldTouched={formik.setFieldTouched}
|
||||||
error={formik.touched.province_id && Boolean(formik.errors.province_id)}
|
error={formik.touched.province_id && Boolean(formik.errors.province_id)}
|
||||||
@@ -538,15 +614,21 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
<Grid item xs={12} sm={6}>
|
<Grid item xs={12} sm={6}>
|
||||||
<SelectBox
|
<SelectBox
|
||||||
name="city_id"
|
name="city_id"
|
||||||
label={isLoadingCityList ? `${t("LoanRequest.cityList_loading")}` : (cityList.length === 0 ? `${t("LoanRequest.cityList_empty")}` : cityTextField)}
|
label={
|
||||||
|
isLoadingCityList
|
||||||
|
? `${t("LoanRequest.cityList_loading")}`
|
||||||
|
: cityList.length === 0
|
||||||
|
? `${t("LoanRequest.cityList_empty")}`
|
||||||
|
: cityTextField
|
||||||
|
}
|
||||||
size="small"
|
size="small"
|
||||||
selectType="city_id"
|
selectType="city_id"
|
||||||
schema={{value: 'value', name: 'name'}}
|
schema={{ value: "value", name: "name" }}
|
||||||
disabled={cityList.length === 0}
|
disabled={cityList.length === 0}
|
||||||
selectors={cityList}
|
selectors={cityList}
|
||||||
select={formik.values.city_id}
|
select={formik.values.city_id}
|
||||||
value={formik.values.city_id}
|
value={formik.values.city_id}
|
||||||
handleChange={(event) => formik.setFieldValue('city_id', event.target.value)}
|
handleChange={(event) => formik.setFieldValue("city_id", event.target.value)}
|
||||||
setFieldTouched={formik.setFieldTouched}
|
setFieldTouched={formik.setFieldTouched}
|
||||||
error={formik.touched.city_id && Boolean(formik.errors.city_id)}
|
error={formik.touched.city_id && Boolean(formik.errors.city_id)}
|
||||||
helperText={formik.touched.city_id && formik.errors.city_id}
|
helperText={formik.touched.city_id && formik.errors.city_id}
|
||||||
@@ -554,32 +636,39 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid container spacing={2} sx={{padding: 2}}>
|
<Grid container spacing={2} sx={{ padding: 2 }}>
|
||||||
<Grid item xs={12} sm={6}>
|
<Grid item xs={12} sm={6}>
|
||||||
<SelectBox
|
<SelectBox
|
||||||
name="vehicle_type"
|
name="vehicle_type"
|
||||||
label={t("LoanRequest.text_field_vehicle_type")}
|
label={t("LoanRequest.text_field_vehicle_type")}
|
||||||
size="small"
|
size="small"
|
||||||
value={formik.values.vehicle_type}
|
value={formik.values.vehicle_type}
|
||||||
schema={{value: 'value', name: 'name'}}
|
schema={{ value: "value", name: "name" }}
|
||||||
selectType="vehicle_type"
|
selectType="vehicle_type"
|
||||||
selectors={[{
|
selectors={[
|
||||||
id: 0, value: "اتوبوس", name: "اتوبوس"
|
{
|
||||||
}, {
|
id: 0,
|
||||||
id: 1, value: "مینی بوس", name: "مینی بوس"
|
value: "اتوبوس",
|
||||||
}]}
|
name: "اتوبوس",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
value: "مینی بوس",
|
||||||
|
name: "مینی بوس",
|
||||||
|
},
|
||||||
|
]}
|
||||||
select={formik.values.vehicle_type}
|
select={formik.values.vehicle_type}
|
||||||
handleChange={(event) => formik.setFieldValue('vehicle_type', event.target.value)}
|
handleChange={(event) => formik.setFieldValue("vehicle_type", event.target.value)}
|
||||||
error={formik.touched.vehicle_type && Boolean(formik.errors.vehicle_type)}
|
error={formik.touched.vehicle_type && Boolean(formik.errors.vehicle_type)}
|
||||||
helperText={formik.touched.vehicle_type && formik.errors.vehicle_type}
|
helperText={formik.touched.vehicle_type && formik.errors.vehicle_type}
|
||||||
onBlur={formik.handleBlur("vehicle_type")}
|
onBlur={formik.handleBlur("vehicle_type")}
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item xs={12} sm={6}>
|
<Grid item xs={12} sm={6}>
|
||||||
<PlateNumber formik={formik}/>
|
<PlateNumber formik={formik} />
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid container spacing={2} sx={{padding: 2}}>
|
<Grid container spacing={2} sx={{ padding: 2 }}>
|
||||||
<Grid item xs={12} sm={6}>
|
<Grid item xs={12} sm={6}>
|
||||||
<SelectBox
|
<SelectBox
|
||||||
name="education_id"
|
name="education_id"
|
||||||
@@ -591,9 +680,9 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
selectors={educationsList}
|
selectors={educationsList}
|
||||||
select={formik.values.education_id}
|
select={formik.values.education_id}
|
||||||
value={formik.values.education_id}
|
value={formik.values.education_id}
|
||||||
schema={{value: 'id', name: 'title'}}
|
schema={{ value: "id", name: "title" }}
|
||||||
handleChange={(event) => {
|
handleChange={(event) => {
|
||||||
formik.setFieldValue('education_id', event.target.value)
|
formik.setFieldValue("education_id", event.target.value);
|
||||||
}}
|
}}
|
||||||
setFieldTouched={formik.setFieldTouched}
|
setFieldTouched={formik.setFieldTouched}
|
||||||
error={formik.touched.education_id && Boolean(formik.errors.education_id)}
|
error={formik.touched.education_id && Boolean(formik.errors.education_id)}
|
||||||
@@ -609,12 +698,12 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
isLoading={isLoadingOccupationsList}
|
isLoading={isLoadingOccupationsList}
|
||||||
errorEcured={errorOccupationsList}
|
errorEcured={errorOccupationsList}
|
||||||
selectType="occupation_id"
|
selectType="occupation_id"
|
||||||
schema={{value: 'id', name: 'title'}}
|
schema={{ value: "id", name: "title" }}
|
||||||
selectors={occupationsList}
|
selectors={occupationsList}
|
||||||
select={formik.values.occupation_id}
|
select={formik.values.occupation_id}
|
||||||
value={formik.values.occupation_id}
|
value={formik.values.occupation_id}
|
||||||
handleChange={(event) => {
|
handleChange={(event) => {
|
||||||
formik.setFieldValue('occupation_id', event.target.value)
|
formik.setFieldValue("occupation_id", event.target.value);
|
||||||
}}
|
}}
|
||||||
setFieldTouched={formik.setFieldTouched}
|
setFieldTouched={formik.setFieldTouched}
|
||||||
error={formik.touched.occupation_id && Boolean(formik.errors.occupation_id)}
|
error={formik.touched.occupation_id && Boolean(formik.errors.occupation_id)}
|
||||||
@@ -623,12 +712,12 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid container spacing={2} sx={{padding: 2}}>
|
<Grid container spacing={2} sx={{ padding: 2 }}>
|
||||||
<Grid item xs={12}>
|
<Grid item xs={12}>
|
||||||
<TextField
|
<TextField
|
||||||
multiline
|
multiline
|
||||||
rows={4}
|
rows={4}
|
||||||
sx={{width: "100%"}}
|
sx={{ width: "100%" }}
|
||||||
name="address"
|
name="address"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
size="small"
|
size="small"
|
||||||
@@ -643,27 +732,29 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid container spacing={2} sx={{padding: 2}}>
|
<Grid container spacing={2} sx={{ padding: 2 }}>
|
||||||
<Grid item xs={12}>
|
<Grid item xs={12}>
|
||||||
<FormControlLabel
|
<FormControlLabel
|
||||||
color={'error.main'}
|
color={"error.main"}
|
||||||
control={<Checkbox
|
control={
|
||||||
checked={formik.values.checkedBox}
|
<Checkbox
|
||||||
onChange={(event) => {
|
checked={formik.values.checkedBox}
|
||||||
formik.setFieldValue("checkedBox", event.target.checked)
|
onChange={(event) => {
|
||||||
}}
|
formik.setFieldValue("checkedBox", event.target.checked);
|
||||||
/>}
|
}}
|
||||||
label={`${t("LoanRequest.checkbox")}`}/>
|
/>
|
||||||
|
}
|
||||||
|
label={`${t("LoanRequest.checkbox")}`}
|
||||||
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
display: "flex",
|
display: "flex",
|
||||||
flexDirection: {xs: "column", sm: "row"},
|
flexDirection: { xs: "column", sm: "row" },
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
mx: "auto",
|
mx: "auto",
|
||||||
width: {xs: "100%", sm: "30%", md: "25%"},
|
width: { xs: "100%", sm: "30%", md: "25%" },
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Button
|
<Button
|
||||||
@@ -672,15 +763,14 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
type="submit"
|
type="submit"
|
||||||
variant="contained"
|
variant="contained"
|
||||||
size="large"
|
size="large"
|
||||||
sx={{my: 4}}
|
sx={{ my: 4 }}
|
||||||
endIcon={<DataSaverOnIcon/>}
|
endIcon={<DataSaverOnIcon />}
|
||||||
disabled={formik.values.checkedBox ? (formik.isSubmitting || !formik.dirty || !formik.isValid) : true}
|
disabled={formik.values.checkedBox ? formik.isSubmitting || !formik.dirty || !formik.isValid : true}
|
||||||
>
|
>
|
||||||
|
|
||||||
{formik.isSubmitting ? t("LoanRequest.button_while_submit") : t("LoanRequest.button_submit")}
|
{formik.isSubmitting ? t("LoanRequest.button_while_submit") : t("LoanRequest.button_submit")}
|
||||||
</Button>
|
</Button>
|
||||||
</Box>
|
</Box>
|
||||||
</>
|
</>
|
||||||
)
|
);
|
||||||
}
|
};
|
||||||
export default RealPersonForm
|
export default RealPersonForm;
|
||||||
|
|||||||
@@ -1,34 +1,36 @@
|
|||||||
import {GET_PROJECT_TITLE} from "@/core/data/apiRoutes";
|
import { GET_PROJECT_TITLE } from "@/core/data/apiRoutes";
|
||||||
import {useRequest} from "@witel/webapp-builder";
|
import { useRequest } from "@witel/webapp-builder";
|
||||||
import {useEffect, useState} from "react";
|
import { useEffect, useState } from "react";
|
||||||
|
|
||||||
const useProjectTitle = () => {
|
const useProjectTitle = () => {
|
||||||
const [isLoadingProjectTitle, setIsLoadingProjectTitle] = useState(false)
|
const [isLoadingProjectTitle, setIsLoadingProjectTitle] = useState(false);
|
||||||
const [errorProjectTitle, setErrorProjectTitle] = useState(false)
|
const [errorProjectTitle, setErrorProjectTitle] = useState(false);
|
||||||
const [projectTitle, setProjectTitle] = useState([])
|
const [projectTitle, setProjectTitle] = useState([]);
|
||||||
const requestServer = useRequest({auth: true, notification: false})
|
const requestServer = useRequest({ auth: true, notification: false });
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setIsLoadingProjectTitle(true)
|
setIsLoadingProjectTitle(true);
|
||||||
requestServer(GET_PROJECT_TITLE, 'get', {auth: true, notification: false}).then(({data}) => {
|
requestServer(GET_PROJECT_TITLE, "get", { auth: true, notification: false })
|
||||||
const formattedData = data.data.map((projectTitle, index) => ({
|
.then(({ data }) => {
|
||||||
id: index,
|
const formattedData = data.data.map((projectTitle, index) => ({
|
||||||
name: projectTitle.title,
|
id: index,
|
||||||
value: projectTitle.id,
|
name: projectTitle.title,
|
||||||
}));
|
value: projectTitle.id,
|
||||||
setIsLoadingProjectTitle(false)
|
}));
|
||||||
setProjectTitle(formattedData);
|
setIsLoadingProjectTitle(false);
|
||||||
}).catch(() => {
|
setProjectTitle(formattedData);
|
||||||
setIsLoadingProjectTitle(false)
|
})
|
||||||
setErrorProjectTitle(true)
|
.catch(() => {
|
||||||
})
|
setIsLoadingProjectTitle(false);
|
||||||
}, [])
|
setErrorProjectTitle(true);
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
projectTitle,
|
projectTitle,
|
||||||
isLoadingProjectTitle,
|
isLoadingProjectTitle,
|
||||||
errorProjectTitle
|
errorProjectTitle,
|
||||||
}
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export default useProjectTitle;
|
export default useProjectTitle;
|
||||||
|
|||||||
Reference in New Issue
Block a user