Merge pull request #681 from sharetribe/fix-editlisting

Fix: Images should not be included if they are undefined
This commit is contained in:
Vesa Luusua 2018-01-31 16:45:20 +02:00 committed by GitHub
commit 5532659506
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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 });
}
};