fix(tradein): guard деления на median=0 в ListingsCard/DealsCard

При пустой оценке (median_price_rub<=0) CV и «ниже рынка» делились на 0 →
клиент видел «Infinity%»/«NaN%». Обёрнуто в guard m>0 ? ... : «—».
Доп: знак сравнения сделок к рынку — «ниже»/«выше» по знаку diff.

Refs #741
This commit is contained in:
bot-frontend 2026-05-30 18:36:32 +03:00
parent 34a13d71c3
commit 7f46d6774e
2 changed files with 11 additions and 3 deletions

View file

@ -86,8 +86,11 @@ export function DealsCard({ estimate }: Props) {
<span className="unit">млн </span>
</div>
<div className="sub">
на {(((estimate.median_price_rub - m) / estimate.median_price_rub) * 100).toFixed(0)}%
ниже рынка
{estimate.median_price_rub > 0
? `на ${Math.abs(((estimate.median_price_rub - m) / estimate.median_price_rub) * 100).toFixed(0)}% ${
estimate.median_price_rub - m >= 0 ? "ниже" : "выше"
} рынка`
: "—"}
</div>
</div>
<div className="count-cell">

View file

@ -150,7 +150,12 @@ export function ListingsCard({ estimate, estimateId }: Props) {
</span>
<span className="unit">млн</span>
</div>
<div className="sub">CV {(((estimate.range_high_rub - estimate.range_low_rub) / m) * 100).toFixed(1)}%</div>
<div className="sub">
CV{" "}
{m > 0
? `${(((estimate.range_high_rub - estimate.range_low_rub) / m) * 100).toFixed(1)}%`
: "—"}
</div>
</div>
</div>