fix: synchronize initial price analysis selection

This commit is contained in:
2026-09-06 16:38:04 +03:00
parent 21b902702c
commit 2bdc89286c
2 changed files with 8 additions and 1 deletions
+3 -1
View File
@@ -13,7 +13,9 @@ export const PriceAnalysis = () => {
const [selectedKey, setSelectedKey] = useState(null);
useEffect(() => {
if (selectedKey && !items.some((item) => `${item.ad}||${item.birim}` === selectedKey)) setSelectedKey(null);
if (!items.length) { if (selectedKey !== null) setSelectedKey(null); return; }
if (!selectedKey || !items.some((item) => `${item.ad}||${item.birim}` === selectedKey))
setSelectedKey(`${items[0].ad}||${items[0].birim}`);
}, [items, selectedKey]);
const selected = useMemo(() => {