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