import { Trash } from 'lucide-react' import { useEffect, useState } from 'react' import { toast } from 'sonner' import { Button, Checkbox } from 'ui' import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal' import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout' import { DocsButton } from '@/components/ui/DocsButton' import Panel from '@/components/ui/Panel' import { useCustomDomainDeleteMutation } from '@/data/custom-domains/custom-domains-delete-mutation' import type { CustomDomainResponse } from '@/data/custom-domains/custom-domains-query' import { DOCS_URL } from '@/lib/constants' export type CustomDomainDeleteProps = { projectRef?: string customDomain: CustomDomainResponse } export const CustomDomainDelete = ({ projectRef, customDomain }: CustomDomainDeleteProps) => { const [removeCustomDomain, setRemoveCustomDomain] = useState(false) const [isDeleteConfirmModalVisible, setIsDeleteConfirmModalVisible] = useState(false) const { mutate: deleteCustomDomain, isPending: isDeletingCustomDomain } = useCustomDomainDeleteMutation({ onSuccess: () => { toast.success( `Successfully deleted custom domain. Refresh your browser to see the changes.` ) setIsDeleteConfirmModalVisible(false) }, }) const onDeleteCustomDomain = async () => { if (!projectRef) return console.error('Project ref is required') deleteCustomDomain({ projectRef, removeAddon: removeCustomDomain }) } useEffect(() => { if (!isDeleteConfirmModalVisible) setRemoveCustomDomain(false) }, [isDeleteConfirmModalVisible]) return ( <>

Active custom domain:

{customDomain.hostname}

Your custom domain is currently active and is serving traffic

setIsDeleteConfirmModalVisible(false)} onConfirm={onDeleteCustomDomain} >

Are you sure you want to delete the custom domain{' '} {customDomain.hostname} for your project? You will need to re-verify this domain if you want to use it again.

setRemoveCustomDomain(!!value)} />
) }