2026-07-15 16:30:17 +00:00
|
|
|
<script lang="ts">
|
2026-07-28 16:16:26 +00:00
|
|
|
import {publish} from "@welshman/app"
|
2026-07-15 16:30:17 +00:00
|
|
|
import RelayForm, {type RelayFormValues} from "@app/components/hosting/RelayForm.svelte"
|
|
|
|
|
import PaymentDialog from "@app/components/hosting/PaymentDialog.svelte"
|
|
|
|
|
import PaymentSetup from "@app/components/hosting/PaymentSetup.svelte"
|
2026-09-26 04:31:17 +00:00
|
|
|
import {roomLists} from "@app/core"
|
2026-09-08 17:23:22 +00:00
|
|
|
import {navigate, pushModal} from "@app/modal"
|
2026-07-15 16:30:17 +00:00
|
|
|
import {makeSpacePath} from "@app/routes"
|
2026-09-26 04:31:17 +00:00
|
|
|
import {createHostedRelay, getHostedRelayUrl, hosting, isPaidPlan} from "@app/hosting"
|
2026-07-15 16:30:17 +00:00
|
|
|
|
2026-09-26 04:31:17 +00:00
|
|
|
const submit = async (values: RelayFormValues) => {
|
|
|
|
|
const relay = await createHostedRelay(values)
|
2026-07-15 16:30:17 +00:00
|
|
|
const url = getHostedRelayUrl(relay)
|
|
|
|
|
|
2026-09-26 04:31:17 +00:00
|
|
|
$hosting.setRelay(relay)
|
|
|
|
|
|
2026-09-24 18:23:21 +00:00
|
|
|
// Join the space now, or the space layout prompts for it and displaces the payment modals.
|
2026-07-28 16:16:26 +00:00
|
|
|
await $roomLists.addRelay(url).then(publish)
|
2026-07-15 16:30:17 +00:00
|
|
|
|
2026-09-26 04:31:17 +00:00
|
|
|
const due = isPaidPlan(values.plan_id) ? await $hosting.findPaymentDue() : undefined
|
2026-07-15 16:30:17 +00:00
|
|
|
|
2026-09-08 17:23:22 +00:00
|
|
|
await navigate(makeSpacePath(url, "admin"), {replaceState: true})
|
2026-07-15 16:30:17 +00:00
|
|
|
|
2026-09-26 04:31:17 +00:00
|
|
|
if (due?.invoice) {
|
|
|
|
|
pushModal(PaymentDialog, {invoice: due.invoice})
|
|
|
|
|
} else if (due) {
|
|
|
|
|
pushModal(PaymentSetup)
|
2026-07-15 16:30:17 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
2026-09-26 04:31:17 +00:00
|
|
|
<RelayForm mode="create" submitLabel="Create Space" onSubmit={submit} />
|