import React, { useState } from 'react'; import { FormattedMessage } from 'react-intl'; import List, { ListItem } from 'soapbox/components/list'; import { Modal, Stack, Text, Toggle } from 'soapbox/components/ui'; interface IConfirmationModal { heading: React.ReactNode, message: React.ReactNode, confirm: React.ReactNode, onClose: (type: string) => void, onConfirm: () => void, secondary: React.ReactNode, onSecondary?: () => void, onCancel: () => void, checkbox?: JSX.Element, } const ConfirmationModal: React.FC = ({ heading, message, confirm, onClose, onConfirm, secondary, onSecondary, onCancel, checkbox, }) => { const [checked, setChecked] = useState(false); const handleClick = () => { onClose('CONFIRM'); onConfirm(); }; const handleSecondary = () => { onClose('CONFIRM'); onSecondary!(); }; const handleCancel = () => { onClose('CONFIRM'); if (onCancel) onCancel(); }; const handleCheckboxChange: React.ChangeEventHandler = e => { setChecked(e.target.checked); }; return ( } cancelAction={handleCancel} secondaryText={secondary} secondaryAction={onSecondary && handleSecondary} > {message} {checkbox && ( )} ); }; export default ConfirmationModal;