"use client"; import type { RecommendBucket } from "@/types/analytics"; interface DerivedBucket extends RecommendBucket { effective_share_pct: number; effective_units: number | null; effective_revenue_rub: number | null; } interface Props { rows: DerivedBucket[]; hasAllocation: boolean; priceFactor?: number; elasticity?: number; } const fmtInt = (n: number | null | undefined) => n == null ? "—" : Math.round(n).toLocaleString("ru"); const fmtMln = (rub: number | null | undefined) => rub == null ? "—" : `${(rub / 1_000_000).toFixed(1)} млн ₽`; export function RecommendBucketsTable({ rows, hasAllocation, priceFactor = 1, elasticity = -1.5, }: Props) { const pfPow = priceFactor > 0 ? priceFactor ** elasticity : 1; return (
| {h} | ))}|||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| {r.bucket} | {r.is_top_success === true ? ( ⭐ ) : null} | {r.effective_share_pct.toFixed(1)}% | {fmtInt(r.deal_count)} | {r.area_avg_m2.toFixed(1)} | {fmtInt(adjP25)} | {fmtInt(adjPriceMedian)} | {fmtInt(adjP75)} | {adjVelocity > 0 ? adjVelocity.toFixed(1) : "—"} | {hasAllocation ? ( <>{fmtInt(r.effective_units)} | {months == null ? "—" : months > 60 ? "60+" : months.toFixed(1)} | {fmtMln(adjRevenue)} | > ) : null}