Browse Source

:construction: completed save survey state on refresh

tags/0.0.3^2
tomit4 3 years ago
parent
commit
fde10f8d54
1 changed files with 6 additions and 2 deletions
  1. 6
    2
      frontend/src/views/OnboardingView.vue

+ 6
- 2
frontend/src/views/OnboardingView.vue View File

66
         // and redirects the user to their last unanswered survey question
66
         // and redirects the user to their last unanswered survey question
67
         if (localStorage['currentStep'] &&
67
         if (localStorage['currentStep'] &&
68
             localStorage['currentProfileId'] &&
68
             localStorage['currentProfileId'] &&
69
-            localStorage['responses']) {
69
+            localStorage['responses'] &&
70
+            localStorage['answered']) {
70
             this.currentStep = Number(localStorage['currentStep'])
71
             this.currentStep = Number(localStorage['currentStep'])
71
             this.currentProfileId = Number(localStorage['currentProfileId'])
72
             this.currentProfileId = Number(localStorage['currentProfileId'])
72
             this.responses = JSON.parse(localStorage['responses'])
73
             this.responses = JSON.parse(localStorage['responses'])
74
+            this.answered = JSON.parse(localStorage['answered'])
73
             this.goToStep(this.currentStep)
75
             this.goToStep(this.currentStep)
74
         }
76
         }
75
     },
77
     },
101
                 response.response_key_id = payload.question.response_key_id
103
                 response.response_key_id = payload.question.response_key_id
102
                 response.val = payload.input
104
                 response.val = payload.input
103
                 this.responses.push(response)
105
                 this.responses.push(response)
106
+                // save user's progress through survey
107
+                localStorage.setItem('responses', JSON.stringify(this.responses))
108
+                localStorage.setItem('answered', JSON.stringify(this.answered))
104
 
109
 
105
                 // sends latest survey response to db
110
                 // sends latest survey response to db
106
                 if (this.currentProfileId) {
111
                 if (this.currentProfileId) {
118
                     this.currentProfileId = newProfile.profile_id
123
                     this.currentProfileId = newProfile.profile_id
119
                     // save user's progress through survey
124
                     // save user's progress through survey
120
                     localStorage.setItem('currentProfileId', Number(newProfile.profile_id))
125
                     localStorage.setItem('currentProfileId', Number(newProfile.profile_id))
121
-                    localStorage.setItem('responses', JSON.stringify(this.responses))
122
                 }
126
                 }
123
 
127
 
124
                 if (k === 'aspects') return
128
                 if (k === 'aspects') return

Loading…
Cancel
Save