Initial Axo Blocks commit

This commit is contained in:
Daniel Dudzic 2024-09-05 21:17:36 +02:00
parent 796ded031e
commit ebd87b70e9
No known key found for this signature in database
GPG key ID: 31B40D33E3465483
27 changed files with 43827 additions and 1 deletions

View file

@ -0,0 +1,39 @@
export const snapshotFields = ( shippingAddress, billingAddress ) => {
if ( ! shippingAddress || ! billingAddress ) {
console.warn( 'Shipping or billing address is missing:', {
shippingAddress,
billingAddress,
} );
}
const originalData = { shippingAddress, billingAddress };
console.log( 'Snapshot data:', originalData ); // Debug data
localStorage.setItem(
'originalCheckoutFields',
JSON.stringify( originalData )
);
console.log( 'Original fields saved to localStorage', originalData );
};
export const restoreOriginalFields = (
updateShippingAddress,
updateBillingAddress
) => {
const savedData = localStorage.getItem( 'originalCheckoutFields' );
console.log( 'Data retrieved from localStorage:', savedData );
if ( savedData ) {
const parsedData = JSON.parse( savedData );
if ( parsedData.shippingAddress ) {
updateShippingAddress( parsedData.shippingAddress );
}
if ( parsedData.billingAddress ) {
updateBillingAddress( parsedData.billingAddress );
}
console.log( 'Original fields restored from localStorage', parsedData );
} else {
console.warn(
'No data found in localStorage under originalCheckoutFields'
);
}
};