Feature/new fields
This commit is contained in:
@@ -8,6 +8,8 @@ NEXT_PUBLIC_SECONDARY_MAIN = "#FF4E00"
|
||||
|
||||
NEXT_PUBLIC_MIN_BIRTHDAY = 1327
|
||||
NEXT_PUBLIC_MAX_BIRTHDAY = 1380
|
||||
NEXT_PUBLIC_BUS_AMOUNT=10000000000
|
||||
NEXT_PUBLIC_MINIBUS_AMOUNT=4000000000
|
||||
|
||||
NEXT_PUBLIC_BASE_URL = "https://loan-v2.witel.ir"
|
||||
NEXT_PUBLIC_POWERED_BY_URL = "https://witel.ir"
|
||||
|
||||
@@ -158,6 +158,7 @@
|
||||
"LoanRequest": {
|
||||
"finish_loan_request": "درخواست شما با موفقیت ثبت شد",
|
||||
"button_while_submit": "درحال بارگذاری ...",
|
||||
"max_amount": "حداکثر مبلغ تسهیلات مورد تقاضا {value} ریال می باشد",
|
||||
"checkbox": "بدینوسیله صحت کلیه اطلاعات مندرج در این فرم را تایید و گواهی میدهم .",
|
||||
"back_to_dashboard": "پیگیری درخواست ها",
|
||||
"cityList_empty": "ابتدا استان را وارد کنید",
|
||||
@@ -167,6 +168,13 @@
|
||||
"personal_info": "اطلاعات شخصی",
|
||||
"real_person": "شخص حقیقی",
|
||||
"legal_person": "شخص حقوقی",
|
||||
"user_committed_employment" :"تعداد اشتغال متعهد متقاضی",
|
||||
"user_existing_employment" : "تعداد اشتغال موجود متقاضی",
|
||||
"error_message_user_committed_employment" : " لطفا تعداد اشتغال متعهد متقاضی را وارد کنید!",
|
||||
"error_message_user_existing_employment" : " لطفا تعداد اشتغال موجود متقاضی را وارد کنید!",
|
||||
"text_field_requested_facilities" : "تسهیلات مورد تقاضا(ریال)",
|
||||
"text_field_investment" : "سرمایه گذاری انجام شده(ریال)",
|
||||
"text_field_applicant_payment" : "آورده متقاضی(ریال)",
|
||||
"national_code_number": "کد ملی می بایست شامل اعداد باشد",
|
||||
"boss_national_code_number": "کد ملی مدیر عامل می بایست شامل اعداد باشد",
|
||||
"national_number_number": "شناسه ملی شرکت می بایست شامل اعداد باشد",
|
||||
@@ -189,6 +197,9 @@
|
||||
"error_message_name": "لطفا نام خود را وارد کنید!",
|
||||
"error_message_company_name": "لطفا نام شرکت خود را وارد کنید!",
|
||||
"error_message_first_name": "لطفا نام خود را وارد کنید!",
|
||||
"error_message_requested_facilities": "لطفا تسهیلات مورد تقاضا را وارد نمایید!",
|
||||
"error_message_investment": "لطفا سرمایه گذاری انجام شده را وارد نمایید!",
|
||||
"error_message_applicant_payment": "لطفا آورده متقاضی را وارد نمایید!",
|
||||
"error_message_boss_first_name": "لطفا نام مدیر عامل را وارد کنید!",
|
||||
"error_message_last_name": "لطفا نام خانوادگی خود را وارد کنید!",
|
||||
"error_message_boss_last_name": "لطفا نام خانوادگی مدیر عامل را وارد کنید!",
|
||||
@@ -302,6 +313,7 @@
|
||||
"ShowLoan": {
|
||||
"show_loan_page": "نمایش وام | ناوگان",
|
||||
"text_field_activity_type": "نوع فعالیت",
|
||||
"max_amount": "حداکثر مبلغ تسهیلات مورد تقاضا {value} ریال می باشد",
|
||||
"text_field_navgan_plan_id": "عنوان پروژه",
|
||||
"update_loan_page": "نمایش وام | {person_type} | کد یکتا {id}",
|
||||
"edit_loan_page": "ویرایش وام | {person_type} | کد یکتا {id}",
|
||||
@@ -319,12 +331,19 @@
|
||||
"error_message_tracking_code": "لطفا کد رهگیری کارت ملی خود را وارد کنید!",
|
||||
"text_field_shenasname_serial": "سریال پشت کارت ملی",
|
||||
"text_field_national_trackin_code": "کد رهگیری کارت ملی",
|
||||
"user_committed_employment" :"تعداد اشتغال متعهد متقاضی",
|
||||
"user_existing_employment" : "تعداد اشتغال موجود متقاضی",
|
||||
"error_message_user_committed_employment" : " لطفا تعداد اشتغال متعهد متقاضی را وارد کنید!",
|
||||
"error_message_user_existing_employment" : " لطفا تعداد اشتغال موجود متقاضی را وارد کنید!",
|
||||
"text_field_national_id": "کد ملی",
|
||||
"text_field_boss_national_id": "کد ملی مدیر عامل",
|
||||
"text_field_register_number": "شماره ثبت شرکت",
|
||||
"text_field_postal_code": "کد پستی",
|
||||
"text_field_national_serial_number": "سریال پشت کارت ملی",
|
||||
"text_field_address": "آدرس",
|
||||
"text_field_requested_facilities" : "تسهیلات مورد تقاضا(ریال)",
|
||||
"text_field_investment" : "سرمایه گذاری انجام شده(ریال)",
|
||||
"text_field_applicant_payment" : "آورده متقاضی(ریال)",
|
||||
"text_field_company_name": "نام شرکت",
|
||||
"text_field_birthday": "تاریخ تولد",
|
||||
"text_field_navgan_id": "کد ناوگان",
|
||||
@@ -369,6 +388,9 @@
|
||||
"error_message_father_name": "لطفا نام پدر خود را وارد کنید!",
|
||||
"error_message_first_name": "لطفا نام خود را وارد کنید!",
|
||||
"error_message_province_id": "لطفا استان را وارد کنید!",
|
||||
"error_message_requested_facilities": "لطفا تسهیلات مورد تقاضا را وارد نمایید!",
|
||||
"error_message_investment": "لطفا سرمایه گذاری انجام شده را وارد نمایید!",
|
||||
"error_message_applicant_payment": "لطفا آورده متقاضی را وارد نمایید!",
|
||||
"error_message_city_id": "لطفا شهر خود را وارد کنید!",
|
||||
"error_message_name": "لطفا نام کامل مالک را وارد کنید!",
|
||||
"error_message_register_number": "لطفا شماره ثبت شرکت خود را وارد کنید!",
|
||||
@@ -391,5 +413,8 @@
|
||||
},
|
||||
"EditLoanRequest": {
|
||||
"edit_loan_request_page": "ویرایش درخواست وام"
|
||||
},
|
||||
"PriceField": {
|
||||
"toman": "تومان"
|
||||
}
|
||||
}
|
||||
@@ -26,11 +26,18 @@ import useProjectTitle from "@/lib/app/hooks/useProjectTitle";
|
||||
import useActivityType from "@/lib/app/hooks/useActivityType";
|
||||
import MuiDatePicker from "@/core/components/MuiDatePicker";
|
||||
import LegalPersonDatePicker from "@/core/components/LegalPersonDatePicker";
|
||||
import PriceField from "@/core/components/PriceField";
|
||||
import { useState } from "react";
|
||||
|
||||
const vehicle_amount = {
|
||||
اتوبوس: parseInt(process.env.NEXT_PUBLIC_BUS_AMOUNT),
|
||||
"مینی بوس": parseInt(process.env.NEXT_PUBLIC_MINIBUS_AMOUNT),
|
||||
};
|
||||
const LegalPersonForm = ({ setFinishLoanRequest }) => {
|
||||
const t = useTranslations();
|
||||
const router = useRouter();
|
||||
const requestServer = useRequest();
|
||||
const [vehicleType, setVehicleType] = useState("");
|
||||
const { getUser, changeUser } = useUser();
|
||||
const { cityTextField, cityList, setProvinceID, isLoadingCityList } = useCities();
|
||||
const { provinceList, isLoadingProvinceList, errorProvinceList } = useLimitedProvince();
|
||||
@@ -45,6 +52,11 @@ const LegalPersonForm = ({ setFinishLoanRequest }) => {
|
||||
activity_type: "",
|
||||
navgan_plan_id: "",
|
||||
birthday: "",
|
||||
investment: "",
|
||||
requested_facilities: "",
|
||||
applicant_payment: "",
|
||||
user_existing_employment: "",
|
||||
user_committed_employment: "",
|
||||
vehicle_type: "",
|
||||
province_id: "",
|
||||
boss_father_name: "",
|
||||
@@ -81,6 +93,18 @@ const LegalPersonForm = ({ setFinishLoanRequest }) => {
|
||||
})
|
||||
.required(t("LoanRequest.error_message_company_tel_number")),
|
||||
vehicle_type: Yup.string().required(t("LoanRequest.error_message_vehicle_type")),
|
||||
requested_facilities: Yup.mixed()
|
||||
.test(
|
||||
"max-amount",
|
||||
`${t("LoanRequest.max_amount", {
|
||||
value: parseInt(vehicle_amount[vehicleType]).toLocaleString("en"),
|
||||
})}`,
|
||||
(value) => value <= vehicle_amount[vehicleType]
|
||||
)
|
||||
.required(t("LoanRequest.error_message_requested_facilities")),
|
||||
investment: Yup.string().required(t("LoanRequest.error_message_investment")),
|
||||
user_committed_employment: Yup.string().required(t("LoanRequest.error_message_user_committed_employment")),
|
||||
user_existing_employment: Yup.string().required(t("LoanRequest.error_message_user_existing_employment")),
|
||||
activity_type: Yup.string().required(t("LoanRequest.error_message_activity_type")),
|
||||
navgan_plan_id: Yup.string().required(t("LoanRequest.error_message_navgan_plan_id")),
|
||||
register_number: Yup.string().required(t("LoanRequest.error_message_register_number")),
|
||||
@@ -192,6 +216,11 @@ const LegalPersonForm = ({ setFinishLoanRequest }) => {
|
||||
navgan_plan_id: values.navgan_plan_id,
|
||||
postal_code: values.company_postal_code,
|
||||
navgan_type: "عمومی",
|
||||
requested_facility_amount: Number(values.requested_facilities),
|
||||
investment_amount: Number(values.investment),
|
||||
person_share: Number(values.applicant_payment),
|
||||
user_committed_employment: Number(values.user_committed_employment),
|
||||
user_existing_employment: Number(values.user_existing_employment),
|
||||
gender: values.boss_gender,
|
||||
plate_part1: values.plate_part1,
|
||||
plate_part2: values.plate_part2,
|
||||
@@ -230,6 +259,16 @@ const LegalPersonForm = ({ setFinishLoanRequest }) => {
|
||||
validationSchema,
|
||||
onSubmit: handleSubmit,
|
||||
});
|
||||
const handleAmountChange = (event) => {
|
||||
if (!isNaN(event.target.value)) {
|
||||
formik.setFieldValue("requested_facilities", event.target.value).then(() => {
|
||||
formik.setFieldTouched("applicant_payment", false, false);
|
||||
formik.setFieldValue("applicant_payment", Math.floor(event.target.value * 0.2));
|
||||
});
|
||||
} else {
|
||||
formik.setFieldValue("requested_facilities", formik.values.requested_facilities);
|
||||
}
|
||||
};
|
||||
return (
|
||||
<>
|
||||
<Grid container spacing={2} sx={{ p: 2 }}>
|
||||
@@ -703,7 +742,10 @@ const LegalPersonForm = ({ setFinishLoanRequest }) => {
|
||||
},
|
||||
]}
|
||||
select={formik.values.vehicle_type}
|
||||
handleChange={(event) => formik.setFieldValue("vehicle_type", event.target.value)}
|
||||
handleChange={(event) => {
|
||||
setVehicleType(event.target.value);
|
||||
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")}
|
||||
@@ -775,6 +817,134 @@ const LegalPersonForm = ({ setFinishLoanRequest }) => {
|
||||
/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Grid container spacing={2} sx={{ p: 2 }}>
|
||||
<Grid item xs={12} sm={6}>
|
||||
<TextField
|
||||
rows={4}
|
||||
sx={{ width: "100%" }}
|
||||
name="user_committed_employment"
|
||||
variant="outlined"
|
||||
value={formik.values.user_committed_employment}
|
||||
size="small"
|
||||
type={"tel"}
|
||||
label={t("ShowLoan.user_committed_employment")}
|
||||
error={!!(formik.touched.user_committed_employment && formik.errors.user_committed_employment)}
|
||||
onChange={(event) => {
|
||||
const inputValue = event.target.value;
|
||||
if (isNaN(Number(inputValue))) {
|
||||
return;
|
||||
}
|
||||
formik.handleChange({
|
||||
target: {
|
||||
name: "user_committed_employment",
|
||||
value: inputValue,
|
||||
},
|
||||
});
|
||||
}}
|
||||
fullWidth
|
||||
helperText={
|
||||
formik.touched.user_committed_employment ? formik.errors.user_committed_employment : null
|
||||
}
|
||||
onBlur={formik.handleBlur("user_committed_employment")}
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={12} sm={6}>
|
||||
<TextField
|
||||
rows={4}
|
||||
sx={{ width: "100%" }}
|
||||
name="user_existing_employment"
|
||||
variant="outlined"
|
||||
type={"tel"}
|
||||
value={formik.values.user_existing_employment}
|
||||
size="small"
|
||||
label={t("ShowLoan.user_existing_employment")}
|
||||
error={!!(formik.touched.user_existing_employment && formik.errors.user_existing_employment)}
|
||||
onChange={(event) => {
|
||||
const inputValue = event.target.value;
|
||||
if (isNaN(Number(inputValue))) {
|
||||
return;
|
||||
}
|
||||
formik.handleChange({
|
||||
target: {
|
||||
name: "user_existing_employment",
|
||||
value: inputValue,
|
||||
},
|
||||
});
|
||||
}}
|
||||
fullWidth
|
||||
helperText={
|
||||
formik.touched.user_existing_employment ? formik.errors.user_existing_employment : null
|
||||
}
|
||||
onBlur={formik.handleBlur("user_existing_employment")}
|
||||
/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Grid container spacing={2} sx={{ padding: 2 }}>
|
||||
<Grid item xs={12} sm={4}>
|
||||
<PriceField
|
||||
name="investment"
|
||||
label={t("LoanRequest.text_field_investment")}
|
||||
type="text"
|
||||
size="small"
|
||||
inputProps={{
|
||||
inputMode: "number",
|
||||
min: 0,
|
||||
pattern: "[0-9]*",
|
||||
}}
|
||||
variant="outlined"
|
||||
value={formik.values.investment}
|
||||
onChange={(event) => {
|
||||
const inputValue = event.target.value;
|
||||
if (isNaN(Number(inputValue))) {
|
||||
return;
|
||||
}
|
||||
formik.setFieldValue("investment", event.target.value);
|
||||
}}
|
||||
onBlur={formik.handleBlur("investment")}
|
||||
error={formik.touched.investment && Boolean(formik.errors.investment)}
|
||||
helperText={formik.touched.investment && formik.errors.investment}
|
||||
fullWidth
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={12} sm={4}>
|
||||
<PriceField
|
||||
name="requested_facilities"
|
||||
label={t("LoanRequest.text_field_requested_facilities")}
|
||||
type="text"
|
||||
size="small"
|
||||
inputProps={{
|
||||
inputMode: "number",
|
||||
min: 0,
|
||||
pattern: "[0-9]*",
|
||||
}}
|
||||
variant="outlined"
|
||||
value={formik.values.requested_facilities}
|
||||
onChange={handleAmountChange}
|
||||
disabled={formik.values.vehicle_type === ""}
|
||||
onBlur={formik.handleBlur("requested_facilities")}
|
||||
error={formik.touched.requested_facilities && Boolean(formik.errors.requested_facilities)}
|
||||
helperText={formik.touched.requested_facilities && formik.errors.requested_facilities}
|
||||
fullWidth
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={12} sm={4}>
|
||||
<PriceField
|
||||
name="applicant_payment"
|
||||
label={t("LoanRequest.text_field_applicant_payment")}
|
||||
type="text"
|
||||
size="small"
|
||||
inputProps={{
|
||||
inputMode: "number",
|
||||
min: 0,
|
||||
pattern: "[0-9]*",
|
||||
}}
|
||||
variant="outlined"
|
||||
value={formik.values.applicant_payment}
|
||||
disabled
|
||||
fullWidth
|
||||
/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Grid container spacing={2} sx={{ padding: 2 }}>
|
||||
<Grid item xs={12}>
|
||||
<TextField
|
||||
|
||||
@@ -25,9 +25,16 @@ import UseEducations from "@/lib/app/hooks/useEducations";
|
||||
import useOccupations from "@/lib/app/hooks/useOccupations";
|
||||
import useActivityType from "@/lib/app/hooks/useActivityType";
|
||||
import useProjectTitle from "@/lib/app/hooks/useProjectTitle";
|
||||
import PriceField from "@/core/components/PriceField";
|
||||
import { useState } from "react";
|
||||
|
||||
const vehicle_amount = {
|
||||
اتوبوس: parseInt(process.env.NEXT_PUBLIC_BUS_AMOUNT),
|
||||
"مینی بوس": parseInt(process.env.NEXT_PUBLIC_MINIBUS_AMOUNT),
|
||||
};
|
||||
const RealPersonForm = ({ setFinishLoanRequest }) => {
|
||||
const t = useTranslations();
|
||||
const [vehicleType, setVehicleType] = useState("");
|
||||
const { provinceList, isLoadingProvinceList, errorProvinceList } = useLimitedProvince();
|
||||
const { cityTextField, cityList, setProvinceID, isLoadingCityList } = useCities();
|
||||
const { educationsList, isLoadingEducationsList, errorEducationsList } = UseEducations();
|
||||
@@ -44,6 +51,11 @@ const RealPersonForm = ({ setFinishLoanRequest }) => {
|
||||
telephone_number: "",
|
||||
activity_type: "",
|
||||
navgan_plan_id: "",
|
||||
investment: "",
|
||||
requested_facilities: "",
|
||||
applicant_payment: "",
|
||||
user_existing_employment: "",
|
||||
user_committed_employment: "",
|
||||
father_name: "",
|
||||
gender: "",
|
||||
first_name: "",
|
||||
@@ -76,6 +88,18 @@ const RealPersonForm = ({ setFinishLoanRequest }) => {
|
||||
})
|
||||
.required(t("LoanRequest.error_message_tel_number")),
|
||||
vehicle_type: Yup.string().required(t("LoanRequest.error_message_vehicle_type")),
|
||||
requested_facilities: Yup.mixed()
|
||||
.test(
|
||||
"max-amount",
|
||||
`${t("LoanRequest.max_amount", {
|
||||
value: parseInt(vehicle_amount[vehicleType]).toLocaleString("en"),
|
||||
})}`,
|
||||
(value) => value <= vehicle_amount[vehicleType]
|
||||
)
|
||||
.required(t("LoanRequest.error_message_requested_facilities")),
|
||||
investment: Yup.string().required(t("LoanRequest.error_message_investment")),
|
||||
user_committed_employment: Yup.string().required(t("LoanRequest.error_message_user_committed_employment")),
|
||||
user_existing_employment: Yup.string().required(t("LoanRequest.error_message_user_existing_employment")),
|
||||
activity_type: Yup.string().required(t("LoanRequest.error_message_activity_type")),
|
||||
navgan_plan_id: Yup.string().required(t("LoanRequest.error_message_navgan_plan_id")),
|
||||
gender: Yup.string().required(t("LoanRequest.error_message_gender")),
|
||||
@@ -139,7 +163,6 @@ const RealPersonForm = ({ setFinishLoanRequest }) => {
|
||||
|
||||
const handleSubmit = async (values, props) => {
|
||||
props.setSubmitting(true);
|
||||
|
||||
const _national_card =
|
||||
values.national_serial_number_or_tracking_code === "national_serial_number"
|
||||
? {
|
||||
@@ -162,6 +185,11 @@ const RealPersonForm = ({ setFinishLoanRequest }) => {
|
||||
postal_code: values.postal_code,
|
||||
navgan_type: "عمومی",
|
||||
gender: values.gender,
|
||||
requested_facility_amount: Number(values.requested_facilities),
|
||||
investment_amount: Number(values.investment),
|
||||
person_share: Number(values.applicant_payment),
|
||||
user_committed_employment: Number(values.user_committed_employment),
|
||||
user_existing_employment: Number(values.user_existing_employment),
|
||||
address: values.address,
|
||||
education_id: values.education_id,
|
||||
occupation_id: values.occupation_id,
|
||||
@@ -199,7 +227,16 @@ const RealPersonForm = ({ setFinishLoanRequest }) => {
|
||||
validationSchema,
|
||||
onSubmit: handleSubmit,
|
||||
});
|
||||
|
||||
const handleAmountChange = (event) => {
|
||||
if (!isNaN(event.target.value)) {
|
||||
formik.setFieldValue("requested_facilities", event.target.value).then(() => {
|
||||
formik.setFieldTouched("applicant_payment", false, false);
|
||||
formik.setFieldValue("applicant_payment", Math.floor(event.target.value * 0.2));
|
||||
});
|
||||
} else {
|
||||
formik.setFieldValue("requested_facilities", formik.values.requested_facilities);
|
||||
}
|
||||
};
|
||||
return (
|
||||
<>
|
||||
<Grid container spacing={2} sx={{ p: 2 }}>
|
||||
@@ -603,7 +640,10 @@ const RealPersonForm = ({ setFinishLoanRequest }) => {
|
||||
},
|
||||
]}
|
||||
select={formik.values.vehicle_type}
|
||||
handleChange={(event) => formik.setFieldValue("vehicle_type", event.target.value)}
|
||||
handleChange={(event) => {
|
||||
setVehicleType(event.target.value);
|
||||
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")}
|
||||
@@ -657,6 +697,134 @@ const RealPersonForm = ({ setFinishLoanRequest }) => {
|
||||
/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Grid container spacing={2} sx={{ p: 2 }}>
|
||||
<Grid item xs={12} sm={6}>
|
||||
<TextField
|
||||
rows={4}
|
||||
sx={{ width: "100%" }}
|
||||
name="user_committed_employment"
|
||||
variant="outlined"
|
||||
value={formik.values.user_committed_employment}
|
||||
size="small"
|
||||
type={"tel"}
|
||||
label={t("ShowLoan.user_committed_employment")}
|
||||
error={!!(formik.touched.user_committed_employment && formik.errors.user_committed_employment)}
|
||||
onChange={(event) => {
|
||||
const inputValue = event.target.value;
|
||||
if (isNaN(Number(inputValue))) {
|
||||
return;
|
||||
}
|
||||
formik.handleChange({
|
||||
target: {
|
||||
name: "user_committed_employment",
|
||||
value: inputValue,
|
||||
},
|
||||
});
|
||||
}}
|
||||
fullWidth
|
||||
helperText={
|
||||
formik.touched.user_committed_employment ? formik.errors.user_committed_employment : null
|
||||
}
|
||||
onBlur={formik.handleBlur("user_committed_employment")}
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={12} sm={6}>
|
||||
<TextField
|
||||
rows={4}
|
||||
sx={{ width: "100%" }}
|
||||
name="user_existing_employment"
|
||||
variant="outlined"
|
||||
type={"tel"}
|
||||
value={formik.values.user_existing_employment}
|
||||
size="small"
|
||||
label={t("ShowLoan.user_existing_employment")}
|
||||
error={!!(formik.touched.user_existing_employment && formik.errors.user_existing_employment)}
|
||||
onChange={(event) => {
|
||||
const inputValue = event.target.value;
|
||||
if (isNaN(Number(inputValue))) {
|
||||
return;
|
||||
}
|
||||
formik.handleChange({
|
||||
target: {
|
||||
name: "user_existing_employment",
|
||||
value: inputValue,
|
||||
},
|
||||
});
|
||||
}}
|
||||
fullWidth
|
||||
helperText={
|
||||
formik.touched.user_existing_employment ? formik.errors.user_existing_employment : null
|
||||
}
|
||||
onBlur={formik.handleBlur("user_existing_employment")}
|
||||
/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Grid container spacing={2} sx={{ padding: 2 }}>
|
||||
<Grid item xs={12} sm={4}>
|
||||
<PriceField
|
||||
name="investment"
|
||||
label={t("LoanRequest.text_field_investment")}
|
||||
type="text"
|
||||
size="small"
|
||||
inputProps={{
|
||||
inputMode: "number",
|
||||
min: 0,
|
||||
pattern: "[0-9]*",
|
||||
}}
|
||||
variant="outlined"
|
||||
value={formik.values.investment}
|
||||
onChange={(event) => {
|
||||
const inputValue = event.target.value;
|
||||
if (isNaN(Number(inputValue))) {
|
||||
return;
|
||||
}
|
||||
formik.setFieldValue("investment", event.target.value);
|
||||
}}
|
||||
onBlur={formik.handleBlur("investment")}
|
||||
error={formik.touched.investment && Boolean(formik.errors.investment)}
|
||||
helperText={formik.touched.investment && formik.errors.investment}
|
||||
fullWidth
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={12} sm={4}>
|
||||
<PriceField
|
||||
name="requested_facilities"
|
||||
label={t("LoanRequest.text_field_requested_facilities")}
|
||||
type="text"
|
||||
size="small"
|
||||
inputProps={{
|
||||
inputMode: "number",
|
||||
min: 0,
|
||||
pattern: "[0-9]*",
|
||||
}}
|
||||
variant="outlined"
|
||||
value={formik.values.requested_facilities}
|
||||
onChange={handleAmountChange}
|
||||
disabled={formik.values.vehicle_type === ""}
|
||||
onBlur={formik.handleBlur("requested_facilities")}
|
||||
error={formik.touched.requested_facilities && Boolean(formik.errors.requested_facilities)}
|
||||
helperText={formik.touched.requested_facilities && formik.errors.requested_facilities}
|
||||
fullWidth
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={12} sm={4}>
|
||||
<PriceField
|
||||
name="applicant_payment"
|
||||
label={t("LoanRequest.text_field_applicant_payment")}
|
||||
type="text"
|
||||
size="small"
|
||||
inputProps={{
|
||||
inputMode: "number",
|
||||
min: 0,
|
||||
pattern: "[0-9]*",
|
||||
}}
|
||||
variant="outlined"
|
||||
value={formik.values.applicant_payment}
|
||||
disabled
|
||||
fullWidth
|
||||
/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Grid container spacing={2} sx={{ padding: 2 }}>
|
||||
<Grid item xs={12}>
|
||||
<TextField
|
||||
|
||||
@@ -19,6 +19,11 @@ import * as React from "react";
|
||||
import useProjectTitle from "@/lib/app/hooks/useProjectTitle";
|
||||
import useActivityType from "@/lib/app/hooks/useActivityType";
|
||||
import LegalPersonDatePicker from "@/core/components/LegalPersonDatePicker";
|
||||
import PriceField from "@/core/components/PriceField";
|
||||
const vehicle_amount = {
|
||||
اتوبوس: parseInt(process.env.NEXT_PUBLIC_BUS_AMOUNT),
|
||||
"مینی بوس": parseInt(process.env.NEXT_PUBLIC_MINIBUS_AMOUNT),
|
||||
};
|
||||
const UpdateFormLegal = ({ LoanDetails, LoanId }) => {
|
||||
const t = useTranslations();
|
||||
const provinceStates = useProvince();
|
||||
@@ -29,7 +34,6 @@ const UpdateFormLegal = ({ LoanDetails, LoanId }) => {
|
||||
const { educationsList, isLoadingEducationsList, errorEducationsList } = UseEducations();
|
||||
const { occupationsList, isLoadingOccupationsList, errorOccupationsList } = useOccupations();
|
||||
const requestServer = useRequest();
|
||||
|
||||
const initialValues = {
|
||||
is_legal_person: 1,
|
||||
national_serial_number_or_tracking_code: LoanDetails.national_serial_number ? "serial_number" : "tracking_code",
|
||||
@@ -39,6 +43,11 @@ const UpdateFormLegal = ({ LoanDetails, LoanId }) => {
|
||||
postal_code: LoanDetails.postal_code || "",
|
||||
address: LoanDetails.address || "",
|
||||
company_name: LoanDetails.company_name || "",
|
||||
investment: LoanDetails.investment_amount || "",
|
||||
requested_facilities: LoanDetails.requested_facility_amount || "",
|
||||
user_existing_employment: LoanDetails.user_existing_employment || "",
|
||||
user_committed_employment: LoanDetails.user_committed_employment || "",
|
||||
applicant_payment: LoanDetails.person_share || "",
|
||||
register_number: LoanDetails.register_number || "",
|
||||
company_date: LoanDetails.company_register_date ? moment(LoanDetails.company_register_date) : "",
|
||||
birthday: LoanDetails.birthday ? moment(LoanDetails.birthday) : "",
|
||||
@@ -48,7 +57,7 @@ const UpdateFormLegal = ({ LoanDetails, LoanId }) => {
|
||||
boss_first_name: LoanDetails.first_name || "",
|
||||
boss_last_name: LoanDetails.last_name || "",
|
||||
boss_father_name: LoanDetails.father_name || "",
|
||||
gender: LoanDetails.gender || "",
|
||||
gender: LoanDetails.gender === null ? "" : LoanDetails.gender,
|
||||
navgan_type: LoanDetails.navgan_type || "",
|
||||
vehicle_type: LoanDetails.vehicle_type || "",
|
||||
telephone_number: LoanDetails.telephone_number || "",
|
||||
@@ -71,6 +80,18 @@ const UpdateFormLegal = ({ LoanDetails, LoanId }) => {
|
||||
postal_code: Yup.mixed()
|
||||
.test("max", `${t("ShowLoan.postal_code_max")}`, (value) => value.toString().length === 10)
|
||||
.required(t("ShowLoan.error_message_postal_code")),
|
||||
requested_facilities: Yup.mixed()
|
||||
.test(
|
||||
"max-amount",
|
||||
`${t("ShowLoan.max_amount", {
|
||||
value: parseInt(vehicle_amount[LoanDetails.vehicle_type]).toLocaleString("en"),
|
||||
})}`,
|
||||
(value) => value <= vehicle_amount[LoanDetails.vehicle_type]
|
||||
)
|
||||
.required(t("ShowLoan.error_message_requested_facilities")),
|
||||
investment: Yup.string().required(t("ShowLoan.error_message_investment")),
|
||||
user_committed_employment: Yup.string().required(t("ShowLoan.error_message_user_committed_employment")),
|
||||
user_existing_employment: Yup.string().required(t("ShowLoan.error_message_user_existing_employment")),
|
||||
address: Yup.string().required(t("ShowLoan.error_message_address")),
|
||||
province_id: Yup.string().required(t("ShowLoan.error_message_province_id")),
|
||||
activity_type: Yup.string().required(t("ShowLoan.error_message_activity_type")),
|
||||
@@ -165,6 +186,11 @@ const UpdateFormLegal = ({ LoanDetails, LoanId }) => {
|
||||
formData.append("last_name", values.boss_last_name);
|
||||
formData.append("father_name", values.boss_father_name);
|
||||
formData.append("gender", values.gender);
|
||||
formData.append("requested_facility_amount", Number(values.requested_facilities));
|
||||
formData.append("investment_amount", Number(values.investment));
|
||||
formData.append("person_share", Number(values.applicant_payment));
|
||||
formData.append("user_committed_employment", values.user_committed_employment);
|
||||
formData.append("user_existing_employment", values.user_existing_employment);
|
||||
formData.append("city_id", values.city_id);
|
||||
formData.append("telephone_number", values.telephone_number);
|
||||
formData.append("education_id", values.education_id);
|
||||
@@ -193,6 +219,16 @@ const UpdateFormLegal = ({ LoanDetails, LoanId }) => {
|
||||
validationSchema,
|
||||
onSubmit: handleSubmit,
|
||||
});
|
||||
const handleAmountChange = (event) => {
|
||||
if (!isNaN(event.target.value)) {
|
||||
formik.setFieldValue("requested_facilities", event.target.value).then(() => {
|
||||
formik.setFieldTouched("applicant_payment", false, false);
|
||||
formik.setFieldValue("applicant_payment", Math.floor(event.target.value * 0.2));
|
||||
});
|
||||
} else {
|
||||
formik.setFieldValue("requested_facilities", formik.values.requested_facilities);
|
||||
}
|
||||
};
|
||||
return (
|
||||
<>
|
||||
<Box sx={{ width: "80%", my: 2 }}>
|
||||
@@ -413,8 +449,9 @@ const UpdateFormLegal = ({ LoanDetails, LoanId }) => {
|
||||
]}
|
||||
schema={{ value: "value", name: "name" }}
|
||||
select={formik.values.gender}
|
||||
isLoading={!formik.values.gender}
|
||||
handleChange={formik.handleChange}
|
||||
handleChange={(event) => {
|
||||
formik.setFieldValue("gender", event.target.value);
|
||||
}}
|
||||
setFieldTouched={formik.setFieldTouched}
|
||||
error={formik.touched.gender && Boolean(formik.errors.gender)}
|
||||
helperText={formik.touched.gender && formik.errors.gender}
|
||||
@@ -796,6 +833,143 @@ const UpdateFormLegal = ({ LoanDetails, LoanId }) => {
|
||||
/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Grid container spacing={2} sx={{ p: 2 }}>
|
||||
<Grid item xs={12} sm={6}>
|
||||
<TextField
|
||||
disabled={LoanDetails.state_id !== 17}
|
||||
rows={4}
|
||||
sx={{ width: "100%" }}
|
||||
name="user_committed_employment"
|
||||
variant="outlined"
|
||||
value={formik.values.user_committed_employment}
|
||||
size="small"
|
||||
type={"tel"}
|
||||
label={t("ShowLoan.user_committed_employment")}
|
||||
error={
|
||||
!!(formik.touched.user_committed_employment && formik.errors.user_committed_employment)
|
||||
}
|
||||
onChange={(event) => {
|
||||
const inputValue = event.target.value;
|
||||
if (isNaN(Number(inputValue))) {
|
||||
return;
|
||||
}
|
||||
formik.handleChange({
|
||||
target: {
|
||||
name: "user_committed_employment",
|
||||
value: inputValue,
|
||||
},
|
||||
});
|
||||
}}
|
||||
fullWidth
|
||||
helperText={
|
||||
formik.touched.user_committed_employment
|
||||
? formik.errors.user_committed_employment
|
||||
: null
|
||||
}
|
||||
onBlur={formik.handleBlur("user_committed_employment")}
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={12} sm={6}>
|
||||
<TextField
|
||||
disabled={LoanDetails.state_id !== 17}
|
||||
rows={4}
|
||||
sx={{ width: "100%" }}
|
||||
name="user_existing_employment"
|
||||
variant="outlined"
|
||||
type={"tel"}
|
||||
value={formik.values.user_existing_employment}
|
||||
size="small"
|
||||
label={t("ShowLoan.user_existing_employment")}
|
||||
error={
|
||||
!!(formik.touched.user_existing_employment && formik.errors.user_existing_employment)
|
||||
}
|
||||
onChange={(event) => {
|
||||
const inputValue = event.target.value;
|
||||
if (isNaN(Number(inputValue))) {
|
||||
return;
|
||||
}
|
||||
formik.handleChange({
|
||||
target: {
|
||||
name: "user_existing_employment",
|
||||
value: inputValue,
|
||||
},
|
||||
});
|
||||
}}
|
||||
fullWidth
|
||||
helperText={
|
||||
formik.touched.user_existing_employment ? formik.errors.user_existing_employment : null
|
||||
}
|
||||
onBlur={formik.handleBlur("user_existing_employment")}
|
||||
/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Grid container spacing={2} sx={{ padding: 2 }}>
|
||||
<Grid item xs={12} sm={4}>
|
||||
<PriceField
|
||||
name="investment"
|
||||
label={t("ShowLoan.text_field_investment")}
|
||||
type="text"
|
||||
size="small"
|
||||
inputProps={{
|
||||
inputMode: "number",
|
||||
min: 0,
|
||||
pattern: "[0-9]*",
|
||||
}}
|
||||
variant="outlined"
|
||||
value={formik.values.investment}
|
||||
onChange={(event) => {
|
||||
const inputValue = event.target.value;
|
||||
if (isNaN(Number(inputValue))) {
|
||||
return;
|
||||
}
|
||||
formik.setFieldValue("investment", event.target.value);
|
||||
}}
|
||||
disabled={LoanDetails.state_id !== 17}
|
||||
onBlur={formik.handleBlur("investment")}
|
||||
error={formik.touched.investment && Boolean(formik.errors.investment)}
|
||||
helperText={formik.touched.investment && formik.errors.investment}
|
||||
fullWidth
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={12} sm={4}>
|
||||
<PriceField
|
||||
name="requested_facilities"
|
||||
label={t("ShowLoan.text_field_requested_facilities")}
|
||||
type="text"
|
||||
size="small"
|
||||
inputProps={{
|
||||
inputMode: "number",
|
||||
min: 0,
|
||||
pattern: "[0-9]*",
|
||||
}}
|
||||
variant="outlined"
|
||||
value={formik.values.requested_facilities}
|
||||
onChange={handleAmountChange}
|
||||
disabled={formik.values.vehicle_type === "" || LoanDetails.state_id !== 17}
|
||||
onBlur={formik.handleBlur("requested_facilities")}
|
||||
error={formik.touched.requested_facilities && Boolean(formik.errors.requested_facilities)}
|
||||
helperText={formik.touched.requested_facilities && formik.errors.requested_facilities}
|
||||
fullWidth
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={12} sm={4}>
|
||||
<PriceField
|
||||
name="applicant_payment"
|
||||
label={t("ShowLoan.text_field_applicant_payment")}
|
||||
type="text"
|
||||
size="small"
|
||||
inputProps={{
|
||||
inputMode: "number",
|
||||
min: 0,
|
||||
pattern: "[0-9]*",
|
||||
}}
|
||||
variant="outlined"
|
||||
value={formik.values.applicant_payment}
|
||||
disabled
|
||||
fullWidth
|
||||
/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Grid container spacing={2} sx={{ p: 2 }}>
|
||||
<Grid item xs={12} sm={12}>
|
||||
<TextField
|
||||
|
||||
@@ -18,6 +18,12 @@ import EditIcon from "@mui/icons-material/Edit";
|
||||
import * as React from "react";
|
||||
import useProjectTitle from "@/lib/app/hooks/useProjectTitle";
|
||||
import useActivityType from "@/lib/app/hooks/useActivityType";
|
||||
import PriceField from "@/core/components/PriceField";
|
||||
const vehicle_amount = {
|
||||
اتوبوس: parseInt(process.env.NEXT_PUBLIC_BUS_AMOUNT),
|
||||
"مینی بوس": parseInt(process.env.NEXT_PUBLIC_MINIBUS_AMOUNT),
|
||||
};
|
||||
|
||||
const UpdateFormReal = ({ LoanDetails, LoanId }) => {
|
||||
const t = useTranslations();
|
||||
const provinceStates = useProvince();
|
||||
@@ -35,15 +41,20 @@ const UpdateFormReal = ({ LoanDetails, LoanId }) => {
|
||||
activity_type: LoanDetails.activity_type_id || "",
|
||||
navgan_plan_id: LoanDetails.navgan_plan_id || "",
|
||||
postal_code: LoanDetails.postal_code || "",
|
||||
user_existing_employment: LoanDetails.user_existing_employment || "",
|
||||
user_committed_employment: LoanDetails.user_committed_employment || "",
|
||||
address: LoanDetails.address || "",
|
||||
birthday: LoanDetails.birthday ? moment(LoanDetails.birthday) : "",
|
||||
navgan_id: LoanDetails.navgan_id || "",
|
||||
province_id: LoanDetails.province_id || "",
|
||||
investment: Number(LoanDetails.investment_amount) || "",
|
||||
requested_facilities: Number(LoanDetails.requested_facility_amount) || "",
|
||||
applicant_payment: Number(LoanDetails.person_share) || "",
|
||||
city_id: LoanDetails.city_id || "",
|
||||
first_name: LoanDetails.first_name || "",
|
||||
last_name: LoanDetails.last_name || "",
|
||||
father_name: LoanDetails.father_name || "",
|
||||
gender: LoanDetails.gender || "",
|
||||
gender: LoanDetails.gender === null ? "" : LoanDetails.gender,
|
||||
occupation_id: LoanDetails.occupation_id || "",
|
||||
navgan_type: LoanDetails.navgan_type || "",
|
||||
vehicle_type: LoanDetails.vehicle_type || "",
|
||||
@@ -67,6 +78,16 @@ const UpdateFormReal = ({ LoanDetails, LoanId }) => {
|
||||
address: Yup.string().required(t("ShowLoan.error_message_address")),
|
||||
province_id: Yup.string().required(t("ShowLoan.error_message_province_id")),
|
||||
activity_type: Yup.string().required(t("ShowLoan.error_message_activity_type")),
|
||||
requested_facilities: Yup.mixed()
|
||||
.test(
|
||||
"max-amount",
|
||||
`${t("ShowLoan.max_amount", {
|
||||
value: parseInt(vehicle_amount[LoanDetails.vehicle_type]).toLocaleString("en"),
|
||||
})}`,
|
||||
(value) => value <= vehicle_amount[LoanDetails.vehicle_type]
|
||||
)
|
||||
.required(t("ShowLoan.error_message_requested_facilities")),
|
||||
investment: Yup.string().required(t("ShowLoan.error_message_investment")),
|
||||
navgan_plan_id: Yup.string().required(t("ShowLoan.error_message_navgan_plan_id")),
|
||||
city_id: Yup.string().required(t("ShowLoan.error_message_city_id")),
|
||||
telephone_number: Yup.mixed()
|
||||
@@ -79,6 +100,8 @@ const UpdateFormReal = ({ LoanDetails, LoanId }) => {
|
||||
first_name: Yup.string().required(t("ShowLoan.error_message_first_name")),
|
||||
last_name: Yup.string().required(t("ShowLoan.error_message_last_name")),
|
||||
gender: Yup.string().required(t("ShowLoan.error_message_gender")),
|
||||
user_committed_employment: Yup.string().required(t("ShowLoan.error_message_user_committed_employment")),
|
||||
user_existing_employment: Yup.string().required(t("ShowLoan.error_message_user_existing_employment")),
|
||||
father_name: Yup.string().required(t("ShowLoan.error_message_father_name")),
|
||||
education_id: Yup.string().required(t("ShowLoan.error_message_education_id")),
|
||||
birthday: Yup.string().required(t("ShowLoan.error_message_date_of_birth")),
|
||||
@@ -125,6 +148,11 @@ const UpdateFormReal = ({ LoanDetails, LoanId }) => {
|
||||
formData.append("navgan_plan_id", values.navgan_plan_id);
|
||||
formData.append("activity_type_id", values.activity_type);
|
||||
formData.append("first_name", values.first_name);
|
||||
formData.append("requested_facility_amount", Number(values.requested_facilities));
|
||||
formData.append("investment_amount", Number(values.investment));
|
||||
formData.append("person_share", Number(values.applicant_payment));
|
||||
formData.append("user_committed_employment", values.user_committed_employment);
|
||||
formData.append("user_existing_employment", values.user_existing_employment);
|
||||
formData.append("last_name", values.last_name);
|
||||
formData.append("father_name", values.father_name);
|
||||
formData.append("gender", values.gender);
|
||||
@@ -153,6 +181,17 @@ const UpdateFormReal = ({ LoanDetails, LoanId }) => {
|
||||
validationSchema,
|
||||
onSubmit: handleSubmit,
|
||||
});
|
||||
const handleAmountChange = (event) => {
|
||||
if (!isNaN(event.target.value)) {
|
||||
formik.setFieldValue("requested_facilities", event.target.value).then(() => {
|
||||
formik.setFieldTouched("applicant_payment", false, false);
|
||||
formik.setFieldValue("applicant_payment", Math.floor(event.target.value * 0.2));
|
||||
});
|
||||
} else {
|
||||
formik.setFieldValue("requested_facilities", formik.values.requested_facilities);
|
||||
}
|
||||
};
|
||||
console.log(formik.values.requested_facilities);
|
||||
return (
|
||||
<>
|
||||
<Box sx={{ width: "80%", my: 2 }}>
|
||||
@@ -305,7 +344,6 @@ const UpdateFormReal = ({ LoanDetails, LoanId }) => {
|
||||
]}
|
||||
schema={{ value: "value", name: "name" }}
|
||||
select={formik.values.gender}
|
||||
isLoading={!formik.values.gender}
|
||||
handleChange={formik.handleChange}
|
||||
setFieldTouched={formik.setFieldTouched}
|
||||
error={formik.touched.gender && Boolean(formik.errors.gender)}
|
||||
@@ -718,6 +756,143 @@ const UpdateFormReal = ({ LoanDetails, LoanId }) => {
|
||||
)}
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Grid container spacing={2} sx={{ p: 2 }}>
|
||||
<Grid item xs={12} sm={6}>
|
||||
<TextField
|
||||
disabled={LoanDetails.state_id !== 17}
|
||||
rows={4}
|
||||
sx={{ width: "100%" }}
|
||||
name="user_committed_employment"
|
||||
variant="outlined"
|
||||
value={formik.values.user_committed_employment}
|
||||
size="small"
|
||||
type={"tel"}
|
||||
label={t("ShowLoan.user_committed_employment")}
|
||||
error={
|
||||
!!(formik.touched.user_committed_employment && formik.errors.user_committed_employment)
|
||||
}
|
||||
onChange={(event) => {
|
||||
const inputValue = event.target.value;
|
||||
if (isNaN(Number(inputValue))) {
|
||||
return;
|
||||
}
|
||||
formik.handleChange({
|
||||
target: {
|
||||
name: "user_committed_employment",
|
||||
value: inputValue,
|
||||
},
|
||||
});
|
||||
}}
|
||||
fullWidth
|
||||
helperText={
|
||||
formik.touched.user_committed_employment
|
||||
? formik.errors.user_committed_employment
|
||||
: null
|
||||
}
|
||||
onBlur={formik.handleBlur("user_committed_employment")}
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={12} sm={6}>
|
||||
<TextField
|
||||
disabled={LoanDetails.state_id !== 17}
|
||||
rows={4}
|
||||
sx={{ width: "100%" }}
|
||||
name="user_existing_employment"
|
||||
variant="outlined"
|
||||
type={"tel"}
|
||||
value={formik.values.user_existing_employment}
|
||||
size="small"
|
||||
label={t("ShowLoan.user_existing_employment")}
|
||||
error={
|
||||
!!(formik.touched.user_existing_employment && formik.errors.user_existing_employment)
|
||||
}
|
||||
onChange={(event) => {
|
||||
const inputValue = event.target.value;
|
||||
if (isNaN(Number(inputValue))) {
|
||||
return;
|
||||
}
|
||||
formik.handleChange({
|
||||
target: {
|
||||
name: "user_existing_employment",
|
||||
value: inputValue,
|
||||
},
|
||||
});
|
||||
}}
|
||||
fullWidth
|
||||
helperText={
|
||||
formik.touched.user_existing_employment ? formik.errors.user_existing_employment : null
|
||||
}
|
||||
onBlur={formik.handleBlur("user_existing_employment")}
|
||||
/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Grid container spacing={2} sx={{ padding: 2 }}>
|
||||
<Grid item xs={12} sm={4}>
|
||||
<PriceField
|
||||
name="investment"
|
||||
label={t("ShowLoan.text_field_investment")}
|
||||
type="text"
|
||||
size="small"
|
||||
inputProps={{
|
||||
inputMode: "number",
|
||||
min: 0,
|
||||
pattern: "[0-9]*",
|
||||
}}
|
||||
variant="outlined"
|
||||
value={formik.values.investment}
|
||||
onChange={(event) => {
|
||||
const inputValue = event.target.value;
|
||||
if (isNaN(Number(inputValue))) {
|
||||
return;
|
||||
}
|
||||
formik.setFieldValue("investment", event.target.value);
|
||||
}}
|
||||
disabled={LoanDetails.state_id !== 17}
|
||||
onBlur={formik.handleBlur("investment")}
|
||||
error={formik.touched.investment && Boolean(formik.errors.investment)}
|
||||
helperText={formik.touched.investment && formik.errors.investment}
|
||||
fullWidth
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={12} sm={4}>
|
||||
<PriceField
|
||||
name="requested_facilities"
|
||||
label={t("ShowLoan.text_field_requested_facilities")}
|
||||
type="text"
|
||||
size="small"
|
||||
inputProps={{
|
||||
inputMode: "number",
|
||||
min: 0,
|
||||
pattern: "[0-9]*",
|
||||
}}
|
||||
variant="outlined"
|
||||
value={formik.values.requested_facilities}
|
||||
onChange={handleAmountChange}
|
||||
disabled={formik.values.vehicle_type === "" || LoanDetails.state_id !== 17}
|
||||
onBlur={formik.handleBlur("requested_facilities")}
|
||||
error={formik.touched.requested_facilities && Boolean(formik.errors.requested_facilities)}
|
||||
helperText={formik.touched.requested_facilities && formik.errors.requested_facilities}
|
||||
fullWidth
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={12} sm={4}>
|
||||
<PriceField
|
||||
name="applicant_payment"
|
||||
label={t("ShowLoan.text_field_applicant_payment")}
|
||||
type="text"
|
||||
size="small"
|
||||
inputProps={{
|
||||
inputMode: "number",
|
||||
min: 0,
|
||||
pattern: "[0-9]*",
|
||||
}}
|
||||
variant="outlined"
|
||||
value={formik.values.applicant_payment}
|
||||
disabled
|
||||
fullWidth
|
||||
/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Grid container spacing={2} sx={{ p: 2 }}>
|
||||
<Grid item xs={12} sm={12}>
|
||||
<TextField
|
||||
|
||||
11
src/core/components/LtrTextField.jsx
Normal file
11
src/core/components/LtrTextField.jsx
Normal file
@@ -0,0 +1,11 @@
|
||||
import { styled, TextField } from "@mui/material";
|
||||
|
||||
const LtrTextField = styled(TextField)`
|
||||
.MuiInputBase-input {
|
||||
/* @noflip */
|
||||
direction: ltr;
|
||||
text-align: left;
|
||||
}
|
||||
`;
|
||||
|
||||
export default LtrTextField;
|
||||
23
src/core/components/PriceField.jsx
Normal file
23
src/core/components/PriceField.jsx
Normal file
@@ -0,0 +1,23 @@
|
||||
import { Stack, Typography } from "@mui/material";
|
||||
import { useTranslations } from "next-intl";
|
||||
import LtrTextField from "@/core/components/LtrTextField";
|
||||
|
||||
const PriceField = (props) => {
|
||||
const t = useTranslations();
|
||||
return (
|
||||
<Stack spacing={1}>
|
||||
<Stack>
|
||||
<LtrTextField {...props} />
|
||||
</Stack>
|
||||
<Stack direction="row" alignItems="center">
|
||||
<Typography sx={{ margin: 1 }} component="span">
|
||||
{(props.value / 10).toLocaleString()}
|
||||
</Typography>
|
||||
<Typography component="span" variant="caption" color={"gray"}>
|
||||
{t("PriceField.toman")}
|
||||
</Typography>
|
||||
</Stack>
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
export default PriceField;
|
||||
Reference in New Issue
Block a user