Fix CYS updateStorePatters to use the new images endpoint structure (#43285)
* Return the correct empty images response * Use the correct structure in the images endpoint response * Add changefile(s) from automation for the following project(s): woocommerce * Throw error when no images and the store is already ai generated --------- Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
parent
6099718727
commit
5752bd7a9f
|
@ -238,7 +238,7 @@ export const updateStorePatterns = async (
|
||||||
|
|
||||||
const { images } = await apiFetch< {
|
const { images } = await apiFetch< {
|
||||||
ai_content_generated: boolean;
|
ai_content_generated: boolean;
|
||||||
images: Array< unknown >;
|
images: { images: Array< unknown >; search_term: string };
|
||||||
} >( {
|
} >( {
|
||||||
path: '/wc/private/ai/images',
|
path: '/wc/private/ai/images',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
@ -248,7 +248,20 @@ export const updateStorePatterns = async (
|
||||||
},
|
},
|
||||||
} );
|
} );
|
||||||
|
|
||||||
if ( ! images.length ) {
|
const { is_ai_generated } = await apiFetch< {
|
||||||
|
is_ai_generated: boolean;
|
||||||
|
} >( {
|
||||||
|
path: '/wc/private/ai/store-info',
|
||||||
|
method: 'GET',
|
||||||
|
} );
|
||||||
|
|
||||||
|
if ( ! images.images.length ) {
|
||||||
|
if ( is_ai_generated ) {
|
||||||
|
throw new Error(
|
||||||
|
'AI content not generated: images not available'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
await resetPatternsAndProducts()();
|
await resetPatternsAndProducts()();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: minor
|
||||||
|
Type: fix
|
||||||
|
|
||||||
|
Use the new AI images endpoint response structure.
|
|
@ -102,7 +102,10 @@ class Images extends AbstractRoute {
|
||||||
$images = ( new Pexels() )->get_images( $ai_connection, $token, $business_description );
|
$images = ( new Pexels() )->get_images( $ai_connection, $token, $business_description );
|
||||||
|
|
||||||
if ( is_wp_error( $images ) ) {
|
if ( is_wp_error( $images ) ) {
|
||||||
$images = [];
|
$images = array(
|
||||||
|
'images' => array(),
|
||||||
|
'search_term' => '',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return rest_ensure_response(
|
return rest_ensure_response(
|
||||||
|
|
Loading…
Reference in New Issue