Skip to content

Commit 6a03f87

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

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,23 @@ export default {
4343
this.imageIndex += 1;
4444
} else {
4545
this.$emit('saveInput', this.slide.key, this.imagesUploaded);
46+
this.sendImagesToBackend();
47+
}
48+
},
49+
async sendImagesToBackend() {
50+
try {
51+
for (let i = 0; i < this.imagesUploaded.length; i += 1) {
52+
const formData = new FormData();
53+
if (i === 0) {
54+
formData.append('ProfileImage', this.imagesUploaded[i].content);
55+
await this.$http.post('/profile/images?is_primary=true', formData);
56+
} else {
57+
formData.append('ExtraImage', this.imagesUploaded[i].content);
58+
await this.$http.post('/profile/images?is_primary=false', formData);
59+
}
60+
}
61+
} catch (error) {
62+
console.log(error);
4663
}
4764
},
4865
},

frontend/src/plugins/http.js

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

56
import Axios from 'axios';
67
import Vue from 'vue';
78
import { getAccessToken, getRefreshToken, handleAccessTokenExpiration } from '../auth/tokens';
89

910
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'; */
1014

1115
Axios.interceptors.request.use(async function (config) {
1216
if (config.url === '/auth/refresh' || config.url === '/auth/refresh_revoke') {

frontend/src/views/app/Onboarding.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
current: slideCurrent,
3232
count: slideCount,
3333
header: 'Sexuality',
34-
options: ['heterosexual', 'homosexual', 'bi-sexual', 'other'],
34+
options: ['heterosexual', 'homosexual', 'bisexual', 'other'],
3535
buttonText}"
3636
v-on:saveInput="saveInput"
3737
v-if="slideCurrent === 3"></SingleChoice>
@@ -110,7 +110,9 @@ export default {
110110
if (key === 'birthdate') {
111111
value = this.formatBirthdate(value);
112112
}
113-
this.userData[key] = value;
113+
if (key !== 'images') {
114+
this.userData[key] = value;
115+
}
114116
console.log(this.userData);
115117
this.nextSlide();
116118
},

0 commit comments

Comments
 (0)