diff --git a/.changeset/eight-zoos-add.md b/.changeset/eight-zoos-add.md new file mode 100644 index 0000000000..676d40d752 --- /dev/null +++ b/.changeset/eight-zoos-add.md @@ -0,0 +1,5 @@ +--- +"@medusajs/dashboard": patch +--- + +fix(dashboard): preserve old image ids when deleting a product image diff --git a/packages/admin/dashboard/src/routes/products/product-detail/components/product-media-section/product-media-section.tsx b/packages/admin/dashboard/src/routes/products/product-detail/components/product-media-section/product-media-section.tsx index 4b12d0eb53..c3a654af70 100644 --- a/packages/admin/dashboard/src/routes/products/product-detail/components/product-media-section/product-media-section.tsx +++ b/packages/admin/dashboard/src/routes/products/product-detail/components/product-media-section/product-media-section.tsx @@ -68,7 +68,7 @@ export const ProductMediaSection = ({ product }: ProductMedisaSectionProps) => { const mediaToKeep = product.images .filter((i) => !ids.includes(i.id)) - .map((i) => ({ url: i.url })) + .map((i) => ({ id: i.id, url: i.url })) await mutateAsync( { diff --git a/packages/admin/dashboard/src/routes/products/product-media/components/product-media-gallery/product-media-gallery.tsx b/packages/admin/dashboard/src/routes/products/product-media/components/product-media-gallery/product-media-gallery.tsx index 5147dc0437..98d20dceb5 100644 --- a/packages/admin/dashboard/src/routes/products/product-media/components/product-media-gallery/product-media-gallery.tsx +++ b/packages/admin/dashboard/src/routes/products/product-media/components/product-media-gallery/product-media-gallery.tsx @@ -90,7 +90,7 @@ export const ProductMediaGallery = ({ product }: ProductMediaGalleryProps) => { const mediaToKeep = product.images ?.filter((i) => i.id !== current.id) - .map((i) => ({ url: i.url })) || [] + .map((i) => ({ id: i.id, url: i.url })) || [] if (curr === media.length - 1) { setCurr((prev) => prev - 1)