Setup step 3 asks where you live and shows that country's bank feed (#6)

Saved as BROKE_COUNTRY. US and Canada get Plaid, NZ Akahu, UK and Europe
Enable Banking, Australia Basiq, Brazil Belvo. Countries with no feed are
told to import a statement after sign-in. Onboarding uses the saved
country instead of asking again.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
minimus7andClaude Opus 5.5 authored and GitHub committed 2026-11-16 11:15:28 -06:00
1 parent 1e246336a2
commit b532bb8dd8
8 files changed
+136 -60

No files matched your search

+49
View File
@@ -2,6 +2,8 @@
import { Check, Copy, Eye, EyeOff } from "lucide-react";
import { useEffect, useState } from "react";
import { Dropdown } from "@/components/Dropdown";
import { COUNTRIES, countryOf, guessCountry, OTHER } from "@/lib/countries";
import type { Field } from "@/lib/setup";
export function CopyCommand({ command }: { command: string }) {
@@ -208,3 +210,50 @@ export function ConnectSupabaseButton({ onDone, onFail }: { onDone: () => void;
);
}
const COUNTRY_OPTIONS = [...COUNTRIES, OTHER].map((c) => ({ value: c.code, label: c.name }));
// Step 3 asks where they live first, so it can show that country's bank feed. Saved as BROKE_COUNTRY; onboarding uses it
// instead of asking again. Nothing saved yet: the guess from this computer, with a Continue button.
export function CountryPick({ saved, canWrite, writeNote, onSaved }: { saved: string; canWrite: boolean; writeNote?: string; onSaved: () => void }) {
const [guess, setGuess] = useState("");
const [value, setValue] = useState(saved);
const [busy, setBusy] = useState(false);
const [err, setErr] = useState("");
useEffect(() => {
if (saved) return; // the checklist remounts this (key) when the saved country changes
const g = guessCountry(navigator.languages ?? [navigator.language], Intl.DateTimeFormat().resolvedOptions().timeZone);
setGuess(g);
setValue((v) => v || g);
}, [saved]);
async function save(code: string) {
setBusy(true);
setErr("");
try {
const res = await fetch("/api/setup/env", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ values: { BROKE_COUNTRY: code } }) });
const body = (await res.json().catch(() => ({}))) as { error?: string; errors?: Record<string, string> };
if (res.ok) onSaved();
else setErr(body.errors?.BROKE_COUNTRY ?? body.error ?? "Couldn't save.");
} catch {
setErr("Couldn't reach broke. Is it still running?");
}
setBusy(false);
}
if (!canWrite) return <p className="text-sm text-muted">Where you live: {saved ? countryOf(saved).name : "not set"}. {writeNote} Set BROKE_COUNTRY there.</p>;
return (
<div className="space-y-2">
<span className="block text-sm font-medium">Where do you live?</span>
<div className="flex flex-wrap items-center gap-3">
<div className="w-64 max-w-full">
<Dropdown label="Country" value={value} options={COUNTRY_OPTIONS} onChange={(c) => { setValue(c); if (saved) save(c); }} placeholder="Choose a country" searchable />
</div>
{!saved && <button className="btn-primary" disabled={busy || !value} onClick={() => save(value)}>{busy ? "Saving..." : "Continue"}</button>}
{saved && busy && <span className="text-sm text-muted">Saving...</span>}
</div>
{!saved && value && value === guess && <p className="text-xs text-muted">Guessed from this computer&apos;s time zone and language. Change it if that&apos;s wrong.</p>}
{err && <p className="text-sm text-bad">{err}</p>}
</div>
);
}
+4 -4
View File
@@ -5,7 +5,7 @@ import Link from "next/link";
import { useCallback, useEffect, useState } from "react";
import { Logo } from "@/components/Logo";
import type { AiRow, Part, Section, SetupStatus } from "@/lib/setup";
import { CopyCommand, KeyForm, ConnectSupabaseButton, MigrateButton } from "./SetupActions";
import { CopyCommand, CountryPick, KeyForm, ConnectSupabaseButton, MigrateButton } from "./SetupActions";
export function ExtLink({ href, children }: { href: string; children: React.ReactNode }) {
return (
@@ -83,9 +83,8 @@ export function SetupChecklist({ signedIn }: { signedIn: boolean }) {
const main = sections.filter((s) => s.kind !== "more");
const more = sections.filter((s) => s.kind === "more");
const required = main.filter((s) => s.kind === "required");
const done = required.filter((s) => s.status === "done").length;
const next = required.find((s) => s.status !== "done");
const canSkipBank = next?.id === "plaid"; // the database works, so broke can open: statements can be imported without a bank feed
const canSkipBank = next?.country !== undefined; // the database works, so broke can open: statements can be imported without a bank feed
return (
<main className="min-h-screen bg-canvas px-4 py-8 md:py-12">
@@ -97,7 +96,7 @@ export function SetupChecklist({ signedIn }: { signedIn: boolean }) {
<section className="card p-7 space-y-5">
<div className="space-y-1">
<h1 className="text-2xl font-semibold">{!data ? "Set up broke" : !next ? "You're all set" : `Step ${done + 1} of ${required.length}: ${next.title}`}</h1>
<h1 className="text-2xl font-semibold">{!data ? "Set up broke" : !next ? "You're all set" : `Step ${required.indexOf(next) + 1} of ${required.length}: ${next.title}`}</h1>
<p className="text-sm text-muted">
{!data ? "Checking what's connected… " : !next ? "Open broke and sign in with your email. " : "It's free. Follow the steps below and paste each key in. "}
Your keys stay on this computer.
@@ -186,6 +185,7 @@ function SectionCard({ s, n, open, onToggle, data, signedIn, reload }: { s: Sect
</button>
<Collapse open={open}>
<div className="px-6 pb-6 pt-1 @md:pl-[4.25rem] space-y-4">
{s.country !== undefined && <CountryPick key={s.country} saved={s.country} canWrite={data.canWrite} writeNote={data.writeNote} onSaved={reload} />}
<Body s={s} data={data} signedIn={signedIn} reload={reload} />
</div>
</Collapse>