bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/error-screen/component.jsx
2017-04-28 17:24:47 -03:00

77 lines
1.6 KiB
JavaScript
Executable File

import React, { Component, PropTypes } from 'react';
import { defineMessages, injectIntl } from 'react-intl';
import Button from '/imports/ui/components/button/component'
import styles from './styles.scss';
const intlMessages = defineMessages({
500: {
id: 'app.error.500',
defaultMessage: 'Ops, something went wrong',
},
404: {
id: 'app.error.404',
defaultMessage: 'Not found',
},
401: {
id: 'app.error.401',
},
403: {
id: 'app.error.403',
},
leave: {
id: 'app.leaveConfirmation.confirmLabel',
description: 'aria-label for leaving',
},
});
const propTypes = {
code: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
]),
};
const defaultProps = {
code: 500,
};
class ErrorScreen extends Component {
onClick() {
window.location = window.location.origin;
}
render() {
const { intl, code, children } = this.props;
let formatedMessage = intl.formatMessage(intlMessages[500]);
if (code in intlMessages) {
formatedMessage = intl.formatMessage(intlMessages[code]);
}
return (
<div className={styles.background}>
<h1 className={styles.code}>
{code}
</h1>
<h1 className={styles.message}>
{formatedMessage}
</h1>
<div className={styles.content}>
{children}
</div>
<div className={styles.content}>
<Button size={"sm"} label={intl.formatMessage(intlMessages.leave)} onClick={this.onClick}/>
</div>
</div>
);
}
}
export default injectIntl(ErrorScreen);
ErrorScreen.propTypes = propTypes;
ErrorScreen.defaultProps = defaultProps;