Skip to content

Commit a652f21

Browse files
committed
Read config from store
1 parent 855aa9c commit a652f21

File tree

4 files changed

+32
-4
lines changed

4 files changed

+32
-4
lines changed

modules/ppcp-paylater-configurator/resources/js/paylater-configurator.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ document.addEventListener( 'DOMContentLoaded', () => {
5151
.then( ( data ) => {
5252
if ( data.success ) {
5353
const config = data.data;
54+
console.log( config );
5455

5556
merchantConfigurators.Messaging( {
5657
config,

modules/ppcp-settings/resources/js/Components/Screens/Overview/TabPayLaterMessaging.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import React, { useEffect } from 'react';
2+
import { PayLaterMessagingHooks } from '../../../data';
23

34
const TabPayLaterMessaging = () => {
4-
const config = {}; // Replace with the appropriate/saved configuration.
5+
const { config } = PayLaterMessagingHooks.usePayLaterMessaging();
56
const PcpPayLaterConfigurator =
67
window.ppcpSettings?.PcpPayLaterConfigurator;
78

@@ -37,7 +38,7 @@ const TabPayLaterMessaging = () => {
3738
},
3839
} );
3940
}
40-
}, [ PcpPayLaterConfigurator ] );
41+
}, [ PcpPayLaterConfigurator, config ] );
4142

4243
return (
4344
<div

modules/ppcp-settings/resources/js/data/pay-later-messaging/hooks.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,24 @@ const useHooks = () => {
2626
// TODO: Replace with real property.
2727
const [ sampleValue, setSampleValue ] = usePersistent( 'sampleValue' );
2828

29+
const [ cart ] = usePersistent( 'cart' );
30+
const [ checkout ] = usePersistent( 'checkout' );
31+
const [ product ] = usePersistent( 'product' );
32+
const [ shop ] = usePersistent( 'shop' );
33+
const [ home ] = usePersistent( 'home' );
34+
const [ custom_placement ] = usePersistent( 'custom_placement' );
35+
2936
return {
3037
persist,
3138
isReady,
3239
sampleValue,
3340
setSampleValue,
41+
cart,
42+
checkout,
43+
product,
44+
shop,
45+
home,
46+
custom_placement,
3447
};
3548
};
3649

@@ -48,3 +61,18 @@ export const useSampleValue = () => {
4861
setSampleValue,
4962
};
5063
};
64+
65+
export const usePayLaterMessaging = () => {
66+
const { cart, checkout, product, shop, home, customPlacement } = useHooks();
67+
68+
return {
69+
config: {
70+
cart,
71+
checkout,
72+
product,
73+
shop,
74+
home,
75+
customPlacement,
76+
},
77+
};
78+
};

modules/ppcp-settings/resources/js/data/pay-later-messaging/resolvers.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ export const resolvers = {
2222
try {
2323
const result = yield apiFetch( { path: REST_HYDRATE_PATH } );
2424

25-
console.log( result );
26-
2725
yield dispatch( STORE_NAME ).hydrate( result );
2826
yield dispatch( STORE_NAME ).setIsReady( true );
2927
} catch ( e ) {

0 commit comments

Comments
 (0)