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,
|
DialogContent,
|
||||||
FormHelperText,
|
FormHelperText,
|
||||||
Grid,
|
Grid,
|
||||||
InputAdornment,
|
|
||||||
LinearProgress,
|
LinearProgress,
|
||||||
Stack,
|
Stack,
|
||||||
TextField,
|
TextField,
|
||||||
@@ -21,6 +20,7 @@ import PriceField from "@/core/components/PriceField";
|
|||||||
import * as Yup from "yup";
|
import * as Yup from "yup";
|
||||||
import CustomAccordion from "@/core/components/CustomAccordion";
|
import CustomAccordion from "@/core/components/CustomAccordion";
|
||||||
import ImageContent from "@/core/components/ImageContent";
|
import ImageContent from "@/core/components/ImageContent";
|
||||||
|
import SelectBox from "@/core/components/SelectBox";
|
||||||
|
|
||||||
const vehicle_amount = {
|
const vehicle_amount = {
|
||||||
"اتوبوس": 7000,
|
"اتوبوس": 7000,
|
||||||
@@ -232,51 +232,93 @@ const ConfirmContent = ({mutate, setOpenConfirmDialog, rowId, vehicle_type, hand
|
|||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Stack>
|
<Stack>
|
||||||
<TextField
|
<SelectBox
|
||||||
name="sakht_period"
|
name="sakht_period"
|
||||||
label={t("ConfirmDialog.sakht_period")}
|
label={t("ConfirmDialog.sakht_period")}
|
||||||
type={'number'}
|
size="small"
|
||||||
value={formik.values.sakht_period}
|
value={formik.values.sakht_period}
|
||||||
onChange={formik.handleChange}
|
selectType="sakht_period"
|
||||||
fullWidth
|
selectors={[
|
||||||
variant="outlined"
|
{
|
||||||
sx={{mt: 1}}
|
id: 1,
|
||||||
onBlur={formik.handleBlur("sakht_period")}
|
value: "30",
|
||||||
error={
|
name: "1 ماه - 30 روز"
|
||||||
formik.touched.sakht_period &&
|
},
|
||||||
Boolean(formik.errors.sakht_period)
|
{
|
||||||
}
|
id: 2,
|
||||||
helperText={
|
value: "60",
|
||||||
formik.touched.sakht_period && formik.errors.sakht_period
|
name: "2 ماه - 60 روز"
|
||||||
}
|
},
|
||||||
InputProps={{
|
{
|
||||||
endAdornment: <InputAdornment
|
id: 3,
|
||||||
position="end">{t("ConfirmDialog.sakht_period_day")}</InputAdornment>,
|
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>
|
||||||
<Stack>
|
<Stack>
|
||||||
<TextField
|
<SelectBox
|
||||||
name="tanafos_period"
|
name="tanafos_period"
|
||||||
label={t("ConfirmDialog.tanafos_period")}
|
label={t("ConfirmDialog.tanafos_period")}
|
||||||
type={'number'}
|
size="small"
|
||||||
value={formik.values.tanafos_period}
|
value={formik.values.tanafos_period}
|
||||||
onChange={formik.handleChange}
|
selectType="tanafos_period"
|
||||||
fullWidth
|
selectors={[
|
||||||
variant="outlined"
|
{
|
||||||
sx={{mt: 1}}
|
id: 1,
|
||||||
onBlur={formik.handleBlur("tanafos_period")}
|
value: "1",
|
||||||
error={
|
name: "1 ماه"
|
||||||
formik.touched.tanafos_period &&
|
},
|
||||||
Boolean(formik.errors.tanafos_period)
|
{
|
||||||
}
|
id: 2,
|
||||||
helperText={
|
value: "2",
|
||||||
formik.touched.tanafos_period && formik.errors.tanafos_period
|
name: "2 ماه"
|
||||||
}
|
},
|
||||||
InputProps={{
|
{
|
||||||
endAdornment: <InputAdornment
|
id: 3,
|
||||||
position="end">{t("ConfirmDialog.tanafos_period_month")}</InputAdornment>,
|
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>
|
||||||
<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