44 lines
713 B
TypeScript
Raw Normal View History

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