import { Card } from "@/components/ui/card"; import type { PovertyOverview } from "@/lib/poverty-types"; interface PovertyStatsCardsProps { overview: PovertyOverview | null; } export function PovertyStatsCards({ overview }: PovertyStatsCardsProps) { const totals = overview?.totals; const byLabel = overview?.by_label ?? {}; const highPriority = (byLabel["SANGAT TINGGI"] ?? 0) + (byLabel["TINGGI"] ?? 0); const poiTotal = Object.values(overview?.poi ?? {}).reduce((s, n) => s + n, 0); const avgDependents = totals && totals.household_count > 0 ? (totals.total_dependents / totals.household_count).toFixed(1) : null; return ( <> Warga Terdata {totals ? totals.household_count : "—"} KK {poiTotal} fasilitas umum terpetakan Total Tanggungan {totals ? totals.total_dependents : "—"} jiwa {avgDependents ? `rata-rata ${avgDependents} jiwa per KK` : "belum ada data"} Rata-rata Penghasilan {totals ? `Rp ${Math.round(totals.avg_income).toLocaleString("id-ID")}` : "—"} per kepala keluarga per bulan Rata-rata Skor Fuzzy {totals?.avg_score != null ? Number(totals.avg_score).toFixed(1) : "—"} / 100 {highPriority} KK prioritas tinggi ke atas > ); }