Merge branch 'feature/amin_sakht_tanafos_select' into 'develop'
replace select box instead of text field sakht and tanafos periode" See merge request witel-front-end/loan-facilities/expert!144
This commit is contained in:
@@ -7,7 +7,6 @@ import {
|
||||
DialogContent,
|
||||
FormHelperText,
|
||||
Grid,
|
||||
InputAdornment,
|
||||
LinearProgress,
|
||||
Stack,
|
||||
TextField,
|
||||
@@ -21,6 +20,7 @@ import PriceField from "@/core/components/PriceField";
|
||||
import * as Yup from "yup";
|
||||
import CustomAccordion from "@/core/components/CustomAccordion";
|
||||
import ImageContent from "@/core/components/ImageContent";
|
||||
import SelectBox from "@/core/components/SelectBox";
|
||||
|
||||
const vehicle_amount = {
|
||||
"اتوبوس": 7000,
|
||||
@@ -232,51 +232,93 @@ const ConfirmContent = ({mutate, setOpenConfirmDialog, rowId, vehicle_type, hand
|
||||
/>
|
||||
</Stack>
|
||||
<Stack>
|
||||
<TextField
|
||||
<SelectBox
|
||||
name="sakht_period"
|
||||
label={t("ConfirmDialog.sakht_period")}
|
||||
type={'number'}
|
||||
size="small"
|
||||
value={formik.values.sakht_period}
|
||||
onChange={formik.handleChange}
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
sx={{mt: 1}}
|
||||
onBlur={formik.handleBlur("sakht_period")}
|
||||
error={
|
||||
formik.touched.sakht_period &&
|
||||
Boolean(formik.errors.sakht_period)
|
||||
}
|
||||
helperText={
|
||||
formik.touched.sakht_period && formik.errors.sakht_period
|
||||
}
|
||||
InputProps={{
|
||||
endAdornment: <InputAdornment
|
||||
position="end">{t("ConfirmDialog.sakht_period_day")}</InputAdornment>,
|
||||
selectType="sakht_period"
|
||||
selectors={[
|
||||
{
|
||||
id: 1,
|
||||
value: "30",
|
||||
name: "1 ماه - 30 روز"
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
value: "60",
|
||||
name: "2 ماه - 60 روز"
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
value: "90",
|
||||
name: "3 ماه - 90 روز"
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
value: "120",
|
||||
name: "4 ماه - 120 روز"
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
value: "150",
|
||||
name: "5 ماه - 150 روز"
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
value: "180",
|
||||
name: "6 ماه - 180 روز"
|
||||
}
|
||||
]}
|
||||
schema={{value: 'value', name: 'name'}}
|
||||
select={formik.values.sakht_period}
|
||||
handleChange={(event) => {
|
||||
formik.setFieldValue('sakht_period', event.target.value)
|
||||
}}
|
||||
setFieldTouched={formik.setFieldTouched}
|
||||
error={formik.touched.sakht_period && Boolean(formik.errors.sakht_period)}
|
||||
helperText={formik.touched.sakht_period && formik.errors.sakht_period}
|
||||
onBlur={formik.handleBlur("sakht_period")}
|
||||
/>
|
||||
</Stack>
|
||||
<Stack>
|
||||
<TextField
|
||||
<SelectBox
|
||||
name="tanafos_period"
|
||||
label={t("ConfirmDialog.tanafos_period")}
|
||||
type={'number'}
|
||||
size="small"
|
||||
value={formik.values.tanafos_period}
|
||||
onChange={formik.handleChange}
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
sx={{mt: 1}}
|
||||
onBlur={formik.handleBlur("tanafos_period")}
|
||||
error={
|
||||
formik.touched.tanafos_period &&
|
||||
Boolean(formik.errors.tanafos_period)
|
||||
}
|
||||
helperText={
|
||||
formik.touched.tanafos_period && formik.errors.tanafos_period
|
||||
}
|
||||
InputProps={{
|
||||
endAdornment: <InputAdornment
|
||||
position="end">{t("ConfirmDialog.tanafos_period_month")}</InputAdornment>,
|
||||
selectType="tanafos_period"
|
||||
selectors={[
|
||||
{
|
||||
id: 1,
|
||||
value: "1",
|
||||
name: "1 ماه"
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
value: "2",
|
||||
name: "2 ماه"
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
value: "3",
|
||||
name: "3 ماه"
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
value: "4",
|
||||
name: "4 ماه"
|
||||
}
|
||||
]}
|
||||
schema={{value: 'value', name: 'name'}}
|
||||
select={formik.values.tanafos_period}
|
||||
handleChange={(event) => {
|
||||
formik.setFieldValue('tanafos_period', event.target.value)
|
||||
}}
|
||||
setFieldTouched={formik.setFieldTouched}
|
||||
error={formik.touched.tanafos_period && Boolean(formik.errors.tanafos_period)}
|
||||
helperText={formik.touched.tanafos_period && formik.errors.tanafos_period}
|
||||
onBlur={formik.handleBlur("tanafos_period")}
|
||||
/>
|
||||
</Stack>
|
||||
<Stack>
|
||||
|
||||
58
src/core/components/SelectBox.jsx
Normal file
58
src/core/components/SelectBox.jsx
Normal file
@@ -0,0 +1,58 @@
|
||||
import {FormControl, FormHelperText, InputLabel, MenuItem, Select,} from "@mui/material";
|
||||
import {useTranslations} from "next-intl";
|
||||
|
||||
function SelectBox({
|
||||
select,
|
||||
name,
|
||||
selectors,
|
||||
label,
|
||||
handleChange,
|
||||
error,
|
||||
onBlur,
|
||||
schema,
|
||||
disabled,
|
||||
helperText,
|
||||
isLoading,
|
||||
errorEcured,
|
||||
variant = "outlined"
|
||||
}) {
|
||||
const t = useTranslations();
|
||||
|
||||
return (
|
||||
<FormControl
|
||||
disabled={disabled || false}
|
||||
variant={variant}
|
||||
fullWidth
|
||||
size="small"
|
||||
error={error}
|
||||
>
|
||||
<InputLabel>{label}</InputLabel>
|
||||
<Select
|
||||
label={label}
|
||||
name={name}
|
||||
size="small"
|
||||
value={isLoading ? "" : select}
|
||||
onChange={handleChange}
|
||||
onBlur={onBlur}
|
||||
|
||||
>
|
||||
{isLoading ? (
|
||||
<MenuItem sx={{color: "primary.main"}}>{t("text_field_loading")}</MenuItem>
|
||||
) : errorEcured ? (
|
||||
<MenuItem sx={{color: "secondary.main"}}>
|
||||
{t("text_field_error_fetching")}
|
||||
</MenuItem>
|
||||
) : (
|
||||
selectors.map((selector) => (
|
||||
<MenuItem key={selector.id} value={selector[schema.value]}>
|
||||
{selector[schema.name]}
|
||||
</MenuItem>
|
||||
))
|
||||
)}
|
||||
</Select>
|
||||
<FormHelperText>{helperText}</FormHelperText>
|
||||
</FormControl>
|
||||
);
|
||||
}
|
||||
|
||||
export default SelectBox;
|
||||
Reference in New Issue
Block a user