diff --git a/web/src/pages/OnboardingPage.tsx b/web/src/pages/OnboardingPage.tsx index 4d6f1c3..106ab60 100644 --- a/web/src/pages/OnboardingPage.tsx +++ b/web/src/pages/OnboardingPage.tsx @@ -16,6 +16,7 @@ type Step = 1 | 2 | 3 | 4 | 5 | 6; type IncomeType = "regular" | "irregular"; type BudgetConservatism = "tight" | "moderate" | "relaxed" | "custom"; +type FixedAmountMode = "fixed" | "estimated"; type VariableCat = { id: string; @@ -37,6 +38,7 @@ type FixedItem = { id: string; name: string; amountCents: number; // absolute amount + amountMode: FixedAmountMode; priority: number; dueOn: string; // yyyy-mm-dd frequency?: "one-time" | "weekly" | "biweekly" | "monthly"; @@ -139,6 +141,7 @@ export default function OnboardingPage() { setFixeds( s.fixeds.map((f: FixedItem) => ({ ...f, + amountMode: f.amountMode === "estimated" ? "estimated" : "fixed", schedule: f.schedule ?? defaultSchedule(), autoPayEnabled: !!f.autoPayEnabled, })) @@ -317,6 +320,7 @@ export default function OnboardingPage() { id: crypto.randomUUID(), name: "", amountCents: 0, + amountMode: "fixed", priority: list.length + 1, dueOn: getTodayInTimezone(userTimezone), frequency: "monthly", @@ -405,6 +409,8 @@ export default function OnboardingPage() { const name = f.name.trim(); if (!name) continue; // skip empties just in case try { + const amountMode = f.amountMode ?? "fixed"; + const planAmountCents = Math.max(0, f.amountCents || 0); const schedule = f.autoPayEnabled ? { frequency: "monthly" as const, @@ -420,8 +426,10 @@ export default function OnboardingPage() { const created = await fixedPlansApi.create({ name, - totalCents: f.amountCents, + totalCents: planAmountCents, fundedCents: 0, + amountMode, + estimatedCents: amountMode === "estimated" ? planAmountCents : null, priority: i + 1, dueOn: dueOnISO, frequency: f.frequency, @@ -520,7 +528,11 @@ export default function OnboardingPage() { dashboardSnapshot.fixedPlans.map((p, i) => ({ id: p.id, name: p.name, - amountCents: p.totalCents, + amountCents: + (p as any).amountMode === "estimated" + ? Number((p as any).estimatedCents ?? p.totalCents) + : p.totalCents, + amountMode: (p as any).amountMode === "estimated" ? "estimated" : "fixed", priority: i + 1, dueOn: p.dueOn, autoPayEnabled: false, @@ -969,8 +981,8 @@ export default function OnboardingPage() {
{incomeType === "regular" - ? "Set amounts for recurring bills and expenses" - : "Set amounts for recurring bills and choose payment planning options"} + ? "Set fixed or estimated amounts for recurring bills and expenses" + : "Set fixed or estimated amounts and choose payment planning options"}
@@ -1007,6 +1019,18 @@ export default function OnboardingPage() {