mirror of
https://github.com/Unleash/unleash.git
synced 2025-05-31 01:16:01 +02:00
Co-authored-by: Christopher Kolstad <chriswk@getunleash.ai> Co-authored-by: Fredrik Strand Oseberg <fredrik.no@gmail.com>
24 lines
725 B
JavaScript
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;
|