complete edit and details part of loan
This commit is contained in:
@@ -43,6 +43,7 @@ function ButtonDatePicker(props) {
|
||||
<DatePicker
|
||||
slots={{field: ButtonField, ...props.slots}}
|
||||
disableFuture
|
||||
disabled={props.disabled}
|
||||
slotProps={{
|
||||
formik: props.formik,
|
||||
field: {setOpen},
|
||||
@@ -58,8 +59,7 @@ function ButtonDatePicker(props) {
|
||||
);
|
||||
}
|
||||
|
||||
export default function PickerWithButtonField({formik, error, helperText}) {
|
||||
const [value, setValue] = useState(null);
|
||||
export default function PickerWithButtonField({formik, disabled}) {
|
||||
return (
|
||||
<FormControl
|
||||
variant={"outlined"}
|
||||
@@ -69,16 +69,14 @@ export default function PickerWithButtonField({formik, error, helperText}) {
|
||||
>
|
||||
<LocalizationProvider dateAdapter={AdapterDateFnsJalali}>
|
||||
<ButtonDatePicker
|
||||
label={value == null ? null : moment(value)
|
||||
label={formik.values.birthday
|
||||
.locale("fa")
|
||||
.format("YYYY/MM/DD")}
|
||||
value={value}
|
||||
value={formik.values.birthday.toDate()}
|
||||
formik={formik}
|
||||
disabled={disabled}
|
||||
onChange={(newValue) => {
|
||||
const formattedBirthday = moment(newValue).locale("fa").format("YYYY-MM-DD")
|
||||
formik.setFieldValue("birthday", formattedBirthday)
|
||||
setValue(newValue)
|
||||
console.log(formattedBirthday)
|
||||
formik.setFieldValue("birthday", moment(newValue))
|
||||
}}
|
||||
|
||||
/>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Box, Button, Drawer, FormHelperText, InputBase, Stack} from "@mui/material";
|
||||
import {Box, Button, Drawer, FormHelperText, Stack, TextField} from "@mui/material";
|
||||
import {useTranslations} from "next-intl";
|
||||
import AccessibleIcon from '@mui/icons-material/Accessible';
|
||||
import {useState} from "react";
|
||||
@@ -123,39 +123,58 @@ const plate_words = [
|
||||
const PlateNumber = ({formik, disabled}) => {
|
||||
const t = useTranslations();
|
||||
const [plateDrawer, setPlateDrawer] = useState(false);
|
||||
const [selectedWordName, setSelectedWordName] = useState("الف");
|
||||
const [selectedWordValue, setSelectedWordValue] = useState("");
|
||||
|
||||
const isErrorPlate = Boolean(formik.errors.plate_part1 || formik.errors.plate_part3 || formik.errors.plate_part4)
|
||||
const isTouched = (formik.touched.plate_part1 || formik.touched.plate_part3 || formik.touched.plate_part4)
|
||||
return (
|
||||
<>
|
||||
<Stack direction={'row'}
|
||||
sx={{border: 1, overflow: 'hidden', borderColor: 'divider', borderRadius: 1}}>
|
||||
<InputBase
|
||||
type={'number'}
|
||||
disabled={disabled}
|
||||
sx={{
|
||||
border: 1,
|
||||
overflow: 'hidden',
|
||||
borderColor: (isTouched && isErrorPlate) ? 'error.main' : 'divider',
|
||||
borderRadius: 1
|
||||
}}>
|
||||
<TextField
|
||||
name={'plate_part4'}
|
||||
type={'tel'}
|
||||
value={formik.values.plate_part4}
|
||||
onInput={(event) => event.target.value.length <= 2 ? formik.setFieldValue("plate_part4", event.target.value) : null}
|
||||
size={'small'}
|
||||
placeholder={'xx'} sx={{flexGrow: 2}}
|
||||
inputProps={{sx: {textAlign: 'center'}}}/>
|
||||
<InputBase
|
||||
type={'number'}
|
||||
disabled={disabled}
|
||||
size={'small'}
|
||||
placeholder={'xx'} sx={{flexGrow: 2, "& fieldset": {border: 'none'}}}
|
||||
inputProps={{sx: {textAlign: 'center'}}}
|
||||
onChange={(event) => event.target.value.length <= 2 ? formik.setFieldValue("plate_part4", event.target.value) : null}
|
||||
onBlur={formik.handleBlur}
|
||||
error={formik.touched.plate_part4 && Boolean(formik.errors.plate_part4)}
|
||||
/>
|
||||
<TextField
|
||||
name={'plate_part3'}
|
||||
type={'tel'}
|
||||
value={formik.values.plate_part3}
|
||||
onInput={(event) => event.target.value.length <= 3 ? formik.setFieldValue("plate_part3", event.target.value) : null}
|
||||
size={'small'} placeholder={'xxx'} sx={{
|
||||
flexGrow: 3, borderLeft: 1, borderRadius: 0, borderColor: 'divider'
|
||||
}} inputProps={{sx: {textAlign: 'center'}}}/>
|
||||
size={'small'}
|
||||
disabled={disabled}
|
||||
placeholder={'xxx'}
|
||||
sx={{
|
||||
flexGrow: 3,
|
||||
borderLeft: 1,
|
||||
borderRadius: 0,
|
||||
borderColor: 'divider',
|
||||
"& fieldset": {border: 'none'}
|
||||
}}
|
||||
inputProps={{sx: {textAlign: 'center'}}}
|
||||
onChange={(event) => event.target.value.length <= 3 ? formik.setFieldValue("plate_part3", event.target.value) : null}
|
||||
onBlur={formik.handleBlur}
|
||||
error={formik.touched.plate_part3 && Boolean(formik.errors.plate_part3)}
|
||||
/>
|
||||
<Box sx={{flexGrow: 1}}>
|
||||
<Button
|
||||
onClick={() => setPlateDrawer(true)}
|
||||
disabled={disabled}
|
||||
sx={{borderRadius: 0, borderColor: 'divider'}}
|
||||
sx={{height: '100%', borderRadius: 0, borderColor: 'divider'}}
|
||||
size={'small'}
|
||||
data-selected-word={selectedWordValue}
|
||||
data-selected-word={formik.values.plate_part2}
|
||||
disabled={disabled}
|
||||
fullWidth
|
||||
>
|
||||
{selectedWordName}
|
||||
{plate_words.find(p => p.value === formik.values.plate_part2).name}
|
||||
</Button>
|
||||
</Box>
|
||||
<Drawer
|
||||
@@ -176,8 +195,6 @@ const PlateNumber = ({formik, disabled}) => {
|
||||
<Button
|
||||
key={item.id}
|
||||
onClick={() => {
|
||||
setSelectedWordName(item.name);
|
||||
setSelectedWordValue(item.value);
|
||||
formik.setFieldValue("plate_part2", item.value)
|
||||
setPlateDrawer(false);
|
||||
}}
|
||||
@@ -191,22 +208,27 @@ const PlateNumber = ({formik, disabled}) => {
|
||||
))}
|
||||
</Box>
|
||||
</Drawer>
|
||||
<InputBase
|
||||
type={'number'}
|
||||
<TextField
|
||||
name={'plate_part1'}
|
||||
type={'tel'}
|
||||
disabled={disabled}
|
||||
value={formik.values.plate_part1}
|
||||
onInput={(event) => event.target.value.length <= 2 ? formik.setFieldValue("plate_part1", event.target.value) : null}
|
||||
size={'small'}
|
||||
placeholder={'xx'}
|
||||
sx={{flexGrow: 2}}
|
||||
inputProps={{sx: {textAlign: 'center'}}}/>
|
||||
sx={{flexGrow: 2, "& fieldset": {border: 'none'}}}
|
||||
inputProps={{sx: {textAlign: 'center'}}}
|
||||
onChange={(event) => event.target.value.length <= 2 ? formik.setFieldValue("plate_part1", event.target.value) : null}
|
||||
onBlur={formik.handleBlur}
|
||||
error={true}
|
||||
/>
|
||||
<Stack sx={{width: 24, borderLeft: 1, borderColor: 'divider'}}>
|
||||
<Box sx={{flexGrow: 1, bgcolor: '#1ebc1e'}}></Box>
|
||||
<Box sx={{flexGrow: 1, bgcolor: 'white'}}></Box>
|
||||
<Box sx={{flexGrow: 1, bgcolor: '#f52121'}}></Box>
|
||||
</Stack>
|
||||
</Stack>
|
||||
<FormHelperText>{t("error_message_plate_number")}</FormHelperText>
|
||||
<FormHelperText
|
||||
error={(isTouched && isErrorPlate)}>{(isTouched && isErrorPlate) ? `${t("LoanRequest.error_message_plate_number")}` : null}</FormHelperText>
|
||||
</>
|
||||
|
||||
)
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import {Button} from "@mui/material";
|
||||
import {useTranslations} from "next-intl";
|
||||
import {useEffect} from "react";
|
||||
import {SEND_OTP_TOKEN} from "../data/apiRoutes";
|
||||
import {SEND_OTP_TOKEN} from "../data/apiRoutes";
|
||||
import {useDirection, useRequest} from "@witel/webapp-builder";
|
||||
import {SEND_OTP_TOKEN} from "@/core/data/apiRoutes";
|
||||
|
||||
const ResendToken = ({initialTimerValue, timer, setTimer, PhoneNumber, disabled}) => {
|
||||
const t = useTranslations();
|
||||
|
||||
@@ -9,23 +9,22 @@ function SelectBox({
|
||||
handleChange,
|
||||
error,
|
||||
onBlur,
|
||||
schema,
|
||||
disabled,
|
||||
helperText,
|
||||
isLoading,
|
||||
errorEcured,
|
||||
variant
|
||||
variant = "outlined"
|
||||
}) {
|
||||
const t = useTranslations();
|
||||
|
||||
return (
|
||||
<FormControl
|
||||
disabled={disabled || false}
|
||||
variant={variant || "outlined"}
|
||||
margin="normal"
|
||||
variant={variant}
|
||||
fullWidth
|
||||
size="small"
|
||||
error={error}
|
||||
sx={{mt: 0}}
|
||||
>
|
||||
<InputLabel>{label}</InputLabel>
|
||||
<Select
|
||||
@@ -38,16 +37,15 @@ function SelectBox({
|
||||
|
||||
>
|
||||
{isLoading ? (
|
||||
<MenuItem
|
||||
sx={{color: "primary.main"}}>{t("LoanRequest.text_field_loading_provinces_list")}</MenuItem>
|
||||
<MenuItem sx={{color: "primary.main"}}>{t("text_field_loading")}</MenuItem>
|
||||
) : errorEcured ? (
|
||||
<MenuItem sx={{color: "secondary.main"}}>
|
||||
{t("LoanRequest.text_field_error_fetching_provinces")}
|
||||
{t("text_field_error_fetching")}
|
||||
</MenuItem>
|
||||
) : (
|
||||
selectors.map((selector) => (
|
||||
<MenuItem key={selector.id} value={selector.value}>
|
||||
{selector.name}
|
||||
<MenuItem key={selector.id} value={selector[schema.value]}>
|
||||
{selector[schema.name]}
|
||||
</MenuItem>
|
||||
))
|
||||
)}
|
||||
|
||||
@@ -14,6 +14,11 @@ export const SEND_LOAN_REQUEST_WELFARE = BASE_URL + "/refahi/loan/store";
|
||||
export const UPDATE_LOAN_REQUEST_WELFARE = BASE_URL + "/refahi/loan/update/";
|
||||
export const DETAILS_LOAN_REQUEST_WELFARE = BASE_URL + "/refahi/loan/details/";
|
||||
export const GET_PROVINCE_LIST = BASE_URL + "/provinces";
|
||||
export const GET_CITIES_LIST = BASE_URL + "/cities"
|
||||
export const GET_CITIES_LIST = BASE_URL + "/cities";
|
||||
export const GET_EDUCATIONS_LIST = BASE_URL + "/education";
|
||||
export const GET_OCCUPATIONS_LIST = BASE_URL + "/occupations";
|
||||
|
||||
export const GET_LOAN_DETAILS = BASE_URL + "/navgan/loan/details/"
|
||||
export const UPDATE_LOAN = BASE_URL + "/navgan/loan/update/"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user