diff --git a/src/components/modal/ConfirmationModal.tsx b/src/components/modal/ConfirmationModal.tsx new file mode 100644 index 00000000..04c221e6 --- /dev/null +++ b/src/components/modal/ConfirmationModal.tsx @@ -0,0 +1,124 @@ +'use client'; + +import { RefObject } from 'react'; + +import { Icon } from '@iconify/react'; +import Modal from '@/components/Modal'; +import Button from '@/components/Button'; + +import { cn } from '@/lib/helper'; +import { Color } from '@/types/theme'; + +interface ConfirmationModalProps { + ref: RefObject; + type?: 'info' | 'success' | 'error'; + text?: string; + closeOnBackdrop?: boolean; + primaryButton?: { + text?: string; + color?: Color; + isLoading?: boolean; + onClick?: () => void; + }; + secondaryButton?: { + text?: string; + color?: Color; + isLoading?: boolean; + onClick?: () => void; + }; + className?: { + modal?: string; + modalBox?: string; + }; +} + +const ConfirmationModal = ({ + ref, + type = 'info', + text, + closeOnBackdrop, + primaryButton, + secondaryButton, + className, +}: ConfirmationModalProps) => { + const closeModalHandler = () => { + ref.current?.close(); + }; + + return ( + +
+
+ {type === 'info' && ( + + )} + + {type === 'success' && ( + + )} + + {type === 'error' && ( + + )} +
+ +

+ {text ?? 'Apakah anda yakin ingin melakukan hal ini?'} +

+ +
+ {secondaryButton && secondaryButton.text && ( + + )} + + {primaryButton && primaryButton.text && ( + + )} +
+
+
+ ); +}; + +export default ConfirmationModal;