1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-05-31 01:16:01 +02:00
unleash.unleash/frontend/src/store/user/index.js
Ivar Conradi Østhus 5342c86b60 fix: one and only one front (#244)
Co-authored-by: Christopher Kolstad <chriswk@getunleash.ai>
Co-authored-by: Fredrik Strand Oseberg <fredrik.no@gmail.com>
2021-02-24 11:03:18 +01:00

24 lines
725 B
JavaScript

import { Map as $Map } from 'immutable';
import { USER_CHANGE_CURRENT, USER_LOGOUT } from './actions';
import { AUTH_REQUIRED } from '../util';
const userStore = (state = new $Map(), action) => {
switch (action.type) {
case USER_CHANGE_CURRENT:
state = state
.set('profile', action.value)
.set('showDialog', false)
.set('authDetails', undefined);
return state;
case AUTH_REQUIRED:
state = state.set('authDetails', action.error.body).set('showDialog', true);
return state;
case USER_LOGOUT:
return new $Map();
default:
return state;
}
};
export default userStore;