From b2bd914752c75c188147b5418d1e04d9813cd006 Mon Sep 17 00:00:00 2001 From: Markus Grigull Date: Mon, 27 Mar 2017 21:23:42 +0200 Subject: [PATCH] Add backend offline notification --- src/containers/login.js | 8 ++++++++ src/stores/user-store.js | 8 +++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/containers/login.js b/src/containers/login.js index 7f62ab4..9453900 100644 --- a/src/containers/login.js +++ b/src/containers/login.js @@ -10,10 +10,12 @@ import React, { Component } from 'react'; import { Container } from 'flux/utils'; import { PageHeader } from 'react-bootstrap'; +import NotificationSystem from 'react-notification-system'; import LoginForm from '../components/login-form'; import Header from '../components/header'; import Footer from '../components/footer'; +import NotificationsDataManager from '../data-managers/notifications-data-manager'; import AppDispatcher from '../app-dispatcher'; import UserStore from '../stores/user-store'; @@ -30,6 +32,10 @@ class Login extends Component { }; } + componentDidMount() { + NotificationsDataManager.setSystem(this.refs.notificationSystem); + } + componentWillUpdate(nextProps, nextState) { // if token stored locally, request user if (nextState.token == null) { @@ -56,6 +62,8 @@ class Login extends Component { render() { return (
+ +
diff --git a/src/stores/user-store.js b/src/stores/user-store.js index c2111b7..a0765f7 100644 --- a/src/stores/user-store.js +++ b/src/stores/user-store.js @@ -11,6 +11,7 @@ import { ReduceStore } from 'flux/utils'; import AppDispatcher from '../app-dispatcher'; import UsersDataManager from '../data-managers/users-data-manager'; +import NotificationsDataManager from '../data-managers/notifications-data-manager'; class UserStore extends ReduceStore { constructor() { @@ -50,7 +51,12 @@ class UserStore extends ReduceStore { return Object.assign({}, state, { currentUser: null, token: null }); case 'users/login-error': - console.log(action); + // server offline + NotificationsDataManager.addNotification({ + title: 'Server offline', + message: 'The server is offline. Please try again later.', + level: 'error' + }); return state; default: