Further separate code into hooks: useAxoCleanup, useAxoSetup, usePayPalScript and usePaymentSetup. Hide Shipping and Billing details on load.

This commit is contained in:
Daniel Dudzic 2024-09-13 19:24:23 +02:00
parent 90aa261c8b
commit 4bda191f0e
No known key found for this signature in database
GPG key ID: 31B40D33E3465483
13 changed files with 282 additions and 165 deletions

View file

@ -1,7 +1,7 @@
import { populateWooFields } from '../helpers/fieldHelpers';
import { injectShippingChangeButton } from '../components/Shipping';
import { injectCardChangeButton } from '../components/Card';
import { setIsGuest } from '../stores/axoStore';
import { setIsGuest, setIsEmailLookupCompleted } from '../stores/axoStore';
export const createEmailLookupHandler = (
fastlaneSdk,
@ -34,6 +34,11 @@ export const createEmailLookupHandler = (
console.log( 'Lookup response:', lookup );
// Gary flow
if ( lookup && lookup.customerContextId === '' ) {
setIsEmailLookupCompleted( true );
}
if ( ! lookup || ! lookup.customerContextId ) {
console.warn( 'No customerContextId found in the response' );
return;
@ -50,9 +55,13 @@ export const createEmailLookupHandler = (
const { authenticationState, profileData } = authResponse;
// OTP success/fail/cancel flow
if ( authResponse ) {
setIsEmailLookupCompleted( true );
}
if ( authenticationState === 'succeeded' ) {
snapshotFields( wooShippingAddress, wooBillingAddress );
setIsGuest( false );
if ( profileData && profileData.shippingAddress ) {