2018-05-28 07:51:33 +00:00
|
|
|
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';
|
|
|
|
|
2018-05-28 08:28:56 +00:00
|
|
|
export function reducer(state: State = initialState, action: MemberActions | AuthActions): State {
|
2018-05-28 07:51:33 +00:00
|
|
|
switch (action.type) {
|
|
|
|
case MemberActionType.Signin: {
|
|
|
|
return {
|
2018-05-28 11:39:58 +00:00
|
|
|
member: null,
|
2018-05-28 07:51:33 +00:00
|
|
|
pending: true,
|
|
|
|
error: null,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
case AuthActionType.SigninSuccess: {
|
|
|
|
return {
|
2018-05-28 11:39:58 +00:00
|
|
|
member: action.payload.domainMember.member,
|
2018-05-28 07:51:33 +00:00
|
|
|
pending: false,
|
|
|
|
error: null,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
case AuthActionType.SigninFailure: {
|
|
|
|
return {
|
2018-05-28 11:39:58 +00:00
|
|
|
member: null,
|
2018-05-28 07:51:33 +00:00
|
|
|
pending: false,
|
|
|
|
error: action.payload,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
default: {
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|