From 3674750011bbc3927fb6d0dcd631189b047613c8 Mon Sep 17 00:00:00 2001 From: Wahyu Kurniawan Date: Thu, 14 Mar 2024 21:49:45 +0700 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20feat:=20update=20confirm?= =?UTF-8?q?=20dialog=20to=20use=20new=20modal=20component?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/shared/ConfirmDialog.tsx | 44 ++++++++++++------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/packages/frontend/src/components/shared/ConfirmDialog.tsx b/packages/frontend/src/components/shared/ConfirmDialog.tsx index 9a943d54..e7374ad5 100644 --- a/packages/frontend/src/components/shared/ConfirmDialog.tsx +++ b/packages/frontend/src/components/shared/ConfirmDialog.tsx @@ -1,37 +1,49 @@ -import React from 'react'; - -import { color } from '@material-tailwind/react/types/components/button'; +import React, { ReactNode } from 'react'; import { Modal, ModalProps } from './Modal'; -import { Button } from './Button'; +import { Button, ButtonOrLinkProps } from './Button'; -type ConfirmDialogProp = ModalProps & { - children: React.ReactNode; - dialogTitle: string; +export type ConfirmDialogProps = ModalProps & { + children?: ReactNode; + dialogTitle?: string; open: boolean; - handleOpen: () => void; - confirmButtonTitle: string; + handleCancel: () => void; + confirmButtonTitle?: string; handleConfirm?: () => void; - color: color; + cancelButtonProps?: ButtonOrLinkProps; + confirmButtonProps?: ButtonOrLinkProps; }; const ConfirmDialog = ({ children, dialogTitle, - handleOpen, + handleCancel, confirmButtonTitle, handleConfirm, + cancelButtonProps, + confirmButtonProps, ...props -}: ConfirmDialogProp) => { +}: ConfirmDialogProps) => { + // Close the dialog when the user clicks outside of it + const handleOpenChange = (open: boolean) => { + if (!open) return handleCancel?.(); + }; + return ( - + {dialogTitle} {children} - - - +