1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/web/ synced 2025-03-09 00:00:01 +01:00

handle taken usernames add/edit user

This commit is contained in:
Ricardo Hernandez-Montoya 2017-05-03 17:30:40 +02:00
parent 1c20d0c87d
commit 059512333f
2 changed files with 27 additions and 1 deletions

View file

@ -95,7 +95,6 @@ class ArrayStore extends ReduceStore {
return this.updateElements(state, [action.data]);
case this.type + '/add-error':
console.log('something happened');
// TODO: Add error message
return state;

View file

@ -21,6 +21,7 @@
import ArrayStore from './array-store';
import UsersDataManager from '../data-managers/users-data-manager';
import NotificationsDataManager from '../data-managers/notifications-data-manager';
class UsersStore extends ArrayStore {
constructor() {
@ -30,6 +31,32 @@ class UsersStore extends ArrayStore {
reduce(state, action) {
switch (action.type) {
case this.type + '/add-error':
if (action.error && !action.error.handled && action.error.response) {
// If it was an error and hasn't been handled, user could not be added
const USER_ADD_ERROR_NOTIFICATION = {
title: 'Failed to add new user',
message: action.error.response.body.message,
level: 'error'
}
NotificationsDataManager.addNotification(USER_ADD_ERROR_NOTIFICATION);
}
return super.reduce(state, action);
case this.type + '/edit-error':
if (action.error && !action.error.handled && action.error.response) {
// If it was an error and hasn't been handled, user couldn't not be updated
const USER_EDIT_ERROR_NOTIFICATION = {
title: 'Failed to edit user',
message: action.error.response.body.message,
level: 'error'
}
NotificationsDataManager.addNotification(USER_EDIT_ERROR_NOTIFICATION);
}
return super.reduce(state, action);
default:
return super.reduce(state, action);
}