From 4ae61dfb584b78c622683ee439bdb007cec34515 Mon Sep 17 00:00:00 2001
From: Philipp Stracker
Date: Wed, 20 Nov 2024 16:32:07 +0100
Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20incorrect=20param=20name?=
=?UTF-8?q?=20in=20reducer=20utils?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
modules/ppcp-settings/resources/js/data/utils.js | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/modules/ppcp-settings/resources/js/data/utils.js b/modules/ppcp-settings/resources/js/data/utils.js
index 2cec07815..45c652862 100644
--- a/modules/ppcp-settings/resources/js/data/utils.js
+++ b/modules/ppcp-settings/resources/js/data/utils.js
@@ -30,10 +30,10 @@ const updateObject = ( oldObject, newValues, allowedKeys = {} ) => ( {
* @return {[Function, Function]} An array containing setTransient and setPersistent functions.
*/
export const createSetters = ( defaultTransient, defaultPersistent ) => {
- const setTransient = ( oldState, newValues ) =>
+ const setTransient = ( oldState, newValues = {} ) =>
updateObject( oldState, newValues, defaultTransient );
- const setPersistent = ( oldState, newValues ) => ( {
+ const setPersistent = ( oldState, newValues = {} ) => ( {
...oldState,
data: updateObject( oldState.data, newValues, defaultPersistent ),
} );
@@ -67,7 +67,7 @@ export const createReducer = (
return function reducer( state = initialState, action ) {
if ( Object.hasOwnProperty.call( handlers, action.type ) ) {
- return handlers[ action.type ]( state, action.data );
+ return handlers[ action.type ]( state, action.payload ?? {} );
}
return state;