woocommerce/plugins/woocommerce-admin/client/store/taxes/reducer.js

33 lines
578 B
JavaScript

/** @format */
/**
* External dependencies
*/
import { merge } from 'lodash';
/**
* Internal dependencies
*/
import { ERROR } from 'store/constants';
import { getJsonString } from 'store/utils';
const DEFAULT_STATE = {};
export default function taxesReducer( state = DEFAULT_STATE, action ) {
const queryKey = getJsonString( action.query );
switch ( action.type ) {
case 'SET_TAXES':
return merge( {}, state, {
[ queryKey ]: action.taxes,
} );
case 'SET_TAXES_ERROR':
return merge( {}, state, {
[ queryKey ]: ERROR,
} );
}
return state;
}