Merge branch 'trunk' of github.com:woocommerce/woocommerce-paypal-payments into PCP-3770-fastlane-implement-insights-sdk-for-block-checkout-ver2

This commit is contained in:
Daniel Dudzic 2024-11-19 11:23:08 +01:00
commit d84f29a274
No known key found for this signature in database
GPG key ID: 31B40D33E3465483
111 changed files with 5597 additions and 2508 deletions

View file

@ -12,6 +12,7 @@ const DEFAULT_STATE = {
shippingAddress: null,
cardDetails: null,
phoneNumber: '',
cardChangeHandler: null,
};
// Action creators for updating the store state
@ -52,6 +53,10 @@ const actions = {
type: 'SET_PHONE_NUMBER',
payload: phoneNumber,
} ),
setCardChangeHandler: ( cardChangeHandler ) => ( {
type: 'SET_CARD_CHANGE_HANDLER',
payload: cardChangeHandler,
} ),
};
/**
@ -81,6 +86,8 @@ const reducer = ( state = DEFAULT_STATE, action ) => {
return { ...state, cardDetails: action.payload };
case 'SET_PHONE_NUMBER':
return { ...state, phoneNumber: action.payload };
case 'SET_CARD_CHANGE_HANDLER':
return { ...state, cardChangeHandler: action.payload };
default:
return state;
}
@ -97,6 +104,7 @@ const selectors = {
getShippingAddress: ( state ) => state.shippingAddress,
getCardDetails: ( state ) => state.cardDetails,
getPhoneNumber: ( state ) => state.phoneNumber,
getCardChangeHandler: ( state ) => state.cardChangeHandler,
};
// Create and register the Redux store for the AXO block
@ -165,3 +173,12 @@ export const setCardDetails = ( cardDetails ) => {
export const setPhoneNumber = ( phoneNumber ) => {
dispatch( STORE_NAME ).setPhoneNumber( phoneNumber );
};
/**
* Action dispatcher to update the card change handler in the store.
*
* @param {Function} cardChangeHandler - The card change handler function.
*/
export const setCardChangeHandler = ( cardChangeHandler ) => {
dispatch( STORE_NAME ).setCardChangeHandler( cardChangeHandler );
};