fix: distinguish units in price analysis selection

This commit is contained in:
2026-09-06 16:33:57 +03:00
parent 1c2651fc0e
commit d4e7ea44c5
2 changed files with 10 additions and 5 deletions
+5 -5
View File
@@ -12,7 +12,7 @@ export const PriceAnalysis = () => {
const selected = useMemo(() => {
if (!items.length) return null;
const found = items.find((i) => i.ad === selectedKey);
const found = items.find((i) => `${i.ad}||${i.birim}` === selectedKey);
return found || items[0];
}, [items, selectedKey]);
@@ -91,14 +91,14 @@ export const PriceAnalysis = () => {
</h3>
{items.slice(0, 60).map((it) => (
<button
key={it.ad}
onClick={() => setSelectedKey(it.ad)}
key={`${it.ad}||${it.birim}`}
onClick={() => setSelectedKey(`${it.ad}||${it.birim}`)}
className={`w-full text-left p-2.5 rounded-lg text-xs font-semibold transition-all ${
selected?.ad === it.ad ? 'bg-emerald-600 text-white' : 'bg-slate-50 hover:bg-slate-100 text-slate-700 border border-slate-200'
selectedKey === `${it.ad}||${it.birim}` ? 'bg-emerald-600 text-white' : 'bg-slate-50 hover:bg-slate-100 text-slate-700 border border-slate-200'
}`}
>
<div className="truncate">📦 {it.ad}</div>
<div className={`text-[10px] ${selected?.ad === it.ad ? 'text-emerald-100' : 'text-slate-400'}`}>{it.count} kayıt · medyan {formatTL(it.median)}</div>
<div className={`text-[10px] ${selectedKey === `${it.ad}||${it.birim}` ? 'text-emerald-100' : 'text-slate-400'}`}>{it.count} kayıt · {it.birim} medyan {formatTL(it.median)}</div>
</button>
))}
</div>