Skip to content

Commit b0c6d31

Browse files
(SP:1) [SHOP] finalize review fixes for ProductForm photo errors and PDP data flow
1 parent 6ac709d commit b0c6d31

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

frontend/app/[locale]/admin/shop/products/_components/ProductForm.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -674,13 +674,22 @@ export function ProductForm({
674674
setSlugError('This slug is already used. Try changing the title.');
675675
}
676676

677+
const photoErrorFields = new Set([
678+
'image',
679+
'photos',
680+
'photoPlan',
681+
'newImages',
682+
'newImageUploadIds',
683+
]);
684+
677685
if (
686+
(typeof data.field === 'string' &&
687+
photoErrorFields.has(data.field)) ||
678688
data.code === 'IMAGE_UPLOAD_FAILED' ||
679-
data.code === 'IMAGE_REQUIRED' ||
680-
data.field === 'image' ||
681-
data.field === 'photos'
689+
data.code === 'IMAGE_REQUIRED'
682690
) {
683691
setImageError(data.error ?? 'Failed to update product photos');
692+
return;
684693
}
685694

686695
if (data.code === 'SALE_ORIGINAL_REQUIRED') {
@@ -698,6 +707,7 @@ export function ProductForm({
698707
setError(data.error ?? msg);
699708
return;
700709
}
710+
701711
if (
702712
response.status === 403 &&
703713
(data.code === 'CSRF_MISSING' || data.code === 'CSRF_INVALID')

0 commit comments

Comments
 (0)