feat: CarBodySelect initial value

This commit is contained in:
RustamRu 2025-01-19 17:39:12 +03:00
parent fd79ab4e72
commit b719006c79

View File

@ -18,7 +18,9 @@ import { CarBodySelectOption } from './types';
export const CarBodySelect = forwardRef<HTMLInputElement, InputProps>( export const CarBodySelect = forwardRef<HTMLInputElement, InputProps>(
function CarBodySelect(props, ref) { function CarBodySelect(props, ref) {
const [selected, setSelected] = useState<Partial<CarBodySelectOption>>({}); const initialOption = carBodySelectOptions.find(({ value }) => value === Number(props.value));
const [selected, setSelected] = useState<Partial<CarBodySelectOption>>(initialOption);
const handleOptionClick = (option: CarBodySelectOption) => { const handleOptionClick = (option: CarBodySelectOption) => {
setSelected(option); setSelected(option);
// eslint-disable-next-line @typescript-eslint/ban-ts-comment // eslint-disable-next-line @typescript-eslint/ban-ts-comment