2018-09-03 16:17:36 +02:00
|
|
|
//@flow
|
|
|
|
|
import React from "react";
|
|
|
|
|
import { translate } from "react-i18next";
|
|
|
|
|
import Notification from "./Notification";
|
2018-12-12 13:35:58 +01:00
|
|
|
import {UNAUTHORIZED_ERROR} from "./apiclient";
|
2018-09-03 16:17:36 +02:00
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
|
t: string => string,
|
|
|
|
|
error?: Error
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class ErrorNotification extends React.Component<Props> {
|
2018-12-12 13:35:58 +01:00
|
|
|
|
2018-09-03 16:17:36 +02:00
|
|
|
render() {
|
|
|
|
|
const { t, error } = this.props;
|
|
|
|
|
if (error) {
|
2018-12-12 13:35:58 +01:00
|
|
|
if (error === UNAUTHORIZED_ERROR) {
|
|
|
|
|
return (
|
|
|
|
|
<Notification type="danger">
|
|
|
|
|
<strong>{t("error-notification.prefix")}:</strong> {t("error-notification.timeout")}
|
|
|
|
|
{" "}
|
|
|
|
|
<a href="javascript:window.location.reload(true)">{t("error-notification.loginLink")}</a>
|
|
|
|
|
</Notification>
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
return (
|
|
|
|
|
<Notification type="danger">
|
|
|
|
|
<strong>{t("error-notification.prefix")}:</strong> {error.message}
|
|
|
|
|
</Notification>
|
|
|
|
|
);
|
|
|
|
|
}
|
2018-09-03 16:17:36 +02:00
|
|
|
}
|
2018-11-19 10:31:01 +01:00
|
|
|
return null;
|
2018-09-03 16:17:36 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default translate("commons")(ErrorNotification);
|