member_webapp/@overflow/target/store/modify/modify.reducer.ts

44 lines
713 B
TypeScript
Raw Normal View History

2018-04-06 11:02:18 +00:00
import {
2018-05-02 08:25:38 +00:00
Actions,
ActionType,
} from './modify.action';
2018-04-06 11:02:18 +00:00
2018-05-02 08:25:38 +00:00
import {
State,
initialState,
} from './modify.state';
2018-04-06 11:02:18 +00:00
2018-05-02 08:25:38 +00:00
export function reducer(state = initialState, action: Actions): State {
switch (action.type) {
case ActionType.Modify: {
return {
...state,
error: null,
pending: true,
};
}
2018-04-06 11:02:18 +00:00
2018-05-02 08:25:38 +00:00
case ActionType.ModifySuccess: {
return {
...state,
error: null,
pending: false,
target: action.payload
};
}
2018-04-06 11:02:18 +00:00
2018-05-02 08:25:38 +00:00
case ActionType.ModifyFailure: {
return {
...state,
error: action.payload,
pending: false,
target: null,
};
}
2018-04-06 11:02:18 +00:00
2018-05-02 08:25:38 +00:00
default: {
return state;
2018-04-06 11:02:18 +00:00
}
}
2018-05-02 08:25:38 +00:00
}