From 934cd9cf54d177cf5bf0e8b81a2d958fc128a6c8 Mon Sep 17 00:00:00 2001 From: AmirHossein Mahmoodi Date: Wed, 7 Feb 2024 17:17:39 +0330 Subject: [PATCH] change edit structure --- .../navgan/followUp-loan/RequestCard.jsx | 40 +- .../dashboard/navgan/show/form/UpdateForm.jsx | 1185 ++++++++--------- .../dashboard/navgan/show/form/index.jsx | 3 +- 3 files changed, 566 insertions(+), 662 deletions(-) diff --git a/src/components/dashboard/navgan/followUp-loan/RequestCard.jsx b/src/components/dashboard/navgan/followUp-loan/RequestCard.jsx index 30e19e5..f608686 100644 --- a/src/components/dashboard/navgan/followUp-loan/RequestCard.jsx +++ b/src/components/dashboard/navgan/followUp-loan/RequestCard.jsx @@ -14,7 +14,12 @@ const RequestCard = ({item}) => { width: "100%", boxShadow: "rgba(0, 0, 0, 0.15) 0px 5px 15px 0px" }}> - + { paddingLeft: '10px', }} > - + {`${t("LoanFollowUp.loan_unique_code")}: ${item.id}`} - + {`${t("LoanFollowUp.loan_date")}: ${moment(item.created_at).locale("fa").format("HH:mm | YYYY/MM/DD")}`} - + {`${t("LoanFollowUp.loan_bank_branch")}: ${item.branch_info === null ? '-' : item.branch_info}`} - + {`${t("LoanFollowUp.loan_status")}: `} {item.loan_state} - {item.state_id >= 1 && item.state_id <= 6 && } - {item.state_id === 8 && } - {item.state_id === 7 && } + {item.state_id >= 1 && item.state_id <= 6 && + } + {item.state_id === 8 && + } + {item.state_id === 7 && + } - {item.state_id !== 7 && item.state_id !== 8 && ( - - )} - {item.state_id === 7 && ( + {item.state_id === 7 && ( { {`${t("LoanFollowUp.loan_description")}: ${item.latest_history.expert_description}`} )} + {item.state_id === 8 && item.bank_status === 0 && ( + + )} diff --git a/src/components/dashboard/navgan/show/form/UpdateForm.jsx b/src/components/dashboard/navgan/show/form/UpdateForm.jsx index 4c3474e..6c05779 100644 --- a/src/components/dashboard/navgan/show/form/UpdateForm.jsx +++ b/src/components/dashboard/navgan/show/form/UpdateForm.jsx @@ -64,9 +64,7 @@ const UpdateForm = ({LoanDetails, LoanId}) => { const validationSchema = Yup.object().shape({ postal_code: Yup.mixed() .test("max", `${t("ShowLoan.postal_code_max")}`, (value) => value.toString().length === 10) - .required( - t("ShowLoan.error_message_postal_code") - ), + .required(t("ShowLoan.error_message_postal_code")), address: Yup.string().required(t("ShowLoan.error_message_address")), province_id: Yup.string().required(t("ShowLoan.error_message_province_id")), city_id: Yup.string().required(t("ShowLoan.error_message_city_id")), @@ -134,663 +132,562 @@ const UpdateForm = ({LoanDetails, LoanId}) => { }; // end submit - return ( - <> - - - - - - + + + + + + + {(props) => ( - {(props) => ( - + - - - + - - - - - - { - initialValues.is_legal_person === 1 && ( - - - - ) - } - - - - - - - + + + + + {initialValues.is_legal_person === 1 && ( + + )} + + + + + + + { - props.setFieldValue('navgan_type', event.target.value) - }} - setFieldTouched={props.setFieldTouched} - error={props.touched.navgan_type && Boolean(props.errors.navgan_type)} - helperText={props.touched.navgan_type && props.errors.navgan_type} - onBlur={props.handleBlur("navgan_type")} - /> - - - { + props.setFieldValue('navgan_type', event.target.value) }} - > - - - - - + + + + + + + + props.setFieldValue('vehicle_type', event.target.value)} - error={props.touched.vehicle_type && Boolean(props.errors.vehicle_type)} - helperText={props.touched.vehicle_type && props.errors.vehicle_type} - onBlur={props.handleBlur("vehicle_type")} - /> - - - props.setFieldValue('vehicle_type', event.target.value)} + error={props.touched.vehicle_type && Boolean(props.errors.vehicle_type)} + helperText={props.touched.vehicle_type && props.errors.vehicle_type} + onBlur={props.handleBlur("vehicle_type")} + /> + + + + + { + if (value === null) return + props.handleChange({ + target: { + name: "national_serial_number_or_tracking_code", value: value, + }, + }) + value === "serial_number" ? props.setFieldValue("national_tracking_code", props.initialValues.national_tracking_code, false) : props.setFieldValue("national_serial_number", props.initialValues.national_serial_number, false) }} > - - { - if (value === null) return - props.handleChange({ - target: { - name: "national_serial_number_or_tracking_code", value: value, - }, - }) - value === "serial_number" ? - props.setFieldValue("national_tracking_code", props.initialValues.national_tracking_code, false) - : props.setFieldValue("national_serial_number", props.initialValues.national_serial_number, false) - }} - > - - {t("ShowLoan.text_field_shenasname_serial")} - - - {t("ShowLoan.text_field_national_trackin_code")} - - - - - {props.values.national_serial_number_or_tracking_code === "serial_number" ? ( - - ) : ( - - )} - - - - - - + {t("ShowLoan.text_field_shenasname_serial")} + + + {t("ShowLoan.text_field_national_trackin_code")} + + + + + {props.values.national_serial_number_or_tracking_code === "serial_number" ? () : ()} + + + + + + + + { + const inputValue = event.target.value; + if (isNaN(Number(inputValue))) { + return; + } + props.handleChange({ + target: { + name: "postal_code", value: inputValue, + }, + }); }} - > - - { - const inputValue = event.target.value; - if (isNaN(Number(inputValue))) { - return; - } - props.handleChange({ - target: { - name: "postal_code", - value: inputValue, - }, - }); - }} - error={!!(props.touched.postal_code && props.errors.postal_code)} - fullWidth - helperText={ - props.touched.postal_code - ? props.errors.postal_code - : null - } - /> - - - {provinceStates.provinceList.length !== 0 ? - { - props.setFieldValue('province_id', event.target.value); - citiesStates.setProvinceID(event.target.value) - props.setFieldTouched("city_id", false, false); - props.setFieldValue("city_id", "") - }} - setFieldTouched={props.setFieldTouched} - error={props.touched.province_id && Boolean(props.errors.province_id)} - helperText={props.touched.province_id && props.errors.province_id} - onBlur={props.handleBlur("province_id")} - /> : } + error={!!(props.touched.postal_code && props.errors.postal_code)} + fullWidth + helperText={props.touched.postal_code ? props.errors.postal_code : null} + /> + + + {provinceStates.provinceList.length !== 0 ? { + props.setFieldValue('province_id', event.target.value); + citiesStates.setProvinceID(event.target.value) + props.setFieldTouched("city_id", false, false); + props.setFieldValue("city_id", "") + }} + setFieldTouched={props.setFieldTouched} + error={props.touched.province_id && Boolean(props.errors.province_id)} + helperText={props.touched.province_id && props.errors.province_id} + onBlur={props.handleBlur("province_id")} + /> : } - - - {citiesStates.cityList.length !== 0 ? - props.setFieldValue('city_id', event.target.value)} - setFieldTouched={props.setFieldTouched} - error={props.touched.city_id && Boolean(props.errors.city_id)} - helperText={props.touched.city_id && props.errors.city_id} - onBlur={props.handleBlur("city_id")} - /> : } - - - + + {citiesStates.cityList.length !== 0 ? props.setFieldValue('city_id', event.target.value)} + setFieldTouched={props.setFieldTouched} + error={props.touched.city_id && Boolean(props.errors.city_id)} + helperText={props.touched.city_id && props.errors.city_id} + onBlur={props.handleBlur("city_id")} + /> : } + + + + + { + const inputValue = event.target.value; + if (isNaN(Number(inputValue))) { + return; + } + props.handleChange({ + target: { + name: "telephone_number", value: inputValue, + }, + }); }} - > - - { - const inputValue = event.target.value; - if (isNaN(Number(inputValue))) { - return; - } - props.handleChange({ - target: { - name: "telephone_number", - value: inputValue, - }, - }); - }} - label={t("ShowLoan.text_field_tel_number")} - placeholder={t( - "ShowLoan.text_field_enter_your_tel_number" - )} - fullWidth - onBlur={props.handleBlur("telephone_number")} - error={props.touched.telephone_number && Boolean(props.errors.telephone_number)} - helperText={props.touched.telephone_number && props.errors.telephone_number} - /> - - - {educationStates.educationsList.length !== 0 ? - { - props.setFieldValue('education_id', event.target.value) - }} - setFieldTouched={props.setFieldTouched} - error={props.touched.education_id && Boolean(props.errors.education_id)} - helperText={props.touched.education_id && props.errors.education_id} - onBlur={props.handleBlur("education_id")} - /> : } - - - {occupationStates.occupationsList.length !== 0 ? - { - props.setFieldValue('occupation_id', event.target.value) - }} - setFieldTouched={props.setFieldTouched} - error={props.touched.occupation_id && Boolean(props.errors.occupation_id)} - helperText={props.touched.occupation_id && props.errors.occupation_id} - onBlur={props.handleBlur("occupation_id")} - /> : } - - - + + + {educationStates.educationsList.length !== 0 ? { + props.setFieldValue('education_id', event.target.value) }} - > - - - - - : } + + + {occupationStates.occupationsList.length !== 0 ? { + props.setFieldValue('occupation_id', event.target.value) }} - > - - - - - )} - - - ); + setFieldTouched={props.setFieldTouched} + error={props.touched.occupation_id && Boolean(props.errors.occupation_id)} + helperText={props.touched.occupation_id && props.errors.occupation_id} + onBlur={props.handleBlur("occupation_id")} + /> : } + + + + + + + + + + + + )} + + ); }; export default UpdateForm; diff --git a/src/components/dashboard/navgan/show/form/index.jsx b/src/components/dashboard/navgan/show/form/index.jsx index 833a797..e8280d2 100644 --- a/src/components/dashboard/navgan/show/form/index.jsx +++ b/src/components/dashboard/navgan/show/form/index.jsx @@ -26,8 +26,7 @@ const ShowLoanForm = () => { {t("ShowLoan.loading_show_component")} ); - } - else if(LoanDetails.state_id===8 || LoanDetails.state_id===7) { + } else if (!(LoanDetails.state_id === 8 && LoanDetails.bank_status === 0)) { return ( {t("ShowLoan.error_message_not_show_state")}