diff --git a/components/Domains/DomainSettingsView.tsx b/components/Domains/DomainSettingsView.tsx index 406a8d12..02782036 100644 --- a/components/Domains/DomainSettingsView.tsx +++ b/components/Domains/DomainSettingsView.tsx @@ -9,6 +9,7 @@ import { useIdentityData, mutateIdentityData, } from "components/IdentityProvider"; +import { ButtonPrimary } from "components/Buttons"; import { getDomainAssignment } from "./domainAssignment"; export function DomainSettingsView(props: { @@ -197,25 +198,67 @@ export function DomainSettingsView(props: {
-
- {props.onDeleteDomain && ( - - )} -
+ + + + ); +} + +function DeleteDomainButton(props: { + domain: string; + onDeleteDomain?: () => void; + mutateIdentity: ReturnType["mutate"]; +}) { + let [confirming, setConfirming] = useState(false); + + if (!props.onDeleteDomain) return null; + + if (!confirming) { + return ( +
+ +
+ ); + } + + return ( +
+

+ Are you sure you want to delete {props.domain}? This + will remove all assignments and cannot be undone. +

+
+ + { + mutateIdentityData(props.mutateIdentity, (draft) => { + draft.custom_domains = draft.custom_domains.filter( + (d) => d.domain !== props.domain, + ); + }); + props.onDeleteDomain?.(); + await deleteDomain({ domain: props.domain }); + }} + > + Delete +
);