diff --git a/example.env.local b/example.env.local index cb040cb..56b0b7f 100644 --- a/example.env.local +++ b/example.env.local @@ -1,5 +1,5 @@ NEXT_PUBLIC_API_NAME = "Loan Facilities Dashboard" -NEXT_PUBLIC_API_VERSION = "1.26.16" +NEXT_PUBLIC_API_VERSION = "1.27.1" NEXT_PUBLIC_DEFAULT_LANGUAGE = "fa" NEXT_PUBLIC_DEFAULT_DIRECTION = "rtl" diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index 119b0b0..5c4d71d 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -238,9 +238,11 @@ "text_field_navgan_id": "کد ناوگان", "text_field_province_id": "استان", "text_field_education_id": "تحصیلات", + "text_field_national_tracking_code": "کد رهگیری کارت ملی", "text_field_occupation_id": "شغل", "text_field_name": "نام کامل مالک", "text_field_navgan_type": "نوع ناوگان", + "text_field_shenase_meli": "شناسه ملی", "text_field_vehicle_type": "نوع وسیله", "text_field_tel_number": "شماره ثابت (با پیش شماره استان)", "text_field_enter_your_national_id": "کد ملی را وارد کنید", @@ -251,6 +253,8 @@ "text_field_enter_your_birthday": "تاریخ تولد را وارد کنید", "text_field_enter_your_navgan_id": "کد ناوگان را وارد کنید", "text_field_enter_your_name": "نام کامل مالک را وارد کنید", + "text_field_enter_your_shenase_meli": "شناسه ملی را وارد کنید", + "text_field_enter_your_national_tracking_code": "کد رهگیری کارت ملی را وارد کنید", "postal_code_max": "کد پستی می بایست 10 رقم باشد", "error_message_postal_code": "لطفا کد پستی را وارد کنید!", "error_message_national_serial_number": "لطفا سریال پشت کارت ملی را وارد کنید!", diff --git a/src/components/dashboard/navgan/show/form/UpdateForm.jsx b/src/components/dashboard/navgan/show/form/UpdateForm.jsx index 871c9a2..edddcc1 100644 --- a/src/components/dashboard/navgan/show/form/UpdateForm.jsx +++ b/src/components/dashboard/navgan/show/form/UpdateForm.jsx @@ -1,8 +1,7 @@ import StyledForm from "@/core/components/StyledForm"; -import {Box, Button, Chip, Divider, Stack, TextField} from "@mui/material"; +import {Box, Chip, Divider, Stack, TextField} from "@mui/material"; import {Field, Formik} from "formik"; import {useTranslations} from "next-intl"; -import EditIcon from '@mui/icons-material/Edit'; import * as Yup from "yup"; import SelectBox from "@/core/components/SelectBox"; import PlateNumber from "@/core/components/PlateNumber"; @@ -26,11 +25,20 @@ const UpdateForm = ({LoanDetails, LoanId}) => { const occupationStates = useOccupations(); const requestServer = useRequest(); + let _shenase_meli = LoanDetails.is_legal_person === 1 ? { + shenase_meli: LoanDetails.shenase_meli + } : {} + + const _national_card = LoanDetails.national_serial_number ? { + national_serial_number: LoanDetails.national_serial_number + } : { + national_tracking_code: LoanDetails.national_card_tracking_code + } // initial values const initialValues = { + is_legal_person: LoanDetails.is_legal_person, national_id: LoanDetails.national_id, postal_code: LoanDetails.postal_code, - national_serial_number: LoanDetails.national_serial_number, address: LoanDetails.address, birthday: moment(LoanDetails.birthday), navgan_id: LoanDetails.navgan_id, @@ -45,7 +53,7 @@ const UpdateForm = ({LoanDetails, LoanId}) => { plate_part3: LoanDetails.plate_number.split("-")[2], plate_part4: LoanDetails.plate_number.split("-")[3], education_id: LoanDetails.education_id, - occupation_id: LoanDetails.occupation_id, + occupation_id: LoanDetails.occupation_id, ..._national_card, ..._shenase_meli, }; // end initial values @@ -72,8 +80,24 @@ const UpdateForm = ({LoanDetails, LoanId}) => { occupation_id: Yup.string().required(t("ShowLoan.error_message_occupation_id")), education_id: Yup.string().required(t("ShowLoan.error_message_education_id")), birthday: Yup.string().required(t("ShowLoan.error_message_date_of_birth")), - national_serial_number: Yup.string().required(t("ShowLoan.error_message_national_serial_number")), - + national_id: Yup.mixed() + .test("is-number", `${t("LoanRequest.national_code_number")}`, (value) => !isNaN(value)) + .test("positive", `${t("LoanRequest.national_code_positive")}`, (value) => value >= 0) + .test("max", `${t("LoanRequest.national_code_max")}`, (value) => value.toString().length === 10) + .required(t("LoanRequest.error_message_national_id")), + shenase_meli: Yup.mixed().when('is_legal_person', ([is_legal_person], schema) => { + return is_legal_person === 1 ? schema + .test("is-number", `${t("LoanRequest.national_number_number")}`, (value) => !isNaN(value)) + .test("positive", `${t("LoanRequest.national_number_positive")}`, (value) => value >= 0) + .test("max", `${t("LoanRequest.national_number_max")}`, (value) => value && value.toString().length === 11) + .required(t("LoanRequest.error_message_national_number")) : schema; + }), + national_serial_number: Yup.string().when('national_serial_number_or_tracking_code', ([national_serial_number_or_tracking_code], schema) => { + return national_serial_number_or_tracking_code === 'national_serial_number' ? schema.required(t("LoanRequest.error_message_shenasname_serial")) : schema + }), + national_card_tracking_code: Yup.string().when('national_serial_number_or_tracking_code', ([national_serial_number_or_tracking_code], schema) => { + return national_serial_number_or_tracking_code === 'national_card_tracking_code' ? schema.required(t("LoanRequest.error_message_tracking_code")) : schema + }) }); // end validation @@ -185,6 +209,36 @@ const UpdateForm = ({LoanDetails, LoanId}) => { } /> + { + initialValues.is_legal_person === 1 && ( + + + + ) + } { width: "100%", }} > - - - + { + initialValues.national_serial_number ? ( + + + + ) : ( + + + + ) + } { > { as={TextField} sx={{width: "100%"}} name="postal_code" - variant="outlined" + variant="standard" size="small" + disabled label={t("ShowLoan.text_field_postal_code")} placeholder={t( "ShowLoan.text_field_enter_your_postal_code" @@ -438,6 +525,8 @@ const UpdateForm = ({LoanDetails, LoanId}) => { name="province_id" label={t("ShowLoan.text_field_province_id")} size="small" + disabled + variant="standard" selectType="province_id" schema={{value: "value", name: "name"}} isLoading={provinceStates.isLoadingProvinceList} @@ -457,7 +546,6 @@ const UpdateForm = ({LoanDetails, LoanId}) => { /> : { label={citiesStates.cityList.length === 0 ? `${t("ShowLoan.cityList_empty")}` : citiesStates.cityTextField} size="small" selectType="city_id" - disabled={citiesStates.cityList.length === 0} + // disabled={citiesStates.cityList.length === 0} + disabled + variant="standard" selectors={citiesStates.cityList} select={props.values.city_id} schema={{value: "value", name: "name"}} @@ -491,7 +581,6 @@ const UpdateForm = ({LoanDetails, LoanId}) => { /> : { { @@ -557,6 +647,8 @@ const UpdateForm = ({LoanDetails, LoanId}) => { name="education_id" label={t("ShowLoan.text_field_education_id")} size="small" + variant="standard" + disabled isLoading={educationStates.isLoadingEducationsList} errorEcured={educationStates.errorEducationsList} selectType="education_id" @@ -573,7 +665,6 @@ const UpdateForm = ({LoanDetails, LoanId}) => { /> : { name="occupation_id" label={t("ShowLoan.text_field_occupation_id")} size="small" + disabled + variant="standard" isLoading={occupationStates.isLoadingOccupationsList} errorEcured={occupationStates.errorOccupationsList} selectType="occupation_id" @@ -609,7 +702,6 @@ const UpdateForm = ({LoanDetails, LoanId}) => { /> : { rows={4} sx={{width: "100%"}} name="address" - variant="outlined" + variant="standard" size="small" + disabled label={t("ShowLoan.text_field_address")} placeholder={t("ShowLoan.text_field_enter_your_address")} type={"text"} @@ -660,17 +753,17 @@ const UpdateForm = ({LoanDetails, LoanId}) => { width: {xs: "100%", sm: "30%", md: "25%"}, }} > - + {/*}*/} + {/* disabled={props.isSubmitting || !props.dirty || !props.isValid}*/} + {/*>*/} + {/* {t("ShowLoan.button_submit")}*/} + {/**/} diff --git a/src/core/components/SelectBox.jsx b/src/core/components/SelectBox.jsx index 6fc787c..e9fb2e0 100644 --- a/src/core/components/SelectBox.jsx +++ b/src/core/components/SelectBox.jsx @@ -21,8 +21,8 @@ function SelectBox({ return (