import * as actions from './authActions' import { ITokens } from './localStorage' export interface IAuthState
{ initialized: boolean principal: P | null tokens: ITokens | null } export function authReducer
(state: IAuthState
, action: any): IAuthState
{ switch (action.type) { case actions.AUTH_INIT: return { ...state, initialized: true, } case actions.AUTH_LOGIN: case actions.AUTH_REFRESH: return { ...state, principal: action.principal, tokens: action.tokens, } case actions.AUTH_LOGOUT: return { ...state, principal: null, tokens: null, } default: return ( state || { initialized: false, principal: null, tokens: null, } ) } }