submit api
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"app_name": "سامانه جامع تسهیلات",
|
"app_name": "سامانه جامع تسهیلات",
|
||||||
"app_short_name": "سامانه تسهیلات",
|
"app_short_name": "سامانه تسهیلات",
|
||||||
"birthday": "تاریخ تولد",
|
"birthday": "تاریخ تولد {value}",
|
||||||
"company_date": "تاریخ ثبت شرکت",
|
"company_date": "تاریخ ثبت شرکت",
|
||||||
"birthday_error": "تاریخ تولد خود را وارد کنید!",
|
"birthday_error": "تاریخ تولد {value} را وارد کنید!",
|
||||||
"dashboard": "داشبورد",
|
"dashboard": "داشبورد",
|
||||||
"text_field_city_id": "شهر",
|
"text_field_city_id": "شهر",
|
||||||
"text_field_error_fetching_cities": "لطفا شهر خود را وارد کنید!",
|
"text_field_error_fetching_cities": "لطفا شهر خود را وارد کنید!",
|
||||||
@@ -198,6 +198,7 @@
|
|||||||
"error_message_national_id": "لطفا کد ملی خود را وارد کنید!",
|
"error_message_national_id": "لطفا کد ملی خود را وارد کنید!",
|
||||||
"error_message_national_number": "لطفا شناسه ملی شرکت خود را وارد کنید!",
|
"error_message_national_number": "لطفا شناسه ملی شرکت خود را وارد کنید!",
|
||||||
"error_message_date_of_birth": "لطفا تاریخ تولد خود را وارد کنید!",
|
"error_message_date_of_birth": "لطفا تاریخ تولد خود را وارد کنید!",
|
||||||
|
"error_message_boss_date_of_birth": "لطفا تاریخ تولد مدیر عامل را وارد کنید!",
|
||||||
"error_message_shenasname_serial": "لطفا سریال پشت کارت ملی خود را وارد کنید!",
|
"error_message_shenasname_serial": "لطفا سریال پشت کارت ملی خود را وارد کنید!",
|
||||||
"error_message_boss_shenasname_serial": "لطفا سریال پشت کارت ملی مدیر عامل را وارد کنید!",
|
"error_message_boss_shenasname_serial": "لطفا سریال پشت کارت ملی مدیر عامل را وارد کنید!",
|
||||||
"error_message_boss_national_serial_number": "لطفا سریال پشت کارت ملی مدیر عامل را وارد کنید!",
|
"error_message_boss_national_serial_number": "لطفا سریال پشت کارت ملی مدیر عامل را وارد کنید!",
|
||||||
@@ -210,7 +211,7 @@
|
|||||||
"error_message_address": "لطفا آدرس خود را وارد کنید!",
|
"error_message_address": "لطفا آدرس خود را وارد کنید!",
|
||||||
"error_message_activity_type": "لطفا نوع فعالیت خود را وارد کنید!",
|
"error_message_activity_type": "لطفا نوع فعالیت خود را وارد کنید!",
|
||||||
"error_message_priority_list": "لطفا اولویت فعالیت خود را وارد کنید!",
|
"error_message_priority_list": "لطفا اولویت فعالیت خود را وارد کنید!",
|
||||||
"error_message_project_title": "لطفا عنوان پروژه خود را وارد کنید!",
|
"error_message_navgan_plan_id": "لطفا عنوان پروژه خود را وارد کنید!",
|
||||||
"text_field_tel_number": "شماره ثابت (با پیش شماره استان)",
|
"text_field_tel_number": "شماره ثابت (با پیش شماره استان)",
|
||||||
"text_field_company_tel_number": "شماره ثابت شرکت (با پیش شماره استان)",
|
"text_field_company_tel_number": "شماره ثابت شرکت (با پیش شماره استان)",
|
||||||
"text_field_education_id": "مدرک تحصیلی",
|
"text_field_education_id": "مدرک تحصیلی",
|
||||||
@@ -221,7 +222,7 @@
|
|||||||
"text_field_name": "نام",
|
"text_field_name": "نام",
|
||||||
"text_field_company_name": "نام شرکت",
|
"text_field_company_name": "نام شرکت",
|
||||||
"text_field_first_name": "نام",
|
"text_field_first_name": "نام",
|
||||||
"text_field_project_title": "عنوان پروژه",
|
"text_field_navgan_plan_id": "عنوان پروژه",
|
||||||
"text_field_boss_first_name": "نام مدیر عامل",
|
"text_field_boss_first_name": "نام مدیر عامل",
|
||||||
"text_field_last_name": "نام خانوادگی",
|
"text_field_last_name": "نام خانوادگی",
|
||||||
"text_field_boss_last_name": "نام خانوادگی مدیر عامل",
|
"text_field_boss_last_name": "نام خانوادگی مدیر عامل",
|
||||||
|
|||||||
@@ -53,8 +53,8 @@ function ButtonDatePicker(props) {
|
|||||||
formik: props.formik,
|
formik: props.formik,
|
||||||
field: { setOpen },
|
field: { setOpen },
|
||||||
textField: {
|
textField: {
|
||||||
helperText: props.formik.errors.birthday
|
helperText: props.formik.errors.company_date
|
||||||
? `${t("birthday_error")}`
|
? `${t("company_date")}`
|
||||||
: null,
|
: null,
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import {useFormik} from "formik";
|
|||||||
import LegalPersonDatePicker from "@/components/dashboard/navgan/add-request-loan/forms/LegalPersonDatePicker";
|
import LegalPersonDatePicker from "@/components/dashboard/navgan/add-request-loan/forms/LegalPersonDatePicker";
|
||||||
import useProjectTitle from "@/lib/app/hooks/useProjectTitle";
|
import useProjectTitle from "@/lib/app/hooks/useProjectTitle";
|
||||||
import useActivityType from "@/lib/app/hooks/useActivityType";
|
import useActivityType from "@/lib/app/hooks/useActivityType";
|
||||||
import usePriorityLists from "@/lib/app/hooks/usePriorityLists";
|
import MuiDatePicker from "@/core/components/MuiDatePicker";
|
||||||
|
|
||||||
const LegalPersonForm = ({setFinishLoanRequest}) => {
|
const LegalPersonForm = ({setFinishLoanRequest}) => {
|
||||||
const t = useTranslations();
|
const t = useTranslations();
|
||||||
@@ -37,15 +37,14 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
const {educationsList, isLoadingEducationsList, errorEducationsList} = UseEducations();
|
const {educationsList, isLoadingEducationsList, errorEducationsList} = UseEducations();
|
||||||
const {occupationsList, isLoadingOccupationsList, errorOccupationsList} = useOccupations();
|
const {occupationsList, isLoadingOccupationsList, errorOccupationsList} = useOccupations();
|
||||||
const {activityType, isLoadingActivityType, errorActivityType} = useActivityType();
|
const {activityType, isLoadingActivityType, errorActivityType} = useActivityType();
|
||||||
const {priorityLists, isLoadingPriorityLists, errorPriorityLists} = usePriorityLists();
|
|
||||||
const {projectTitle, isLoadingProjectTitle, errorProjectTitle} = useProjectTitle();
|
const {projectTitle, isLoadingProjectTitle, errorProjectTitle} = useProjectTitle();
|
||||||
|
|
||||||
const initialValues = {
|
const initialValues = {
|
||||||
person_type: "legal",
|
person_type: "legal",
|
||||||
company_tel_number: "",
|
company_tel_number: "",
|
||||||
activity_type: "",
|
activity_type: "",
|
||||||
project_title: "",
|
navgan_plan_id: "",
|
||||||
priority_list: "",
|
birthday: "",
|
||||||
vehicle_type: "",
|
vehicle_type: "",
|
||||||
province_id: "",
|
province_id: "",
|
||||||
boss_father_name: "",
|
boss_father_name: "",
|
||||||
@@ -83,10 +82,9 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
.required(t("LoanRequest.error_message_company_tel_number")),
|
.required(t("LoanRequest.error_message_company_tel_number")),
|
||||||
vehicle_type: Yup.string().required(t("LoanRequest.error_message_vehicle_type")),
|
vehicle_type: Yup.string().required(t("LoanRequest.error_message_vehicle_type")),
|
||||||
activity_type: Yup.string().required(t("LoanRequest.error_message_activity_type")),
|
activity_type: Yup.string().required(t("LoanRequest.error_message_activity_type")),
|
||||||
project_title: Yup.string().required(t("LoanRequest.error_message_project_title")),
|
navgan_plan_id: Yup.string().required(t("LoanRequest.error_message_navgan_plan_id")),
|
||||||
priority_list: Yup.string().required(t("LoanRequest.error_message_priority_list")),
|
|
||||||
register_number: Yup.string().required(t("LoanRequest.error_message_register_number")),
|
register_number: Yup.string().required(t("LoanRequest.error_message_register_number")),
|
||||||
boss_father_name: Yup.string().required(t("LoanRequest.error_message_boss_father_name")),
|
birthday: Yup.string().required(t("LoanRequest.error_message_boss_date_of_birth")),
|
||||||
company_name: Yup.string().required(t("LoanRequest.error_message_company_name")),
|
company_name: Yup.string().required(t("LoanRequest.error_message_company_name")),
|
||||||
boss_gender: Yup.string().required(t("LoanRequest.error_message_boss_gender")),
|
boss_gender: Yup.string().required(t("LoanRequest.error_message_boss_gender")),
|
||||||
navgan_type: Yup.string().required(t("LoanRequest.error_message_navgan_type")),
|
navgan_type: Yup.string().required(t("LoanRequest.error_message_navgan_type")),
|
||||||
@@ -171,6 +169,7 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
: {
|
: {
|
||||||
national_tracking_code: values.boss_national_card_tracking_code,
|
national_tracking_code: values.boss_national_card_tracking_code,
|
||||||
};
|
};
|
||||||
|
const _father_name = values.boss_father_name !== "" ? {father_name: values.boss_father_name} : {}
|
||||||
|
|
||||||
let _data = {
|
let _data = {
|
||||||
is_legal_person: 1,
|
is_legal_person: 1,
|
||||||
@@ -181,13 +180,11 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
company_name: values.company_name,
|
company_name: values.company_name,
|
||||||
province_id: values.province_id,
|
province_id: values.province_id,
|
||||||
city_id: values.city_id,
|
city_id: values.city_id,
|
||||||
father_name: values.boss_father_name,
|
|
||||||
first_name: values.boss_first_name,
|
first_name: values.boss_first_name,
|
||||||
last_name: values.boss_last_name,
|
last_name: values.boss_last_name,
|
||||||
navgan_id: values.navgan_id,
|
navgan_id: values.navgan_id,
|
||||||
activity_type_id: values.activity_type,
|
activity_type_id: values.activity_type,
|
||||||
project_title: values.project_title,
|
navgan_plan_id: values.navgan_plan_id,
|
||||||
activity_priority_id: values.priority_list,
|
|
||||||
postal_code: values.company_postal_code,
|
postal_code: values.company_postal_code,
|
||||||
navgan_type: values.navgan_type,
|
navgan_type: values.navgan_type,
|
||||||
gender: values.boss_gender,
|
gender: values.boss_gender,
|
||||||
@@ -197,10 +194,12 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
plate_part4: values.plate_part4,
|
plate_part4: values.plate_part4,
|
||||||
address: values.address,
|
address: values.address,
|
||||||
company_register_date: values.company_date.locale("en").format("YYYY-MM-DD"),
|
company_register_date: values.company_date.locale("en").format("YYYY-MM-DD"),
|
||||||
|
birthday: values.birthday.locale("en").format("YYYY-MM-DD"),
|
||||||
education_id: values.education_id,
|
education_id: values.education_id,
|
||||||
occupation_id: values.occupation_id,
|
occupation_id: values.occupation_id,
|
||||||
..._national_card,
|
..._national_card,
|
||||||
..._national_number,
|
..._national_number,
|
||||||
|
..._father_name
|
||||||
};
|
};
|
||||||
|
|
||||||
await requestServer(SEND_LOAN_REQUEST_NAVGAN, "post", {
|
await requestServer(SEND_LOAN_REQUEST_NAVGAN, "post", {
|
||||||
@@ -229,28 +228,28 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Grid container spacing={2} sx={{p: 2}}>
|
<Grid container spacing={2} sx={{p: 2}}>
|
||||||
<Grid item xs={12} sm={4}>
|
<Grid item xs={12} sm={6}>
|
||||||
<SelectBox
|
<SelectBox
|
||||||
name="project_title"
|
name="navgan_plan_id"
|
||||||
label={t("LoanRequest.text_field_project_title")}
|
label={t("LoanRequest.text_field_navgan_plan_id")}
|
||||||
size="small"
|
size="small"
|
||||||
selectType="project_title"
|
selectType="navgan_plan_id"
|
||||||
isLoading={isLoadingProjectTitle}
|
isLoading={isLoadingProjectTitle}
|
||||||
errorEcured={errorProjectTitle}
|
errorEcured={errorProjectTitle}
|
||||||
selectors={projectTitle}
|
selectors={projectTitle}
|
||||||
schema={{value: "name", name: "name"}}
|
schema={{value: "value", name: "name"}}
|
||||||
select={formik.values.project_title}
|
select={formik.values.navgan_plan_id}
|
||||||
value={formik.values.project_title}
|
value={formik.values.navgan_plan_id}
|
||||||
handleChange={(event) => {
|
handleChange={(event) => {
|
||||||
formik.setFieldValue("project_title", event.target.value);
|
formik.setFieldValue("navgan_plan_id", event.target.value);
|
||||||
}}
|
}}
|
||||||
setFieldTouched={formik.setFieldTouched}
|
setFieldTouched={formik.setFieldTouched}
|
||||||
error={formik.touched.project_title && Boolean(formik.errors.project_title)}
|
error={formik.touched.navgan_plan_id && Boolean(formik.errors.navgan_plan_id)}
|
||||||
helperText={formik.touched.project_title && formik.errors.project_title}
|
helperText={formik.touched.navgan_plan_id && formik.errors.navgan_plan_id}
|
||||||
onBlur={formik.handleBlur("project_title")}
|
onBlur={formik.handleBlur("navgan_plan_id")}
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item xs={12} sm={4}>
|
<Grid item xs={12} sm={6}>
|
||||||
<SelectBox
|
<SelectBox
|
||||||
name="activity_type"
|
name="activity_type"
|
||||||
label={t("LoanRequest.text_field_activity_type")}
|
label={t("LoanRequest.text_field_activity_type")}
|
||||||
@@ -271,27 +270,6 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
onBlur={formik.handleBlur("activity_type")}
|
onBlur={formik.handleBlur("activity_type")}
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</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>
|
||||||
<Grid container spacing={2} sx={{p: 2}}>
|
<Grid container spacing={2} sx={{p: 2}}>
|
||||||
<Grid item xs={12} sm={4}>
|
<Grid item xs={12} sm={4}>
|
||||||
@@ -549,7 +527,7 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid container spacing={2} sx={{padding: 2}}>
|
<Grid container spacing={2} sx={{padding: 2}}>
|
||||||
<Grid item xs={12} sm={6}>
|
<Grid item xs={12} sm={4}>
|
||||||
<TextField
|
<TextField
|
||||||
sx={{width: "100%"}}
|
sx={{width: "100%"}}
|
||||||
name="boss_first_name"
|
name="boss_first_name"
|
||||||
@@ -565,7 +543,7 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
helperText={formik.touched.boss_first_name && formik.errors.boss_first_name}
|
helperText={formik.touched.boss_first_name && formik.errors.boss_first_name}
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item xs={12} sm={6}>
|
<Grid item xs={12} sm={4}>
|
||||||
<TextField
|
<TextField
|
||||||
sx={{width: "100%"}}
|
sx={{width: "100%"}}
|
||||||
name="boss_last_name"
|
name="boss_last_name"
|
||||||
@@ -581,6 +559,14 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
helperText={formik.touched.boss_last_name && formik.errors.boss_last_name}
|
helperText={formik.touched.boss_last_name && formik.errors.boss_last_name}
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
<Grid item xs={12} sm={4}>
|
||||||
|
<MuiDatePicker
|
||||||
|
formik={formik}
|
||||||
|
error={formik.touched.birthday && Boolean(formik.errors.birthday)}
|
||||||
|
helperText={formik.touched.birthday && formik.errors.birthday}
|
||||||
|
onBlur={formik.handleBlur("birthday")}
|
||||||
|
/>
|
||||||
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid container spacing={2} sx={{padding: 2}}>
|
<Grid container spacing={2} sx={{padding: 2}}>
|
||||||
<Grid item xs={12} sm={4}>
|
<Grid item xs={12} sm={4}>
|
||||||
@@ -665,9 +651,6 @@ const LegalPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
label={t("LoanRequest.text_field_boss_father_name")}
|
label={t("LoanRequest.text_field_boss_father_name")}
|
||||||
placeholder={t("LoanRequest.text_field_enter_your_boss_father_name")}
|
placeholder={t("LoanRequest.text_field_enter_your_boss_father_name")}
|
||||||
fullWidth
|
fullWidth
|
||||||
onBlur={formik.handleBlur("boss_father_name")}
|
|
||||||
error={formik.touched.boss_father_name && Boolean(formik.errors.boss_father_name)}
|
|
||||||
helperText={formik.touched.boss_father_name && formik.errors.boss_father_name}
|
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import * as React from "react";
|
|||||||
import UseEducations from "@/lib/app/hooks/useEducations";
|
import UseEducations from "@/lib/app/hooks/useEducations";
|
||||||
import useOccupations from "@/lib/app/hooks/useOccupations";
|
import useOccupations from "@/lib/app/hooks/useOccupations";
|
||||||
import useActivityType from "@/lib/app/hooks/useActivityType";
|
import useActivityType from "@/lib/app/hooks/useActivityType";
|
||||||
import usePriorityLists from "@/lib/app/hooks/usePriorityLists";
|
|
||||||
import useProjectTitle from "@/lib/app/hooks/useProjectTitle";
|
import useProjectTitle from "@/lib/app/hooks/useProjectTitle";
|
||||||
|
|
||||||
const RealPersonForm = ({setFinishLoanRequest}) => {
|
const RealPersonForm = ({setFinishLoanRequest}) => {
|
||||||
@@ -34,7 +33,6 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
const {educationsList, isLoadingEducationsList, errorEducationsList} = UseEducations();
|
const {educationsList, isLoadingEducationsList, errorEducationsList} = UseEducations();
|
||||||
const {occupationsList, isLoadingOccupationsList, errorOccupationsList} = useOccupations();
|
const {occupationsList, isLoadingOccupationsList, errorOccupationsList} = useOccupations();
|
||||||
const {activityType, isLoadingActivityType, errorActivityType} = useActivityType();
|
const {activityType, isLoadingActivityType, errorActivityType} = useActivityType();
|
||||||
const {priorityLists, isLoadingPriorityLists, errorPriorityLists} = usePriorityLists();
|
|
||||||
const {projectTitle, isLoadingProjectTitle, errorProjectTitle} = useProjectTitle();
|
const {projectTitle, isLoadingProjectTitle, errorProjectTitle} = useProjectTitle();
|
||||||
const requestServer = useRequest();
|
const requestServer = useRequest();
|
||||||
const {getUser, changeUser} = useUser();
|
const {getUser, changeUser} = useUser();
|
||||||
@@ -45,8 +43,7 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
vehicle_type: "",
|
vehicle_type: "",
|
||||||
telephone_number: "",
|
telephone_number: "",
|
||||||
activity_type: "",
|
activity_type: "",
|
||||||
project_title: "",
|
navgan_plan_id: "",
|
||||||
priority_list: "",
|
|
||||||
father_name: "",
|
father_name: "",
|
||||||
gender: "",
|
gender: "",
|
||||||
first_name: "",
|
first_name: "",
|
||||||
@@ -78,11 +75,9 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
return stringValue.length === 11;
|
return stringValue.length === 11;
|
||||||
})
|
})
|
||||||
.required(t("LoanRequest.error_message_tel_number")),
|
.required(t("LoanRequest.error_message_tel_number")),
|
||||||
father_name: Yup.string().required(t("LoanRequest.error_message_father_name")),
|
|
||||||
vehicle_type: Yup.string().required(t("LoanRequest.error_message_vehicle_type")),
|
vehicle_type: Yup.string().required(t("LoanRequest.error_message_vehicle_type")),
|
||||||
activity_type: Yup.string().required(t("LoanRequest.error_message_activity_type")),
|
activity_type: Yup.string().required(t("LoanRequest.error_message_activity_type")),
|
||||||
project_title: Yup.string().required(t("LoanRequest.error_message_project_title")),
|
navgan_plan_id: Yup.string().required(t("LoanRequest.error_message_navgan_plan_id")),
|
||||||
priority_list: Yup.string().required(t("LoanRequest.error_message_priority_list")),
|
|
||||||
gender: Yup.string().required(t("LoanRequest.error_message_gender")),
|
gender: Yup.string().required(t("LoanRequest.error_message_gender")),
|
||||||
occupation_id: Yup.string().required(t("LoanRequest.error_message_occupation_id")),
|
occupation_id: Yup.string().required(t("LoanRequest.error_message_occupation_id")),
|
||||||
education_id: Yup.string().required(t("LoanRequest.error_message_education_id")),
|
education_id: Yup.string().required(t("LoanRequest.error_message_education_id")),
|
||||||
@@ -147,6 +142,7 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
: {
|
: {
|
||||||
national_tracking_code: values.national_card_tracking_code,
|
national_tracking_code: values.national_card_tracking_code,
|
||||||
};
|
};
|
||||||
|
const _father_name = values.father_name !== "" ? {father_name: values.father_name} : {}
|
||||||
|
|
||||||
let _data = {
|
let _data = {
|
||||||
is_legal_person: 0,
|
is_legal_person: 0,
|
||||||
@@ -155,7 +151,6 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
vehicle_type: values.vehicle_type,
|
vehicle_type: values.vehicle_type,
|
||||||
province_id: values.province_id,
|
province_id: values.province_id,
|
||||||
city_id: values.city_id,
|
city_id: values.city_id,
|
||||||
father_name: values.father_name,
|
|
||||||
first_name: values.first_name,
|
first_name: values.first_name,
|
||||||
last_name: values.last_name,
|
last_name: values.last_name,
|
||||||
navgan_id: values.navgan_id,
|
navgan_id: values.navgan_id,
|
||||||
@@ -166,14 +161,14 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
education_id: values.education_id,
|
education_id: values.education_id,
|
||||||
occupation_id: values.occupation_id,
|
occupation_id: values.occupation_id,
|
||||||
activity_type_id: values.activity_type,
|
activity_type_id: values.activity_type,
|
||||||
project_title: values.project_title,
|
navgan_plan_id: values.navgan_plan_id,
|
||||||
activity_priority_id: values.priority_list,
|
|
||||||
plate_part1: values.plate_part1,
|
plate_part1: values.plate_part1,
|
||||||
plate_part2: values.plate_part2,
|
plate_part2: values.plate_part2,
|
||||||
plate_part3: values.plate_part3,
|
plate_part3: values.plate_part3,
|
||||||
plate_part4: values.plate_part4,
|
plate_part4: values.plate_part4,
|
||||||
birthday: values.birthday.locale("en").format("YYYY-MM-DD"),
|
birthday: values.birthday.locale("en").format("YYYY-MM-DD"),
|
||||||
..._national_card,
|
..._national_card,
|
||||||
|
..._father_name
|
||||||
};
|
};
|
||||||
|
|
||||||
await requestServer(SEND_LOAN_REQUEST_NAVGAN, "post", {
|
await requestServer(SEND_LOAN_REQUEST_NAVGAN, "post", {
|
||||||
@@ -204,28 +199,28 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Grid container spacing={2} sx={{p: 2}}>
|
<Grid container spacing={2} sx={{p: 2}}>
|
||||||
<Grid item xs={12} sm={4}>
|
<Grid item xs={12} sm={6}>
|
||||||
<SelectBox
|
<SelectBox
|
||||||
name="project_title"
|
name="navgan_plan_id"
|
||||||
label={t("LoanRequest.text_field_project_title")}
|
label={t("LoanRequest.text_field_navgan_plan_id")}
|
||||||
size="small"
|
size="small"
|
||||||
selectType="project_title"
|
selectType="navgan_plan_id"
|
||||||
isLoading={isLoadingProjectTitle}
|
isLoading={isLoadingProjectTitle}
|
||||||
errorEcured={errorProjectTitle}
|
errorEcured={errorProjectTitle}
|
||||||
selectors={projectTitle}
|
selectors={projectTitle}
|
||||||
schema={{value: "name", name: "name"}}
|
schema={{value: "value", name: "name"}}
|
||||||
select={formik.values.project_title}
|
select={formik.values.navgan_plan_id}
|
||||||
value={formik.values.project_title}
|
value={formik.values.navgan_plan_id}
|
||||||
handleChange={(event) => {
|
handleChange={(event) => {
|
||||||
formik.setFieldValue("project_title", event.target.value);
|
formik.setFieldValue("navgan_plan_id", event.target.value);
|
||||||
}}
|
}}
|
||||||
setFieldTouched={formik.setFieldTouched}
|
setFieldTouched={formik.setFieldTouched}
|
||||||
error={formik.touched.project_title && Boolean(formik.errors.project_title)}
|
error={formik.touched.navgan_plan_id && Boolean(formik.errors.navgan_plan_id)}
|
||||||
helperText={formik.touched.project_title && formik.errors.project_title}
|
helperText={formik.touched.navgan_plan_id && formik.errors.navgan_plan_id}
|
||||||
onBlur={formik.handleBlur("project_title")}
|
onBlur={formik.handleBlur("navgan_plan_id")}
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item xs={12} sm={4}>
|
<Grid item xs={12} sm={6}>
|
||||||
<SelectBox
|
<SelectBox
|
||||||
name="activity_type"
|
name="activity_type"
|
||||||
label={t("LoanRequest.text_field_activity_type")}
|
label={t("LoanRequest.text_field_activity_type")}
|
||||||
@@ -246,27 +241,6 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
onBlur={formik.handleBlur("activity_type")}
|
onBlur={formik.handleBlur("activity_type")}
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</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>
|
||||||
<Grid container spacing={2} sx={{padding: 2}}>
|
<Grid container spacing={2} sx={{padding: 2}}>
|
||||||
<Grid item xs={12} sm={4}>
|
<Grid item xs={12} sm={4}>
|
||||||
@@ -412,9 +386,6 @@ const RealPersonForm = ({setFinishLoanRequest}) => {
|
|||||||
label={t("LoanRequest.text_field_father_name")}
|
label={t("LoanRequest.text_field_father_name")}
|
||||||
placeholder={t("LoanRequest.text_field_enter_your_father_name")}
|
placeholder={t("LoanRequest.text_field_enter_your_father_name")}
|
||||||
fullWidth
|
fullWidth
|
||||||
onBlur={formik.handleBlur("father_name")}
|
|
||||||
error={formik.touched.father_name && Boolean(formik.errors.father_name)}
|
|
||||||
helperText={formik.touched.father_name && formik.errors.father_name}
|
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item xs={12} sm={4}>
|
<Grid item xs={12} sm={4}>
|
||||||
|
|||||||
@@ -1,119 +1,121 @@
|
|||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import { useMemo, useState } from "react";
|
import {useMemo, useState} from "react";
|
||||||
import Button from "@mui/material/Button";
|
import Button from "@mui/material/Button";
|
||||||
import { AdapterDateFnsJalali } from "@mui/x-date-pickers/AdapterDateFnsJalali";
|
import {AdapterDateFnsJalali} from "@mui/x-date-pickers/AdapterDateFnsJalali";
|
||||||
import { LocalizationProvider } from "@mui/x-date-pickers/LocalizationProvider";
|
import {LocalizationProvider} from "@mui/x-date-pickers/LocalizationProvider";
|
||||||
import { DatePicker } from "@mui/x-date-pickers/DatePicker";
|
import {DatePicker} from "@mui/x-date-pickers/DatePicker";
|
||||||
import { faIR } from "@mui/x-date-pickers/locales";
|
import {faIR} from "@mui/x-date-pickers/locales";
|
||||||
import { useTranslations } from "next-intl";
|
import {useTranslations} from "next-intl";
|
||||||
import moment from "jalali-moment";
|
import moment from "jalali-moment";
|
||||||
import { FormControl, FormHelperText } from "@mui/material";
|
import {FormControl, FormHelperText} from "@mui/material";
|
||||||
import { useConfig } from "@witel/webapp-builder";
|
import {useConfig} from "@witel/webapp-builder";
|
||||||
|
|
||||||
function ButtonField(props) {
|
function ButtonField(props) {
|
||||||
const t = useTranslations();
|
const t = useTranslations();
|
||||||
const {
|
const {
|
||||||
setOpen,
|
setOpen,
|
||||||
label,
|
label,
|
||||||
id,
|
id,
|
||||||
disabled,
|
disabled,
|
||||||
InputProps: { ref } = {},
|
InputProps: {ref} = {},
|
||||||
inputProps: { "aria-label": ariaLabel } = {},
|
inputProps: {"aria-label": ariaLabel} = {},
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Button
|
<Button
|
||||||
sx={{ width: "100%", padding: 0.8 }}
|
sx={{width: "100%", padding: 0.8}}
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
color={
|
color={
|
||||||
props.slotProps.formik.touched.birthday &&
|
props.slotProps.formik.touched.birthday &&
|
||||||
Boolean(props.slotProps.formik.errors.birthday)
|
Boolean(props.slotProps.formik.errors.birthday)
|
||||||
? "error"
|
? "error"
|
||||||
: "primary"
|
: "primary"
|
||||||
}
|
}
|
||||||
id={id}
|
id={id}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
ref={ref}
|
ref={ref}
|
||||||
aria-label={ariaLabel}
|
aria-label={ariaLabel}
|
||||||
onClick={() => setOpen?.((prev) => !prev)}
|
onClick={() => setOpen?.((prev) => !prev)}
|
||||||
>
|
>
|
||||||
{label ? `${t("birthday")}: ${label}` : `${t("birthday")}`}
|
{label ? `${t("birthday",
|
||||||
</Button>
|
{value: `${props.slotProps.formik.values.person_type === "legal" ? "مدیر عامل" : ""}`})}: ${label}` : `${t("birthday",
|
||||||
);
|
{value: `${props.slotProps.formik.values.person_type === "legal" ? "مدیر عامل" : ""}`})}`}
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ButtonDatePicker(props) {
|
function ButtonDatePicker(props) {
|
||||||
const { config } = useConfig();
|
const {config} = useConfig();
|
||||||
const t = useTranslations();
|
const t = useTranslations();
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
const dateRange = useMemo(() => {
|
const dateRange = useMemo(() => {
|
||||||
const today = moment();
|
const today = moment();
|
||||||
const min = moment(
|
const min = moment(
|
||||||
`${config.add_request_loan_birthday_range.min}-01-01`,
|
`${config.add_request_loan_birthday_range.min}-01-01`,
|
||||||
"jYYYY-jMM-jDD"
|
"jYYYY-jMM-jDD"
|
||||||
).toDate();
|
).toDate();
|
||||||
const max = moment(
|
const max = moment(
|
||||||
`${config.add_request_loan_birthday_range.max}-${today.format(
|
`${config.add_request_loan_birthday_range.max}-${today.format(
|
||||||
"jMM-jDD"
|
"jMM-jDD"
|
||||||
)}`,
|
)}`,
|
||||||
"jYYYY-jMM-jDD"
|
"jYYYY-jMM-jDD"
|
||||||
).toDate();
|
).toDate();
|
||||||
return { min, max };
|
return {min, max};
|
||||||
}, [config.add_request_loan_birthday_range]);
|
}, [config.add_request_loan_birthday_range]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DatePicker
|
<DatePicker
|
||||||
slots={{ field: ButtonField, ...props.slots }}
|
slots={{field: ButtonField, ...props.slots}}
|
||||||
disabled={props.disabled}
|
disabled={props.disabled}
|
||||||
slotProps={{
|
slotProps={{
|
||||||
formik: props.formik,
|
formik: props.formik,
|
||||||
field: { setOpen },
|
field: {setOpen},
|
||||||
textField: {
|
textField: {
|
||||||
helperText: props.formik.errors.birthday
|
helperText: props.formik.errors.birthday
|
||||||
? `${t("birthday_error")}`
|
? `${t("birthday_error", {value: `${props.formik.values.person_type === "legal" ? "مدیر عامل" : "خود"}`})}`
|
||||||
: null,
|
: null,
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
{...props}
|
{...props}
|
||||||
open={open}
|
open={open}
|
||||||
minDate={dateRange.min}
|
minDate={dateRange.min}
|
||||||
maxDate={dateRange.max}
|
maxDate={dateRange.max}
|
||||||
onClose={() => setOpen(false)}
|
onClose={() => setOpen(false)}
|
||||||
onOpen={() => setOpen(true)}
|
onOpen={() => setOpen(true)}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function PickerWithButtonField({ formik, disabled }) {
|
export default function PickerWithButtonField({formik, disabled}) {
|
||||||
return (
|
return (
|
||||||
<FormControl variant={"outlined"} fullWidth size="small" error={true}>
|
<FormControl variant={"outlined"} fullWidth size="small" error={true}>
|
||||||
<LocalizationProvider
|
<LocalizationProvider
|
||||||
dateAdapter={AdapterDateFnsJalali}
|
dateAdapter={AdapterDateFnsJalali}
|
||||||
localeText={{
|
localeText={{
|
||||||
...faIR.components.MuiLocalizationProvider.defaultProps.localeText,
|
...faIR.components.MuiLocalizationProvider.defaultProps.localeText,
|
||||||
okButtonLabel: "تایید",
|
okButtonLabel: "تایید",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<ButtonDatePicker
|
<ButtonDatePicker
|
||||||
label={
|
label={
|
||||||
formik.values.birthday !== "" &&
|
formik.values.birthday !== "" &&
|
||||||
formik.values.birthday.locale("fa").format("YYYY/MM/DD")
|
formik.values.birthday.locale("fa").format("YYYY/MM/DD")
|
||||||
}
|
}
|
||||||
value={
|
value={
|
||||||
formik.values.birthday !== ""
|
formik.values.birthday !== ""
|
||||||
? formik.values.birthday.toDate()
|
? formik.values.birthday.toDate()
|
||||||
: null
|
: null
|
||||||
}
|
}
|
||||||
formik={formik}
|
formik={formik}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
onChange={(newValue) => {
|
onChange={(newValue) => {
|
||||||
formik.setFieldValue("birthday", moment(newValue));
|
formik.setFieldValue("birthday", moment(newValue));
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</LocalizationProvider>
|
</LocalizationProvider>
|
||||||
<FormHelperText>
|
<FormHelperText>
|
||||||
{formik.touched.birthday && formik.errors.birthday}
|
{formik.touched.birthday && formik.errors.birthday}
|
||||||
</FormHelperText>
|
</FormHelperText>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
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;
|
|
||||||
@@ -25,7 +25,6 @@ const useProjectTitle = () => {
|
|||||||
setErrorProjectTitle(true);
|
setErrorProjectTitle(true);
|
||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
projectTitle,
|
projectTitle,
|
||||||
isLoadingProjectTitle,
|
isLoadingProjectTitle,
|
||||||
|
|||||||
Reference in New Issue
Block a user