import { Description, Dialog, DialogBackdrop, DialogPanel, DialogTitle, } from '@headlessui/react' import type { ReactNode } from 'react' import { LeftArrow } from '~/components/icons/left-arrow' import { Button } from '~/components/ui/button' import { APP } from '~/data/meta' type ModalProperties = { isOpen: boolean onClose: () => void children?: ReactNode type: | 'success' | 'error' | 'warning' | 'success-reset-password' | 'success-register' | 'success-payment' } type DescriptionMap = { [key in ModalProperties['type']]: string } const DESCRIPTIONS: DescriptionMap = { 'success-reset-password': 'Link Reset Password telah dikirimkan ke email anda', 'success-register': 'Selamat! pendaftaran anda berhasil!', 'success-payment': 'Selamat! Pembayaran anda berhasil!', warning: 'Mohon maaf fitur berikut hanya untuk anggota yang sudah tersubscribe', error: 'Terjadi kesalahan. Silakan coba lagi.', success: '', } export const SuccessModal = ({ isOpen, onClose, type = 'success-register', }: ModalProperties) => { if (!isOpen) return const message = DESCRIPTIONS[type] || 'Terjadi kesalahan. Silakan coba lagi.' return (
{APP.title} {message}
{[ 'success-reset-password', 'success-register', 'success-payment', ].includes(type) && (
{APP.title}
)} {type === 'warning' && (
{APP.title}
)}
) }