♻️ refactor: create delete webhook dialog component
This commit is contained in:
parent
c1696fbf48
commit
f5807c1126
@ -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 (
|
||||||
|
<ConfirmDialog
|
||||||
|
{...props}
|
||||||
|
dialogTitle="Delete webhook?"
|
||||||
|
handleCancel={handleCancel}
|
||||||
|
open={open}
|
||||||
|
confirmButtonTitle="Yes, confirm delete"
|
||||||
|
handleConfirm={handleConfirm}
|
||||||
|
confirmButtonProps={{ variant: 'danger' }}
|
||||||
|
>
|
||||||
|
<p className="text-sm text-elements-mid-em">
|
||||||
|
Are you sure you want to delete{' '}
|
||||||
|
<span className="text-sm font-mono text-elements-high-em px-0.5">
|
||||||
|
{webhookUrl}
|
||||||
|
</span>
|
||||||
|
?
|
||||||
|
</p>
|
||||||
|
</ConfirmDialog>
|
||||||
|
);
|
||||||
|
};
|
@ -1,9 +1,9 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import toast from 'react-hot-toast';
|
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 {
|
interface WebhookCardProps {
|
||||||
webhookUrl: string;
|
webhookUrl: string;
|
||||||
@ -15,7 +15,6 @@ const WebhookCard = ({ webhookUrl, onDelete }: WebhookCardProps) => {
|
|||||||
return (
|
return (
|
||||||
<div className="flex justify-between w-full mb-3">
|
<div className="flex justify-between w-full mb-3">
|
||||||
{webhookUrl}
|
{webhookUrl}
|
||||||
|
|
||||||
<div className="flex gap-3">
|
<div className="flex gap-3">
|
||||||
<Button
|
<Button
|
||||||
size="sm"
|
size="sm"
|
||||||
@ -38,23 +37,15 @@ const WebhookCard = ({ webhookUrl, onDelete }: WebhookCardProps) => {
|
|||||||
X
|
X
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
<DeleteWebhookDialog
|
||||||
<ConfirmDialog
|
handleCancel={() => setDeleteDialogOpen((preVal) => !preVal)}
|
||||||
dialogTitle="Delete webhook"
|
|
||||||
handleOpen={() => setDeleteDialogOpen((preVal) => !preVal)}
|
|
||||||
open={deleteDialogOpen}
|
open={deleteDialogOpen}
|
||||||
confirmButtonTitle="Yes, Confirm delete"
|
|
||||||
handleConfirm={() => {
|
handleConfirm={() => {
|
||||||
setDeleteDialogOpen((preVal) => !preVal);
|
setDeleteDialogOpen((preVal) => !preVal);
|
||||||
onDelete();
|
onDelete();
|
||||||
}}
|
}}
|
||||||
color="red"
|
webhookUrl={webhookUrl}
|
||||||
>
|
/>
|
||||||
<Typography variant="small" placeholder={''}>
|
|
||||||
Are you sure you want to delete the variable{' '}
|
|
||||||
<span className="bg-blue-100 p-0.5 rounded-sm">{webhookUrl}</span>?
|
|
||||||
</Typography>
|
|
||||||
</ConfirmDialog>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user