add activity and priority list
This commit is contained in:
@@ -204,6 +204,8 @@
|
||||
"error_message_checkedBox": "لطفا کد صحت اطلاعات خود را تایید کنید!",
|
||||
"error_message_navgan_type": "لطفا نوع ناوگان خود را وارد کنید!",
|
||||
"error_message_address": "لطفا آدرس خود را وارد کنید!",
|
||||
"error_message_activity_type": "لطفا نوع فعالیت خود را وارد کنید!",
|
||||
"error_message_priority_list": "لطفا اولویت فعالیت خود را وارد کنید!",
|
||||
"text_field_tel_number": "شماره ثابت (با پیش شماره استان)",
|
||||
"text_field_company_tel_number": "شماره ثابت شرکت (با پیش شماره استان)",
|
||||
"text_field_education_id": "مدرک تحصیلی",
|
||||
@@ -218,6 +220,8 @@
|
||||
"text_field_last_name": "نام خانوادگی",
|
||||
"text_field_boss_last_name": "نام خانوادگی مدیر عامل",
|
||||
"text_field_gender": "جنسیت",
|
||||
"text_field_activity_type": "نوع فعالیت",
|
||||
"text_field_priority_list": "اولویت فعالیت",
|
||||
"text_field_boss_gender": "جنسیت مدیر عامل",
|
||||
"text_field_register_number": "شماره ثبت شرکت",
|
||||
"text_field_father_name": "نام پدر",
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -184,7 +184,7 @@ const PlateNumber = ({formik, disabled}) => {
|
||||
disabled={disabled}
|
||||
fullWidth
|
||||
>
|
||||
{plate_words.find(p => p.value === formik.values.plate_part2).name}
|
||||
{plate_words.find(p => p.value === formik.values.plate_part2)?.name}
|
||||
</Button>
|
||||
</Box>
|
||||
<Drawer
|
||||
|
||||
@@ -24,4 +24,8 @@ export const GET_OCCUPATIONS_LIST = BASE_URL + "/occupations";
|
||||
export const GET_LOAN_DETAILS = BASE_URL + "/navgan/loan/details/"
|
||||
export const UPDATE_LOAN = BASE_URL + "/navgan/loan/update/"
|
||||
|
||||
export const GET_PROJECT_TITLE = BASE_URL + "/navgan_plans"
|
||||
export const GET_ACTIVITY_LIST = BASE_URL + "/activity_types"
|
||||
export const GET_PRIORITY_LIST = BASE_URL + "/activity_priorities"
|
||||
|
||||
|
||||
|
||||
34
src/lib/app/hooks/useActivityType.jsx
Normal file
34
src/lib/app/hooks/useActivityType.jsx
Normal file
@@ -0,0 +1,34 @@
|
||||
import {GET_ACTIVITY_LIST} from "@/core/data/apiRoutes";
|
||||
import {useRequest} from "@witel/webapp-builder";
|
||||
import {useEffect, useState} from "react";
|
||||
|
||||
const useActivityType = () => {
|
||||
const [isLoadingActivityType, setIsLoadingActivityType] = useState(false)
|
||||
const [errorActivityType, setErrorActivityType] = useState(false)
|
||||
const [activityType, setActivityType] = useState([])
|
||||
const requestServer = useRequest({auth: true, notification: false})
|
||||
|
||||
useEffect(() => {
|
||||
setIsLoadingActivityType(true)
|
||||
requestServer(GET_ACTIVITY_LIST, 'get', {auth: true, notification: false}).then(({data}) => {
|
||||
const formattedData = data.data.map((activityList, index) => ({
|
||||
id: index,
|
||||
name: activityList.name,
|
||||
value: activityList.id,
|
||||
}));
|
||||
setIsLoadingActivityType(false)
|
||||
setActivityType(formattedData);
|
||||
}).catch(() => {
|
||||
setIsLoadingActivityType(false)
|
||||
setErrorActivityType(true)
|
||||
})
|
||||
}, [])
|
||||
|
||||
return {
|
||||
activityType,
|
||||
isLoadingActivityType,
|
||||
errorActivityType
|
||||
}
|
||||
};
|
||||
|
||||
export default useActivityType;
|
||||
34
src/lib/app/hooks/usePriorityLists.jsx
Normal file
34
src/lib/app/hooks/usePriorityLists.jsx
Normal file
@@ -0,0 +1,34 @@
|
||||
import {GET_PRIORITY_LIST} from "@/core/data/apiRoutes";
|
||||
import {useRequest} from "@witel/webapp-builder";
|
||||
import {useEffect, useState} from "react";
|
||||
|
||||
const usePriorityLists = () => {
|
||||
const [isLoadingPriorityLists, setIsLoadingPriorityLists] = useState(false)
|
||||
const [errorPriorityLists, setErrorPriorityLists] = useState(false)
|
||||
const [priorityLists, setPriorityLists] = useState([])
|
||||
const requestServer = useRequest({auth: true, notification: false})
|
||||
|
||||
useEffect(() => {
|
||||
setIsLoadingPriorityLists(true)
|
||||
requestServer(GET_PRIORITY_LIST, 'get', {auth: true, notification: false}).then(({data}) => {
|
||||
const formattedData = data.data.map((priorityList, index) => ({
|
||||
id: index,
|
||||
name: priorityList.name,
|
||||
value: priorityList.id,
|
||||
}));
|
||||
setIsLoadingPriorityLists(false)
|
||||
setPriorityLists(formattedData);
|
||||
}).catch(() => {
|
||||
setIsLoadingPriorityLists(false)
|
||||
setErrorPriorityLists(true)
|
||||
})
|
||||
}, [])
|
||||
|
||||
return {
|
||||
priorityLists,
|
||||
isLoadingPriorityLists,
|
||||
errorPriorityLists
|
||||
}
|
||||
};
|
||||
|
||||
export default usePriorityLists;
|
||||
35
src/lib/app/hooks/useProjectTitle.jsx
Normal file
35
src/lib/app/hooks/useProjectTitle.jsx
Normal file
@@ -0,0 +1,35 @@
|
||||
import {GET_PROJECT_TITLE, GET_PROVINCE_LIST} 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})
|
||||
|
||||
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)
|
||||
})
|
||||
}, [])
|
||||
|
||||
return {
|
||||
projectTitle,
|
||||
isLoadingProjectTitle,
|
||||
errorProjectTitle
|
||||
}
|
||||
};
|
||||
|
||||
export default useProjectTitle;
|
||||
Reference in New Issue
Block a user