@@ -77,13 +77,13 @@ export const updatePart = async ({ id, input }) => {
|
|||||||
}
|
}
|
||||||
const originalPart = await db.part.findUnique({ where: { id } })
|
const originalPart = await db.part.findUnique({ where: { id } })
|
||||||
const imageToDestroy =
|
const imageToDestroy =
|
||||||
originalPart.mainImage !== input.mainImage && originalPart.mainImage
|
originalPart.mainImage !== input.mainImage && input.mainImage && originalPart.mainImage
|
||||||
const update = await db.part.update({
|
const update = await db.part.update({
|
||||||
data: foreignKeyReplacement(input),
|
data: foreignKeyReplacement(input),
|
||||||
where: { id },
|
where: { id },
|
||||||
})
|
})
|
||||||
if (imageToDestroy) {
|
if (imageToDestroy) {
|
||||||
console.log(`image destroyed, publicId: ${imageToDestroy}, partId: ${id}`)
|
console.log(`image destroyed, publicId: ${imageToDestroy}, partId: ${id}, replacing image is ${input.mainImage}`)
|
||||||
// destroy after the db has been updated
|
// destroy after the db has been updated
|
||||||
destroyImage({ publicId: imageToDestroy })
|
destroyImage({ publicId: imageToDestroy })
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ const SmallLoadingPing = (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const BigLoadingPing = () => (
|
const BigLoadingPing = () => (
|
||||||
<div className="inset-0 absolute flex items-center justify-center">
|
<div className="inset-0 absolute flex items-center justify-center bg-ch-gray-800">
|
||||||
<div className="h-16 w-16 bg-pink-600 rounded-full animate-ping"></div>
|
<div className="h-16 w-16 bg-pink-600 rounded-full animate-ping"></div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user