Refactor folder structure (#4759)
This commit is contained in:
parent
a0e16692da
commit
346bc2afe2
1218 changed files with 187 additions and 177 deletions
71
web/core/components/web-hooks/delete-webhook-modal.tsx
Normal file
71
web/core/components/web-hooks/delete-webhook-modal.tsx
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
"use client";
|
||||
|
||||
import React, { FC, useState } from "react";
|
||||
import { useParams, useRouter } from "next/navigation";
|
||||
// ui
|
||||
import { TOAST_TYPE, setToast } from "@plane/ui";
|
||||
// components
|
||||
import { AlertModalCore } from "@/components/core";
|
||||
// hooks
|
||||
import { useWebhook } from "@/hooks/store";
|
||||
|
||||
interface IDeleteWebhook {
|
||||
isOpen: boolean;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
export const DeleteWebhookModal: FC<IDeleteWebhook> = (props) => {
|
||||
const { isOpen, onClose } = props;
|
||||
// states
|
||||
const [isDeleting, setIsDeleting] = useState(false);
|
||||
// router
|
||||
const router = useRouter();
|
||||
// store hooks
|
||||
const { removeWebhook } = useWebhook();
|
||||
|
||||
const { workspaceSlug, webhookId } = useParams();
|
||||
|
||||
const handleClose = () => {
|
||||
onClose();
|
||||
};
|
||||
|
||||
const handleDelete = async () => {
|
||||
if (!workspaceSlug || !webhookId) return;
|
||||
|
||||
setIsDeleting(true);
|
||||
|
||||
removeWebhook(workspaceSlug.toString(), webhookId.toString())
|
||||
.then(() => {
|
||||
setToast({
|
||||
type: TOAST_TYPE.SUCCESS,
|
||||
title: "Success!",
|
||||
message: "Webhook deleted successfully.",
|
||||
});
|
||||
router.replace(`/${workspaceSlug}/settings/webhooks/`);
|
||||
})
|
||||
.catch((error) =>
|
||||
setToast({
|
||||
type: TOAST_TYPE.ERROR,
|
||||
title: "Error!",
|
||||
message: error?.error ?? "Something went wrong. Please try again.",
|
||||
})
|
||||
)
|
||||
.finally(() => 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.
|
||||
</>
|
||||
}
|
||||
/>
|
||||
);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue