This commit is contained in:
@@ -50,6 +50,8 @@ export type Relay = {
|
||||
status: string
|
||||
sync_error: string
|
||||
synced: number
|
||||
custom_domain: string
|
||||
custom_domain_verified: number
|
||||
info_name: string
|
||||
info_icon: string
|
||||
info_description: string
|
||||
@@ -76,6 +78,7 @@ export type CreateRelayInput = {
|
||||
blossom_enabled?: number
|
||||
livekit_enabled?: number
|
||||
push_enabled?: number
|
||||
custom_domain?: string
|
||||
}
|
||||
|
||||
export type UpdateRelayInput = {
|
||||
@@ -91,6 +94,7 @@ export type UpdateRelayInput = {
|
||||
blossom_enabled?: number
|
||||
livekit_enabled?: number
|
||||
push_enabled?: number
|
||||
custom_domain?: string
|
||||
}
|
||||
|
||||
export type Tenant = {
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
import { createSignal } from "solid-js"
|
||||
import type { Relay } from "@/lib/api"
|
||||
import { getRelay, updateRelay } from "@/lib/api"
|
||||
|
||||
export default function useCustomDomain(relayId: () => string, mutate: (relay: Relay) => void) {
|
||||
const [saving, setSaving] = createSignal(false)
|
||||
const [verifying, setVerifying] = createSignal(false)
|
||||
const [error, setError] = createSignal<string>()
|
||||
|
||||
async function saveDomain(domain: string) {
|
||||
setSaving(true)
|
||||
setError(undefined)
|
||||
try {
|
||||
const updated = await updateRelay(relayId(), { custom_domain: domain })
|
||||
mutate(updated)
|
||||
} catch (e: unknown) {
|
||||
setError(e instanceof Error ? e.message : "Failed to save domain")
|
||||
} finally {
|
||||
setSaving(false)
|
||||
}
|
||||
}
|
||||
|
||||
// Verification runs in a background poller on the backend; reload the relay so
|
||||
// the UI picks up the latest custom_domain_verified state.
|
||||
async function verifyDomain() {
|
||||
setVerifying(true)
|
||||
setError(undefined)
|
||||
try {
|
||||
const updated = await getRelay(relayId())
|
||||
mutate(updated)
|
||||
} catch (e: unknown) {
|
||||
setError(e instanceof Error ? e.message : "Verification failed")
|
||||
} finally {
|
||||
setVerifying(false)
|
||||
}
|
||||
}
|
||||
|
||||
return { saving, verifying, error, saveDomain, verifyDomain }
|
||||
}
|
||||
Reference in New Issue
Block a user