@woocommerce/data
Version:
WooCommerce Admin data store and utilities
50 lines (49 loc) • 1.28 kB
JavaScript
/**
* Internal dependencies
*/
import TYPES from './action-types';
const initialState = {
itemErrors: {},
items: {},
statErrors: {},
stats: {},
};
const reducer = (state = initialState, action) => {
switch (action.type) {
case TYPES.SET_REPORT_ITEMS:
return {
...state,
items: {
...state.items,
[]: action.items,
},
};
case TYPES.SET_REPORT_STATS:
return {
...state,
stats: {
...state.stats,
[]: action.stats,
},
};
case TYPES.SET_ITEM_ERROR:
return {
...state,
itemErrors: {
...state.itemErrors,
[]: action.error,
},
};
case TYPES.SET_STAT_ERROR:
return {
...state,
statErrors: {
...state.statErrors,
[]: action.error,
},
};
default:
return state;
}
};
export default reducer;