Updating messages, cleanup

This commit is contained in:
inpsyde-maticluznar 2024-12-20 09:58:15 +01:00
parent 80853c6fd4
commit f4b1a6e392
No known key found for this signature in database
GPG key ID: D005973F231309F6
3 changed files with 20 additions and 19 deletions

View file

@ -19,6 +19,7 @@ const ResubscribeBlock = () => {
} catch ( error ) { } catch ( error ) {
setResubscribing( false ); setResubscribing( false );
createErrorNotice( createErrorNotice(
'❌ ' +
__( __(
'Operation failed. Check WooCommerce logs for more details.', 'Operation failed. Check WooCommerce logs for more details.',
'woocommerce-paypal-payments' 'woocommerce-paypal-payments'
@ -29,6 +30,7 @@ const ResubscribeBlock = () => {
setResubscribing( false ); setResubscribing( false );
createSuccessNotice( createSuccessNotice(
'✔️ ' +
__( __(
'Webhooks were successfully re-subscribed.', 'Webhooks were successfully re-subscribed.',
'woocommerce-paypal-payments' 'woocommerce-paypal-payments'

View file

@ -7,7 +7,7 @@ import { useDispatch } from '@wordpress/data';
import { store as noticesStore } from '@wordpress/notices'; import { store as noticesStore } from '@wordpress/notices';
const SimulationBlock = () => { const SimulationBlock = () => {
const { createSuccessNotice, createErrorNotice } = const { createSuccessNotice, createInfoNotice, createErrorNotice } =
useDispatch( noticesStore ); useDispatch( noticesStore );
const [ simulating, setSimulating ] = useState( false ); const [ simulating, setSimulating ] = useState( false );
@ -29,13 +29,10 @@ const SimulationBlock = () => {
} ); } );
}, [] ); }, [] );
const startSimulation = async () => { const startSimulation = async ( retriesBeforeErrorMessage, maxRetries ) => {
const retriesBeforeErrorMessage = 15;
const maxRetries = 30;
setSimulating( true ); setSimulating( true );
createSuccessNotice( createInfoNotice(
__( __(
'Waiting for the webhook to arrive…', 'Waiting for the webhook to arrive…',
'woocommerce-paypal-payments' 'woocommerce-paypal-payments'
@ -48,6 +45,7 @@ const SimulationBlock = () => {
setSimulating( false ); setSimulating( false );
createErrorNotice( createErrorNotice(
__( __(
'❌ ' +
'Operation failed. Check WooCommerce logs for more details.', 'Operation failed. Check WooCommerce logs for more details.',
'woocommerce-paypal-payments' 'woocommerce-paypal-payments'
) )
@ -87,6 +85,7 @@ const SimulationBlock = () => {
if ( i === retriesBeforeErrorMessage ) { if ( i === retriesBeforeErrorMessage ) {
createErrorNotice( createErrorNotice(
__( __(
'❌ ' +
'Looks like the webhook cannot be received. Check that your website is accessible from the internet.', 'Looks like the webhook cannot be received. Check that your website is accessible from the internet.',
'woocommerce-paypal-payments' 'woocommerce-paypal-payments'
) )
@ -107,7 +106,7 @@ const SimulationBlock = () => {
actionProps={ { actionProps={ {
buttonType: 'secondary', buttonType: 'secondary',
isBusy: simulating, isBusy: simulating,
callback: () => startSimulation(), callback: () => startSimulation( 15, 30 ),
value: __( value: __(
'Simulate webhooks', 'Simulate webhooks',
'woocommerce-paypal-payments' 'woocommerce-paypal-payments'

View file

@ -87,9 +87,9 @@ const commonReducer = createReducer( defaultTransient, defaultPersistent, {
[ ACTION_TYPES.HYDRATE ]: ( state, payload ) => { [ ACTION_TYPES.HYDRATE ]: ( state, payload ) => {
const newState = setPersistent( state, payload.data ); const newState = setPersistent( state, payload.data );
console.log( state, payload );
// Populate read-only properties. // Populate read-only properties.
[ 'wooSettings', 'merchant', 'webhooks' ].forEach( ( key ) => { [ 'wooSettings', 'merchant' ].forEach( ( key ) => {
if ( ! payload[ key ] ) { if ( ! payload[ key ] ) {
return; return;
} }