complete show part and disabled update for while
This commit is contained in:
@@ -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": "لطفا سریال پشت کارت ملی را وارد کنید!",
|
||||
|
||||
@@ -25,7 +25,7 @@ const UpdateForm = ({LoanDetails, LoanId}) => {
|
||||
const occupationStates = useOccupations();
|
||||
const requestServer = useRequest();
|
||||
|
||||
let _national_number = LoanDetails.is_legal_person === 1 ? {
|
||||
let _shenase_meli = LoanDetails.is_legal_person === 1 ? {
|
||||
shenase_meli: LoanDetails.shenase_meli
|
||||
} : {}
|
||||
|
||||
@@ -36,6 +36,7 @@ const UpdateForm = ({LoanDetails, LoanId}) => {
|
||||
}
|
||||
// initial values
|
||||
const initialValues = {
|
||||
is_legal_person: LoanDetails.is_legal_person,
|
||||
national_id: LoanDetails.national_id,
|
||||
postal_code: LoanDetails.postal_code,
|
||||
address: LoanDetails.address,
|
||||
@@ -52,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, ..._national_card, ..._national_number,
|
||||
occupation_id: LoanDetails.occupation_id, ..._national_card, ..._shenase_meli,
|
||||
};
|
||||
// end initial values
|
||||
|
||||
@@ -79,24 +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_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")),
|
||||
// national_number: Yup.mixed().when('person_type', ([person_type], schema) => {
|
||||
// return person_type === 'legal' ? 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
|
||||
// })
|
||||
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
|
||||
|
||||
@@ -208,6 +209,36 @@ const UpdateForm = ({LoanDetails, LoanId}) => {
|
||||
}
|
||||
/>
|
||||
</Box>
|
||||
{
|
||||
initialValues.is_legal_person === 1 && (
|
||||
<Box
|
||||
sx={{
|
||||
mx: {xs: 0, sm: 2},
|
||||
my: 2,
|
||||
width: "100%",
|
||||
}}
|
||||
>
|
||||
<Field
|
||||
as={TextField}
|
||||
sx={{width: "100%"}}
|
||||
name="shenase_meli"
|
||||
disabled
|
||||
variant="standard"
|
||||
size="small"
|
||||
label={t("ShowLoan.text_field_shenase_meli")}
|
||||
placeholder={t("ShowLoan.text_field_enter_your_shenase_meli")}
|
||||
type={"text"}
|
||||
error={!!(props.touched.shenase_meli && props.errors.shenase_meli)}
|
||||
fullWidth
|
||||
helperText={
|
||||
props.touched.shenase_meli
|
||||
? props.errors.shenase_meli
|
||||
: null
|
||||
}
|
||||
/>
|
||||
</Box>
|
||||
)
|
||||
}
|
||||
</Box>
|
||||
<Box
|
||||
sx={{
|
||||
@@ -358,34 +389,63 @@ const UpdateForm = ({LoanDetails, LoanId}) => {
|
||||
width: "100%",
|
||||
}}
|
||||
>
|
||||
<Box
|
||||
sx={{
|
||||
mx: {xs: 0, sm: 2},
|
||||
my: 2,
|
||||
width: "100%",
|
||||
}}
|
||||
>
|
||||
<Field
|
||||
as={TextField}
|
||||
sx={{width: "100%"}}
|
||||
name="national_serial_number"
|
||||
size="small"
|
||||
disabled
|
||||
variant="standard"
|
||||
label={t("ShowLoan.text_field_national_serial_number")}
|
||||
placeholder={t(
|
||||
"ShowLoan.text_field_enter_your_national_serial_number"
|
||||
)}
|
||||
type={"text"}
|
||||
error={!!(props.touched.national_serial_number && props.errors.national_serial_number)}
|
||||
fullWidth
|
||||
helperText={
|
||||
props.touched.national_serial_number
|
||||
? props.errors.national_serial_number
|
||||
: null
|
||||
}
|
||||
/>
|
||||
</Box>
|
||||
{
|
||||
initialValues.national_serial_number ? (
|
||||
<Box
|
||||
sx={{
|
||||
mx: {xs: 0, sm: 2},
|
||||
my: 2,
|
||||
width: "100%",
|
||||
}}
|
||||
>
|
||||
<Field
|
||||
as={TextField}
|
||||
sx={{width: "100%"}}
|
||||
name="national_serial_number"
|
||||
size="small"
|
||||
disabled
|
||||
variant="standard"
|
||||
label={t("ShowLoan.text_field_national_serial_number")}
|
||||
placeholder={t("ShowLoan.text_field_enter_your_national_serial_number")}
|
||||
type={"text"}
|
||||
error={!!(props.touched.national_serial_number && props.errors.national_serial_number)}
|
||||
fullWidth
|
||||
helperText={
|
||||
props.touched.national_serial_number
|
||||
? props.errors.national_serial_number
|
||||
: null
|
||||
}
|
||||
/>
|
||||
</Box>
|
||||
) : (
|
||||
<Box
|
||||
sx={{
|
||||
mx: {xs: 0, sm: 2},
|
||||
my: 2,
|
||||
width: "100%",
|
||||
}}
|
||||
>
|
||||
<Field
|
||||
as={TextField}
|
||||
sx={{width: "100%"}}
|
||||
name="national_tracking_code"
|
||||
size="small"
|
||||
disabled
|
||||
variant="standard"
|
||||
label={t("ShowLoan.text_field_national_tracking_code")}
|
||||
placeholder={t("ShowLoan.text_field_enter_your_national_tracking_code")}
|
||||
type={"text"}
|
||||
error={!!(props.touched.national_tracking_code && props.errors.national_tracking_code)}
|
||||
fullWidth
|
||||
helperText={
|
||||
props.touched.national_tracking_code
|
||||
? props.errors.national_tracking_code
|
||||
: null
|
||||
}
|
||||
/>
|
||||
</Box>
|
||||
)
|
||||
}
|
||||
<Box
|
||||
sx={{
|
||||
mx: {xs: 0, sm: 2},
|
||||
|
||||
Reference in New Issue
Block a user