member_webapp/src/packages/target/store/modify/modify.reducer.ts

46 lines
828 B
TypeScript
Raw Normal View History

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