2018-04-06 06:59:49 +00:00
|
|
|
import {
|
|
|
|
Actions,
|
|
|
|
ActionType,
|
|
|
|
} from './signup.action';
|
|
|
|
|
|
|
|
import {
|
|
|
|
State,
|
|
|
|
initialState,
|
|
|
|
} from './signup.state';
|
|
|
|
|
2018-05-02 08:09:39 +00:00
|
|
|
import { Member } from '@overflow/commons-typescript/model/member';
|
2018-04-06 06:59:49 +00:00
|
|
|
|
|
|
|
export function reducer(state = initialState, action: Actions): State {
|
|
|
|
switch (action.type) {
|
|
|
|
case ActionType.Signup: {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
error: null,
|
|
|
|
pending: true,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
case ActionType.SignupSuccess: {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
error: null,
|
|
|
|
pending: false,
|
|
|
|
member: action.payload,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
case ActionType.SignupFailure: {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
error: action.payload,
|
|
|
|
pending: false,
|
|
|
|
member: null,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
default: {
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|