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.2KB

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