//@flow import React from "react"; import { translate } from "react-i18next"; import { BackendError, UnauthorizedError } from "./errors"; import Notification from "./Notification"; import BackendErrorNotification from "./BackendErrorNotification"; type Props = { t: string => string, error?: Error }; class ErrorNotification extends React.Component { render() { const { t, error } = this.props; if (error) { if (error instanceof BackendError) { return } else if (error instanceof UnauthorizedError) { return ( {t("error-notification.prefix")}:{" "} {t("error-notification.timeout")}{" "} {t("error-notification.loginLink")} ); } else { return ( {t("error-notification.prefix")}: {error.message} ); } } return null; } } export default translate("commons")(ErrorNotification);