From f5807c1126271fc5f84819384fb549b6b91e446e Mon Sep 17 00:00:00 2001 From: Wahyu Kurniawan Date: Thu, 14 Mar 2024 21:56:00 +0700 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor:=20create=20delet?= =?UTF-8?q?e=20webhook=20dialog=20component?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../projects/Dialog/DeleteWebhookDialog.tsx | 36 +++++++++++++++++++ .../projects/project/settings/WebhookCard.tsx | 21 ++++------- 2 files changed, 42 insertions(+), 15 deletions(-) create mode 100644 packages/frontend/src/components/projects/Dialog/DeleteWebhookDialog.tsx diff --git a/packages/frontend/src/components/projects/Dialog/DeleteWebhookDialog.tsx b/packages/frontend/src/components/projects/Dialog/DeleteWebhookDialog.tsx new file mode 100644 index 00000000..c2c82c16 --- /dev/null +++ b/packages/frontend/src/components/projects/Dialog/DeleteWebhookDialog.tsx @@ -0,0 +1,36 @@ +import ConfirmDialog, { + ConfirmDialogProps, +} from 'components/shared/ConfirmDialog'; +import React from 'react'; + +interface DeleteWebhookDialogProps extends ConfirmDialogProps { + webhookUrl: string; +} + +export const DeleteWebhookDialog = ({ + webhookUrl, + open, + handleCancel, + handleConfirm, + ...props +}: DeleteWebhookDialogProps) => { + return ( + +

+ Are you sure you want to delete{' '} + + {webhookUrl} + + ? +

+
+ ); +}; diff --git a/packages/frontend/src/components/projects/project/settings/WebhookCard.tsx b/packages/frontend/src/components/projects/project/settings/WebhookCard.tsx index 0d03e46e..80aaf4f1 100644 --- a/packages/frontend/src/components/projects/project/settings/WebhookCard.tsx +++ b/packages/frontend/src/components/projects/project/settings/WebhookCard.tsx @@ -1,9 +1,9 @@ import React, { useState } from 'react'; import toast from 'react-hot-toast'; -import { Button, Typography } from '@material-tailwind/react'; +import { Button } from '@material-tailwind/react'; -import ConfirmDialog from '../../../shared/ConfirmDialog'; +import { DeleteWebhookDialog } from 'components/projects/Dialog/DeleteWebhookDialog'; interface WebhookCardProps { webhookUrl: string; @@ -15,7 +15,6 @@ const WebhookCard = ({ webhookUrl, onDelete }: WebhookCardProps) => { return (
{webhookUrl} -
- - setDeleteDialogOpen((preVal) => !preVal)} + setDeleteDialogOpen((preVal) => !preVal)} open={deleteDialogOpen} - confirmButtonTitle="Yes, Confirm delete" handleConfirm={() => { setDeleteDialogOpen((preVal) => !preVal); onDelete(); }} - color="red" - > - - Are you sure you want to delete the variable{' '} - {webhookUrl}? - - + webhookUrl={webhookUrl} + />
); };