76 lines
2.0 KiB
TypeScript
Raw Normal View History

2016-07-29 20:55:19 +03:00
import React from 'react';
import { FormattedMessage as Message } from 'react-intl';
import { IntlProvider } from 'app/components/i18n';
import logger from 'app/services/logger';
import appInfo from 'app/components/auth/appInfo/AppInfo.intl.json';
import styles from './styles.scss';
import BoxesField from './BoxesField';
import messages from './BSoD.intl.json';
2019-12-07 13:28:52 +02:00
interface State {
lastEventId?: string | void;
}
// TODO: probably it is better to render this view from the App view
// to remove dependencies from store and IntlProvider
2019-12-07 13:28:52 +02:00
class BSoD extends React.Component<{}, State> {
state: State = {};
2018-05-02 21:22:13 +03:00
componentDidMount() {
// poll for event id
const timer = setInterval(() => {
if (!logger.getLastEventId()) {
return;
}
2018-05-02 21:22:13 +03:00
clearInterval(timer);
2018-05-02 21:22:13 +03:00
this.setState({
lastEventId: logger.getLastEventId(),
});
}, 500);
}
2018-05-02 21:22:13 +03:00
render() {
const { lastEventId } = this.state;
2018-05-02 21:22:13 +03:00
let emailUrl = 'mailto:support@ely.by';
2018-05-02 21:22:13 +03:00
if (lastEventId) {
emailUrl += `?subject=Bug report for #${lastEventId}`;
}
2018-05-02 21:22:13 +03:00
return (
2019-12-07 13:28:52 +02:00
<IntlProvider>
<div className={styles.body}>
<canvas
className={styles.canvas}
2019-12-07 13:28:52 +02:00
ref={(el: HTMLCanvasElement | null) => el && new BoxesField(el)}
/>
2018-05-02 21:22:13 +03:00
<div className={styles.wrapper}>
<div className={styles.title}>
<Message {...appInfo.appName} />
</div>
<div className={styles.lineWithMargin}>
<Message {...messages.criticalErrorHappened} />
</div>
<div className={styles.line}>
<Message {...messages.reloadPageOrContactUs} />
</div>
<a href={emailUrl} className={styles.support}>
support@ely.by
</a>
<div className={styles.easterEgg}>
<Message {...messages.alsoYouCanInteractWithBackground} />
</div>
</div>
</div>
</IntlProvider>
);
}
2016-07-29 20:55:19 +03:00
}
2019-12-07 13:28:52 +02:00
export default BSoD;