diff --git a/plugins/woocommerce-admin/client/customize-store/design-with-ai/services.ts b/plugins/woocommerce-admin/client/customize-store/design-with-ai/services.ts index b2b2c1d0b22..a069943a4c1 100644 --- a/plugins/woocommerce-admin/client/customize-store/design-with-ai/services.ts +++ b/plugins/woocommerce-admin/client/customize-store/design-with-ai/services.ts @@ -473,15 +473,21 @@ const saveAiResponseToOption = ( context: designWithAiStateMachineContext ) => { } ); }; -const resetPatterns = () => async () => { +const resetPatternsAndProducts = () => async () => { await dispatch( OPTIONS_STORE_NAME ).updateOptions( { woocommerce_blocks_allow_ai_connection: 'yes', } ); - return await apiFetch( { - path: '/wc/private/ai/patterns', - method: 'DELETE', - } ); + return Promise.all( [ + apiFetch( { + path: '/wc/private/ai/patterns', + method: 'DELETE', + } ), + apiFetch( { + path: '/wc/private/ai/products', + method: 'DELETE', + } ), + ] ); }; export const services = { @@ -491,5 +497,5 @@ export const services = { updateStorePatterns, saveAiResponseToOption, installAndActivateTheme, - resetPatterns, + resetPatternsAndProducts, }; diff --git a/plugins/woocommerce-admin/client/customize-store/design-with-ai/state-machine.tsx b/plugins/woocommerce-admin/client/customize-store/design-with-ai/state-machine.tsx index e79cd41bd58..5391f132886 100644 --- a/plugins/woocommerce-admin/client/customize-store/design-with-ai/state-machine.tsx +++ b/plugins/woocommerce-admin/client/customize-store/design-with-ai/state-machine.tsx @@ -355,7 +355,7 @@ export const designWithAiStateMachineDefinition = createMachine( cond: 'isAiOnline', }, { - target: 'resetPatterns', + target: 'resetPatternsAndProducts', }, ], }, @@ -373,9 +373,9 @@ export const designWithAiStateMachineDefinition = createMachine( }, }, }, - resetPatterns: { + resetPatternsAndProducts: { invoke: { - src: 'resetPatterns', + src: 'resetPatternsAndProducts', onDone: { target: 'success', }, diff --git a/plugins/woocommerce/changelog/41923-41921-cys-ai-offline-flow-reset-products b/plugins/woocommerce/changelog/41923-41921-cys-ai-offline-flow-reset-products new file mode 100644 index 00000000000..a7bda9153ac --- /dev/null +++ b/plugins/woocommerce/changelog/41923-41921-cys-ai-offline-flow-reset-products @@ -0,0 +1,4 @@ +Significance: minor +Type: update + +CYS: Reset products when the AI is offline. \ No newline at end of file