Axo Block: Improve code comments and fix minor misc bugs

This commit is contained in:
Daniel Dudzic 2024-10-03 14:09:12 +02:00
parent 1f3034136e
commit 2436ceb487
No known key found for this signature in database
GPG key ID: 31B40D33E3465483
29 changed files with 449 additions and 39 deletions

View file

@ -1,5 +1,13 @@
import { useEffect, useCallback } from '@wordpress/element';
/**
* Custom hook to handle payment setup effects in the checkout flow.
*
* @param {Function} onPaymentSetup - Function to subscribe to payment setup events.
* @param {Function} handlePaymentSetup - Callback to process payment setup.
* @param {Function} setPaymentComponent - Function to update the payment component state.
* @return {Object} Object containing the handlePaymentLoad function.
*/
const usePaymentSetupEffect = (
onPaymentSetup,
handlePaymentSetup,
@ -17,6 +25,11 @@ const usePaymentSetupEffect = (
};
}, [ onPaymentSetup, handlePaymentSetup ] );
/**
* Callback function to handle payment component loading.
*
* @param {Object} component - The loaded payment component.
*/
const handlePaymentLoad = useCallback(
( component ) => {
setPaymentComponent( component );