import { Box, Button, ButtonGroup, Icon, Modal, ButtonProps } from '@rocket.chat/fuselage'; import React, { FC } from 'react'; import { useTranslation } from '../contexts/TranslationContext'; import { withDoNotAskAgain, RequiredModalProps } from './withDoNotAskAgain'; type VariantType = 'danger' | 'warning' | 'info' | 'success'; type GenericModalProps = RequiredModalProps & { variant?: VariantType; cancelText?: string; confirmText?: string; title?: string; icon?: string; onCancel?: () => void; onClose: () => void; onConfirm: () => void; }; const iconMap = { danger: 'modal-warning', warning: 'modal-warning', info: 'info', success: 'check', }; const getButtonProps = (variant: VariantType): ButtonProps => { switch (variant) { case 'danger': return { primary: true, danger: true }; case 'warning': return { primary: true }; default: return {}; } }; const GenericModal: FC = ({ variant = 'info', children, cancelText, confirmText, title, icon, onCancel, onClose, onConfirm, dontAskAgain, ...props }) => { const t = useTranslation(); return ( {icon !== null && } {title ?? t('Are_you_sure')} {children} {dontAskAgain} {onCancel && ( )} ); }; export const GenericModalDoNotAskAgain = withDoNotAskAgain(GenericModal); export default GenericModal;