Add invoice payment dialog

This commit is contained in:
Jon Staab
2026-03-31 08:02:35 -07:00
parent 95c971af1a
commit 15394f55d2
7 changed files with 337 additions and 18 deletions
+8 -2
View File
@@ -1,5 +1,5 @@
import { createSignal } from "solid-js"
import { updateRelayById, deactivateRelayById, type Relay } from "@/lib/hooks"
import { updateRelayById, deactivateRelayById, checkPendingInvoice, type Invoice, type Relay } from "@/lib/hooks"
import { setToastMessage } from "@/components/Toast"
import type { PlanId } from "@/lib/api"
@@ -30,6 +30,7 @@ export default function useRelayToggles(
{ refetch, mutate }: RelayActions,
) {
const [busy, setBusy] = createSignal(false)
const [pendingInvoice, setPendingInvoice] = createSignal<Invoice | undefined>()
async function updateRelay(next: Relay, previous: Relay) {
mutate(next)
@@ -85,6 +86,11 @@ export default function useRelayToggles(
setToastMessage(e instanceof Error ? e.message : "Failed to update relay plan")
throw e
}
if (plan !== "free") {
const invoice = await checkPendingInvoice()
if (invoice) setPendingInvoice(invoice)
}
}
const toggles = {
@@ -97,5 +103,5 @@ export default function useRelayToggles(
onToggleLivekitSupport: () => toggle("livekit_enabled", relay()?.plan !== "free"),
}
return { busy, handleDeactivate, handleUpdatePlan, toggles }
return { busy, handleDeactivate, handleUpdatePlan, pendingInvoice, clearPendingInvoice: () => setPendingInvoice(undefined), toggles }
}