add activity and priority list
This commit is contained in:
@@ -14,6 +14,9 @@ import {SEND_LOAN_REQUEST_NAVGAN} from "@/core/data/apiRoutes";
|
||||
import DataSaverOnIcon from "@mui/icons-material/DataSaverOn";
|
||||
import {useFormik} from "formik";
|
||||
import LegalPersonDatePicker from "@/components/dashboard/navgan/add-request-loan/forms/LegalPersonDatePicker";
|
||||
import useProjectTitle from "@/lib/app/hooks/useProjectTitle";
|
||||
import useActivityType from "@/lib/app/hooks/useActivityType";
|
||||
import usePriorityLists from "@/lib/app/hooks/usePriorityLists";
|
||||
|
||||
const LegalPersonForm = ({setFinishLoanRequest}) => {
|
||||
const t = useTranslations();
|
||||
@@ -24,10 +27,14 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
||||
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 initialValues = {
|
||||
person_type: "legal",
|
||||
company_tel_number: "",
|
||||
activity_type: "",
|
||||
priority_list: "",
|
||||
vehicle_type: "",
|
||||
province_id: "",
|
||||
boss_father_name: "",
|
||||
@@ -64,6 +71,8 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
||||
})
|
||||
.required(t("LoanRequest.error_message_company_tel_number")),
|
||||
vehicle_type: Yup.string().required(t("LoanRequest.error_message_vehicle_type")),
|
||||
activity_type: Yup.string().required(t("LoanRequest.error_message_activity_type")),
|
||||
priority_list: Yup.string().required(t("LoanRequest.error_message_priority_list")),
|
||||
register_number: Yup.string().required(t("LoanRequest.error_message_register_number")),
|
||||
boss_father_name: Yup.string().required(t("LoanRequest.error_message_boss_father_name")),
|
||||
company_name: Yup.string().required(t("LoanRequest.error_message_company_name")),
|
||||
@@ -165,6 +174,72 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
||||
})
|
||||
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={isLoadingProvinceList}*/}
|
||||
{/* errorEcured={errorProvinceList}*/}
|
||||
{/* selectors={provinceList}*/}
|
||||
{/* 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="activity_type"
|
||||
label={t("LoanRequest.text_field_activity_type")}
|
||||
size="small"
|
||||
selectType="activity_type"
|
||||
isLoading={isLoadingActivityType}
|
||||
errorEcured={errorActivityType}
|
||||
selectors={activityType}
|
||||
schema={{value: 'value', name: 'name'}}
|
||||
select={formik.values.activity_type}
|
||||
value={formik.values.activity_type}
|
||||
handleChange={(event) => {
|
||||
formik.setFieldValue('activity_type', event.target.value)
|
||||
}}
|
||||
setFieldTouched={formik.setFieldTouched}
|
||||
error={formik.touched.activity_type && Boolean(formik.errors.activity_type)}
|
||||
helperText={formik.touched.activity_type && formik.errors.activity_type}
|
||||
onBlur={formik.handleBlur("activity_type")}
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={12} sm={4}>
|
||||
<SelectBox
|
||||
name="priority_list"
|
||||
label={t("LoanRequest.text_field_priority_list")}
|
||||
size="small"
|
||||
selectType="priority_list"
|
||||
isLoading={isLoadingPriorityLists}
|
||||
errorEcured={errorPriorityLists}
|
||||
selectors={priorityLists}
|
||||
schema={{value: 'value', name: 'name'}}
|
||||
select={formik.values.priority_list}
|
||||
value={formik.values.priority_list}
|
||||
handleChange={(event) => {
|
||||
formik.setFieldValue('priority_list', event.target.value)
|
||||
}}
|
||||
setFieldTouched={formik.setFieldTouched}
|
||||
error={formik.touched.priority_list && Boolean(formik.errors.priority_list)}
|
||||
helperText={formik.touched.priority_list && formik.errors.priority_list}
|
||||
onBlur={formik.handleBlur("priority_list")}
|
||||
/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Grid container spacing={2} sx={{p: 2}}>
|
||||
<Grid item xs={12} sm={4}>
|
||||
<TextField
|
||||
|
||||
@@ -10,25 +10,39 @@ import DataSaverOnIcon from "@mui/icons-material/DataSaverOn";
|
||||
import {SEND_LOAN_REQUEST_NAVGAN} from "@/core/data/apiRoutes";
|
||||
import {useRequest, useUser} from "@witel/webapp-builder";
|
||||
import {useRouter} from "next/router";
|
||||
import {useState} from "react";
|
||||
import PlateNumber from "@/core/components/PlateNumber";
|
||||
import * as React from "react";
|
||||
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";
|
||||
|
||||
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 initialValues = {
|
||||
person_type : "real",
|
||||
vehicle_type : "",
|
||||
telephone_number: "",
|
||||
activity_type: "",
|
||||
priority_list: "",
|
||||
father_name: "",
|
||||
gender: "",
|
||||
first_name: "",
|
||||
last_name: "",
|
||||
city_id: "",
|
||||
province_id: "",
|
||||
education_id: "",
|
||||
occupation_id: "",
|
||||
navgan_id: "",
|
||||
national_code: "",
|
||||
national_serial_number: "",
|
||||
@@ -37,6 +51,10 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
||||
postal_code: "",
|
||||
navgan_type: "",
|
||||
address: "",
|
||||
plate_part1: "",
|
||||
plate_part2: "الف",
|
||||
plate_part3: "",
|
||||
plate_part4: "",
|
||||
birthday: "",
|
||||
checkedBox: false,
|
||||
};
|
||||
@@ -49,7 +67,12 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
||||
})
|
||||
.required(t("LoanRequest.error_message_tel_number")),
|
||||
father_name: Yup.string().required(t("LoanRequest.error_message_father_name")),
|
||||
vehicle_type: Yup.string().required(t("LoanRequest.error_message_vehicle_type")),
|
||||
activity_type: Yup.string().required(t("LoanRequest.error_message_activity_type")),
|
||||
priority_list: Yup.string().required(t("LoanRequest.error_message_priority_list")),
|
||||
gender: Yup.string().required(t("LoanRequest.error_message_gender")),
|
||||
occupation_id: Yup.string().required(t("LoanRequest.error_message_occupation_id")),
|
||||
education_id: Yup.string().required(t("LoanRequest.error_message_education_id")),
|
||||
navgan_type: Yup.string().required(t("LoanRequest.error_message_navgan_type")),
|
||||
address: Yup.string().required(t("LoanRequest.error_message_address")),
|
||||
birthday: Yup.string().required(t("LoanRequest.error_message_date_of_birth")),
|
||||
@@ -61,6 +84,14 @@ 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)
|
||||
.required(t("LoanRequest.error_message_plate_number")),
|
||||
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_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)
|
||||
@@ -130,6 +161,72 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
||||
|
||||
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={isLoadingProvinceList}*/}
|
||||
{/* errorEcured={errorProvinceList}*/}
|
||||
{/* selectors={provinceList}*/}
|
||||
{/* 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="activity_type"
|
||||
label={t("LoanRequest.text_field_activity_type")}
|
||||
size="small"
|
||||
selectType="activity_type"
|
||||
isLoading={isLoadingActivityType}
|
||||
errorEcured={errorActivityType}
|
||||
selectors={activityType}
|
||||
schema={{value: 'value', name: 'name'}}
|
||||
select={formik.values.activity_type}
|
||||
value={formik.values.activity_type}
|
||||
handleChange={(event) => {
|
||||
formik.setFieldValue('activity_type', event.target.value)
|
||||
}}
|
||||
setFieldTouched={formik.setFieldTouched}
|
||||
error={formik.touched.activity_type && Boolean(formik.errors.activity_type)}
|
||||
helperText={formik.touched.activity_type && formik.errors.activity_type}
|
||||
onBlur={formik.handleBlur("activity_type")}
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={12} sm={4}>
|
||||
<SelectBox
|
||||
name="priority_list"
|
||||
label={t("LoanRequest.text_field_priority_list")}
|
||||
size="small"
|
||||
selectType="priority_list"
|
||||
isLoading={isLoadingPriorityLists}
|
||||
errorEcured={errorPriorityLists}
|
||||
selectors={priorityLists}
|
||||
schema={{value: 'value', name: 'name'}}
|
||||
select={formik.values.priority_list}
|
||||
value={formik.values.priority_list}
|
||||
handleChange={(event) => {
|
||||
formik.setFieldValue('priority_list', event.target.value)
|
||||
}}
|
||||
setFieldTouched={formik.setFieldTouched}
|
||||
error={formik.touched.priority_list && Boolean(formik.errors.priority_list)}
|
||||
helperText={formik.touched.priority_list && formik.errors.priority_list}
|
||||
onBlur={formik.handleBlur("priority_list")}
|
||||
/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Grid container spacing={2} sx={{padding: 2}}>
|
||||
<Grid item xs={12} sm={4}>
|
||||
<ToggleButtonGroup
|
||||
@@ -449,6 +546,75 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
||||
/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Grid container spacing={2} sx={{padding: 2}}>
|
||||
<Grid item xs={12} sm={6}>
|
||||
<SelectBox
|
||||
name="vehicle_type"
|
||||
label={t("LoanRequest.text_field_vehicle_type")}
|
||||
size="small"
|
||||
value={formik.values.vehicle_type}
|
||||
schema={{value: 'value', name: 'name'}}
|
||||
selectType="vehicle_type"
|
||||
selectors={[{
|
||||
id: 0, value: "اتوبوس", name: "اتوبوس"
|
||||
}, {
|
||||
id: 1, value: "مینی بوس", name: "مینی بوس"
|
||||
}]}
|
||||
select={formik.values.vehicle_type}
|
||||
handleChange={(event) => formik.setFieldValue('vehicle_type', event.target.value)}
|
||||
error={formik.touched.vehicle_type && Boolean(formik.errors.vehicle_type)}
|
||||
helperText={formik.touched.vehicle_type && formik.errors.vehicle_type}
|
||||
onBlur={formik.handleBlur("vehicle_type")}
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={12} sm={6}>
|
||||
<PlateNumber formik={formik}/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Grid container spacing={2} sx={{padding: 2}}>
|
||||
<Grid item xs={12} sm={6}>
|
||||
<SelectBox
|
||||
name="education_id"
|
||||
label={t("LoanRequest.text_field_education_id")}
|
||||
size="small"
|
||||
isLoading={isLoadingEducationsList}
|
||||
errorEcured={errorEducationsList}
|
||||
selectType="education_id"
|
||||
selectors={educationsList}
|
||||
select={formik.values.education_id}
|
||||
value={formik.values.education_id}
|
||||
schema={{value: 'id', name: 'title'}}
|
||||
handleChange={(event) => {
|
||||
formik.setFieldValue('education_id', event.target.value)
|
||||
}}
|
||||
setFieldTouched={formik.setFieldTouched}
|
||||
error={formik.touched.education_id && Boolean(formik.errors.education_id)}
|
||||
helperText={formik.touched.education_id && formik.errors.education_id}
|
||||
onBlur={formik.handleBlur("education_id")}
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={12} sm={6}>
|
||||
<SelectBox
|
||||
name="occupation_id"
|
||||
label={t("LoanRequest.text_field_occupation_id")}
|
||||
size="small"
|
||||
isLoading={isLoadingOccupationsList}
|
||||
errorEcured={errorOccupationsList}
|
||||
selectType="occupation_id"
|
||||
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)
|
||||
}}
|
||||
setFieldTouched={formik.setFieldTouched}
|
||||
error={formik.touched.occupation_id && Boolean(formik.errors.occupation_id)}
|
||||
helperText={formik.touched.occupation_id && formik.errors.occupation_id}
|
||||
onBlur={formik.handleBlur("occupation_id")}
|
||||
/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Grid container spacing={2} sx={{padding: 2}}>
|
||||
<Grid item xs={12}>
|
||||
<TextField
|
||||
|
||||
Reference in New Issue
Block a user