|
|
@@ -112,20 +112,24 @@ export default {
|
|
112
|
112
|
methods: {
|
|
113
|
113
|
changeAnswers(){
|
|
114
|
114
|
console.log('change answers')
|
|
115
|
|
-
|
|
116
|
115
|
},
|
|
117
|
116
|
|
|
118
|
|
- async finalSubmit(){
|
|
|
117
|
+ async finalSubmit() {
|
|
119
|
118
|
// separate user info from responses
|
|
120
|
|
- const [user, survey] = this._separateUserInfoFromResponses(this.answers)
|
|
|
119
|
+ const [user, survey] = this._separateUserInfoFromResponses(
|
|
|
120
|
+ this.answers,
|
|
|
121
|
+ )
|
|
121
|
122
|
|
|
122
|
123
|
// create user
|
|
123
|
124
|
const createdUser = await signUpUser(user)
|
|
124
|
125
|
if (!createdUser) return
|
|
125
|
126
|
|
|
126
|
|
- // create profile
|
|
127
|
|
- const userProfile = await createProfileForUserId(createdUser.user_id, survey)
|
|
128
|
|
- if(!userProfile) return
|
|
|
127
|
+ // create profile
|
|
|
128
|
+ const userProfile = await createProfileForUserId(
|
|
|
129
|
+ createdUser.user_id,
|
|
|
130
|
+ survey,
|
|
|
131
|
+ )
|
|
|
132
|
+ if (!userProfile) return
|
|
129
|
133
|
|
|
130
|
134
|
this._setLoginForProfile(userProfile)
|
|
131
|
135
|
|
|
|
@@ -133,13 +137,13 @@ export default {
|
|
133
|
137
|
},
|
|
134
|
138
|
|
|
135
|
139
|
// TODO write logic to parse answers
|
|
136
|
|
- _separateUserInfoFromResponses(answers){
|
|
137
|
|
- return ['','']
|
|
|
140
|
+ _separateUserInfoFromResponses(answers) {
|
|
|
141
|
+ return ['', '']
|
|
138
|
142
|
},
|
|
139
|
143
|
|
|
140
|
|
- async _setLoginForProfile(profile){
|
|
|
144
|
+ async _setLoginForProfile(profile) {
|
|
141
|
145
|
const currentId = currentProfile.login(profile.profile_id)
|
|
142
|
|
- if(currentId && profile.responses.length){
|
|
|
146
|
+ if (currentId && profile.responses.length) {
|
|
143
|
147
|
currentProfile.setResponses(profile.responses)
|
|
144
|
148
|
}
|
|
145
|
149
|
if (!currentProfile.isComplete) {
|