import React, { PureComponent } from 'react'; import PropTypes from 'prop-types'; import { defineMessages, injectIntl } from 'react-intl'; import { Meteor } from 'meteor/meteor'; import { Session } from 'meteor/session'; import AudioManager from '/imports/ui/services/audio-manager'; import { styles } from './styles'; const intlMessages = defineMessages({ 500: { id: 'app.error.500', defaultMessage: 'Oops, something went wrong', }, 410: { id: 'app.error.410', }, 408: { id: 'app.error.408', }, 404: { id: 'app.error.404', defaultMessage: 'Not found', }, 403: { id: 'app.error.403', }, 401: { id: 'app.error.401', }, 400: { id: 'app.error.400', }, }); const propTypes = { code: PropTypes.oneOfType([ PropTypes.string, PropTypes.number, ]), }; const defaultProps = { code: 500, }; class ErrorScreen extends PureComponent { componentDidMount() { AudioManager.exitAudio(); Meteor.disconnect(); } render() { const { intl, code, children, } = this.props; let formatedMessage = intl.formatMessage(intlMessages[defaultProps.code]); if (code in intlMessages) { formatedMessage = intl.formatMessage(intlMessages[code]); } return (

{formatedMessage}

{ !Session.get('errorMessageDescription') || (
{Session.get('errorMessageDescription')}
) }

{code}

{children}
); } } export default injectIntl(ErrorScreen); ErrorScreen.propTypes = propTypes; ErrorScreen.defaultProps = defaultProps;