46 lines
753 B
TypeScript
46 lines
753 B
TypeScript
|
import {
|
||
|
Actions,
|
||
|
ActionType,
|
||
|
} from './signup.action';
|
||
|
|
||
|
import {
|
||
|
State,
|
||
|
initialState,
|
||
|
} from './signup.state';
|
||
|
|
||
|
import { Member } from '../../model';
|
||
|
|
||
|
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;
|
||
|
}
|
||
|
}
|
||
|
}
|