implemented unauthorized error message and link to reload page

This commit is contained in:
Florian Scholdei
2018-12-12 13:29:37 +01:00
parent 8927d56b5c
commit c3a8ef9986
2 changed files with 16 additions and 6 deletions

View File

@@ -2,6 +2,7 @@
import React from "react"; import React from "react";
import { translate } from "react-i18next"; import { translate } from "react-i18next";
import Notification from "./Notification"; import Notification from "./Notification";
import { UNAUTHORIZED_ERROR } from "./apiclient";
type Props = { type Props = {
t: string => string, t: string => string,
@@ -12,12 +13,20 @@ class ErrorNotification extends React.Component<Props> {
render() { render() {
const { t, error } = this.props; const { t, error } = this.props;
if (error) { if (error) {
if (error == UNAUTHORIZED_ERROR) {
return (
<Notification type="danger">
<strong>{t("error-notification.prefix")}:</strong> {t("error-notification.timeout")} <Link to={"/login"}>Login</Link>
</Notification>
);
} else {
return ( return (
<Notification type="danger"> <Notification type="danger">
<strong>{t("error-notification.prefix")}:</strong> {error.message} <strong>{t("error-notification.prefix")}:</strong> {error.message}
</Notification> </Notification>
); );
} }
}
return null; return null;
} }
} }

View File

@@ -20,7 +20,8 @@
} }
}, },
"error-notification": { "error-notification": {
"prefix": "Error" "prefix": "Error",
"timeout": "The session has expired. Please login again."
}, },
"loading": { "loading": {
"alt": "Loading ..." "alt": "Loading ..."