You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

OnboardingView.vue 5.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <template lang="pug">
  2. main.view--onboarding
  3. article(
  4. style='display: flex; flex-direction: column; align-items: center'
  5. v-if='survey'
  6. )
  7. p {{ currentStep }}
  8. p(v-if='currentStep != 0') You have completed: {{ currentStep - 1 }} / 7 survey steps
  9. .answers(v-for='(value, key) in answered')
  10. span(v-if='key == "name" && value && currentStep == 2') Hi {{ value }}!
  11. span(v-if='key == "email" && value && currentStep == 3') Thanks for the contact info, {{ answered.name }}!
  12. span(v-if='key == "zipcode" && value && currentStep == 5') Very cool, {{ answered.name }}, we'll be sure only to show you results in your area. Now let's get to know more about you!
  13. .step(v-for='(step, i) in survey.steps')
  14. component(
  15. :aspect-questions='step.component == "Aspects" ? survey.aspectQuestions : null'
  16. :is='step.component'
  17. :question='step'
  18. @handle-submit='onSubmit'
  19. @update-answers='updateAnswers'
  20. v-if='step && currentStep == i'
  21. )
  22. // TODO: change to different vue component
  23. article(
  24. style='display: flex; flex-direction: column; align-items: center; text-align: center;'
  25. v-if='currentStep == 8'
  26. )
  27. h1 Thanks for Completing Our Survey!!
  28. h2 Please review your answers and let us know if you need to change anything.
  29. span Your name: {{ answered.name }}
  30. span Your email: {{ answered.email }}
  31. span Your zipcode: {{ answered.zipcode }}
  32. span Your blurb: {{ answered.blurb }}
  33. span Your image: {{ answered.image }}
  34. br
  35. button(@click="changeAnswers") Change Answers
  36. br
  37. button(@click="finalSubmit") Submit Answers
  38. </template>
  39. <script>
  40. import { surveyFactory } from '@/utils'
  41. import { allSteps } from '@/utils/lang'
  42. import stepViews from '@/components/onboarding'
  43. // import savesurveybyprfileid - call it on submit
  44. // paginate to save every steps answers
  45. export default {
  46. name: 'OnboardingView',
  47. components: {
  48. ...stepViews,
  49. },
  50. data: () => ({
  51. answered: {},
  52. aspectQuestions: [],
  53. currentStep: 0,
  54. survey: null,
  55. }),
  56. async created() {
  57. this.survey = await surveyFactory.createSurvey(allSteps['usa'])
  58. },
  59. methods: {
  60. onSubmit() {
  61. console.log(JSON.stringify(this.answered))
  62. // TODO: Change to different vue component
  63. this.goToStep(this.currentStep + 1)
  64. },
  65. goToStep(num) {
  66. this.currentStep = num
  67. },
  68. updateAnswers(payload) {
  69. // null payload is passed on splash page
  70. if (payload) {
  71. const k = payload.question.response_key_prompt
  72. this.answered[k] = payload.answer
  73. console.log(`${k}:`, this.answered[k])
  74. console.log(`Updated answers: ${JSON.stringify(this.answered)}`)
  75. if (k === 'aspects') return
  76. }
  77. this.goToStep(this.currentStep + 1)
  78. },
  79. },
  80. }
  81. </script>
  82. <style lang="sass">
  83. .view--onboarding
  84. width: 100%
  85. max-width: 428px
  86. background-color: #fff
  87. color: #1F2024
  88. font-family: Century Gothic,CenturyGothic,AppleGothic,sans-serif
  89. margin: 0 auto
  90. article
  91. height: 100vh
  92. .answers
  93. text-align: center
  94. .w-button
  95. display: flex
  96. width: 315px
  97. height: 60px
  98. border-radius: 6
  99. background-color: #D5D5D5
  100. color: #1F2024
  101. margin: 11px auto
  102. font-weight: bold
  103. font-size: 16px
  104. text-transform: uppercase
  105. &.next-btn
  106. border-radius: 6px
  107. background-color: #5BA626
  108. color: #1F2024
  109. height: 50px
  110. width: 315px
  111. font-size: 18px
  112. padding: 7px
  113. .w-card
  114. background-color: #1F2024
  115. justify-content: center
  116. align-items: center
  117. width: 100%
  118. h3
  119. text-transform: uppercase
  120. text-align: center
  121. font-size: 28px
  122. font-weight: bold
  123. color: white
  124. margin-top: 88px
  125. p
  126. color: white
  127. font-size: 18px
  128. padding: 11px
  129. text-align: center
  130. margin: 22px auto
  131. font-weight: bold
  132. input
  133. display: flex
  134. width: 315px
  135. height: 60px
  136. padding: 11px
  137. border-radius: 6
  138. background-color: #D5D5D5
  139. color: #1F2024
  140. margin: 11px auto
  141. font-weight: bold
  142. font-size: 16px
  143. .w-select
  144. padding: 11px
  145. color: #1F2024
  146. .search-type
  147. color: #1F2024
  148. height: 50px
  149. &.question
  150. p
  151. font-size: 18px
  152. text-align: left
  153. margin: 7px auto
  154. font-weight: normal
  155. section
  156. p
  157. margin: 0
  158. font-weight: bold
  159. text-transform: capitalize
  160. .w-radio__input
  161. &.primary
  162. background-color: #FFFFFF
  163. border: #BCC5D3 1px solid
  164. .w-card__content
  165. .w-button
  166. height: 50px
  167. background-color: #5BA626
  168. </style>