import { useState } from 'react' import { toast } from 'sonner' 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' import { Trash } from 'lucide-react' import { Button } from 'ui' import ConfirmModal from 'ui-patterns/Dialogs/ConfirmDialog' export type CustomDomainDeleteProps = { projectRef?: string customDomain: CustomDomainResponse } const CustomDomainDelete = ({ projectRef, customDomain }: CustomDomainDeleteProps) => { const [isDeleteConfirmModalVisible, setIsDeleteConfirmModalVisible] = useState(false) const { mutate: deleteCustomDomain } = useCustomDomainDeleteMutation({ onSuccess: () => { toast.success( `Successfully deleted custom domain. It may take a few seconds before your custom domain is fully removed, hence you may need to refresh your browser.` ) setIsDeleteConfirmModalVisible(false) }, }) const onDeleteCustomDomain = async () => { if (!projectRef) return console.error('Project ref is required') deleteCustomDomain({ projectRef }) } return ( <>

Active custom domain:

{customDomain.hostname}

Your custom domain is currently active and is serving traffic

Are you sure you want to delete the custom domain{' '} {customDomain.hostname} for the project?
} description="Your custom domain will be deactivated. You will need to re-verify your domain if you want to use it again." buttonLabel="Delete" buttonLoadingLabel="Deleting" onSelectCancel={() => setIsDeleteConfirmModalVisible(false)} onSelectConfirm={onDeleteCustomDomain} /> ) } export default CustomDomainDelete