Images should not be included if they are undefined

This commit is contained in:
Vesa Luusua 2018-01-31 16:35:31 +02:00
parent d6707b7f1d
commit f25d4e89c7

View file

@ -85,9 +85,11 @@ const EditListingWizardTab = props => {
handleCreateListing({ ...listing.attributes, images: imageIdArray });
}
} else {
const { images: updatedImages, ...rest } = updateValues;
// Normalize images for API call
const imageIdArray = imageIds(updateValues.images);
onUpdateListing(tab, { ...updateValues, id: currentListing.id, images: imageIdArray });
const imageProperty =
typeof updatedImages !== 'undefined' ? { images: imageIds(updatedImages) } : {};
onUpdateListing(tab, { ...rest, id: currentListing.id, ...imageProperty });
}
};