Refactored ErrorNotification/ErrorPage

Added i18n for error codes
This commit is contained in:
Philipp Czora
2019-02-27 10:45:10 +01:00
parent 6b55df464c
commit 510c295e00
9 changed files with 77 additions and 91 deletions

View File

@@ -1,6 +1,7 @@
//@flow
import React from "react";
import ErrorNotification from "./ErrorNotification";
import { BackendError } from "./errors";
type Props = {
error: Error,
@@ -10,18 +11,26 @@ type Props = {
class ErrorPage extends React.Component<Props> {
render() {
const { title, subtitle, error } = this.props;
const { title, error } = this.props;
return (
<section className="section">
<div className="box column is-4 is-offset-4 container">
<h1 className="title">{title}</h1>
<p className="subtitle">{subtitle}</p>
{this.renderSubtitle()}
<ErrorNotification error={error} />
</div>
</section>
);
}
renderSubtitle = () => {
const { error, subtitle } = this.props;
if (error instanceof BackendError) {
return null;
}
return <p className="subtitle">{subtitle}</p>
}
}
export default ErrorPage;