Fix tax task showing as not completed after setting up tax (#36468)

* Wait for requests to finish before redirecting

* Add changelog
This commit is contained in:
Chi-Hsuan Huang 2023-01-19 13:01:31 +08:00 committed by GitHub
parent c71573d7f9
commit 025c6aab17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 13 deletions

View File

@ -92,20 +92,34 @@ const Tax: React.FC< TaxProps > = ( { onComplete, query, task } ) => {
} }
}, [] ); }, [] );
const onAutomate = useCallback( () => { const onAutomate = useCallback( async () => {
setIsPending( true ); setIsPending( true );
updateAndPersistSettingsForGroup( 'tax', { try {
tax: { await Promise.all( [
...taxSettings, updateAndPersistSettingsForGroup( 'tax', {
wc_connect_taxes_enabled: 'yes', tax: {
}, ...taxSettings,
} ); wc_connect_taxes_enabled: 'yes',
updateAndPersistSettingsForGroup( 'general', { },
general: { } ),
...generalSettings, updateAndPersistSettingsForGroup( 'general', {
woocommerce_calc_taxes: 'yes', general: {
}, ...generalSettings,
} ); woocommerce_calc_taxes: 'yes',
},
} ),
] );
} catch ( error: unknown ) {
setIsPending( false );
createNotice(
'error',
__(
'There was a problem setting up automated taxes. Please try again.',
'woocommerce'
)
);
return;
}
createNotice( createNotice(
'success', 'success',

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
Fix tax task showing as not completed after setting up tax