Kaynağa Gözat

:gears: WIP finalSubmit function at end of onboarding

tags/0.0.4
juancarbajal98 2 yıl önce
ebeveyn
işleme
93e263b1ec
1 değiştirilmiş dosya ile 48 ekleme ve 3 silme
  1. 48
    3
      frontend/src/views/SurveyCompleteView.vue

+ 48
- 3
frontend/src/views/SurveyCompleteView.vue Dosyayı Görüntüle

@@ -1,13 +1,15 @@
1 1
 <template lang="pug">
2 2
 main.view--surveycomplete
3
-    article(style='display: flex; flex-direction: column; align-items: center; text-align: center;')
3
+    article(
4
+        style='display: flex; flex-direction: column; align-items: center; text-align: center'
5
+    )
4 6
         h2 Thanks for Completing Our Survey!!
5 7
         h1 Please review your answers and let us know if you need to change anything.
6 8
         div(v-for='response in responses')
7
-            p Your {{ response.stage }}: 
9
+            p Your {{ response.stage }}:
8 10
             p {{ response.val }}
9 11
             br
10
-        div.survey-spacer
12
+        .survey-spacer
11 13
         div(v-for='aspectResponse in aspectResponses')
12 14
             p {{ aspectResponse.question }} :
13 15
             br
@@ -106,6 +108,49 @@ export default {
106 108
         },
107 109
         // changeAnswers() {},
108 110
     },
111
+    /*
112
+    methods: {
113
+        changeAnswers(){
114
+            console.log('change answers')
115
+            
116
+        },
117
+
118
+        async finalSubmit(){
119
+            // separate user info from responses
120
+            const [user, survey] = this._separateUserInfoFromResponses(this.answers)
121
+
122
+            // create user
123
+            const createdUser = await signUpUser(user)
124
+            if (!createdUser) return
125
+
126
+            // create profile 
127
+            const userProfile = await createProfileForUserId(createdUser.user_id, survey)
128
+            if(!userProfile) return
129
+
130
+            this._setLoginForProfile(userProfile)
131
+
132
+            this.$router.push({ name: 'HomeView' })
133
+        },
134
+
135
+        // TODO write logic to parse answers
136
+        _separateUserInfoFromResponses(answers){
137
+            return ['','']
138
+        },
139
+
140
+        async _setLoginForProfile(profile){
141
+            const currentId = currentProfile.login(profile.profile_id)
142
+            if(currentId && profile.responses.length){
143
+                currentProfile.setResponses(profile.responses)
144
+            }
145
+            if (!currentProfile.isComplete) {
146
+                console.error(
147
+                    `Profile ${currentProfile.id} is incomplete. Please make sure all survey questions have been answered.`,
148
+                )
149
+                return
150
+            }
151
+        }
152
+    }
153
+    */
109 154
 }
110 155
 </script>
111 156
 <style>

Loading…
İptal
Kaydet