2019-10-19 16:38:07 +02:00
|
|
|
import React from 'react';
|
|
|
|
|
import ErrorNotification from './ErrorNotification';
|
|
|
|
|
import { BackendError, ForbiddenError } from './errors';
|
2018-09-03 16:17:36 +02:00
|
|
|
|
|
|
|
|
type Props = {
|
2019-10-19 16:38:07 +02:00
|
|
|
error: Error;
|
|
|
|
|
title: string;
|
|
|
|
|
subtitle: string;
|
2018-09-03 16:17:36 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class ErrorPage extends React.Component<Props> {
|
|
|
|
|
render() {
|
2019-02-27 10:45:10 +01:00
|
|
|
const { title, error } = this.props;
|
2018-09-03 16:17:36 +02:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<section className="section">
|
|
|
|
|
<div className="box column is-4 is-offset-4 container">
|
|
|
|
|
<h1 className="title">{title}</h1>
|
2019-02-27 10:45:10 +01:00
|
|
|
{this.renderSubtitle()}
|
2018-09-03 16:17:36 +02:00
|
|
|
<ErrorNotification error={error} />
|
|
|
|
|
</div>
|
|
|
|
|
</section>
|
|
|
|
|
);
|
|
|
|
|
}
|
2019-02-27 10:45:10 +01:00
|
|
|
|
|
|
|
|
renderSubtitle = () => {
|
|
|
|
|
const { error, subtitle } = this.props;
|
2019-03-04 11:49:12 +01:00
|
|
|
if (error instanceof BackendError || error instanceof ForbiddenError) {
|
2019-02-27 10:45:10 +01:00
|
|
|
return null;
|
|
|
|
|
}
|
2019-10-19 16:38:07 +02:00
|
|
|
return <p className="subtitle">{subtitle}</p>;
|
|
|
|
|
};
|
2018-09-03 16:17:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default ErrorPage;
|