2020-05-22 22:35:24 +08:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
import { defineMessages } from 'react-intl';
|
2022-02-15 23:54:55 +08:00
|
|
|
import { withModalMounter } from '/imports/ui/components/common/modal/service';
|
2022-03-02 21:42:17 +08:00
|
|
|
import PropTypes from 'prop-types';
|
2021-11-11 03:10:35 +08:00
|
|
|
import Styled from './styles';
|
2020-05-22 22:35:24 +08:00
|
|
|
|
|
|
|
const messages = defineMessages({
|
|
|
|
yesLabel: {
|
|
|
|
id: 'app.endMeeting.yesLabel',
|
|
|
|
description: 'confirm button label',
|
|
|
|
},
|
|
|
|
noLabel: {
|
|
|
|
id: 'app.endMeeting.noLabel',
|
|
|
|
description: 'cancel confirm button label',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
const propTypes = {
|
2022-03-02 21:42:17 +08:00
|
|
|
confirmButtonColor: PropTypes.string,
|
|
|
|
};
|
|
|
|
|
|
|
|
const defaultProps = {
|
|
|
|
confirmButtonColor: 'primary',
|
2020-05-22 22:35:24 +08:00
|
|
|
};
|
|
|
|
|
2022-03-02 21:42:17 +08:00
|
|
|
class ConfirmationModal extends Component {
|
2020-05-22 22:35:24 +08:00
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
this.state = {
|
|
|
|
checked: false,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const {
|
2022-03-02 21:42:17 +08:00
|
|
|
intl,
|
|
|
|
mountModal,
|
|
|
|
onConfirm,
|
|
|
|
title,
|
|
|
|
titleMessageId,
|
|
|
|
titleMessageExtra,
|
|
|
|
checkboxMessageId,
|
|
|
|
confirmButtonColor,
|
|
|
|
confirmParam,
|
2020-05-22 22:35:24 +08:00
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
const {
|
|
|
|
checked,
|
|
|
|
} = this.state;
|
|
|
|
|
2022-03-02 21:42:17 +08:00
|
|
|
const hasCheckbox = !!checkboxMessageId;
|
|
|
|
|
2020-05-22 22:35:24 +08:00
|
|
|
return (
|
2022-03-02 21:42:17 +08:00
|
|
|
<Styled.ConfirmationModal
|
2020-05-22 22:35:24 +08:00
|
|
|
onRequestClose={() => mountModal(null)}
|
|
|
|
hideBorder
|
|
|
|
contentLabel={title}
|
|
|
|
>
|
2021-11-11 03:10:35 +08:00
|
|
|
<Styled.Container>
|
|
|
|
<Styled.Header>
|
|
|
|
<Styled.Title>
|
2022-03-02 21:42:17 +08:00
|
|
|
{intl.formatMessage({ id: titleMessageId }, { 0: titleMessageExtra })}
|
2021-11-11 03:10:35 +08:00
|
|
|
</Styled.Title>
|
|
|
|
</Styled.Header>
|
|
|
|
<Styled.Description>
|
2022-03-02 21:42:17 +08:00
|
|
|
{ hasCheckbox ? (
|
|
|
|
<label htmlFor="confirmationCheckbox" key="confirmation-checkbox">
|
|
|
|
<Styled.Checkbox
|
|
|
|
type="checkbox"
|
|
|
|
id="confirmationCheckbox"
|
|
|
|
onChange={() => this.setState({ checked: !checked })}
|
|
|
|
checked={checked}
|
|
|
|
aria-label={intl.formatMessage({ id: checkboxMessageId })}
|
|
|
|
/>
|
|
|
|
<span aria-hidden>{intl.formatMessage({ id: checkboxMessageId })}</span>
|
|
|
|
</label>
|
|
|
|
) : null }
|
2021-11-11 03:10:35 +08:00
|
|
|
</Styled.Description>
|
2020-05-22 22:35:24 +08:00
|
|
|
|
2021-11-11 03:10:35 +08:00
|
|
|
<Styled.Footer>
|
2021-11-22 20:51:25 +08:00
|
|
|
<Styled.ConfirmButton
|
2022-03-02 21:42:17 +08:00
|
|
|
color={confirmButtonColor}
|
2020-05-22 22:35:24 +08:00
|
|
|
label={intl.formatMessage(messages.yesLabel)}
|
|
|
|
onClick={() => {
|
2022-03-02 21:42:17 +08:00
|
|
|
onConfirm(confirmParam, checked);
|
2020-05-22 22:35:24 +08:00
|
|
|
mountModal(null);
|
|
|
|
}}
|
|
|
|
/>
|
2021-11-11 03:10:35 +08:00
|
|
|
<Styled.DismissButton
|
2020-05-22 22:35:24 +08:00
|
|
|
label={intl.formatMessage(messages.noLabel)}
|
|
|
|
onClick={() => mountModal(null)}
|
|
|
|
/>
|
2021-11-11 03:10:35 +08:00
|
|
|
</Styled.Footer>
|
|
|
|
</Styled.Container>
|
2022-03-02 21:42:17 +08:00
|
|
|
</Styled.ConfirmationModal>
|
2020-05-22 22:35:24 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-02 21:42:17 +08:00
|
|
|
ConfirmationModal.propTypes = propTypes;
|
|
|
|
ConfirmationModal.defaultProps = defaultProps;
|
|
|
|
|
|
|
|
export default withModalMounter(ConfirmationModal);
|