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,20 +19,22 @@ const ResubscribeBlock = () => {
} catch ( error ) {
setResubscribing( false );
createErrorNotice(
__(
'Operation failed. Check WooCommerce logs for more details.',
'woocommerce-paypal-payments'
)
'❌ ' +
__(
'Operation failed. Check WooCommerce logs for more details.',
'woocommerce-paypal-payments'
)
);
return;
}
setResubscribing( false );
createSuccessNotice(
__(
'Webhooks were successfully re-subscribed.',
'woocommerce-paypal-payments'
)
'✔️ ' +
__(
'Webhooks were successfully re-subscribed.',
'woocommerce-paypal-payments'
)
);
};

View file

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

View file

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