Skip to content

Commit fbc5f96

Browse files
committed
WIP hooking to backend
1 parent 6a03f87 commit fbc5f96

File tree

3 files changed

+13
-16
lines changed

3 files changed

+13
-16
lines changed

frontend/src/components/app/onboarding/MainAndSecondaryImagesUpload.vue

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,24 +42,23 @@ export default {
4242
this.bus.$emit('clearForNextImage');
4343
this.imageIndex += 1;
4444
} else {
45-
this.$emit('saveInput', this.slide.key, this.imagesUploaded);
45+
this.$emit('nextSlide');
4646
this.sendImagesToBackend();
4747
}
4848
},
4949
async sendImagesToBackend() {
50-
try {
51-
for (let i = 0; i < this.imagesUploaded.length; i += 1) {
50+
for (let i = 0; i < this.imagesUploaded.length; i += 1) {
51+
try {
5252
const formData = new FormData();
53+
formData.append('file[]', this.imagesUploaded[i].content);
5354
if (i === 0) {
54-
formData.append('ProfileImage', this.imagesUploaded[i].content);
5555
await this.$http.post('/profile/images?is_primary=true', formData);
5656
} else {
57-
formData.append('ExtraImage', this.imagesUploaded[i].content);
5857
await this.$http.post('/profile/images?is_primary=false', formData);
5958
}
59+
} catch (error) {
60+
console.log(error);
6061
}
61-
} catch (error) {
62-
console.log(error);
6362
}
6463
},
6564
},

frontend/src/plugins/http.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
/* eslint-disable prefer-arrow-callback */
22
/* eslint-disable func-names */
33
/* eslint-disable no-param-reassign */
4-
/* eslint-disable max-len */
54

65
import Axios from 'axios';
76
import Vue from 'vue';
87
import { getAccessToken, getRefreshToken, handleAccessTokenExpiration } from '../auth/tokens';
98

109
Axios.defaults.baseURL = process.env.VUE_APP_BACKEND_BASE_URL;
11-
Axios.defaults.headers.common['Access-Control-Allow-Origin'] = '*';
12-
Axios.defaults.headers.common['Access-Control-Allow-Methods'] = 'DELETE, POST, GET, OPTIONS';
13-
/* Axios.defaults.headers.common['Access-Control-Allow-Headers'] = 'Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With'; */
10+
Axios.defaults.headers.common['Content-Type'] = 'application/json';
11+
Axios.defaults.headers.common.Accept = 'application/json';
1412

1513
Axios.interceptors.request.use(async function (config) {
1614
if (config.url === '/auth/refresh' || config.url === '/auth/refresh_revoke') {
@@ -25,6 +23,9 @@ Axios.interceptors.request.use(async function (config) {
2523
return { headers: {}, method: config.method, url: '' };
2624
}
2725
}
26+
if (config.url.search('/profile/images') !== -1) {
27+
config.headers['Content-Type'] = 'multipart/form-data';
28+
}
2829
return config;
2930
}, function (error) {
3031
return Promise.reject(error);

frontend/src/views/app/Onboarding.vue

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
secondaryImageExplanation: 'Extra image',
6868
maxImagesAllowed: 5,
6969
buttonText}"
70-
v-on:saveInput="saveInput"
70+
v-on:nextSlide="nextSlide"
7171
v-if="slideCurrent === 5"></MainAndSecondaryImagesUpload>
7272
<Textblock
7373
v-bind:slide="{
@@ -110,10 +110,7 @@ export default {
110110
if (key === 'birthdate') {
111111
value = this.formatBirthdate(value);
112112
}
113-
if (key !== 'images') {
114-
this.userData[key] = value;
115-
}
116-
console.log(this.userData);
113+
this.userData[key] = value;
117114
this.nextSlide();
118115
},
119116
nextSlide() {

0 commit comments

Comments
 (0)