logininfo.reducer.ts 725 Bytes
Newer Older
1
2
3
4
5
import { ILoginInfo, ILoginInfoToken } from './logininfo.types';
import { INITIAL_STATE } from './logininfo.initial-state';
import { Seq } from 'immutable';

import {
6
7
  LOGININFO_SAVE,
  LOGININFO_INIT
8
9
10
11
12
13
} from '../../constants';

export function loginInfoReducer(state: ILoginInfo = INITIAL_STATE, action): ILoginInfo {
  switch (action.type) {
    case LOGININFO_SAVE:
        let loginInfoTokens = Array<ILoginInfoToken>();
14
        loginInfoTokens.push(<ILoginInfoToken>{auth_token: action.payload.loginInfo.auth_token, auth_role: action.payload.loginInfo.auth_role});
15
        return Seq(loginInfoTokens).map(n => n).toList();
16
17
    case LOGININFO_INIT:
        return INITIAL_STATE;
18
19
    default:
        return state;
20
21
  }
};