From ab273ea7d0cb76ba0f563388fe4088dc213a32e3 Mon Sep 17 00:00:00 2001 From: MOHAN Date: Thu, 16 Jul 2026 15:38:00 +0530 Subject: [PATCH] feat: show household health score --- app/settings/households/page.tsx | 72 +++++++++++++++++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-) diff --git a/app/settings/households/page.tsx b/app/settings/households/page.tsx index 2ab3627..e80ce4b 100644 --- a/app/settings/households/page.tsx +++ b/app/settings/households/page.tsx @@ -43,6 +43,26 @@ type CashflowMonth = { transactionCount: number; }; +type HealthScore = { + score: number; + rating: "excellent" | "strong" | "building" | "needs_attention" | string; + components: { + cashflow: number; + balanceBuffer: number; + goalProgress: number; + collaboration: number; + syncHealth: number; + }; + metrics: { + savingsRate: number; + bufferMonths: number; + activeGoalCount: number; + jointAccountCount: number; + collaborativeTransactionCount: number; + }; + recommendations: string[]; +}; + type RecentTransaction = { date: string; description: string; @@ -88,6 +108,7 @@ type DashboardData = { monthlyNet: number; }; ownershipBreakdown: Record; + healthScore: HealthScore; accounts: HouseholdAccount[]; cashflow: CashflowMonth[]; recentTransactions: RecentTransaction[]; @@ -116,6 +137,10 @@ function accountLabel(account: HouseholdAccount | RecentTransaction["account"]) return `${account.institutionName ?? "Account"}${mask}`; } +function healthRatingLabel(value: string) { + return value.replace(/_/g, " "); +} + export default function HouseholdSettingsPage() { const [households, setHouseholds] = useState([]); const [selectedId, setSelectedId] = useState(""); @@ -343,7 +368,7 @@ export default function HouseholdSettingsPage() {
Loading households...
) : dashboard ? ( <> -
+

Total balance

{formatMoney(dashboard.summary.totalBalance)}

@@ -368,6 +393,51 @@ export default function HouseholdSettingsPage() {

{dashboard.summary.memberCount}

Active household access

+
+

Health score

+

{dashboard.healthScore.score}

+

{healthRatingLabel(dashboard.healthScore.rating)}

+
+
+ +
+
+
+

Couples financial health

+

{dashboard.healthScore.score}

+

{healthRatingLabel(dashboard.healthScore.rating)}

+
+
+ {[ + ["Cashflow", dashboard.healthScore.components.cashflow, 35], + ["Balance buffer", dashboard.healthScore.components.balanceBuffer, 20], + ["Goal progress", dashboard.healthScore.components.goalProgress, 20], + ["Collaboration", dashboard.healthScore.components.collaboration, 15], + ["Sync health", dashboard.healthScore.components.syncHealth, 10], + ].map(([label, value, max]) => ( +
+
+ {label} + {value}/{max} +
+
+
+
+
+ ))} +
+
+

Next best moves

+
+ {dashboard.healthScore.recommendations.map((recommendation) => ( +

{recommendation}

+ ))} + {!dashboard.healthScore.recommendations.length && ( +

Shared cashflow, goals, collaboration, and sync health are all in strong shape.

+ )} +
+
+