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

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

10
export function loginInfoReducer(state: ILoginInfo = LOGININFO_INITIAL_STATE, action): ILoginInfo {
11
12
  switch (action.type) {
    case LOGININFO_SAVE:
13
14
15
		let loginInfoTokens = Array<ILoginInfoToken>();
        let i=0;
        action.payload.loginInfos.forEach(loginInfo => {
Open Source Developer's avatar
Open Source Developer committed
16
            loginInfoTokens.push(<ILoginInfoToken>{auth_token: loginInfo.auth_token, auth_role: loginInfo.auth_role, cu_name: loginInfo.cu_name});
17
18
            i++;
        });
19
        return Seq(loginInfoTokens).map(n => n).toList();
20

21
    case LOGININFO_INIT:
22
        return LOGININFO_INITIAL_STATE;
23
24
    default:
        return state;
25
26
  }
};