import { t } from "@lingui/core/macro"; import { HiXMark } from "react-icons/hi2"; import Button from "~/components/Button"; import { useModal } from "~/providers/modal"; import { usePopup } from "~/providers/popup"; import { api } from "~/utils/api"; interface DeleteWebhookConfirmationProps { workspacePublicId: string; } export function DeleteWebhookConfirmation({ workspacePublicId, }: DeleteWebhookConfirmationProps) { const { closeModal, entityId: webhookPublicId, entityLabel: webhookName, } = useModal(); const { showPopup } = usePopup(); const utils = api.useUtils(); const deleteWebhookMutation = api.webhook.delete.useMutation({ onSuccess: () => { void utils.webhook.list.invalidate({ workspacePublicId }); showPopup({ header: t`Webhook deleted`, message: t`Webhook deleted successfully`, icon: "success", }); closeModal(); }, onError: (error) => { showPopup({ header: t`Unable to delete webhook`, message: error.message || t`Failed to delete webhook`, icon: "error", }); }, }); const handleDelete = () => { if (!webhookPublicId) return; deleteWebhookMutation.mutate({ workspacePublicId, webhookPublicId: webhookPublicId, }); }; return (
{t`Are you sure you want to delete the webhook "${webhookName}"? This action cannot be undone.`}