Add better state management utilizing Redux

This commit is contained in:
Daniel Dudzic 2024-09-10 12:03:50 +02:00
parent db449b5d70
commit bccfe4c436
No known key found for this signature in database
GPG key ID: 31B40D33E3465483
11 changed files with 432 additions and 172 deletions

View file

@ -1,13 +1,18 @@
import { useEffect, useCallback } from '@wordpress/element';
import { useSelect } from '@wordpress/data';
import { CreditCard } from './CreditCard';
import { STORE_NAME } from '../stores/axoStore';
export const Payment = ( {
fastlaneSdk,
card,
shippingAddress,
isGuest,
onPaymentLoad,
} ) => {
const isGuest = useSelect( ( select ) =>
select( STORE_NAME ).getIsGuest()
);
// Memoized Fastlane card rendering
const loadPaymentComponent = useCallback( async () => {
if ( isGuest ) {
@ -31,6 +36,7 @@ export const Payment = ( {
card={ card }
shippingAddress={ shippingAddress }
fastlaneSdk={ fastlaneSdk }
showWatermark={ ! isGuest }
/>
);
};