member_webapp/@overflow/member/store/container/signin/member-signin.reducer.ts
crusader ffb65a75f4 ing
2018-05-28 20:39:58 +09:00

48 lines
927 B
TypeScript

import {
Actions as MemberActions,
ActionType as MemberActionType,
} from '../../entity/member/member.action';
import {
State,
initialState,
} from './member-signin.state';
import {
Actions as AuthActions,
ActionType as AuthActionType,
} from '@overflow/shared/auth/store/container/auth';
export function reducer(state: State = initialState, action: MemberActions | AuthActions): State {
switch (action.type) {
case MemberActionType.Signin: {
return {
member: null,
pending: true,
error: null,
};
}
case AuthActionType.SigninSuccess: {
return {
member: action.payload.domainMember.member,
pending: false,
error: null,
};
}
case AuthActionType.SigninFailure: {
return {
member: null,
pending: false,
error: action.payload,
};
}
default: {
return state;
}
}
}