diff --git a/dashboard/src/components/DeleteWebhookModal.tsx b/dashboard/src/components/DeleteWebhookModal.tsx
new file mode 100644
index 0000000..49e1443
--- /dev/null
+++ b/dashboard/src/components/DeleteWebhookModal.tsx
@@ -0,0 +1,106 @@
+import React from 'react';
+import {
+ Button,
+ Center,
+ Flex,
+ MenuItem,
+ Modal,
+ ModalBody,
+ ModalCloseButton,
+ ModalContent,
+ ModalFooter,
+ ModalHeader,
+ ModalOverlay,
+ useDisclosure,
+ Text,
+ useToast,
+} from '@chakra-ui/react';
+import { useClient } from 'urql';
+import { FaRegTrashAlt } from 'react-icons/fa';
+import { DeleteWebhook } from '../graphql/mutation';
+import { capitalizeFirstLetter } from '../utils';
+
+interface deleteWebhookModalInputPropTypes {
+ webhookId: string;
+ eventName: string;
+ fetchWebookData: Function;
+}
+
+const DeleteWebhookModal = ({
+ webhookId,
+ eventName,
+ fetchWebookData,
+}: deleteWebhookModalInputPropTypes) => {
+ const client = useClient();
+ const toast = useToast();
+ const { isOpen, onOpen, onClose } = useDisclosure();
+
+ const deleteHandler = async () => {
+ const res = await client
+ .mutation(DeleteWebhook, { params: { id: webhookId } })
+ .toPromise();
+ if (res.error) {
+ toast({
+ title: capitalizeFirstLetter(res.error.message),
+ isClosable: true,
+ status: 'error',
+ position: 'bottom-right',
+ });
+
+ return;
+ } else if (res.data?._delete_webhook) {
+ toast({
+ title: capitalizeFirstLetter(res.data?._delete_webhook.message),
+ isClosable: true,
+ status: 'success',
+ position: 'bottom-right',
+ });
+ }
+ onClose();
+ fetchWebookData();
+ };
+ return (
+ <>
+
+
+
+
+ Delete Webhook
+
+
+ Are you sure?
+
+
+ Webhook for event {eventName} will be deleted
+ permanently!
+
+
+
+
+
+ }
+ colorScheme="red"
+ variant="solid"
+ onClick={deleteHandler}
+ isDisabled={false}
+ >
+
+ Delete
+
+
+
+
+
+ >
+ );
+};
+
+export default DeleteWebhookModal;
diff --git a/dashboard/src/graphql/mutation/index.ts b/dashboard/src/graphql/mutation/index.ts
index ebb7d48..ee7ade3 100644
--- a/dashboard/src/graphql/mutation/index.ts
+++ b/dashboard/src/graphql/mutation/index.ts
@@ -95,3 +95,11 @@ export const EditWebhook = `
}
}
`;
+
+export const DeleteWebhook = `
+ mutation deleteWebhook($params: WebhookRequest!) {
+ _delete_webhook(params: $params) {
+ message
+ }
+ }
+`;
diff --git a/dashboard/src/pages/Webhooks.tsx b/dashboard/src/pages/Webhooks.tsx
index 5c81cb2..ed1f9fa 100644
--- a/dashboard/src/pages/Webhooks.tsx
+++ b/dashboard/src/pages/Webhooks.tsx
@@ -43,6 +43,7 @@ import {
UpdateWebhookModalViews,
} from '../constants';
import { WebhooksDataQuery } from '../graphql/queries';
+import DeleteWebhookModal from '../components/DeleteWebhookModal';
interface paginationPropTypes {
limit: number;
@@ -209,7 +210,11 @@ const Webhooks = () => {
selectedWebhook={webhook}
fetchWebookData={fetchWebookData}
/>
-
+