logininfo.reducer.ts 860 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
} from '../../constants';

export function loginInfoReducer(state: ILoginInfo = INITIAL_STATE, action): ILoginInfo {
  switch (action.type) {
    case LOGININFO_SAVE:
13
14
15
16
17
18
		let loginInfoTokens = Array<ILoginInfoToken>();
        let i=0;
        action.payload.loginInfos.forEach(loginInfo => {
            loginInfoTokens.push(<ILoginInfoToken>{auth_token: loginInfo.auth_token, auth_role: loginInfo.auth_role, cu_name: loginInfo.cu_name, xcsrftoken: loginInfo.xcsrftoken });
            i++;
        });
19
        return Seq(loginInfoTokens).map(n => n).toList();
20

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