Sign in with a code, made-up data without Plaid, and easier everyday use
- Sign in with a code from your email (the link still works); setup item for the code email - Use made-up data: a pretend bank with three months of spending, no Plaid account needed - Is this your pay? when regular money in is filed as something else, with a one-press fix - They look right: keep every bank-given category in one press - Your week on Home, Plan in the main menu, history start per bank on Accounts - A new version of broke is ready, in the sidebar and Settings - Start skips the rebuild when nothing changed; country screen says it was guessed - Fix: skipping banks no longer sends you back to setup Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
37a97fe20a
commit
73208b79df
30 files changed
+496
-39
No files matched your search
@@ -60,6 +60,12 @@ export default async function Accounts() {
|
||||
supabase.from("accounts").select("id, name, custom_name, mask, type, subtype, current_balance:balance, currency, home:home_balance, included").eq("manual", true).eq("user_id", user!.id),
|
||||
]);
|
||||
const items = (data ?? []) as unknown as Item[];
|
||||
// How far back each bank's transactions go, so a short history doesn't read as a strange month.
|
||||
const since = new Map(await Promise.all(items.map(async (i) => {
|
||||
const ids = i.accounts.map((a) => a.id);
|
||||
const { data: first } = ids.length ? await supabase.from("transactions").select("date").in("account_id", ids).order("date").limit(1) : { data: [] };
|
||||
return [i.id, (first?.[0]?.date as string | undefined) ?? null] as const;
|
||||
})));
|
||||
const manualItem = { id: "manual", institution_name: "Added by you", institution_logo: null, institution_color: null, last_synced_at: null, accounts: [] };
|
||||
const all = [
|
||||
...items.flatMap((i) => i.accounts.map((a) => ({ ...a, item: i }))),
|
||||
@@ -164,7 +170,7 @@ export default async function Accounts() {
|
||||
<div className="text-xs text-muted">
|
||||
{item.status && item.status !== "ok"
|
||||
? item.status === "ITEM_LOGIN_REQUIRED" ? "Sign in to your bank again to keep syncing." : (item.error ?? "This connection stopped syncing.")
|
||||
: `${holds(item.accounts) ? `${holds(item.accounts)} · ` : ""}${plural(item.accounts.length, "account")} · synced ${item.last_synced_at ? ago(item.last_synced_at) : "never"}`}
|
||||
: `${holds(item.accounts) ? `${holds(item.accounts)} · ` : ""}${plural(item.accounts.length, "account")}${since.get(item.id) ? ` · history from ${new Date(`${since.get(item.id)}T12:00:00Z`).toLocaleDateString("en-US", { month: "short", day: "numeric", year: "numeric", timeZone: "UTC" })}` : ""} · synced ${item.last_synced_at ? ago(item.last_synced_at) : "never"}`}
|
||||
</div>
|
||||
</div>
|
||||
<ConnectionActions itemId={item.id} broken={item.provider === "plaid" && !!item.status && item.status !== "ok"} name={item.institution_name ?? "this bank"} />
|
||||
|
||||
@@ -11,12 +11,14 @@ import { countryOf } from "@/lib/countries";
|
||||
import { getUser, userTz } from "@/lib/data";
|
||||
import { fmtFor, todayIn } from "@/lib/format";
|
||||
import { modeOf } from "@/lib/privacy";
|
||||
import { updateReady } from "@/lib/updates";
|
||||
import { createClient } from "@/utils/supabase/server";
|
||||
|
||||
// Accounts made before country support are treated as US (countryOf default) and get a dashboard nudge instead.
|
||||
const FIRST_RUN_SINCE = "2026-10-22";
|
||||
|
||||
export default async function AppLayout({ children }: { children: React.ReactNode }) {
|
||||
const update = await updateReady();
|
||||
const [{ user }, tz] = await Promise.all([getUser(), userTz()]);
|
||||
const profile = user?.user_metadata?.profile;
|
||||
// created_at isn't in the token, so only users with no country pay for the full user record.
|
||||
@@ -47,6 +49,7 @@ export default async function AppLayout({ children }: { children: React.ReactNod
|
||||
</div>
|
||||
<Nav />
|
||||
<div className="hidden md:block mt-auto px-3 space-y-3">
|
||||
{update && <Link href="/settings#improve" className="block text-sm underline underline-offset-4">A new version of broke is ready</Link>}
|
||||
<ThemeToggle />
|
||||
<p className="text-[11px] text-muted leading-relaxed">broke is a personal project. Bank data comes from Plaid.</p>
|
||||
</div>
|
||||
|
||||
@@ -1,25 +1,17 @@
|
||||
import { ChevronRight, Sparkles } from "lucide-react";
|
||||
import { DonateLink } from "@/components/Donate";
|
||||
import Link from "next/link";
|
||||
import { countryOf } from "@/lib/countries";
|
||||
import { getUser } from "@/lib/data";
|
||||
|
||||
const PAGES = [
|
||||
{ href: "/debt", label: "Debt", what: "What you owe, what you're paying and what it costs." },
|
||||
{ href: "/plan", label: "Money plan", what: "Every move broke found for you, in order." },
|
||||
{ href: "/optimize", label: "Optimize", what: "Tax and savings ideas for your country." },
|
||||
{ href: "/bonuses", label: "Bonuses", what: "Sign-up bonuses from banks and cards." },
|
||||
{ href: "/cards", label: "Cards", what: "Your cards and which one to use." },
|
||||
];
|
||||
|
||||
// Everything that isn't part of the three steps on Home.
|
||||
export default async function More() {
|
||||
const { user } = await getUser();
|
||||
const cards = countryOf(user?.user_metadata?.profile?.country).cards;
|
||||
// What isn't in the main menu: Debt, connecting your AI and supporting broke.
|
||||
export default function More() {
|
||||
return (
|
||||
<div className="max-w-2xl space-y-4">
|
||||
<section className="card overflow-hidden">
|
||||
{PAGES.filter((p) => cards || p.href !== "/cards").map((p) => (
|
||||
{PAGES.map((p) => (
|
||||
<Link key={p.href} href={p.href} prefetch className="row-hover flex items-center gap-3 px-6 py-4 border-b border-line last:border-0">
|
||||
<span className="flex-1 min-w-0"><span className="block font-medium">{p.label}</span><span className="block text-sm text-muted">{p.what}</span></span>
|
||||
<ChevronRight size={18} className="text-muted shrink-0" />
|
||||
|
||||
@@ -6,13 +6,16 @@ import { CountryBanner } from "@/components/CountryPicker";
|
||||
import { EmptyBank } from "@/components/EmptyBank";
|
||||
import { GoLiveCard } from "@/components/GoLiveCard";
|
||||
import { Merchant } from "@/components/Merchant";
|
||||
import { PayFound } from "@/components/PayFound";
|
||||
import { PayQuestion } from "@/components/PayQuestion";
|
||||
import { SyncButton } from "@/components/PlaidButtons";
|
||||
import { TxnList } from "@/components/TxnList";
|
||||
import { WeekCard } from "@/components/WeekCard";
|
||||
import { categories, getUser, moneyByMonth, today, TXN_SELECT, withAccountNames, type Txn } from "@/lib/data";
|
||||
import { dateLabel, money0, monthStart, ymd } from "@/lib/format";
|
||||
import { deterministicMoves, ladder } from "@/lib/plan";
|
||||
import { myPlanFacts } from "@/lib/plan-facts";
|
||||
import { payGuess } from "@/lib/pay";
|
||||
import { moneyPicture } from "@/lib/steps";
|
||||
import { fetchChecks } from "@/lib/unsure";
|
||||
|
||||
@@ -22,6 +25,23 @@ async function HomeCheck({ checks }: { checks: Promise<Checks> }) {
|
||||
return c.total > 0 ? <CategoryCheck initial={c} closed /> : null;
|
||||
}
|
||||
|
||||
// Pay the bank filed as something else (lib/pay.ts). Streams in beside the rest.
|
||||
async function PayCheck({ uid, today, notPay }: { uid: string; today: string; notPay: string[] }) {
|
||||
const { supabase } = await getUser();
|
||||
const since = ymd(new Date(Date.parse(today) - 90 * 864e5));
|
||||
const { data } = await supabase.from("transactions").select("date, amount, name, merchant_name, custom_name, category:categories(id, key, label, kind)")
|
||||
.eq("user_id", uid).eq("ignored", false).lt("amount", -200).gte("date", since).limit(500);
|
||||
type R = { date: string; amount: number; name: string; merchant_name: string | null; custom_name: string | null; category: { key: string; label: string; kind: string } | null };
|
||||
const rows = (data ?? []) as unknown as R[];
|
||||
const name = (r: R) => r.merchant_name ?? r.name;
|
||||
const pay = payGuess(rows.map((r) => ({ name: name(r), date: r.date, amount: Number(r.amount), kind: r.category?.kind ?? null })), notPay);
|
||||
if (!pay) return null;
|
||||
const { data: income } = await supabase.from("categories").select("id").eq("key", "INCOME").is("user_id", null).maybeSingle();
|
||||
if (!income) return null;
|
||||
const filedAs = rows.find((r) => name(r) === pay.name)?.category?.label ?? "something else";
|
||||
return <PayFound pay={pay} filedAs={filedAs} incomeId={income.id as string} notPay={notPay} />;
|
||||
}
|
||||
|
||||
// One line pointing at the plan, or the one question broke needs answered. Streams in: the plan facts are the slow part.
|
||||
async function NextStep({ profile }: { profile: Record<string, unknown> }) {
|
||||
const facts = await myPlanFacts();
|
||||
@@ -91,8 +111,10 @@ export default async function Dashboard() {
|
||||
))}
|
||||
</section>
|
||||
|
||||
<Suspense fallback={null}><PayCheck uid={uid} today={day} notPay={(user?.user_metadata?.not_pay as string[] | undefined) ?? []} /></Suspense>
|
||||
<Suspense fallback={null}><NextStep profile={profile ?? {}} /></Suspense>
|
||||
<Suspense fallback={null}><HomeCheck checks={checks} /></Suspense>
|
||||
<WeekCard />
|
||||
|
||||
<div className="grid grid-cols-1 gap-4 @3xl:grid-cols-2 items-start">
|
||||
<section className="card p-5 space-y-3">
|
||||
|
||||
@@ -36,13 +36,13 @@ const NAV: { id: Group; label: string; icon: LucideIcon; what: string }[] = [
|
||||
];
|
||||
|
||||
// Which settings page each /setup section belongs on. Sections added later land by what they're about.
|
||||
const PLACE: Record<string, Group> = { supabase: "database", database: "database", plaid: "banks", akahu: "banks", enablebanking: "banks", basiq: "banks", belvo: "banks", ai: "ai", referrals: "referrals", local: "advanced", mcp: "advanced", devlogin: "advanced" };
|
||||
const PLACE: Record<string, Group> = { supabase: "database", database: "database", codes: "database", plaid: "banks", akahu: "banks", enablebanking: "banks", basiq: "banks", belvo: "banks", ai: "ai", referrals: "referrals", local: "advanced", mcp: "advanced", devlogin: "advanced" };
|
||||
const groupOf = (s: Section): Group => PLACE[s.id] ?? (/bank/i.test(`${s.title} ${s.what}`) ? "banks" : "advanced");
|
||||
// Server setup (keys, database, model, testing shortcuts). Only shown on the machine that runs broke.
|
||||
const SERVER: Group[] = ["banks", "database", "referrals", "advanced"];
|
||||
const attention = (s: Section) => s.status === "error" || (s.status === "todo" && s.kind !== "more");
|
||||
|
||||
export function Settings({ signedIn, local, folder, repo, email, profile, mode, testItems, message, aiMode }: { signedIn: boolean; local: boolean; folder: string; repo: string | null; email: string; profile: Profile; mode: Mode; testItems: { id: string; name: string }[]; message?: string; aiMode: AiMode }) {
|
||||
export function Settings({ signedIn, local, folder, repo, update, email, profile, mode, testItems, message, aiMode }: { signedIn: boolean; local: boolean; folder: string; repo: string | null; update: boolean; email: string; profile: Profile; mode: Mode; testItems: { id: string; name: string }[]; message?: string; aiMode: AiMode }) {
|
||||
const [group, setGroup] = useState<Group>("profile");
|
||||
const [data, setData] = useState<SetupStatus | null>(null);
|
||||
const [failed, setFailed] = useState(false);
|
||||
@@ -124,6 +124,7 @@ export function Settings({ signedIn, local, folder, repo, email, profile, mode,
|
||||
<ThemeToggle />
|
||||
</Card>
|
||||
)}
|
||||
{group === "improve" && update && <Card title="A new version of broke is ready" what={folder ? "Your changes stay. Stop broke first, then run this in your broke folder, and start broke again." : "Use Get the latest broke below. Your changes stay."}>{folder && <code className="block font-mono text-[13px] rounded-lg border border-line px-3 py-2">npm run update</code>}</Card>}
|
||||
{group === "improve" && <ImproveCard folder={folder} repo={repo} />}
|
||||
{group === "database" && (
|
||||
<Card title="Clear my data" what="Disconnects every bank and deletes your accounts, transactions, bills, budgets, rules, plans and chats. Your sign-in, profile answers and AI connection stay. Only your own data is touched.">
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { getUser } from "@/lib/data";
|
||||
import { isHosted } from "@/lib/llm/providers";
|
||||
import { updateReady } from "@/lib/updates";
|
||||
import { modeOf } from "@/lib/privacy";
|
||||
import { currentEnv, fromLocalhost, setupAccess, supabaseReady } from "@/lib/setup";
|
||||
import { createAdminClient } from "@/utils/supabase/admin";
|
||||
@@ -21,6 +22,7 @@ export default async function SettingsPage({ searchParams }: { searchParams: Pro
|
||||
signedIn={access.signedIn}
|
||||
local={local}
|
||||
folder={isHosted() ? "" : process.cwd()}
|
||||
update={await updateReady()}
|
||||
repo={process.env.VERCEL_GIT_REPO_OWNER && process.env.VERCEL_GIT_REPO_SLUG ? `${process.env.VERCEL_GIT_REPO_OWNER}/${process.env.VERCEL_GIT_REPO_SLUG}` : null}
|
||||
email={user?.email ?? ""}
|
||||
profile={user?.user_metadata?.profile ?? {}}
|
||||
|
||||
Reference in new issue
Block a user