import type { Overview } from "../lib/overview";
import { yen } from "../lib/format";
import { host } from "../lib/agent";
import { Button, Kpi, NotYet, ScreenHead } from "../components/ui";
export function Wallet({ ov }: { ov: Overview | null }) {
const l = ov?.ledger;
const week = l?.days.length ? l.days.reduce((a, d) => a + d.earned, 0) : null;
return (
<>
<ScreenHead title="Wallet" sub="Amounts in yen (ADR 0027)">
<Button disabled={!ov} onClick={() => ov && host.openExternal(ov.hub.url)}>
Open the hub ↗
</Button>
</ScreenHead>
<div className="grid grid-cols-4 gap-2.5">
<Kpi label="Balance" value={yen(ov?.account?.balance)} sub={ov?.account?.email} />
<Kpi label="Earned today" value={yen(l?.todayEarned)} sub={l?.tz} />
<Kpi label="Earned 7 d" value={yen(week)} />
<Kpi label="Spent this month" value={yen(l?.monthSpent)} />
</div>
<NotYet what="Earned and spent per day, per product and per node." route="GET /v2/ledger" until="zc#516" />
</>
);
}