import React, { Component } from 'react'; import { defineMessages } from 'react-intl'; import PropTypes from 'prop-types'; import Styled from './styles'; const messages = defineMessages({ yesLabel: { id: 'app.confirmationModal.yesLabel', description: 'confirm button label', }, noLabel: { id: 'app.endMeeting.noLabel', description: 'cancel confirm button label', }, }); const propTypes = { confirmButtonColor: PropTypes.string, disableConfirmButton: PropTypes.bool, description: PropTypes.string, }; const defaultProps = { confirmButtonColor: 'primary', disableConfirmButton: false, description: '', }; class ConfirmationModal extends Component { constructor(props) { super(props); this.state = { checked: false, }; } render() { const { intl, setIsOpen, onConfirm, title, titleMessageId, titleMessageExtra, checkboxMessageId, confirmButtonColor, confirmButtonLabel, confirmButtonDataTest, confirmParam, disableConfirmButton, description, } = this.props; const { checked, } = this.state; const hasCheckbox = !!checkboxMessageId; return ( setIsOpen(false)} contentLabel={title} title={title || intl.formatMessage({ id: titleMessageId }, { 0: titleMessageExtra })} {...this.props} > {description} { hasCheckbox ? ( this.setState({ checked: !checked })} checked={checked} aria-label={intl.formatMessage({ id: checkboxMessageId })} /> {intl.formatMessage({ id: checkboxMessageId })} ) : null } { onConfirm(confirmParam, checked); setIsOpen(false); }} /> setIsOpen(false)} /> ); } } ConfirmationModal.propTypes = propTypes; ConfirmationModal.defaultProps = defaultProps; export default ConfirmationModal;