Merge branch 'release/v2.0.3'
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
NEXT_PUBLIC_API_NAME = "Loan Facilities Dashboard"
|
||||
NEXT_PUBLIC_API_VERSION = "2.0.0"
|
||||
NEXT_PUBLIC_API_VERSION = "2.0.3"
|
||||
NEXT_PUBLIC_DEFAULT_LANGUAGE = "fa"
|
||||
NEXT_PUBLIC_DEFAULT_DIRECTION = "rtl"
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
"@mui/lab": "^5.0.0-alpha.152",
|
||||
"@mui/material": "^5.12.0",
|
||||
"@mui/x-date-pickers": "^6.18.5",
|
||||
"@witel/webapp-builder": "^1.3.4",
|
||||
"@witel/webapp-builder": "^1.4.0",
|
||||
"axios": "^1.4.0",
|
||||
"colord": "^2.9.3",
|
||||
"date-fns-jalali": "^2.13.0-0",
|
||||
|
||||
@@ -161,6 +161,9 @@
|
||||
"national_number_number": "شناسه ملی شرکت می بایست شامل اعداد باشد",
|
||||
"national_code_max": "کد ملی می بایست 10 رقم باشد",
|
||||
"national_serial_number_max": "سریال پشت کارت ملی می بایست 10 رقم باشد",
|
||||
"boss_national_serial_number_max": "سریال پشت کارت ملی مدیر عامل می بایست 10 رقم باشد",
|
||||
"national_tracking_code_max": "کد رهگیری کارت ملی می بایست 10 رقم باشد",
|
||||
"national_boss_tracking_code_max": "کد رهگیری کارت ملی مدیر عامل می بایست 10 رقم باشد",
|
||||
"boss_national_code_max": "کد ملی مدیر عامل می بایست 10 رقم باشد",
|
||||
"national_number_max": "شناسه ملی شرکت می بایست 11 رقم باشد",
|
||||
"shenasname_serial_max": "سریال پشت کارت ملی می بایست شامل 10 بخش باشد",
|
||||
@@ -196,6 +199,7 @@
|
||||
"error_message_national_number": "لطفا شناسه ملی شرکت خود را وارد کنید!",
|
||||
"error_message_date_of_birth": "لطفا تاریخ تولد خود را وارد کنید!",
|
||||
"error_message_shenasname_serial": "لطفا سریال پشت کارت ملی خود را وارد کنید!",
|
||||
"error_message_boss_shenasname_serial": "لطفا سریال پشت کارت ملی مدیر عامل را وارد کنید!",
|
||||
"error_message_boss_national_serial_number": "لطفا سریال پشت کارت ملی مدیر عامل را وارد کنید!",
|
||||
"error_message_tracking_code": "لطفا کد رهگیری کارت ملی خود را وارد کنید!",
|
||||
"error_message_boss_national_card_tracking_code": "لطفا کد رهگیری کارت ملی مدیر عامل را وارد کنید!",
|
||||
|
||||
@@ -18,7 +18,7 @@ const FirstComponent = () => {
|
||||
<Typography>{t("Dashboard.go_to_add_request_loan")}</Typography>
|
||||
<Button
|
||||
component={NextLinkComposed}
|
||||
to={{ pathname: "/dashboard/navgan/past-add-request-loan" }}
|
||||
to={{ pathname: "/dashboard/navgan/add-request-loan" }}
|
||||
variant={"contained"}
|
||||
size={"large"}
|
||||
>
|
||||
|
||||
@@ -1,4 +1,13 @@
|
||||
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 {useTranslations} from "next-intl";
|
||||
import useCities from "@/lib/app/hooks/useCities";
|
||||
import UseEducations from "@/lib/app/hooks/useEducations";
|
||||
@@ -20,15 +29,16 @@ import usePriorityLists from "@/lib/app/hooks/usePriorityLists";
|
||||
|
||||
const LegalPersonForm = ({setFinishLoanRequest}) => {
|
||||
const t = useTranslations();
|
||||
const router = useRouter()
|
||||
const requestServer = useRequest()
|
||||
const {getUser, changeUser} = useUser()
|
||||
const {cityTextField, cityList, setProvinceID, isLoadingCityList} = useCities()
|
||||
const {provinceList, isLoadingProvinceList, errorProvinceList} = useLimitedProvince()
|
||||
const {educationsList, isLoadingEducationsList, errorEducationsList} = UseEducations()
|
||||
const {occupationsList, isLoadingOccupationsList, errorOccupationsList} = useOccupations()
|
||||
const {activityType, isLoadingActivityType, errorActivityType} = useActivityType()
|
||||
const {priorityLists, isLoadingPriorityLists, errorPriorityLists} = usePriorityLists()
|
||||
const router = useRouter();
|
||||
const requestServer = useRequest();
|
||||
const {getUser, changeUser} = useUser();
|
||||
const {cityTextField, cityList, setProvinceID, isLoadingCityList} = useCities();
|
||||
const {provinceList, isLoadingProvinceList, errorProvinceList} = useLimitedProvince();
|
||||
const {educationsList, isLoadingEducationsList, errorEducationsList} = UseEducations();
|
||||
const {occupationsList, isLoadingOccupationsList, errorOccupationsList} = useOccupations();
|
||||
const {activityType, isLoadingActivityType, errorActivityType} = useActivityType();
|
||||
const {priorityLists, isLoadingPriorityLists, errorPriorityLists} = usePriorityLists();
|
||||
const {projectTitle, isLoadingProjectTitle, errorProjectTitle} = useProjectTitle();
|
||||
|
||||
const initialValues = {
|
||||
person_type: "legal",
|
||||
@@ -39,7 +49,7 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
||||
vehicle_type: "",
|
||||
province_id: "",
|
||||
boss_father_name: "",
|
||||
company_postal_code : "",
|
||||
company_postal_code: "",
|
||||
register_number: "",
|
||||
boss_gender: "",
|
||||
boss_first_name: "",
|
||||
@@ -68,7 +78,7 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
||||
company_tel_number: Yup.mixed()
|
||||
.test("max", `${t("LoanRequest.company_tel_number_max")}`, (value) => {
|
||||
const stringValue = String(value);
|
||||
return stringValue.length === 11
|
||||
return stringValue.length === 11;
|
||||
})
|
||||
.required(t("LoanRequest.error_message_company_tel_number")),
|
||||
vehicle_type: Yup.string().required(t("LoanRequest.error_message_vehicle_type")),
|
||||
@@ -87,13 +97,15 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
||||
company_postal_code: Yup.mixed()
|
||||
.test("max", `${t("LoanRequest.company_postal_code_max")}`, (value) => value.toString().length === 10)
|
||||
.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")),
|
||||
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")),
|
||||
plate_part3: Yup.mixed().test("max", `${t("LoanRequest.error_message_plate_number")}`, (value) => value.toString().length === 3)
|
||||
.required(t("LoanRequest.error_message_plate_number")),
|
||||
plate_part4: Yup.mixed().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")),
|
||||
navgan_id: Yup.mixed().required(t("LoanRequest.error_message_navgan_id")),
|
||||
province_id: Yup.string().required(t("LoanRequest.error_message_province_id")),
|
||||
@@ -105,99 +117,139 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
||||
.test("positive", `${t("LoanRequest.boss_national_code_positive")}`, (value) => value >= 0)
|
||||
.test("max", `${t("LoanRequest.boss_national_code_max")}`, (value) => value.toString().length === 10)
|
||||
.required(t("LoanRequest.error_message_national_id")),
|
||||
national_number: Yup.mixed().when('person_type', ([person_type], schema) => {
|
||||
return person_type === 'legal' ? schema
|
||||
.test("is-number", `${t("LoanRequest.national_number_number")}`, (value) => !isNaN(value))
|
||||
.test("positive", `${t("LoanRequest.national_number_positive")}`, (value) => value >= 0)
|
||||
.test("max", `${t("LoanRequest.national_number_max")}`, (value) => value && value.toString().length === 11)
|
||||
.required(t("LoanRequest.error_message_national_number")) : schema;
|
||||
national_number: Yup.mixed().when("person_type", ([person_type], schema) => {
|
||||
return person_type === "legal"
|
||||
? schema
|
||||
.test("is-number", `${t("LoanRequest.national_number_number")}`, (value) => !isNaN(value))
|
||||
.test("positive", `${t("LoanRequest.national_number_positive")}`, (value) => value >= 0)
|
||||
.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) => {
|
||||
return national_serial_number_or_tracking_code === 'national_serial_number' ? schema.required(t("LoanRequest.error_message_boss_national_serial_number")) : 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
|
||||
})
|
||||
boss_national_serial_number: Yup.string()
|
||||
.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.test(
|
||||
"max",
|
||||
`${t("LoanRequest.boss_national_serial_number_max")}`,
|
||||
(value) => value && value.toString().length === 10
|
||||
).required(t("LoanRequest.error_message_boss_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.test(
|
||||
"max",
|
||||
`${t("LoanRequest.national_boss_tracking_code_max")}`,
|
||||
(value) => value && value.toString().length === 10
|
||||
).required(t("LoanRequest.error_message_boss_national_card_tracking_code"))
|
||||
: schema;
|
||||
}
|
||||
),
|
||||
});
|
||||
|
||||
const handleSubmit = async (values, props) => {
|
||||
props.setSubmitting(true)
|
||||
let _national_number = values.person_type === "legal" ? {
|
||||
shenase_meli: values.national_number
|
||||
} : {}
|
||||
props.setSubmitting(true);
|
||||
let _national_number =
|
||||
values.person_type === "legal"
|
||||
? {
|
||||
shenase_meli: values.national_number,
|
||||
}
|
||||
: {};
|
||||
|
||||
const _national_card = values.national_serial_number_or_tracking_code === "national_serial_number" ? {
|
||||
national_serial_number: values.national_serial_number
|
||||
} : {
|
||||
national_tracking_code: values.national_card_tracking_code
|
||||
}
|
||||
const _national_card =
|
||||
values.national_serial_number_or_tracking_code === "national_serial_number"
|
||||
? {
|
||||
national_serial_number: values.boss_national_serial_number,
|
||||
}
|
||||
: {
|
||||
national_tracking_code: values.boss_national_card_tracking_code,
|
||||
};
|
||||
|
||||
let _data = {
|
||||
is_legal_person: values.person_type === 'legal' ? 1 : 0,
|
||||
is_legal_person: 1,
|
||||
telephone_number: values.company_tel_number,
|
||||
register_number: values.register_number,
|
||||
national_code: values.boss_national_code,
|
||||
national_id: values.boss_national_code,
|
||||
vehicle_type: values.vehicle_type,
|
||||
company_name: values.company_name,
|
||||
province_id: values.province_id,
|
||||
father_name: values.father_name,
|
||||
first_name: values.first_name,
|
||||
last_name: values.last_name,
|
||||
city_id: values.city_id,
|
||||
father_name: values.boss_father_name,
|
||||
first_name: values.boss_first_name,
|
||||
last_name: values.boss_last_name,
|
||||
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,
|
||||
gender: values.gender,
|
||||
gender: values.boss_gender,
|
||||
plate_part1: values.plate_part1,
|
||||
plate_part2: values.plate_part2,
|
||||
plate_part3: values.plate_part3,
|
||||
plate_part4: values.plate_part4,
|
||||
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,
|
||||
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", {
|
||||
auth: true, notification: true, data: _data
|
||||
}).then(() => {
|
||||
router.replace('/dashboard/navgan/followUp-loan')
|
||||
getUser((data) => {
|
||||
changeUser(data);
|
||||
});
|
||||
}).catch(() => {
|
||||
}).finally(() => {
|
||||
props.setSubmitting(false)
|
||||
auth: true,
|
||||
notification: true,
|
||||
data: _data,
|
||||
})
|
||||
.then(() => {
|
||||
router.replace("/dashboard/navgan/followUp-loan");
|
||||
getUser((data) => {
|
||||
changeUser(data);
|
||||
});
|
||||
})
|
||||
.catch(() => {
|
||||
})
|
||||
.finally(() => {
|
||||
props.setSubmitting(false);
|
||||
});
|
||||
};
|
||||
|
||||
const formik = useFormik({
|
||||
initialValues, validationSchema, onSubmit: handleSubmit
|
||||
})
|
||||
initialValues,
|
||||
validationSchema,
|
||||
onSubmit: handleSubmit,
|
||||
});
|
||||
return (
|
||||
<>
|
||||
<Grid container spacing={2} sx={{p: 2}}>
|
||||
{/*<Grid item xs={12} sm={4}>*/}
|
||||
{/* <SelectBox*/}
|
||||
{/* name="project_title"*/}
|
||||
{/* label={t("LoanRequest.text_field_project_title")}*/}
|
||||
{/* size="small"*/}
|
||||
{/* selectType="project_title"*/}
|
||||
{/* isLoading={isLoadingProjectTitle}*/}
|
||||
{/* errorEcured={errorProjectTitle}*/}
|
||||
{/* selectors={projectTitle}*/}
|
||||
{/* schema={{value: 'value', name: 'name'}}*/}
|
||||
{/* select={formik.values.project_title}*/}
|
||||
{/* value={formik.values.project_title}*/}
|
||||
{/* handleChange={(event) => {*/}
|
||||
{/* formik.setFieldValue('project_title', event.target.value)*/}
|
||||
{/* }}*/}
|
||||
{/* setFieldTouched={formik.setFieldTouched}*/}
|
||||
{/* error={formik.touched.project_title && Boolean(formik.errors.project_title)}*/}
|
||||
{/* helperText={formik.touched.project_title && formik.errors.project_title}*/}
|
||||
{/* onBlur={formik.handleBlur("project_title")}*/}
|
||||
{/* />*/}
|
||||
{/*</Grid>*/}
|
||||
<Grid item xs={12} sm={4}>
|
||||
<SelectBox
|
||||
name="project_title"
|
||||
label={t("LoanRequest.text_field_project_title")}
|
||||
size="small"
|
||||
selectType="project_title"
|
||||
isLoading={isLoadingProjectTitle}
|
||||
errorEcured={errorProjectTitle}
|
||||
selectors={projectTitle}
|
||||
schema={{value: "name", name: "name"}}
|
||||
select={formik.values.project_title}
|
||||
value={formik.values.project_title}
|
||||
handleChange={(event) => {
|
||||
formik.setFieldValue("project_title", event.target.value);
|
||||
}}
|
||||
setFieldTouched={formik.setFieldTouched}
|
||||
error={formik.touched.project_title && Boolean(formik.errors.project_title)}
|
||||
helperText={formik.touched.project_title && formik.errors.project_title}
|
||||
onBlur={formik.handleBlur("project_title")}
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={12} sm={4}>
|
||||
<SelectBox
|
||||
name="activity_type"
|
||||
@@ -207,11 +259,11 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
||||
isLoading={isLoadingActivityType}
|
||||
errorEcured={errorActivityType}
|
||||
selectors={activityType}
|
||||
schema={{value: 'value', name: 'name'}}
|
||||
schema={{value: "value", name: "name"}}
|
||||
select={formik.values.activity_type}
|
||||
value={formik.values.activity_type}
|
||||
handleChange={(event) => {
|
||||
formik.setFieldValue('activity_type', event.target.value)
|
||||
formik.setFieldValue("activity_type", event.target.value);
|
||||
}}
|
||||
setFieldTouched={formik.setFieldTouched}
|
||||
error={formik.touched.activity_type && Boolean(formik.errors.activity_type)}
|
||||
@@ -228,11 +280,11 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
||||
isLoading={isLoadingPriorityLists}
|
||||
errorEcured={errorPriorityLists}
|
||||
selectors={priorityLists}
|
||||
schema={{value: 'value', name: 'name'}}
|
||||
schema={{value: "value", name: "name"}}
|
||||
select={formik.values.priority_list}
|
||||
value={formik.values.priority_list}
|
||||
handleChange={(event) => {
|
||||
formik.setFieldValue('priority_list', event.target.value)
|
||||
formik.setFieldValue("priority_list", event.target.value);
|
||||
}}
|
||||
setFieldTouched={formik.setFieldTouched}
|
||||
error={formik.touched.priority_list && Boolean(formik.errors.priority_list)}
|
||||
@@ -249,8 +301,8 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
||||
variant="outlined"
|
||||
size="small"
|
||||
value={formik.values.national_number}
|
||||
inputProps={{inputMode: 'numeric', pattern: '[0-9]*'}}
|
||||
type={'tel'}
|
||||
inputProps={{inputMode: "numeric", pattern: "[0-9]*"}}
|
||||
type={"tel"}
|
||||
onChange={(event) => {
|
||||
const inputValue = event.target.value;
|
||||
if (isNaN(Number(inputValue))) {
|
||||
@@ -258,7 +310,8 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
||||
}
|
||||
formik.handleChange({
|
||||
target: {
|
||||
name: "national_number", value: inputValue,
|
||||
name: "national_number",
|
||||
value: inputValue,
|
||||
},
|
||||
});
|
||||
}}
|
||||
@@ -293,8 +346,8 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
||||
variant="outlined"
|
||||
size="small"
|
||||
value={formik.values.register_number}
|
||||
inputProps={{inputMode: 'numeric', pattern: '[0-9]*'}}
|
||||
type={'tel'}
|
||||
inputProps={{inputMode: "numeric", pattern: "[0-9]*"}}
|
||||
type={"tel"}
|
||||
onChange={(event) => {
|
||||
const inputValue = event.target.value;
|
||||
if (isNaN(Number(inputValue))) {
|
||||
@@ -302,7 +355,8 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
||||
}
|
||||
formik.handleChange({
|
||||
target: {
|
||||
name: "register_number", value: inputValue,
|
||||
name: "register_number",
|
||||
value: inputValue,
|
||||
},
|
||||
});
|
||||
}}
|
||||
@@ -322,8 +376,8 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
||||
name="company_postal_code"
|
||||
variant="outlined"
|
||||
value={formik.values.company_postal_code}
|
||||
inputProps={{inputMode: 'numeric', pattern: '[0-9]*'}}
|
||||
type={'tel'}
|
||||
inputProps={{inputMode: "numeric", pattern: "[0-9]*"}}
|
||||
type={"tel"}
|
||||
onChange={(event) => {
|
||||
const inputValue = event.target.value;
|
||||
if (isNaN(Number(inputValue))) {
|
||||
@@ -331,7 +385,8 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
||||
}
|
||||
formik.handleChange({
|
||||
target: {
|
||||
name: "company_postal_code", value: inputValue,
|
||||
name: "company_postal_code",
|
||||
value: inputValue,
|
||||
},
|
||||
});
|
||||
}}
|
||||
@@ -350,8 +405,8 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
||||
name="company_tel_number"
|
||||
variant="outlined"
|
||||
value={formik.values.company_tel_number}
|
||||
inputProps={{inputMode: 'numeric', pattern: '[0-9]*'}}
|
||||
type={'tel'}
|
||||
inputProps={{inputMode: "numeric", pattern: "[0-9]*"}}
|
||||
type={"tel"}
|
||||
size="small"
|
||||
onChange={(event) => {
|
||||
const inputValue = event.target.value;
|
||||
@@ -360,7 +415,8 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
||||
}
|
||||
formik.handleChange({
|
||||
target: {
|
||||
name: "company_tel_number", value: inputValue,
|
||||
name: "company_tel_number",
|
||||
value: inputValue,
|
||||
},
|
||||
});
|
||||
}}
|
||||
@@ -391,14 +447,14 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
||||
isLoading={isLoadingProvinceList}
|
||||
errorEcured={errorProvinceList}
|
||||
selectors={provinceList}
|
||||
schema={{value: 'value', name: 'name'}}
|
||||
schema={{value: "value", name: "name"}}
|
||||
select={formik.values.province_id}
|
||||
value={formik.values.province_id}
|
||||
handleChange={(event) => {
|
||||
formik.setFieldValue('province_id', event.target.value);
|
||||
setProvinceID(event.target.value)
|
||||
formik.setFieldValue("province_id", event.target.value);
|
||||
setProvinceID(event.target.value);
|
||||
formik.setFieldTouched("city_id", false, false);
|
||||
formik.setFieldValue("city_id", "")
|
||||
formik.setFieldValue("city_id", "");
|
||||
}}
|
||||
setFieldTouched={formik.setFieldTouched}
|
||||
error={formik.touched.province_id && Boolean(formik.errors.province_id)}
|
||||
@@ -409,15 +465,21 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
||||
<Grid item xs={12} sm={6}>
|
||||
<SelectBox
|
||||
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"
|
||||
selectType="city_id"
|
||||
schema={{value: 'value', name: 'name'}}
|
||||
schema={{value: "value", name: "name"}}
|
||||
disabled={cityList.length === 0}
|
||||
selectors={cityList}
|
||||
select={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}
|
||||
error={formik.touched.city_id && Boolean(formik.errors.city_id)}
|
||||
helperText={formik.touched.city_id && formik.errors.city_id}
|
||||
@@ -433,8 +495,8 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
||||
variant="outlined"
|
||||
size="small"
|
||||
value={formik.values.boss_national_code}
|
||||
inputProps={{inputMode: 'numeric', pattern: '[0-9]*'}}
|
||||
type={'tel'}
|
||||
inputProps={{inputMode: "numeric", pattern: "[0-9]*"}}
|
||||
type={"tel"}
|
||||
onChange={(event) => {
|
||||
const inputValue = event.target.value;
|
||||
if (isNaN(Number(inputValue))) {
|
||||
@@ -442,7 +504,8 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
||||
}
|
||||
formik.handleChange({
|
||||
target: {
|
||||
name: "boss_national_code", value: inputValue,
|
||||
name: "boss_national_code",
|
||||
value: inputValue,
|
||||
},
|
||||
});
|
||||
}}
|
||||
@@ -461,15 +524,22 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
||||
size="small"
|
||||
value={formik.values.boss_gender}
|
||||
selectType="boss_gender"
|
||||
selectors={[{
|
||||
id: 1, value: 1, name: "زن"
|
||||
}, {
|
||||
id: 2, value: 0, name: "مرد"
|
||||
}]}
|
||||
schema={{value: 'value', name: 'name'}}
|
||||
selectors={[
|
||||
{
|
||||
id: 1,
|
||||
value: 1,
|
||||
name: "زن",
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
value: 0,
|
||||
name: "مرد",
|
||||
},
|
||||
]}
|
||||
schema={{value: "value", name: "name"}}
|
||||
select={formik.values.boss_gender}
|
||||
handleChange={(event) => {
|
||||
formik.setFieldValue('boss_gender', event.target.value)
|
||||
formik.setFieldValue("boss_gender", event.target.value);
|
||||
}}
|
||||
setFieldTouched={formik.setFieldTouched}
|
||||
error={formik.touched.boss_gender && Boolean(formik.errors.boss_gender)}
|
||||
@@ -517,16 +587,17 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
||||
<ToggleButtonGroup
|
||||
color="primary"
|
||||
fullWidth
|
||||
size={'small'}
|
||||
size={"small"}
|
||||
value={formik.values.national_serial_number_or_tracking_code}
|
||||
exclusive
|
||||
onChange={(e, value) => {
|
||||
if (value === null) return
|
||||
if (value === null) return;
|
||||
formik.handleChange({
|
||||
target: {
|
||||
name: "national_serial_number_or_tracking_code", value: value,
|
||||
name: "national_serial_number_or_tracking_code",
|
||||
value: value,
|
||||
},
|
||||
})
|
||||
});
|
||||
}}
|
||||
>
|
||||
<ToggleButton value="national_serial_number">
|
||||
@@ -537,9 +608,8 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
||||
</ToggleButton>
|
||||
</ToggleButtonGroup>
|
||||
</Grid>
|
||||
{formik.values.national_serial_number_or_tracking_code === 'national_serial_number' ? (
|
||||
<Grid item xs={12} sm={4}
|
||||
>
|
||||
{formik.values.national_serial_number_or_tracking_code === "national_serial_number" ? (
|
||||
<Grid item xs={12} sm={4}>
|
||||
<TextField
|
||||
sx={{width: "100%"}}
|
||||
name="boss_national_serial_number"
|
||||
@@ -551,10 +621,16 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
||||
fullWidth
|
||||
onChange={formik.handleChange}
|
||||
onBlur={formik.handleBlur("boss_national_serial_number")}
|
||||
error={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}
|
||||
error={
|
||||
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}>
|
||||
<TextField
|
||||
sx={{width: "100%"}}
|
||||
@@ -567,8 +643,14 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
||||
fullWidth
|
||||
onChange={formik.handleChange}
|
||||
onBlur={formik.handleBlur("boss_national_card_tracking_code")}
|
||||
error={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}
|
||||
error={
|
||||
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>
|
||||
)}
|
||||
@@ -597,17 +679,27 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
||||
size="small"
|
||||
value={formik.values.navgan_type}
|
||||
selectType="navgan_type"
|
||||
selectors={[{
|
||||
id: 1, value: "روستایی", name: "روستایی"
|
||||
}, {
|
||||
id: 2, value: "عمومی", name: "عمومی"
|
||||
}, {
|
||||
id: 3, value: "منطقه آزاد", name: "منطقه آزاد"
|
||||
}]}
|
||||
schema={{value: 'value', name: 'name'}}
|
||||
selectors={[
|
||||
{
|
||||
id: 1,
|
||||
value: "روستایی",
|
||||
name: "روستایی",
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
value: "عمومی",
|
||||
name: "عمومی",
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
value: "منطقه آزاد",
|
||||
name: "منطقه آزاد",
|
||||
},
|
||||
]}
|
||||
schema={{value: "value", name: "name"}}
|
||||
select={formik.values.navgan_type}
|
||||
handleChange={(event) => {
|
||||
formik.setFieldValue('navgan_type', event.target.value)
|
||||
formik.setFieldValue("navgan_type", event.target.value);
|
||||
}}
|
||||
setFieldTouched={formik.setFieldTouched}
|
||||
error={formik.touched.navgan_type && Boolean(formik.errors.navgan_type)}
|
||||
@@ -620,8 +712,8 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
||||
sx={{width: "100%"}}
|
||||
name="navgan_id"
|
||||
variant="outlined"
|
||||
inputProps={{inputMode: 'numeric', pattern: '[0-9]*'}}
|
||||
type={'tel'}
|
||||
inputProps={{inputMode: "numeric", pattern: "[0-9]*"}}
|
||||
type={"tel"}
|
||||
value={formik.values.navgan_id}
|
||||
onChange={formik.handleChange}
|
||||
size="small"
|
||||
@@ -641,15 +733,22 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
||||
label={t("LoanRequest.text_field_vehicle_type")}
|
||||
size="small"
|
||||
value={formik.values.vehicle_type}
|
||||
schema={{value: 'value', name: 'name'}}
|
||||
schema={{value: "value", name: "name"}}
|
||||
selectType="vehicle_type"
|
||||
selectors={[{
|
||||
id: 0, value: "اتوبوس", name: "اتوبوس"
|
||||
}, {
|
||||
id: 1, value: "مینی بوس", name: "مینی بوس"
|
||||
}]}
|
||||
selectors={[
|
||||
{
|
||||
id: 0,
|
||||
value: "اتوبوس",
|
||||
name: "اتوبوس",
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
value: "مینی بوس",
|
||||
name: "مینی بوس",
|
||||
},
|
||||
]}
|
||||
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)}
|
||||
helperText={formik.touched.vehicle_type && formik.errors.vehicle_type}
|
||||
onBlur={formik.handleBlur("vehicle_type")}
|
||||
@@ -671,9 +770,9 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
||||
selectors={educationsList}
|
||||
select={formik.values.education_id}
|
||||
value={formik.values.education_id}
|
||||
schema={{value: 'id', name: 'title'}}
|
||||
schema={{value: "id", name: "title"}}
|
||||
handleChange={(event) => {
|
||||
formik.setFieldValue('education_id', event.target.value)
|
||||
formik.setFieldValue("education_id", event.target.value);
|
||||
}}
|
||||
setFieldTouched={formik.setFieldTouched}
|
||||
error={formik.touched.education_id && Boolean(formik.errors.education_id)}
|
||||
@@ -689,12 +788,12 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
||||
isLoading={isLoadingOccupationsList}
|
||||
errorEcured={errorOccupationsList}
|
||||
selectType="occupation_id"
|
||||
schema={{value: 'id', name: 'title'}}
|
||||
schema={{value: "id", name: "title"}}
|
||||
selectors={occupationsList}
|
||||
select={formik.values.occupation_id}
|
||||
value={formik.values.occupation_id}
|
||||
handleChange={(event) => {
|
||||
formik.setFieldValue('occupation_id', event.target.value)
|
||||
formik.setFieldValue("occupation_id", event.target.value);
|
||||
}}
|
||||
setFieldTouched={formik.setFieldTouched}
|
||||
error={formik.touched.occupation_id && Boolean(formik.errors.occupation_id)}
|
||||
@@ -726,15 +825,17 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
||||
<Grid container spacing={2} sx={{padding: 2}}>
|
||||
<Grid item xs={12}>
|
||||
<FormControlLabel
|
||||
color={'error.main'}
|
||||
control={<Checkbox
|
||||
checked={formik.values.checkedBox}
|
||||
onChange={(event) => {
|
||||
formik.setFieldValue("checkedBox", event.target.checked)
|
||||
}}
|
||||
/>}
|
||||
label={`${t("LoanRequest.checkbox")}`}/>
|
||||
|
||||
color={"error.main"}
|
||||
control={
|
||||
<Checkbox
|
||||
checked={formik.values.checkedBox}
|
||||
onChange={(event) => {
|
||||
formik.setFieldValue("checkedBox", event.target.checked);
|
||||
}}
|
||||
/>
|
||||
}
|
||||
label={`${t("LoanRequest.checkbox")}`}
|
||||
/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Box
|
||||
@@ -754,12 +855,12 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
||||
size="large"
|
||||
sx={{my: 4}}
|
||||
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")}
|
||||
</Button>
|
||||
</Box>
|
||||
</>
|
||||
)
|
||||
}
|
||||
export default LegalPersonForm
|
||||
);
|
||||
};
|
||||
export default LegalPersonForm;
|
||||
|
||||
@@ -1,4 +1,13 @@
|
||||
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 MuiDatePicker from "@/core/components/MuiDatePicker";
|
||||
import {useTranslations} from "next-intl";
|
||||
@@ -16,22 +25,24 @@ import UseEducations from "@/lib/app/hooks/useEducations";
|
||||
import useOccupations from "@/lib/app/hooks/useOccupations";
|
||||
import useActivityType from "@/lib/app/hooks/useActivityType";
|
||||
import usePriorityLists from "@/lib/app/hooks/usePriorityLists";
|
||||
import useProjectTitle from "@/lib/app/hooks/useProjectTitle";
|
||||
|
||||
const RealPersonForm = ({setFinishLoanRequest}) => {
|
||||
const t = useTranslations();
|
||||
const {provinceList, isLoadingProvinceList, errorProvinceList} = useLimitedProvince()
|
||||
const {cityTextField, cityList, setProvinceID, isLoadingCityList} = useCities()
|
||||
const {educationsList, isLoadingEducationsList, errorEducationsList} = UseEducations()
|
||||
const {occupationsList, isLoadingOccupationsList, errorOccupationsList} = useOccupations()
|
||||
const {activityType, isLoadingActivityType, errorActivityType} = useActivityType()
|
||||
const {priorityLists, isLoadingPriorityLists, errorPriorityLists} = usePriorityLists()
|
||||
const requestServer = useRequest()
|
||||
const {getUser, changeUser} = useUser()
|
||||
const router = useRouter()
|
||||
const {provinceList, isLoadingProvinceList, errorProvinceList} = useLimitedProvince();
|
||||
const {cityTextField, cityList, setProvinceID, isLoadingCityList} = useCities();
|
||||
const {educationsList, isLoadingEducationsList, errorEducationsList} = UseEducations();
|
||||
const {occupationsList, isLoadingOccupationsList, errorOccupationsList} = useOccupations();
|
||||
const {activityType, isLoadingActivityType, errorActivityType} = useActivityType();
|
||||
const {priorityLists, isLoadingPriorityLists, errorPriorityLists} = usePriorityLists();
|
||||
const {projectTitle, isLoadingProjectTitle, errorProjectTitle} = useProjectTitle();
|
||||
const requestServer = useRequest();
|
||||
const {getUser, changeUser} = useUser();
|
||||
const router = useRouter();
|
||||
|
||||
const initialValues = {
|
||||
person_type : "real",
|
||||
vehicle_type : "",
|
||||
person_type: "real",
|
||||
vehicle_type: "",
|
||||
telephone_number: "",
|
||||
activity_type: "",
|
||||
project_title: "",
|
||||
@@ -64,7 +75,7 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
||||
telephone_number: Yup.mixed()
|
||||
.test("max", `${t("LoanRequest.tel_number_max")}`, (value) => {
|
||||
const stringValue = String(value);
|
||||
return stringValue.length === 11
|
||||
return stringValue.length === 11;
|
||||
})
|
||||
.required(t("LoanRequest.error_message_tel_number")),
|
||||
father_name: Yup.string().required(t("LoanRequest.error_message_father_name")),
|
||||
@@ -86,105 +97,134 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
||||
city_id: Yup.string().required(t("LoanRequest.error_message_city_id")),
|
||||
first_name: Yup.string().required(t("LoanRequest.error_message_first_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")),
|
||||
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")),
|
||||
plate_part3: Yup.mixed().test("max", `${t("LoanRequest.error_message_plate_number")}`, (value) => value.toString().length === 3)
|
||||
.required(t("LoanRequest.error_message_plate_number")),
|
||||
plate_part4: Yup.mixed().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")),
|
||||
national_code: Yup.mixed()
|
||||
.test("is-number", `${t("LoanRequest.national_code_number")}`, (value) => !isNaN(value))
|
||||
.test("positive", `${t("LoanRequest.national_code_positive")}`, (value) => value >= 0)
|
||||
.test("max", `${t("LoanRequest.national_code_max")}`, (value) => value.toString().length === 10)
|
||||
.required(t("LoanRequest.error_message_national_id")),
|
||||
national_number: Yup.mixed().when('person_type', ([person_type], schema) => {
|
||||
return person_type === 'legal' ? schema
|
||||
.test("is-number", `${t("LoanRequest.national_number_number")}`, (value) => !isNaN(value))
|
||||
.test("positive", `${t("LoanRequest.national_number_positive")}`, (value) => value >= 0)
|
||||
.test("max", `${t("LoanRequest.national_number_max")}`, (value) => value && value.toString().length === 11)
|
||||
.required(t("LoanRequest.error_message_national_number")) : 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
|
||||
}),
|
||||
national_serial_number: Yup.string()
|
||||
.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.test(
|
||||
"max",
|
||||
`${t("LoanRequest.national_serial_number_max")}`,
|
||||
(value) => value && value.toString().length === 10
|
||||
).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.test(
|
||||
"max",
|
||||
`${t("LoanRequest.national_tracking_code_max")}`,
|
||||
(value) => value && value.toString().length === 10
|
||||
).required(t("LoanRequest.error_message_tracking_code"))
|
||||
: schema;
|
||||
}
|
||||
),
|
||||
});
|
||||
|
||||
const handleSubmit = async (values, props) => {
|
||||
props.setSubmitting(true)
|
||||
let _national_number = values.person_type === "legal" ? {
|
||||
shenase_meli: values.national_number
|
||||
} : {}
|
||||
props.setSubmitting(true);
|
||||
|
||||
const _national_card = values.national_serial_number_or_tracking_code === "national_serial_number" ? {
|
||||
national_serial_number: values.national_serial_number
|
||||
} : {
|
||||
national_tracking_code: values.national_card_tracking_code
|
||||
}
|
||||
const _national_card =
|
||||
values.national_serial_number_or_tracking_code === "national_serial_number"
|
||||
? {
|
||||
national_serial_number: values.national_serial_number,
|
||||
}
|
||||
: {
|
||||
national_tracking_code: values.national_card_tracking_code,
|
||||
};
|
||||
|
||||
let _data = {
|
||||
is_legal_person: 0,
|
||||
is_legal_person: 0,
|
||||
telephone_number: values.telephone_number,
|
||||
national_code: values.national_code,
|
||||
national_id: values.national_code,
|
||||
vehicle_type: values.vehicle_type,
|
||||
province_id: values.province_id,
|
||||
city_id: values.city_id,
|
||||
father_name: values.father_name,
|
||||
first_name: values.first_name,
|
||||
last_name: values.last_name,
|
||||
city_id: values.city_id,
|
||||
navgan_id: values.navgan_id,
|
||||
postal_code: values.postal_code,
|
||||
navgan_type: values.navgan_type,
|
||||
gender: values.gender,
|
||||
address: values.address,
|
||||
birthday: values.birthday.locale('en').format("YYYY-MM-DD"), ..._national_card, ..._national_number
|
||||
}
|
||||
education_id: values.education_id,
|
||||
occupation_id: values.occupation_id,
|
||||
activity_type_id: values.activity_type,
|
||||
project_title: values.project_title,
|
||||
activity_priority_id: values.priority_list,
|
||||
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,
|
||||
};
|
||||
|
||||
await requestServer(SEND_LOAN_REQUEST_NAVGAN, "post", {
|
||||
auth: true, notification: true, data: _data
|
||||
}).then(() => {
|
||||
router.replace('/dashboard/navgan/followUp-loan')
|
||||
getUser((data) => {
|
||||
changeUser(data);
|
||||
});
|
||||
}).catch(() => {
|
||||
}).finally(() => {
|
||||
props.setSubmitting(false)
|
||||
auth: true,
|
||||
notification: true,
|
||||
data: _data,
|
||||
})
|
||||
.then(() => {
|
||||
router.replace("/dashboard/navgan/followUp-loan");
|
||||
getUser((data) => {
|
||||
changeUser(data);
|
||||
});
|
||||
})
|
||||
.catch(() => {
|
||||
})
|
||||
.finally(() => {
|
||||
props.setSubmitting(false);
|
||||
});
|
||||
};
|
||||
|
||||
const formik = useFormik({
|
||||
initialValues, validationSchema, onSubmit: handleSubmit
|
||||
})
|
||||
initialValues,
|
||||
validationSchema,
|
||||
onSubmit: handleSubmit,
|
||||
});
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
<Grid container spacing={2} sx={{p: 2}}>
|
||||
{/*<Grid item xs={12} sm={4}>*/}
|
||||
{/* <SelectBox*/}
|
||||
{/* name="project_title"*/}
|
||||
{/* label={t("LoanRequest.text_field_project_title")}*/}
|
||||
{/* size="small"*/}
|
||||
{/* selectType="project_title"*/}
|
||||
{/* isLoading={isLoadingProjectTitle}*/}
|
||||
{/* errorEcured={errorProjectTitle}*/}
|
||||
{/* selectors={projectTitle}*/}
|
||||
{/* schema={{value: 'value', name: 'name'}}*/}
|
||||
{/* select={formik.values.project_title}*/}
|
||||
{/* value={formik.values.project_title}*/}
|
||||
{/* handleChange={(event) => {*/}
|
||||
{/* formik.setFieldValue('project_title', event.target.value)*/}
|
||||
{/* }}*/}
|
||||
{/* setFieldTouched={formik.setFieldTouched}*/}
|
||||
{/* error={formik.touched.project_title && Boolean(formik.errors.project_title)}*/}
|
||||
{/* helperText={formik.touched.project_title && formik.errors.project_title}*/}
|
||||
{/* onBlur={formik.handleBlur("project_title")}*/}
|
||||
{/* />*/}
|
||||
{/*</Grid>*/}
|
||||
<Grid item xs={12} sm={4}>
|
||||
<SelectBox
|
||||
name="project_title"
|
||||
label={t("LoanRequest.text_field_project_title")}
|
||||
size="small"
|
||||
selectType="project_title"
|
||||
isLoading={isLoadingProjectTitle}
|
||||
errorEcured={errorProjectTitle}
|
||||
selectors={projectTitle}
|
||||
schema={{value: "name", name: "name"}}
|
||||
select={formik.values.project_title}
|
||||
value={formik.values.project_title}
|
||||
handleChange={(event) => {
|
||||
formik.setFieldValue("project_title", event.target.value);
|
||||
}}
|
||||
setFieldTouched={formik.setFieldTouched}
|
||||
error={formik.touched.project_title && Boolean(formik.errors.project_title)}
|
||||
helperText={formik.touched.project_title && formik.errors.project_title}
|
||||
onBlur={formik.handleBlur("project_title")}
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={12} sm={4}>
|
||||
<SelectBox
|
||||
name="activity_type"
|
||||
@@ -194,11 +234,11 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
||||
isLoading={isLoadingActivityType}
|
||||
errorEcured={errorActivityType}
|
||||
selectors={activityType}
|
||||
schema={{value: 'value', name: 'name'}}
|
||||
schema={{value: "value", name: "name"}}
|
||||
select={formik.values.activity_type}
|
||||
value={formik.values.activity_type}
|
||||
handleChange={(event) => {
|
||||
formik.setFieldValue('activity_type', event.target.value)
|
||||
formik.setFieldValue("activity_type", event.target.value);
|
||||
}}
|
||||
setFieldTouched={formik.setFieldTouched}
|
||||
error={formik.touched.activity_type && Boolean(formik.errors.activity_type)}
|
||||
@@ -215,11 +255,11 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
||||
isLoading={isLoadingPriorityLists}
|
||||
errorEcured={errorPriorityLists}
|
||||
selectors={priorityLists}
|
||||
schema={{value: 'value', name: 'name'}}
|
||||
schema={{value: "value", name: "name"}}
|
||||
select={formik.values.priority_list}
|
||||
value={formik.values.priority_list}
|
||||
handleChange={(event) => {
|
||||
formik.setFieldValue('priority_list', event.target.value)
|
||||
formik.setFieldValue("priority_list", event.target.value);
|
||||
}}
|
||||
setFieldTouched={formik.setFieldTouched}
|
||||
error={formik.touched.priority_list && Boolean(formik.errors.priority_list)}
|
||||
@@ -233,16 +273,17 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
||||
<ToggleButtonGroup
|
||||
color="primary"
|
||||
fullWidth
|
||||
size={'small'}
|
||||
size={"small"}
|
||||
value={formik.values.national_serial_number_or_tracking_code}
|
||||
exclusive
|
||||
onChange={(e, value) => {
|
||||
if (value === null) return
|
||||
if (value === null) return;
|
||||
formik.handleChange({
|
||||
target: {
|
||||
name: "national_serial_number_or_tracking_code", value: value,
|
||||
name: "national_serial_number_or_tracking_code",
|
||||
value: value,
|
||||
},
|
||||
})
|
||||
});
|
||||
}}
|
||||
>
|
||||
<ToggleButton value="national_serial_number">
|
||||
@@ -253,9 +294,8 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
||||
</ToggleButton>
|
||||
</ToggleButtonGroup>
|
||||
</Grid>
|
||||
{formik.values.national_serial_number_or_tracking_code === 'national_serial_number' ? (
|
||||
<Grid item xs={12} sm={4}
|
||||
>
|
||||
{formik.values.national_serial_number_or_tracking_code === "national_serial_number" ? (
|
||||
<Grid item xs={12} sm={4}>
|
||||
<TextField
|
||||
sx={{width: "100%"}}
|
||||
name="national_serial_number"
|
||||
@@ -267,10 +307,13 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
||||
fullWidth
|
||||
onChange={formik.handleChange}
|
||||
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}
|
||||
/>
|
||||
</Grid>) : (
|
||||
</Grid>
|
||||
) : (
|
||||
<Grid item xs={12} sm={4}>
|
||||
<TextField
|
||||
sx={{width: "100%"}}
|
||||
@@ -283,8 +326,13 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
||||
fullWidth
|
||||
onChange={formik.handleChange}
|
||||
onBlur={formik.handleBlur("national_card_tracking_code")}
|
||||
error={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}
|
||||
error={
|
||||
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>
|
||||
)}
|
||||
@@ -295,8 +343,8 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
||||
variant="outlined"
|
||||
size="small"
|
||||
value={formik.values.national_code}
|
||||
inputProps={{inputMode: 'numeric', pattern: '[0-9]*'}}
|
||||
type={'tel'}
|
||||
inputProps={{inputMode: "numeric", pattern: "[0-9]*"}}
|
||||
type={"tel"}
|
||||
onChange={(event) => {
|
||||
const inputValue = event.target.value;
|
||||
if (isNaN(Number(inputValue))) {
|
||||
@@ -304,7 +352,8 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
||||
}
|
||||
formik.handleChange({
|
||||
target: {
|
||||
name: "national_code", value: inputValue,
|
||||
name: "national_code",
|
||||
value: inputValue,
|
||||
},
|
||||
});
|
||||
}}
|
||||
@@ -375,15 +424,22 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
||||
size="small"
|
||||
value={formik.values.gender}
|
||||
selectType="gender"
|
||||
selectors={[{
|
||||
id: 1, value: 1, name: "زن"
|
||||
}, {
|
||||
id: 2, value: 0, name: "مرد"
|
||||
}]}
|
||||
schema={{value: 'value', name: 'name'}}
|
||||
selectors={[
|
||||
{
|
||||
id: 1,
|
||||
value: 1,
|
||||
name: "زن",
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
value: 0,
|
||||
name: "مرد",
|
||||
},
|
||||
]}
|
||||
schema={{value: "value", name: "name"}}
|
||||
select={formik.values.gender}
|
||||
handleChange={(event) => {
|
||||
formik.setFieldValue('gender', event.target.value)
|
||||
formik.setFieldValue("gender", event.target.value);
|
||||
}}
|
||||
setFieldTouched={formik.setFieldTouched}
|
||||
error={formik.touched.gender && Boolean(formik.errors.gender)}
|
||||
@@ -407,8 +463,8 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
||||
name="postal_code"
|
||||
variant="outlined"
|
||||
value={formik.values.postal_code}
|
||||
inputProps={{inputMode: 'numeric', pattern: '[0-9]*'}}
|
||||
type={'tel'}
|
||||
inputProps={{inputMode: "numeric", pattern: "[0-9]*"}}
|
||||
type={"tel"}
|
||||
onChange={(event) => {
|
||||
const inputValue = event.target.value;
|
||||
if (isNaN(Number(inputValue))) {
|
||||
@@ -416,7 +472,8 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
||||
}
|
||||
formik.handleChange({
|
||||
target: {
|
||||
name: "postal_code", value: inputValue,
|
||||
name: "postal_code",
|
||||
value: inputValue,
|
||||
},
|
||||
});
|
||||
}}
|
||||
@@ -435,8 +492,8 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
||||
name="telephone_number"
|
||||
variant="outlined"
|
||||
value={formik.values.telephone_number}
|
||||
inputProps={{inputMode: 'numeric', pattern: '[0-9]*'}}
|
||||
type={'tel'}
|
||||
inputProps={{inputMode: "numeric", pattern: "[0-9]*"}}
|
||||
type={"tel"}
|
||||
size="small"
|
||||
onChange={(event) => {
|
||||
const inputValue = event.target.value;
|
||||
@@ -445,7 +502,8 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
||||
}
|
||||
formik.handleChange({
|
||||
target: {
|
||||
name: "telephone_number", value: inputValue,
|
||||
name: "telephone_number",
|
||||
value: inputValue,
|
||||
},
|
||||
});
|
||||
}}
|
||||
@@ -466,17 +524,27 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
||||
size="small"
|
||||
value={formik.values.navgan_type}
|
||||
selectType="navgan_type"
|
||||
selectors={[{
|
||||
id: 1, value: "روستایی", name: "روستایی"
|
||||
}, {
|
||||
id: 2, value: "عمومی", name: "عمومی"
|
||||
}, {
|
||||
id: 3, value: "منطقه آزاد", name: "منطقه آزاد"
|
||||
}]}
|
||||
schema={{value: 'value', name: 'name'}}
|
||||
selectors={[
|
||||
{
|
||||
id: 1,
|
||||
value: "روستایی",
|
||||
name: "روستایی",
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
value: "عمومی",
|
||||
name: "عمومی",
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
value: "منطقه آزاد",
|
||||
name: "منطقه آزاد",
|
||||
},
|
||||
]}
|
||||
schema={{value: "value", name: "name"}}
|
||||
select={formik.values.navgan_type}
|
||||
handleChange={(event) => {
|
||||
formik.setFieldValue('navgan_type', event.target.value)
|
||||
formik.setFieldValue("navgan_type", event.target.value);
|
||||
}}
|
||||
setFieldTouched={formik.setFieldTouched}
|
||||
error={formik.touched.navgan_type && Boolean(formik.errors.navgan_type)}
|
||||
@@ -489,8 +557,8 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
||||
sx={{width: "100%"}}
|
||||
name="navgan_id"
|
||||
variant="outlined"
|
||||
inputProps={{inputMode: 'numeric', pattern: '[0-9]*'}}
|
||||
type={'tel'}
|
||||
inputProps={{inputMode: "numeric", pattern: "[0-9]*"}}
|
||||
type={"tel"}
|
||||
value={formik.values.navgan_id}
|
||||
onChange={formik.handleChange}
|
||||
size="small"
|
||||
@@ -513,14 +581,14 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
||||
isLoading={isLoadingProvinceList}
|
||||
errorEcured={errorProvinceList}
|
||||
selectors={provinceList}
|
||||
schema={{value: 'value', name: 'name'}}
|
||||
schema={{value: "value", name: "name"}}
|
||||
select={formik.values.province_id}
|
||||
value={formik.values.province_id}
|
||||
handleChange={(event) => {
|
||||
formik.setFieldValue('province_id', event.target.value);
|
||||
setProvinceID(event.target.value)
|
||||
formik.setFieldValue("province_id", event.target.value);
|
||||
setProvinceID(event.target.value);
|
||||
formik.setFieldTouched("city_id", false, false);
|
||||
formik.setFieldValue("city_id", "")
|
||||
formik.setFieldValue("city_id", "");
|
||||
}}
|
||||
setFieldTouched={formik.setFieldTouched}
|
||||
error={formik.touched.province_id && Boolean(formik.errors.province_id)}
|
||||
@@ -531,15 +599,21 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
||||
<Grid item xs={12} sm={6}>
|
||||
<SelectBox
|
||||
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"
|
||||
selectType="city_id"
|
||||
schema={{value: 'value', name: 'name'}}
|
||||
schema={{value: "value", name: "name"}}
|
||||
disabled={cityList.length === 0}
|
||||
selectors={cityList}
|
||||
select={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}
|
||||
error={formik.touched.city_id && Boolean(formik.errors.city_id)}
|
||||
helperText={formik.touched.city_id && formik.errors.city_id}
|
||||
@@ -554,15 +628,22 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
||||
label={t("LoanRequest.text_field_vehicle_type")}
|
||||
size="small"
|
||||
value={formik.values.vehicle_type}
|
||||
schema={{value: 'value', name: 'name'}}
|
||||
schema={{value: "value", name: "name"}}
|
||||
selectType="vehicle_type"
|
||||
selectors={[{
|
||||
id: 0, value: "اتوبوس", name: "اتوبوس"
|
||||
}, {
|
||||
id: 1, value: "مینی بوس", name: "مینی بوس"
|
||||
}]}
|
||||
selectors={[
|
||||
{
|
||||
id: 0,
|
||||
value: "اتوبوس",
|
||||
name: "اتوبوس",
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
value: "مینی بوس",
|
||||
name: "مینی بوس",
|
||||
},
|
||||
]}
|
||||
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)}
|
||||
helperText={formik.touched.vehicle_type && formik.errors.vehicle_type}
|
||||
onBlur={formik.handleBlur("vehicle_type")}
|
||||
@@ -584,9 +665,9 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
||||
selectors={educationsList}
|
||||
select={formik.values.education_id}
|
||||
value={formik.values.education_id}
|
||||
schema={{value: 'id', name: 'title'}}
|
||||
schema={{value: "id", name: "title"}}
|
||||
handleChange={(event) => {
|
||||
formik.setFieldValue('education_id', event.target.value)
|
||||
formik.setFieldValue("education_id", event.target.value);
|
||||
}}
|
||||
setFieldTouched={formik.setFieldTouched}
|
||||
error={formik.touched.education_id && Boolean(formik.errors.education_id)}
|
||||
@@ -602,12 +683,12 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
||||
isLoading={isLoadingOccupationsList}
|
||||
errorEcured={errorOccupationsList}
|
||||
selectType="occupation_id"
|
||||
schema={{value: 'id', name: 'title'}}
|
||||
schema={{value: "id", name: "title"}}
|
||||
selectors={occupationsList}
|
||||
select={formik.values.occupation_id}
|
||||
value={formik.values.occupation_id}
|
||||
handleChange={(event) => {
|
||||
formik.setFieldValue('occupation_id', event.target.value)
|
||||
formik.setFieldValue("occupation_id", event.target.value);
|
||||
}}
|
||||
setFieldTouched={formik.setFieldTouched}
|
||||
error={formik.touched.occupation_id && Boolean(formik.errors.occupation_id)}
|
||||
@@ -639,15 +720,17 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
||||
<Grid container spacing={2} sx={{padding: 2}}>
|
||||
<Grid item xs={12}>
|
||||
<FormControlLabel
|
||||
color={'error.main'}
|
||||
control={<Checkbox
|
||||
checked={formik.values.checkedBox}
|
||||
onChange={(event) => {
|
||||
formik.setFieldValue("checkedBox", event.target.checked)
|
||||
}}
|
||||
/>}
|
||||
label={`${t("LoanRequest.checkbox")}`}/>
|
||||
|
||||
color={"error.main"}
|
||||
control={
|
||||
<Checkbox
|
||||
checked={formik.values.checkedBox}
|
||||
onChange={(event) => {
|
||||
formik.setFieldValue("checkedBox", event.target.checked);
|
||||
}}
|
||||
/>
|
||||
}
|
||||
label={`${t("LoanRequest.checkbox")}`}
|
||||
/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Box
|
||||
@@ -667,13 +750,12 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
||||
size="large"
|
||||
sx={{my: 4}}
|
||||
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")}
|
||||
</Button>
|
||||
</Box>
|
||||
</>
|
||||
)
|
||||
}
|
||||
export default RealPersonForm
|
||||
);
|
||||
};
|
||||
export default RealPersonForm;
|
||||
|
||||
@@ -1,35 +1,36 @@
|
||||
import {GET_PROJECT_TITLE} from "@/core/data/apiRoutes";
|
||||
import {useRequest} from "@witel/webapp-builder";
|
||||
import {useEffect, useState} from "react";
|
||||
import { GET_PROJECT_TITLE } from "@/core/data/apiRoutes";
|
||||
import { useRequest } from "@witel/webapp-builder";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
const useProjectTitle = () => {
|
||||
const [isLoadingProjectTitle, setIsLoadingProjectTitle] = useState(false)
|
||||
const [errorProjectTitle, setErrorProjectTitle] = useState(false)
|
||||
const [projectTitle, setProjectTitle] = useState([])
|
||||
const requestServer = useRequest({auth: true, notification: false})
|
||||
const [isLoadingProjectTitle, setIsLoadingProjectTitle] = useState(false);
|
||||
const [errorProjectTitle, setErrorProjectTitle] = useState(false);
|
||||
const [projectTitle, setProjectTitle] = useState([]);
|
||||
const requestServer = useRequest({ auth: true, notification: false });
|
||||
|
||||
useEffect(() => {
|
||||
setIsLoadingProjectTitle(true)
|
||||
requestServer(GET_PROJECT_TITLE, 'get', {auth: true, notification: false}).then(({data}) => {
|
||||
console.log(data)
|
||||
const formattedData = data.data.map((projectTitle, index) => ({
|
||||
id: index,
|
||||
name: projectTitle.name,
|
||||
value: projectTitle.id,
|
||||
}));
|
||||
setIsLoadingProjectTitle(false)
|
||||
setProjectTitle(formattedData);
|
||||
}).catch(() => {
|
||||
setIsLoadingProjectTitle(false)
|
||||
setErrorProjectTitle(true)
|
||||
})
|
||||
}, [])
|
||||
setIsLoadingProjectTitle(true);
|
||||
requestServer(GET_PROJECT_TITLE, "get", { auth: true, notification: false })
|
||||
.then(({ data }) => {
|
||||
const formattedData = data.data.map((projectTitle, index) => ({
|
||||
id: index,
|
||||
name: projectTitle.title,
|
||||
value: projectTitle.id,
|
||||
}));
|
||||
setIsLoadingProjectTitle(false);
|
||||
setProjectTitle(formattedData);
|
||||
})
|
||||
.catch(() => {
|
||||
setIsLoadingProjectTitle(false);
|
||||
setErrorProjectTitle(true);
|
||||
});
|
||||
}, []);
|
||||
|
||||
return {
|
||||
projectTitle,
|
||||
isLoadingProjectTitle,
|
||||
errorProjectTitle
|
||||
}
|
||||
errorProjectTitle,
|
||||
};
|
||||
};
|
||||
|
||||
export default useProjectTitle;
|
||||
export default useProjectTitle;
|
||||
|
||||
Reference in New Issue
Block a user