UNPKG

@woocommerce/data

Version:
47 lines (46 loc) 1.38 kB
"use strict"; /** * External dependencies */ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); /** * Internal dependencies */ const action_types_1 = __importDefault(require("./action-types")); const optionsReducer = (state = { isUpdating: false, requestingErrors: {} }, action) => { switch (action.type) { case action_types_1.default.RECEIVE_OPTIONS: state = { ...state, ...action.options, }; break; case action_types_1.default.SET_IS_UPDATING: state = { ...state, isUpdating: action.isUpdating, }; break; case action_types_1.default.SET_REQUESTING_ERROR: state = { ...state, requestingErrors: { [action.name]: action.error, }, }; break; case action_types_1.default.SET_UPDATING_ERROR: state = { ...state, error: action.error, updatingError: action.error, isUpdating: false, }; break; } return state; }; exports.default = optionsReducer;