get api
This commit is contained in:
@@ -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"}
|
||||
>
|
||||
|
||||
@@ -29,6 +29,7 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
||||
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",
|
||||
@@ -133,17 +134,17 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
||||
}
|
||||
|
||||
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,
|
||||
navgan_type: values.navgan_type,
|
||||
@@ -177,27 +178,27 @@ 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={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: '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"
|
||||
|
||||
@@ -16,6 +16,7 @@ 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();
|
||||
@@ -25,6 +26,7 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
||||
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()
|
||||
@@ -129,18 +131,23 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
||||
let _data = {
|
||||
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,
|
||||
education_id: values.education_id,
|
||||
occupation_id: values.occupation_id,
|
||||
activity_type: values.activity_type,
|
||||
project_title: values.project_title,
|
||||
priority_list: values.priority_list,
|
||||
birthday: values.birthday.locale('en').format("YYYY-MM-DD"), ..._national_card, ..._national_number
|
||||
}
|
||||
|
||||
@@ -164,27 +171,27 @@ 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={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: '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"
|
||||
|
||||
@@ -11,10 +11,9 @@ const useProjectTitle = () => {
|
||||
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,
|
||||
name: projectTitle.title,
|
||||
value: projectTitle.id,
|
||||
}));
|
||||
setIsLoadingProjectTitle(false)
|
||||
|
||||
Reference in New Issue
Block a user