"use client"; import type { RecentSoldEntry } from "@/types/trade-in"; type Props = { items: RecentSoldEntry[] }; const fmtPrice = (n: number | null): string => n == null ? "—" : `${(n / 1_000_000).toFixed(2)} М`; const fmtDate = (d: string | null): string => { if (!d) return "—"; try { return new Date(d).toLocaleDateString("ru-RU"); } catch { return d; } }; export function RecentSoldList({ items }: Props) { const suffix = items.length === 1 ? "" : "ов"; return (

Недавно снятые (12 мес)

{items.length} лот{suffix}
{items.map((it) => { const hasDiscount = it.discount_pct != null && it.discount_pct !== 0; const discountColor = it.discount_pct != null && it.discount_pct > 0 ? "#16a34a" : "var(--muted, #6b7280)"; return ( ); })}
Лот Цена Торг Снято Экспозиция
{it.rooms ?? "?"}к, {it.area_m2 ?? "?"} м² {it.floor != null ? `, эт. ${it.floor}` : ""} {fmtPrice(it.last_price)} ₽ {hasDiscount ? `${it.discount_pct! > 0 ? "−" : "+"}${Math.abs(it.discount_pct!).toFixed(1)}%` : "—"} {fmtDate(it.removed_date)} {it.exposure_days ?? "—"} дн.
); }