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

+5 -3
View File
@@ -1,6 +1,6 @@
import { NextResponse } from "next/server";
import { countryOf, wantsAkahu } from "@/lib/countries";
import { fromLocalhost, setupAccess, setupStatus } from "@/lib/setup";
import { currentEnv, fromLocalhost, setupAccess, setupStatus } from "@/lib/setup";
import { createClient } from "@/utils/supabase/server";
// Server setup details are for the owner on this machine only: setup writes already need localhost (writeGate).
@@ -12,12 +12,14 @@ export async function GET() {
// The NZ bank keys only matter to someone with NZ banks. Keys already saved stay visible, so they can be changed or removed.
// Before Supabase is set up there's nobody signed in, and no client to ask.
const user = access.signedIn ? (await (await createClient()).auth.getUser()).data.user : null;
const profile = user?.user_metadata?.profile;
// Before anyone signs in, where they live is what setup step 3 asked (BROKE_COUNTRY).
const profile = user?.user_metadata?.profile ?? { country: currentEnv().BROKE_COUNTRY };
const here = countryOf(profile?.country).providers as string[];
const nz = wantsAkahu(profile);
// Bank connections for other countries stay out of the way, unless keys are already saved.
return NextResponse.json({ ...status, sections: status.sections.filter((s) => {
if (s.kind === "required") return true;
if (s.id === "akahu") return nz || s.status === "done";
return !["enablebanking", "basiq", "belvo"].includes(s.id) || here.includes(s.id) || s.status === "done";
return !["plaid", "enablebanking", "basiq", "belvo"].includes(s.id) || here.includes(s.id) || s.status === "done";
}) });
}