Merge branch 'release/v1.27.1'

This commit is contained in:
AmirHossein Mahmoodi
2024-01-06 15:58:05 +03:30
4 changed files with 150 additions and 53 deletions

View File

@@ -1,5 +1,5 @@
NEXT_PUBLIC_API_NAME = "Loan Facilities Dashboard" 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_LANGUAGE = "fa"
NEXT_PUBLIC_DEFAULT_DIRECTION = "rtl" NEXT_PUBLIC_DEFAULT_DIRECTION = "rtl"

View File

@@ -238,9 +238,11 @@
"text_field_navgan_id": "کد ناوگان", "text_field_navgan_id": "کد ناوگان",
"text_field_province_id": "استان", "text_field_province_id": "استان",
"text_field_education_id": "تحصیلات", "text_field_education_id": "تحصیلات",
"text_field_national_tracking_code": "کد رهگیری کارت ملی",
"text_field_occupation_id": "شغل", "text_field_occupation_id": "شغل",
"text_field_name": "نام کامل مالک", "text_field_name": "نام کامل مالک",
"text_field_navgan_type": "نوع ناوگان", "text_field_navgan_type": "نوع ناوگان",
"text_field_shenase_meli": "شناسه ملی",
"text_field_vehicle_type": "نوع وسیله", "text_field_vehicle_type": "نوع وسیله",
"text_field_tel_number": "شماره ثابت (با پیش شماره استان)", "text_field_tel_number": "شماره ثابت (با پیش شماره استان)",
"text_field_enter_your_national_id": "کد ملی را وارد کنید", "text_field_enter_your_national_id": "کد ملی را وارد کنید",
@@ -251,6 +253,8 @@
"text_field_enter_your_birthday": "تاریخ تولد را وارد کنید", "text_field_enter_your_birthday": "تاریخ تولد را وارد کنید",
"text_field_enter_your_navgan_id": "کد ناوگان را وارد کنید", "text_field_enter_your_navgan_id": "کد ناوگان را وارد کنید",
"text_field_enter_your_name": "نام کامل مالک را وارد کنید", "text_field_enter_your_name": "نام کامل مالک را وارد کنید",
"text_field_enter_your_shenase_meli": "شناسه ملی را وارد کنید",
"text_field_enter_your_national_tracking_code": "کد رهگیری کارت ملی را وارد کنید",
"postal_code_max": "کد پستی می بایست 10 رقم باشد", "postal_code_max": "کد پستی می بایست 10 رقم باشد",
"error_message_postal_code": "لطفا کد پستی را وارد کنید!", "error_message_postal_code": "لطفا کد پستی را وارد کنید!",
"error_message_national_serial_number": "لطفا سریال پشت کارت ملی را وارد کنید!", "error_message_national_serial_number": "لطفا سریال پشت کارت ملی را وارد کنید!",

View File

@@ -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,20 @@ const UpdateForm = ({LoanDetails, LoanId}) => {
const occupationStates = useOccupations(); const occupationStates = useOccupations();
const requestServer = useRequest(); 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 // initial values
const initialValues = { const initialValues = {
is_legal_person: LoanDetails.is_legal_person,
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 +53,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, ..._shenase_meli,
}; };
// end initial values // end initial values
@@ -72,8 +80,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")),
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 // end validation
@@ -185,6 +209,36 @@ const UpdateForm = ({LoanDetails, LoanId}) => {
} }
/> />
</Box> </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>
<Box <Box
sx={{ sx={{
@@ -335,32 +389,63 @@ const UpdateForm = ({LoanDetails, LoanId}) => {
width: "100%", width: "100%",
}} }}
> >
<Box {
sx={{ initialValues.national_serial_number ? (
mx: {xs: 0, sm: 2}, <Box
my: 2, sx={{
width: "100%", mx: {xs: 0, sm: 2},
}} my: 2,
> width: "100%",
<Field }}
as={TextField} >
sx={{width: "100%"}} <Field
name="national_serial_number" as={TextField}
size="small" sx={{width: "100%"}}
label={t("ShowLoan.text_field_national_serial_number")} name="national_serial_number"
placeholder={t( size="small"
"ShowLoan.text_field_enter_your_national_serial_number" disabled
)} variant="standard"
type={"text"} label={t("ShowLoan.text_field_national_serial_number")}
error={!!(props.touched.national_serial_number && props.errors.national_serial_number)} placeholder={t("ShowLoan.text_field_enter_your_national_serial_number")}
fullWidth type={"text"}
helperText={ error={!!(props.touched.national_serial_number && props.errors.national_serial_number)}
props.touched.national_serial_number fullWidth
? props.errors.national_serial_number helperText={
: null props.touched.national_serial_number
} ? props.errors.national_serial_number
/> : null
</Box> }
/>
</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 <Box
sx={{ sx={{
mx: {xs: 0, sm: 2}, mx: {xs: 0, sm: 2},
@@ -370,6 +455,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 +473,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 +525,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 +546,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 +567,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 +581,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 +598,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 +647,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 +665,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 +684,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 +702,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 +732,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 +753,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>

View File

@@ -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}
> >