import { createEffect, createSignal, Show } from "solid-js" import { PaymentSetupShell, PaymentSetupBody, SetupFooter, NwcSetupBody, CardSetupBody } from "@/components/PaymentSetupShell" import { useCardPortal, useNwcSetup } from "@/lib/usePaymentSetup" type Tab = "nwc" | "card" type PaymentSetupProps = { open: boolean onClose: () => void onSaved?: () => void // Which method to show first. Lightning/NWC is the default; pass "card" to land // a tenant on the card tab (e.g. when their card is the method that failed). initialTab?: Tab } export default function PaymentSetup(props: PaymentSetupProps) { const [tab, setTab] = createSignal(props.initialTab ?? "nwc") // Reset to the requested tab each time the dialog opens. createEffect(() => { if (props.open) setTab(props.initialTab ?? "nwc") }) const nwc = useNwcSetup(() => props.onSaved?.()) const card = useCardPortal() // Surface only the active tab's error so a stale failure on one method doesn't // bleed into the other. const error = () => (tab() === "nwc" ? nwc.error() : card.error()) function handleClose() { nwc.reset() card.reset() props.onClose() } return ( } >

Pay with

) }