@woocommerce/data
Version:
WooCommerce Admin data store and utilities
65 lines (64 loc) • 1.89 kB
JavaScript
/**
* External dependencies
*/
/**
* Internal dependencies
*/
import TYPES from './action-types';
import { hashExportArgs } from './utils';
const reducer = (state = {
errors: {},
requesting: {},
exportMeta: {},
exportIds: {},
}, action) => {
switch (action.type) {
case TYPES.SET_IS_REQUESTING:
return {
...state,
requesting: {
...state.requesting,
[]: {
...state.requesting[action.selector],
[]: action.isRequesting,
},
},
};
case TYPES.SET_EXPORT_ID:
const { exportType, exportArgs, exportId } = action;
return {
...state,
exportMeta: {
...state.exportMeta,
[]: {
exportType,
exportArgs,
},
},
exportIds: {
...state.exportIds,
[]: {
...state.exportIds[exportType],
[]: exportId,
},
},
};
case TYPES.SET_ERROR:
return {
...state,
errors: {
...state.errors,
[]: {
...state.errors[action.selector],
[]: action.error,
},
},
};
default:
return state;
}
};
export default reducer;