add plate number postal code navgan type and restyle select component

This commit is contained in:
2023-12-12 16:06:26 +03:30
parent d84367768d
commit 7feec0d209
7 changed files with 467 additions and 145 deletions

View File

@@ -1,46 +1,54 @@
import {FormControl, FormHelperText, InputLabel, MenuItem, Select,} from "@mui/material";
import {useTranslations} from "next-intl";
function SelectBox({
select,
selectType,
name,
selectors,
label,
setFieldValue,
setFieldTouched,
handleChange,
error,
onBlur,
disabled,
helperText,
isLoading,
errorEcured
}) {
const t = useTranslations();
const selectId = String(select);
const handleChange = (event) => {
setFieldValue(selectType, event.target.value);
};
return (
<FormControl
variant="outlined"
disabled={disabled || false}
variant={name === "plate_part2" ? "standard" : "outlined"}
margin="normal"
fullWidth
size="small"
error={error}
sx={{mt: 0}}
>
<InputLabel id="language-label">{label}</InputLabel>
<InputLabel>{label}</InputLabel>
<Select
id={selectId}
label={label}
name={selectId}
name={name}
size="small"
value={select}
value={isLoading?"":select}
onChange={handleChange}
onBlur={onBlur}
>
{selectors.map((selector) => (
<MenuItem key={selector.id} value={selector.value}>
{selector.name}
{isLoading ? (
<MenuItem sx={{color : "primary.main"}}>{t("LoanRequest.text_field_loading_provinces_list")}</MenuItem>
) : errorEcured ? (
<MenuItem sx={{color : "secondary.main"}}>
{t("LoanRequest.text_field_error_fetching_provinces")}
</MenuItem>
))}
) : (
selectors.map((selector) => (
<MenuItem key={selector.id} value={selector.value}>
{selector.name}
</MenuItem>
))
)}
</Select>
<FormHelperText>{helperText}</FormHelperText>
</FormControl>