Skip to content

Commit

Permalink
Merge pull request #223 from helsingborg-stad/fix/events-not-getting-…
Browse files Browse the repository at this point in the history
…images

Fix: Events not getting images
  • Loading branch information
NiclasNorin committed Sep 29, 2023
2 parents 97ef287 + 1839a7c commit b518637
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions source/js/front/form-submit.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ const eventFormSubmit = {
const formData = eventFormSubmit.formToJsonData(form);

const imageData = new FormData();
let image = false;
imageData.append('file', imageInput.files[0]);

const formRequests = [];
if (imageInput.files[0]) {
image = eventFormSubmit.submitImageData(imageData);
formRequests.push(eventFormSubmit.submitImageData(imageData));
} else {
formRequests.push(null);
}

const formUserGroups = formData.user_groups.join(',');
Expand Down Expand Up @@ -68,9 +69,9 @@ const eventFormSubmit = {
}

Promise.all(formRequests)
.then(([organizerResponse, locationResponse]) => {
if (image) {
formData['featured_media'] = image.data;
.then(([imageResponse, organizerResponse, locationResponse]) => {
if (imageResponse?.success) {
formData['featured_media'] = imageResponse.data;
}

if (organizerResponse?.success) {
Expand Down

0 comments on commit b518637

Please sign in to comment.