import { Show, createEffect, createSignal } from "solid-js" import Modal from "@/components/Modal" import type { Relay } from "@/lib/api" type Props = { open: boolean onClose: () => void relay: () => Relay | undefined saving: () => boolean error: () => string | undefined onSave: (domain: string) => Promise } export default function CustomDomainModal(props: Props) { const [input, setInput] = createSignal("") createEffect(() => { if (props.open) { setInput(props.relay()?.custom_domain ?? "") } }) const current = () => props.relay()?.custom_domain ?? "" const inputTrimmed = () => input().trim() async function handleSubmit(e: Event) { e.preventDefault() await props.onSave(inputTrimmed()) if (!props.error()) props.onClose() } return (

Custom domain

setInput(e.currentTarget.value)} placeholder="relay.example.com" class="w-full rounded-lg border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500" autocomplete="off" autocapitalize="none" spellcheck={false} />

Must be a domain you control, e.g. relay.example.com

{props.error()}

) }