add new inputs and disable all item and stop ability of updating(just show data)
This commit is contained in:
@@ -1,8 +1,7 @@
|
|||||||
import StyledForm from "@/core/components/StyledForm";
|
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 {Field, Formik} from "formik";
|
||||||
import {useTranslations} from "next-intl";
|
import {useTranslations} from "next-intl";
|
||||||
import EditIcon from '@mui/icons-material/Edit';
|
|
||||||
import * as Yup from "yup";
|
import * as Yup from "yup";
|
||||||
import SelectBox from "@/core/components/SelectBox";
|
import SelectBox from "@/core/components/SelectBox";
|
||||||
import PlateNumber from "@/core/components/PlateNumber";
|
import PlateNumber from "@/core/components/PlateNumber";
|
||||||
@@ -26,11 +25,19 @@ const UpdateForm = ({LoanDetails, LoanId}) => {
|
|||||||
const occupationStates = useOccupations();
|
const occupationStates = useOccupations();
|
||||||
const requestServer = useRequest();
|
const requestServer = useRequest();
|
||||||
|
|
||||||
|
let _national_number = 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
|
// initial values
|
||||||
const initialValues = {
|
const initialValues = {
|
||||||
national_id: LoanDetails.national_id,
|
national_id: LoanDetails.national_id,
|
||||||
postal_code: LoanDetails.postal_code,
|
postal_code: LoanDetails.postal_code,
|
||||||
national_serial_number: LoanDetails.national_serial_number,
|
|
||||||
address: LoanDetails.address,
|
address: LoanDetails.address,
|
||||||
birthday: moment(LoanDetails.birthday),
|
birthday: moment(LoanDetails.birthday),
|
||||||
navgan_id: LoanDetails.navgan_id,
|
navgan_id: LoanDetails.navgan_id,
|
||||||
@@ -45,7 +52,7 @@ const UpdateForm = ({LoanDetails, LoanId}) => {
|
|||||||
plate_part3: LoanDetails.plate_number.split("-")[2],
|
plate_part3: LoanDetails.plate_number.split("-")[2],
|
||||||
plate_part4: LoanDetails.plate_number.split("-")[3],
|
plate_part4: LoanDetails.plate_number.split("-")[3],
|
||||||
education_id: LoanDetails.education_id,
|
education_id: LoanDetails.education_id,
|
||||||
occupation_id: LoanDetails.occupation_id,
|
occupation_id: LoanDetails.occupation_id, ..._national_card, ..._national_number,
|
||||||
};
|
};
|
||||||
// end initial values
|
// end initial values
|
||||||
|
|
||||||
@@ -72,8 +79,24 @@ const UpdateForm = ({LoanDetails, LoanId}) => {
|
|||||||
occupation_id: Yup.string().required(t("ShowLoan.error_message_occupation_id")),
|
occupation_id: Yup.string().required(t("ShowLoan.error_message_occupation_id")),
|
||||||
education_id: Yup.string().required(t("ShowLoan.error_message_education_id")),
|
education_id: Yup.string().required(t("ShowLoan.error_message_education_id")),
|
||||||
birthday: Yup.string().required(t("ShowLoan.error_message_date_of_birth")),
|
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")),
|
||||||
|
// 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
|
||||||
|
// })
|
||||||
});
|
});
|
||||||
// end validation
|
// end validation
|
||||||
|
|
||||||
@@ -347,6 +370,8 @@ const UpdateForm = ({LoanDetails, LoanId}) => {
|
|||||||
sx={{width: "100%"}}
|
sx={{width: "100%"}}
|
||||||
name="national_serial_number"
|
name="national_serial_number"
|
||||||
size="small"
|
size="small"
|
||||||
|
disabled
|
||||||
|
variant="standard"
|
||||||
label={t("ShowLoan.text_field_national_serial_number")}
|
label={t("ShowLoan.text_field_national_serial_number")}
|
||||||
placeholder={t(
|
placeholder={t(
|
||||||
"ShowLoan.text_field_enter_your_national_serial_number"
|
"ShowLoan.text_field_enter_your_national_serial_number"
|
||||||
@@ -370,6 +395,7 @@ const UpdateForm = ({LoanDetails, LoanId}) => {
|
|||||||
>
|
>
|
||||||
<MuiDatePicker
|
<MuiDatePicker
|
||||||
formik={props}
|
formik={props}
|
||||||
|
disabled
|
||||||
disableFuture={true}
|
disableFuture={true}
|
||||||
error={props.touched.birthday && Boolean(props.errors.birthday)}
|
error={props.touched.birthday && Boolean(props.errors.birthday)}
|
||||||
helperText={props.touched.birthday && props.errors.birthday}
|
helperText={props.touched.birthday && props.errors.birthday}
|
||||||
@@ -387,8 +413,9 @@ const UpdateForm = ({LoanDetails, LoanId}) => {
|
|||||||
as={TextField}
|
as={TextField}
|
||||||
sx={{width: "100%"}}
|
sx={{width: "100%"}}
|
||||||
name="postal_code"
|
name="postal_code"
|
||||||
variant="outlined"
|
variant="standard"
|
||||||
size="small"
|
size="small"
|
||||||
|
disabled
|
||||||
label={t("ShowLoan.text_field_postal_code")}
|
label={t("ShowLoan.text_field_postal_code")}
|
||||||
placeholder={t(
|
placeholder={t(
|
||||||
"ShowLoan.text_field_enter_your_postal_code"
|
"ShowLoan.text_field_enter_your_postal_code"
|
||||||
@@ -438,6 +465,8 @@ const UpdateForm = ({LoanDetails, LoanId}) => {
|
|||||||
name="province_id"
|
name="province_id"
|
||||||
label={t("ShowLoan.text_field_province_id")}
|
label={t("ShowLoan.text_field_province_id")}
|
||||||
size="small"
|
size="small"
|
||||||
|
disabled
|
||||||
|
variant="standard"
|
||||||
selectType="province_id"
|
selectType="province_id"
|
||||||
schema={{value: "value", name: "name"}}
|
schema={{value: "value", name: "name"}}
|
||||||
isLoading={provinceStates.isLoadingProvinceList}
|
isLoading={provinceStates.isLoadingProvinceList}
|
||||||
@@ -457,7 +486,6 @@ const UpdateForm = ({LoanDetails, LoanId}) => {
|
|||||||
/> : <Field
|
/> : <Field
|
||||||
as={TextField}
|
as={TextField}
|
||||||
sx={{width: "100%"}}
|
sx={{width: "100%"}}
|
||||||
variant="outlined"
|
|
||||||
disabled
|
disabled
|
||||||
size="small"
|
size="small"
|
||||||
label={t("ShowLoan.text_field_province_id")}
|
label={t("ShowLoan.text_field_province_id")}
|
||||||
@@ -479,7 +507,9 @@ const UpdateForm = ({LoanDetails, LoanId}) => {
|
|||||||
label={citiesStates.cityList.length === 0 ? `${t("ShowLoan.cityList_empty")}` : citiesStates.cityTextField}
|
label={citiesStates.cityList.length === 0 ? `${t("ShowLoan.cityList_empty")}` : citiesStates.cityTextField}
|
||||||
size="small"
|
size="small"
|
||||||
selectType="city_id"
|
selectType="city_id"
|
||||||
disabled={citiesStates.cityList.length === 0}
|
// disabled={citiesStates.cityList.length === 0}
|
||||||
|
disabled
|
||||||
|
variant="standard"
|
||||||
selectors={citiesStates.cityList}
|
selectors={citiesStates.cityList}
|
||||||
select={props.values.city_id}
|
select={props.values.city_id}
|
||||||
schema={{value: "value", name: "name"}}
|
schema={{value: "value", name: "name"}}
|
||||||
@@ -491,7 +521,6 @@ const UpdateForm = ({LoanDetails, LoanId}) => {
|
|||||||
/> : <Field
|
/> : <Field
|
||||||
as={TextField}
|
as={TextField}
|
||||||
sx={{width: "100%"}}
|
sx={{width: "100%"}}
|
||||||
variant="outlined"
|
|
||||||
disabled
|
disabled
|
||||||
size="small"
|
size="small"
|
||||||
label={t("ShowLoan.cityList_empty")}
|
label={t("ShowLoan.cityList_empty")}
|
||||||
@@ -509,8 +538,9 @@ const UpdateForm = ({LoanDetails, LoanId}) => {
|
|||||||
<TextField
|
<TextField
|
||||||
sx={{width: "100%"}}
|
sx={{width: "100%"}}
|
||||||
name="telephone_number"
|
name="telephone_number"
|
||||||
variant="outlined"
|
|
||||||
size="small"
|
size="small"
|
||||||
|
variant="standard"
|
||||||
|
disabled
|
||||||
type={'tel'}
|
type={'tel'}
|
||||||
value={props.values.telephone_number}
|
value={props.values.telephone_number}
|
||||||
onChange={(event) => {
|
onChange={(event) => {
|
||||||
@@ -557,6 +587,8 @@ const UpdateForm = ({LoanDetails, LoanId}) => {
|
|||||||
name="education_id"
|
name="education_id"
|
||||||
label={t("ShowLoan.text_field_education_id")}
|
label={t("ShowLoan.text_field_education_id")}
|
||||||
size="small"
|
size="small"
|
||||||
|
variant="standard"
|
||||||
|
disabled
|
||||||
isLoading={educationStates.isLoadingEducationsList}
|
isLoading={educationStates.isLoadingEducationsList}
|
||||||
errorEcured={educationStates.errorEducationsList}
|
errorEcured={educationStates.errorEducationsList}
|
||||||
selectType="education_id"
|
selectType="education_id"
|
||||||
@@ -573,7 +605,6 @@ const UpdateForm = ({LoanDetails, LoanId}) => {
|
|||||||
/> : <Field
|
/> : <Field
|
||||||
as={TextField}
|
as={TextField}
|
||||||
sx={{width: "100%"}}
|
sx={{width: "100%"}}
|
||||||
variant="outlined"
|
|
||||||
disabled
|
disabled
|
||||||
size="small"
|
size="small"
|
||||||
label={t("ShowLoan.text_field_education_id")}
|
label={t("ShowLoan.text_field_education_id")}
|
||||||
@@ -593,6 +624,8 @@ const UpdateForm = ({LoanDetails, LoanId}) => {
|
|||||||
name="occupation_id"
|
name="occupation_id"
|
||||||
label={t("ShowLoan.text_field_occupation_id")}
|
label={t("ShowLoan.text_field_occupation_id")}
|
||||||
size="small"
|
size="small"
|
||||||
|
disabled
|
||||||
|
variant="standard"
|
||||||
isLoading={occupationStates.isLoadingOccupationsList}
|
isLoading={occupationStates.isLoadingOccupationsList}
|
||||||
errorEcured={occupationStates.errorOccupationsList}
|
errorEcured={occupationStates.errorOccupationsList}
|
||||||
selectType="occupation_id"
|
selectType="occupation_id"
|
||||||
@@ -609,7 +642,6 @@ const UpdateForm = ({LoanDetails, LoanId}) => {
|
|||||||
/> : <Field
|
/> : <Field
|
||||||
as={TextField}
|
as={TextField}
|
||||||
sx={{width: "100%"}}
|
sx={{width: "100%"}}
|
||||||
variant="outlined"
|
|
||||||
disabled
|
disabled
|
||||||
size="small"
|
size="small"
|
||||||
label={t("ShowLoan.text_field_occupation_id")}
|
label={t("ShowLoan.text_field_occupation_id")}
|
||||||
@@ -640,8 +672,9 @@ const UpdateForm = ({LoanDetails, LoanId}) => {
|
|||||||
rows={4}
|
rows={4}
|
||||||
sx={{width: "100%"}}
|
sx={{width: "100%"}}
|
||||||
name="address"
|
name="address"
|
||||||
variant="outlined"
|
variant="standard"
|
||||||
size="small"
|
size="small"
|
||||||
|
disabled
|
||||||
label={t("ShowLoan.text_field_address")}
|
label={t("ShowLoan.text_field_address")}
|
||||||
placeholder={t("ShowLoan.text_field_enter_your_address")}
|
placeholder={t("ShowLoan.text_field_enter_your_address")}
|
||||||
type={"text"}
|
type={"text"}
|
||||||
@@ -660,17 +693,17 @@ const UpdateForm = ({LoanDetails, LoanId}) => {
|
|||||||
width: {xs: "100%", sm: "30%", md: "25%"},
|
width: {xs: "100%", sm: "30%", md: "25%"},
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Button
|
{/*<Button*/}
|
||||||
fullWidth
|
{/* fullWidth*/}
|
||||||
type="submit"
|
{/* type="submit"*/}
|
||||||
variant="contained"
|
{/* variant="contained"*/}
|
||||||
size="large"
|
{/* size="large"*/}
|
||||||
sx={{mt: 2}}
|
{/* sx={{mt: 2}}*/}
|
||||||
endIcon={<EditIcon/>}
|
{/* endIcon={<EditIcon/>}*/}
|
||||||
disabled={props.isSubmitting || !props.dirty || !props.isValid}
|
{/* disabled={props.isSubmitting || !props.dirty || !props.isValid}*/}
|
||||||
>
|
{/*>*/}
|
||||||
{t("ShowLoan.button_submit")}
|
{/* {t("ShowLoan.button_submit")}*/}
|
||||||
</Button>
|
{/*</Button>*/}
|
||||||
</Box>
|
</Box>
|
||||||
</StyledForm>
|
</StyledForm>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ function SelectBox({
|
|||||||
return (
|
return (
|
||||||
<FormControl
|
<FormControl
|
||||||
disabled={disabled || false}
|
disabled={disabled || false}
|
||||||
variant={variant}
|
|
||||||
fullWidth
|
fullWidth
|
||||||
|
variant={variant}
|
||||||
size="small"
|
size="small"
|
||||||
error={error}
|
error={error}
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user