2017-10-04 04:42:10 +08:00
|
|
|
import React, { Component } from 'react';
|
2017-10-12 05:04:10 +08:00
|
|
|
import PropTypes from 'prop-types';
|
2020-05-26 04:00:13 +08:00
|
|
|
import { defineMessages, injectIntl } from 'react-intl';
|
2024-06-06 21:50:03 +08:00
|
|
|
import Session from '/imports/ui/services/storage/in-memory';
|
2021-11-10 00:11:19 +08:00
|
|
|
import Styled from './styles';
|
2017-10-04 04:42:10 +08:00
|
|
|
|
|
|
|
const intlMessages = defineMessages({
|
2018-04-04 00:48:02 +08:00
|
|
|
confirmLabel: {
|
2017-10-04 04:42:10 +08:00
|
|
|
id: 'app.audioModal.yes',
|
|
|
|
description: 'Hear yourself yes',
|
|
|
|
},
|
2018-04-04 00:48:02 +08:00
|
|
|
disconfirmLabel: {
|
2017-10-04 04:42:10 +08:00
|
|
|
id: 'app.audioModal.no',
|
|
|
|
description: 'Hear yourself no',
|
|
|
|
},
|
2018-04-04 00:48:02 +08:00
|
|
|
confirmAriaLabel: {
|
2018-03-22 01:19:35 +08:00
|
|
|
id: 'app.audioModal.yes.arialabel',
|
|
|
|
description: 'provides better context for yes btn label',
|
|
|
|
},
|
2018-04-04 00:48:02 +08:00
|
|
|
disconfirmAriaLabel: {
|
2018-03-22 01:19:35 +08:00
|
|
|
id: 'app.audioModal.no.arialabel',
|
|
|
|
description: 'provides better context for no btn label',
|
|
|
|
},
|
2017-10-04 04:42:10 +08:00
|
|
|
});
|
|
|
|
|
2017-10-12 05:04:10 +08:00
|
|
|
const propTypes = {
|
|
|
|
handleYes: PropTypes.func.isRequired,
|
|
|
|
handleNo: PropTypes.func.isRequired,
|
2021-08-09 22:24:02 +08:00
|
|
|
intl: PropTypes.shape({
|
|
|
|
formatMessage: PropTypes.func.isRequired,
|
|
|
|
}).isRequired,
|
2017-10-12 05:04:10 +08:00
|
|
|
};
|
|
|
|
|
2017-10-04 04:42:10 +08:00
|
|
|
class EchoTest extends Component {
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
2018-05-15 04:32:28 +08:00
|
|
|
this.state = {
|
|
|
|
disabled: false,
|
|
|
|
};
|
2017-10-05 04:49:11 +08:00
|
|
|
this.handleYes = props.handleYes.bind(this);
|
|
|
|
this.handleNo = props.handleNo.bind(this);
|
2017-10-04 04:42:10 +08:00
|
|
|
}
|
|
|
|
|
2019-02-28 03:59:45 +08:00
|
|
|
componentDidMount() {
|
2024-06-06 21:50:03 +08:00
|
|
|
Session.setItem('inEchoTest', true);
|
2019-02-28 03:59:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
componentWillUnmount() {
|
2024-06-06 21:50:03 +08:00
|
|
|
Session.setItem('inEchoTest', false);
|
2019-02-28 03:59:45 +08:00
|
|
|
}
|
|
|
|
|
2017-10-04 04:42:10 +08:00
|
|
|
render() {
|
|
|
|
const {
|
|
|
|
intl,
|
|
|
|
} = this.props;
|
2021-08-09 22:24:02 +08:00
|
|
|
const { disabled } = this.state;
|
|
|
|
const disableYesButtonClicked = (callback) => () => {
|
2018-05-15 04:32:28 +08:00
|
|
|
this.setState({ disabled: true }, callback);
|
|
|
|
};
|
2017-10-04 04:42:10 +08:00
|
|
|
return (
|
2021-11-10 00:11:19 +08:00
|
|
|
<Styled.EchoTest>
|
|
|
|
<Styled.EchoTestButton
|
2018-04-04 00:48:02 +08:00
|
|
|
label={intl.formatMessage(intlMessages.confirmLabel)}
|
|
|
|
aria-label={intl.formatMessage(intlMessages.confirmAriaLabel)}
|
2022-01-20 21:03:18 +08:00
|
|
|
data-test="echoYesBtn"
|
2018-03-22 01:19:35 +08:00
|
|
|
icon="thumbs_up"
|
2021-08-09 22:24:02 +08:00
|
|
|
disabled={disabled}
|
2017-10-04 04:42:10 +08:00
|
|
|
circle
|
2018-03-22 01:19:35 +08:00
|
|
|
color="success"
|
|
|
|
size="jumbo"
|
2018-05-15 04:32:28 +08:00
|
|
|
onClick={disableYesButtonClicked(this.handleYes)}
|
2017-10-04 04:42:10 +08:00
|
|
|
/>
|
2021-11-10 00:11:19 +08:00
|
|
|
<Styled.EchoTestButton
|
2018-04-04 00:48:02 +08:00
|
|
|
label={intl.formatMessage(intlMessages.disconfirmLabel)}
|
|
|
|
aria-label={intl.formatMessage(intlMessages.disconfirmAriaLabel)}
|
2018-03-22 01:19:35 +08:00
|
|
|
icon="thumbs_down"
|
2017-10-04 04:42:10 +08:00
|
|
|
circle
|
2018-03-22 01:19:35 +08:00
|
|
|
color="danger"
|
|
|
|
size="jumbo"
|
2017-10-12 05:04:10 +08:00
|
|
|
onClick={this.handleNo}
|
2017-10-04 04:42:10 +08:00
|
|
|
/>
|
2021-11-10 00:11:19 +08:00
|
|
|
</Styled.EchoTest>
|
2017-10-04 04:42:10 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default injectIntl(EchoTest);
|
2017-10-12 05:04:10 +08:00
|
|
|
|
|
|
|
EchoTest.propTypes = propTypes;
|