"use client"; import Link from "next/link"; import type { RecommendComparable } from "@/types/analytics"; export function RecommendComparables({ items, }: { items: RecommendComparable[]; }) { if (items.length === 0) { return (

Нет comparable ЖК с такими фильтрами.

); } return (
{items.map((c) => { const sold = c.sold_perc; const soldColor = sold == null ? "#9ca3af" : sold >= 50 ? "#0a7a3a" : sold >= 30 ? "#9a6700" : "#b3261e"; const hasCadQuarter = c.cad_quarter != null; const hasBuildings = c.buildings_n != null && c.buildings_n > 0; const showMeta = hasCadQuarter || hasBuildings; const metaParts: string[] = []; if (hasCadQuarter) metaParts.push(`кв. ${c.cad_quarter}`); if (hasBuildings) metaParts.push(`${c.buildings_n} корп.`); const hasMapLink = c.lat != null && c.lon != null; const mapUrl = hasMapLink ? `https://yandex.ru/maps/?ll=${c.lon}%2C${c.lat}&z=16&pt=${c.lon}%2C${c.lat}` : null; return (
{c.comm_name ?? `ЖК #${c.obj_id}`}
{c.dev_name ?? "—"} {c.obj_class ? ` · ${c.obj_class}` : ""}
{showMeta ? (
{metaParts.join(" · ")} {mapUrl ? ( e.stopPropagation()} style={{ textDecoration: "none", lineHeight: 1, fontSize: 13, }} title="Открыть на карте" > 📍 ) : null}
) : (
)}
Квартир: {c.flat_count ?? "—"} Sold: {sold == null ? "—" : `${sold.toFixed(0)}%`}
); })}
); }