jira/apps/web/core/components/web-hooks/delete-webhook-modal.tsx
sriram veeraghanta 02d0ee3e0f
chore: add copyright (#8584)
* feat: adding new copyright info on all files

* chore: adding CI
2026-01-27 13:54:22 +05:30

72 lines
1.9 KiB
TypeScript

/**
* Copyright (c) 2023-present Plane Software, Inc. and contributors
* SPDX-License-Identifier: AGPL-3.0-only
* See the LICENSE file for details.
*/
import { useState } from "react";
import { useParams } from "next/navigation";
// ui
import { TOAST_TYPE, setToast } from "@plane/propel/toast";
import { AlertModalCore } from "@plane/ui";
// hooks
import { useWebhook } from "@/hooks/store/use-webhook";
import { useAppRouter } from "@/hooks/use-app-router";
interface IDeleteWebhook {
isOpen: boolean;
onClose: () => void;
}
export function DeleteWebhookModal(props: IDeleteWebhook) {
const { isOpen, onClose } = props;
// states
const [isDeleting, setIsDeleting] = useState(false);
// router
const router = useAppRouter();
// store hooks
const { removeWebhook } = useWebhook();
const { workspaceSlug, webhookId } = useParams();
const handleClose = () => {
onClose();
};
const handleDelete = async () => {
if (!workspaceSlug || !webhookId) return;
setIsDeleting(true);
try {
await removeWebhook(workspaceSlug.toString(), webhookId.toString());
router.replace(`/${workspaceSlug}/settings/webhooks/`);
setToast({
type: TOAST_TYPE.SUCCESS,
title: "Success!",
message: "Webhook deleted successfully.",
});
} catch (_error) {
setToast({
type: TOAST_TYPE.ERROR,
title: "Error!",
message: "Webhook could not be deleted. Please try again.",
});
}
setIsDeleting(false);
};
return (
<AlertModalCore
handleClose={handleClose}
handleSubmit={handleDelete}
isSubmitting={isDeleting}
isOpen={isOpen}
title="Delete webhook"
content={
<>
Are you sure you want to delete this webhook? Future events will not be delivered to this webhook. This action
cannot be undone.
</>
}
/>
);
}