client/src/reducers/authReducer.js
changeset 134 be36eed5e6e0
parent 132 906a6c7c7943
child 168 ea92f4fe783d
--- a/client/src/reducers/authReducer.js	Thu Aug 03 09:44:37 2017 +0200
+++ b/client/src/reducers/authReducer.js	Thu Aug 03 17:33:00 2017 +0200
@@ -35,6 +35,27 @@
   }
 }
 
+export const currentGroup = (state = null, action) => {
+  switch (action.type) {
+    case types.AUTH_DEAUTHENTICATE:
+    case types.AUTH_LOGOUT:
+      return null;
+    case types.AUTH_LOGIN_SUCCESS:
+      if( state === null) {
+        return action.user.default_group;
+      }
+      return state;
+    case types.GROUP_CREATE_SUCCESS: {
+      return action.group.name;
+    }
+    case types.GROUP_SET_GROUP:
+      return action.group;
+    default:
+      return state;
+  }
+}
+
+
 export const token = (state = null, action) => {
   switch (action.type) {
     case types.AUTH_DEAUTHENTICATE: