From 55a0b69089f514e1d4caa750a1e970a30b138ce6 Mon Sep 17 00:00:00 2001 From: Jon Staab Date: Mon, 1 Jun 2026 16:01:22 -0700 Subject: [PATCH] Convert inline error message to toast, tweak account page --- frontend/src/components/AppShell.tsx | 6 +---- frontend/src/components/PaymentDialog.tsx | 24 +++++++++---------- frontend/src/lib/billing.ts | 6 ++++- frontend/src/pages/Account.tsx | 29 +++-------------------- 4 files changed, 20 insertions(+), 45 deletions(-) diff --git a/frontend/src/components/AppShell.tsx b/frontend/src/components/AppShell.tsx index e149ed7..fb1bce8 100644 --- a/frontend/src/components/AppShell.tsx +++ b/frontend/src/components/AppShell.tsx @@ -139,11 +139,7 @@ export default function AppShell(props: { children?: any }) {
- {/* Shared billing prompts on every dashboard page; the billing page - renders its own contextual (inline) variant instead. */} - - - +
{props.children}
diff --git a/frontend/src/components/PaymentDialog.tsx b/frontend/src/components/PaymentDialog.tsx index e033ece..fa4847d 100644 --- a/frontend/src/components/PaymentDialog.tsx +++ b/frontend/src/components/PaymentDialog.tsx @@ -3,6 +3,7 @@ import QRCode from "qrcode" import Modal from "@/components/Modal" import PaymentSetup from "@/components/PaymentSetup" import { CardSetupBody } from "@/components/PaymentSetupShell" +import { setToastMessage } from "@/components/Toast" import { useCardPortal } from "@/lib/usePaymentSetup" import { getInvoice, getInvoiceBolt11, listInvoiceItems, type Invoice } from "@/lib/api" import { billingTenant } from "@/lib/state" @@ -26,7 +27,6 @@ export default function PaymentDialog(props: PaymentDialogProps) { const [bolt11Status, setBolt11Status] = createSignal("idle") const [bolt11Error, setBolt11Error] = createSignal("") const [payStatus, setPayStatus] = createSignal("idle") - const [payError, setPayError] = createSignal("") const [payMethod, setPayMethod] = createSignal("lightning") const [showPaymentSetup, setShowPaymentSetup] = createSignal(false) const [setupSaved, setSetupSaved] = createSignal(false) @@ -67,30 +67,35 @@ export default function PaymentDialog(props: PaymentDialogProps) { void loadBolt11() }) + // The card portal lives in a shared hook, so surface its failures here by + // mirroring its error signal into the toast. + createEffect(() => { + const err = card.error() + if (err) setToastMessage(err) + }) + function copyBolt11() { void navigator.clipboard.writeText(bolt11()) } async function checkPayment() { setPayStatus("loading") - setPayError("") try { const invoice = await getInvoice(props.invoice.id) if (invoice.paid_at != null) { setPayStatus("success") } else { setPayStatus("error") - setPayError("Payment not yet confirmed. Please try again after sending.") + setToastMessage("Payment not yet confirmed. Please try again after sending.") } } catch (e) { setPayStatus("error") - setPayError(e instanceof Error ? e.message : "Failed to check payment status") + setToastMessage(e instanceof Error ? e.message : "Failed to check payment status") } } function handleClose() { setPayStatus("idle") - setPayError("") setBolt11Status("idle") setBolt11Error("") setBolt11("") @@ -248,7 +253,7 @@ export default function PaymentDialog(props: PaymentDialogProps) { @@ -257,13 +262,6 @@ export default function PaymentDialog(props: PaymentDialogProps) { - {/* Error */} - -
-

{payError() || card.error()}

-
-
- {/* Footer */}
{ - const due = billing.balance() - return due > 0 ? { kind: "due" as const, amount: due } : { kind: "clear" as const, amount: 0 } - }) - function logout() { localStorage.clear() window.location.href = "/" @@ -103,32 +96,16 @@ export default function Account() {
- {/* Billing prompts, emphasized contextually on the billing page. */} - -
-

Account & Billing

+

Payment Methods

- {status()} + Your account is {status()}
- {/* Current balance (relocated from the old Recurring Billing section, logic unchanged) */} -
-

Current balance

- You're all paid up.

} - > -

${(balance().amount / 100).toFixed(2)} due

-
-
- - {/* Billing methods */} -

Billing methods

    {/* Lightning / NWC row — CTA opens the NWC modal */}
  • @@ -181,7 +158,7 @@ export default function Account() {
-

Invoice History

+

Payment History