import { createSignal, Show } from "solid-js" import Modal from "@/components/Modal" import { updateActiveTenant } from "@/lib/hooks" type PaymentSetupNWCProps = { open: boolean onClose: () => void onSaved?: () => void // The tenant already has a wallet connected, so the copy frames this as // replacing it (the stored URL is write-only and never sent back). isUpdate?: boolean } // Focused Lightning/NWC connect dialog. PaymentSetup offers both methods behind // tabs for the general setup flow; here the entry point is explicitly "connect a // Lightning wallet", so there's no method switcher — the card path lives on its // own row that redirects to Stripe. export default function PaymentSetupNWC(props: PaymentSetupNWCProps) { const [nwcUrl, setNwcUrl] = createSignal("") const [saving, setSaving] = createSignal(false) const [saved, setSaved] = createSignal(false) const [error, setError] = createSignal("") async function save() { const url = nwcUrl().trim() if (!url) return setSaving(true) setError("") try { await updateActiveTenant({ nwc_url: url }) setSaved(true) props.onSaved?.() } catch (e) { setError(e instanceof Error ? e.message : "Failed to save wallet connection") } finally { setSaving(false) } } function handleClose() { setNwcUrl("") setSaved(false) setError("") props.onClose() } return (

{props.isUpdate ? "Update Lightning Wallet" : "Connect Lightning Wallet"}

{props.isUpdate ? "Paste a new Nostr Wallet Connect URL to replace your connected wallet." : "Paste your Nostr Wallet Connect URL to pay invoices automatically over Lightning."}

Wallet connected!

Automatic payments are now enabled.

} >
setNwcUrl(e.currentTarget.value)} placeholder="nostr+walletconnect://..." class="w-full border border-gray-300 rounded-lg px-3 py-2" />

{error()}

Cancel } >
) }