Skip to content

Commit 4436465

Browse files
fix(web): correct dashboard currency and refresh copy (#4, #6)
1 parent 7157b72 commit 4436465

2 files changed

Lines changed: 23 additions & 18 deletions

File tree

apps/web/app/dashboard/page.tsx

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@ import { backendFetch } from '../../src/lib/backend';
77
type Group = { id: string; name: string; currency: string };
88
type Balance = { id: string; userId: string; counterpartyUserId: string; amountCents: string };
99

10-
function formatUsd(cents: bigint): string {
11-
const dollars = Number(cents) / 100;
12-
return dollars.toLocaleString(undefined, { style: 'currency', currency: 'USD' });
10+
function formatMoney(cents: bigint, currency: string | null): string {
11+
if (!currency) {
12+
return '—';
13+
}
14+
15+
const amount = Number(cents) / 100;
16+
return amount.toLocaleString(undefined, { style: 'currency', currency });
1317
}
1418

1519
export default async function DashboardPage() {
@@ -18,7 +22,9 @@ export default async function DashboardPage() {
1822
backendFetch<Group[]>('/groups').catch(() => [] as Group[]),
1923
]);
2024

21-
const activeGroupId = groups[0]?.id;
25+
const activeGroup = groups[0] ?? null;
26+
const activeGroupId = activeGroup?.id;
27+
const activeCurrency = activeGroup?.currency ?? null;
2228

2329
const [balances, activity] = await Promise.all([
2430
activeGroupId
@@ -47,21 +53,21 @@ export default async function DashboardPage() {
4753
<div className="flex items-center justify-between">
4854
<h2 className="text-lg font-bold text-[var(--fs-text-primary)]">Balance summary</h2>
4955
<span className="text-[11px] font-semibold uppercase tracking-[0.12em] text-[var(--fs-text-muted)]">
50-
Updated realtime
56+
Updated on refresh
5157
</span>
5258
</div>
5359
<div className="grid gap-6 md:grid-cols-3">
54-
<SummaryCard title="Active groups" value={groups.length} hint="Registered ensembles" />
55-
<SummaryCard
56-
title="Liabilities"
57-
value={formatUsd(oweCents)}
58-
hint={activeGroupId ? `Group ref: ${activeGroupId.slice(0, 8)}...` : 'No active group'}
59-
/>
60-
<SummaryCard
61-
title="Assets"
62-
value={formatUsd(owedToMeCents)}
63-
hint={me ? `Linked to: ${me.email}` : 'Sign in to track personal totals'}
64-
/>
60+
<SummaryCard title="Active groups" value={groups.length} hint="Registered ensembles" />
61+
<SummaryCard
62+
title="Liabilities"
63+
value={formatMoney(oweCents, activeCurrency)}
64+
hint={activeGroupId ? `${activeGroup?.name} · ${activeCurrency}` : 'No active group selected'}
65+
/>
66+
<SummaryCard
67+
title="Assets"
68+
value={formatMoney(owedToMeCents, activeCurrency)}
69+
hint={activeGroupId ? `Shown in ${activeCurrency}` : 'Select a group to see currency-specific totals'}
70+
/>
6571
</div>
6672
</section>
6773

apps/web/src/components/dashboard/ActivityList.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,11 @@ export function ActivityList({ items, groupId }: { items: ActivityDto[]; groupId
5858
<div className="rounded-2xl border border-[var(--fs-border)] bg-[var(--fs-background)]/50 px-6 py-8 text-center">
5959
<p className="text-sm font-semibold text-[var(--fs-text-primary)] mb-1">No activity yet</p>
6060
<p className="text-[12px] font-medium text-[var(--fs-text-muted)]">
61-
New expenses and settlements will surface here in real time.
61+
Refresh after new expenses or settlements to see the latest activity.
6262
</p>
6363
</div>
6464
) : null}
6565
</div>
6666
</div>
6767
);
6868
}
69-

0 commit comments

Comments
 (0)