From b719006c79770927ed99472b997031c3bbf12ce8 Mon Sep 17 00:00:00 2001 From: RustamRu Date: Sun, 19 Jan 2025 17:39:12 +0300 Subject: [PATCH] feat: CarBodySelect initial value --- src/components/order-form/form/car-body/car-body-select.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/order-form/form/car-body/car-body-select.tsx b/src/components/order-form/form/car-body/car-body-select.tsx index 309958f..ddc873f 100644 --- a/src/components/order-form/form/car-body/car-body-select.tsx +++ b/src/components/order-form/form/car-body/car-body-select.tsx @@ -18,7 +18,9 @@ import { CarBodySelectOption } from './types'; export const CarBodySelect = forwardRef( function CarBodySelect(props, ref) { - const [selected, setSelected] = useState>({}); + const initialOption = carBodySelectOptions.find(({ value }) => value === Number(props.value)); + const [selected, setSelected] = useState>(initialOption); + const handleOptionClick = (option: CarBodySelectOption) => { setSelected(option); // eslint-disable-next-line @typescript-eslint/ban-ts-comment