woocommerce-paypal-payments/modules/ppcp-settings/resources/js/Components/Screens/Overview/TabPayLaterMessaging.js
Emili Castells Guasch a652f21629 Read config from store
2025-01-30 10:50:44 +01:00

51 lines
1.5 KiB
JavaScript

import React, { useEffect } from 'react';
import { PayLaterMessagingHooks } from '../../../data';
const TabPayLaterMessaging = () => {
const { config } = PayLaterMessagingHooks.usePayLaterMessaging();
const PcpPayLaterConfigurator =
window.ppcpSettings?.PcpPayLaterConfigurator;
useEffect( () => {
if ( window.merchantConfigurators && PcpPayLaterConfigurator ) {
window.merchantConfigurators.Messaging( {
config,
merchantClientId: PcpPayLaterConfigurator.merchantClientId,
partnerClientId: PcpPayLaterConfigurator.partnerClientId,
partnerName: 'WooCommerce',
bnCode: PcpPayLaterConfigurator.bnCode,
placements: [
'cart',
'checkout',
'product',
'shop',
'home',
'custom_placement',
],
styleOverrides: {
button: 'ppcp-r-paylater-configurator__publish-button',
header: 'ppcp-r-paylater-configurator__header',
subheader: 'ppcp-r-paylater-configurator__subheader',
},
onSave: ( data ) => {
/*
TODO:
- The saving will be handled in a separate PR.
- One option could be:
- When saving the settings, programmatically click on the configurator's
"Save Changes" button and send the request to PHP.
*/
},
} );
}
}, [ PcpPayLaterConfigurator, config ] );
return (
<div
id="messaging-configurator"
className="ppcp-r-paylater-configurator"
></div>
);
};
export default TabPayLaterMessaging;