network-resurrector-frontend/src/state/reducer.js

34 lines
837 B
JavaScript
Raw Normal View History

2020-12-19 03:38:04 +02:00
export function reducer(state, action) {
switch (action.type) {
case "OnPagerChange": {
return {
...state,
pager: {
...state.pager,
...action.payload
}
};
}
case "OnExportRequest": {
return {
...state,
export: action.value
};
}
default: {
return state;
}
}
}
export const dispatchActions = dispatch => ({
onFilterPropertyValueChange: (prop, value) =>
dispatch({ type: "OnFilterPropertyValueChange", payload: { prop, value } }),
onPagerChange: pager =>
dispatch({ type: "OnPagerChange", payload: { ...pager } }),
onSetCachedFilters: cachedFilters =>
dispatch({ type: "OnSetCachedFilters", payload: cachedFilters }),
onExportRequest: value => dispatch({ type: "OnExportRequest", value: value })
});