"use client"; import { useState } from "react"; import { ButtonPrimary } from "components/Buttons"; import { Input } from "components/Input"; import { useSmoker } from "components/Toast"; import { useIdentityData } from "components/IdentityProvider"; import { addDomain } from "actions/domains"; import { DotLoader } from "components/utils/DotLoader"; import { GoToArrow } from "components/Icons/GoToArrow"; export function AddDomainForm(props: { onDomainAdded: (domain: string) => void; onBack: () => void; }) { let [value, setValue] = useState(""); let [loading, setLoading] = useState(false); let { mutate } = useIdentityData(); let smoker = useSmoker(); let rect = document .getElementById("add-domain-button") ?.getBoundingClientRect(); return (
{ e.preventDefault(); setLoading(true); let { error } = await addDomain(value); if (error) { setLoading(false); smoker({ error: true, text: error === "invalid_domain" ? "Invalid domain! Use just the base domain" : error === "domain_already_in_use" ? "That domain is already in use!" : "An unknown error occured", position: { y: rect ? rect?.right - rect?.width / 2 : 0, x: rect ? rect?.bottom - rect?.height / 2 : 0, }, }); return; } mutate(); props.onDomainAdded(value); }} >

Add a Domain

Just include the base domain
Don't include the protocol{" "} (like https://) or path (you can add that later)
setValue(e.target.value)} />
{loading ? : "Add Domain"}
); }