👔 Introduce new props in the Redux store

This commit is contained in:
Philipp Stracker 2024-10-30 16:56:42 +01:00
parent 49c24f56d0
commit 6a30bb01b3
No known key found for this signature in database
3 changed files with 36 additions and 0 deletions

View file

@ -13,4 +13,6 @@ export default {
SET_MANUAL_CONNECTION_MODE: 'SET_MANUAL_CONNECTION_MODE', SET_MANUAL_CONNECTION_MODE: 'SET_MANUAL_CONNECTION_MODE',
SET_CLIENT_ID: 'SET_CLIENT_ID', SET_CLIENT_ID: 'SET_CLIENT_ID',
SET_CLIENT_SECRET: 'SET_CLIENT_SECRET', SET_CLIENT_SECRET: 'SET_CLIENT_SECRET',
SET_IS_CASUAL_SELLER: 'SET_IS_CASUAL_SELLER',
SET_PRODUCTS: 'SET_PRODUCTS',
}; };

View file

@ -129,6 +129,32 @@ export const setClientSecret = ( clientSecret ) => {
}; };
}; };
/**
* Persistent. Sets the "isCasualSeller" value.
*
* @param {boolean} isCasualSeller
* @return {{type: string, isCasualSeller}} The action.
*/
export const setIsCasualSeller = ( isCasualSeller ) => {
return {
type: ACTION_TYPES.SET_IS_CASUAL_SELLER,
isCasualSeller,
};
};
/**
* Persistent. Sets the "products" array.
*
* @param {string[]} products
* @return {{type: string, products}} The action.
*/
export const setProducts = ( products ) => {
return {
type: ACTION_TYPES.SET_PRODUCTS,
products,
};
};
/** /**
* Saves the persistent details to the WP database. * Saves the persistent details to the WP database.
* *

View file

@ -12,6 +12,8 @@ const defaultState = {
useManualConnection: false, useManualConnection: false,
clientId: '', clientId: '',
clientSecret: '', clientSecret: '',
isCasualSeller: null, // null value will uncheck both options in the UI.
products: [],
}, },
// Read only values, provided by the server. // Read only values, provided by the server.
@ -87,6 +89,12 @@ export const onboardingReducer = (
useManualConnection: action.useManualConnection, useManualConnection: action.useManualConnection,
} ); } );
case ACTION_TYPES.SET_IS_CASUAL_SELLER:
return setPersistent( { isCasualSeller: action.isCasualSeller } );
case ACTION_TYPES.SET_PRODUCTS:
return setPersistent( { products: action.products } );
default: default:
return state; return state;
} }