fix(sf-12): MarketTrend — adaptive n<30/n<100 confidence warnings #287

Merged
lekss361 merged 1 commit from fix/sf-12-trend-confidence-warning into main 2026-05-17 13:39:04 +00:00
Showing only changes of commit 1e1737e829 - Show all commits

View file

@ -13,6 +13,9 @@ const LABEL_COLORS: Record<string, { bg: string; color: string }> = {
Падение: { bg: "#fecaca", color: "#b91c1c" },
};
const N_WEAK = 30;
const N_STRONG = 100;
function trendArrow(delta: number): string {
if (delta > 1) return "↑";
if (delta < -1) return "↓";
@ -52,6 +55,31 @@ export function MarketTrendBlock({ trend }: Props) {
);
}
const n = trend.recent_deals_count;
// n < 30 — hide trend entirely, show data-insufficient state
if (n < N_WEAK) {
return (
<div
style={{
borderRadius: 10,
padding: "14px 16px",
background: "#f3f4f6",
display: "flex",
flexDirection: "column",
gap: 6,
}}
>
<div style={{ fontSize: 12, fontWeight: 700, color: "#374151" }}>
Тренд рынка в радиусе {trend.radius_km} км
</div>
<div style={{ fontSize: 13, color: "#9ca3af" }}>
Недостаточно данных (n={n}) расширьте радиус для анализа тренда
</div>
</div>
);
}
const arrow = trendArrow(trend.delta_6m_pct);
const arrowColor = deltaColor(trend.delta_6m_pct);
const labelStyle = LABEL_COLORS[trend.label] ?? {
@ -132,6 +160,13 @@ export function MarketTrendBlock({ trend }: Props) {
>
{trend.label}
</div>
{/* Weak data warning: 30 ≤ n < 100 */}
{n < N_STRONG && (
<div className="bg-amber-50 border border-amber-200 text-amber-800 text-xs px-2 py-1 rounded">
Слабые данные (n={n}) расширьте радиус для точности
</div>
)}
</div>
);
}