Parcourir la source

:recycle: intermediary refactor for demonstration of cleaning up data-structures

tags/0.0.3^2
j il y a 3 ans
Parent
révision
f0248952fb

+ 18
- 13
frontend/src/components/onboarding/AccountType.vue Voir le fichier

@@ -1,33 +1,38 @@
1 1
 <template lang="pug">
2
-h3 {{question}}
3
-//- w-button.ma1.grow(@click="this.$emit('go-to-step', currentStep + 1)") CANDIDATES
4
-w-button.ma1.grow(@click="handleSubmit('Recruiter')") CANDIDATES
5
-w-button.ma1.grow(@click="handleSubmit('Jobseeker')") JOBS
2
+.account-typpe
3
+    h3 {{ question }}
4
+    //- w-button.ma1.grow(@click="this.$emit('go-to-step', currentStep + 1)") CANDIDATES
5
+    w-button.ma1.grow(@click='handleSubmit("Recruiter")') CANDIDATES
6
+    w-button.ma1.grow(@click='handleSubmit("Jobseeker")') JOBS
6 7
 </template>
7 8
 <script>
8 9
 export default {
9 10
     name: 'AccountType',
10 11
     props: {
11
-        currentStep:{
12
+        currentStep: {
12 13
             required: true,
13 14
             type: Number,
14
-            default: 0
15
-        }
15
+            default: 0,
16
+        },
17
+        aspectQuestions: {
18
+            required: false,
19
+        },
16 20
     },
17 21
     emits: ['go-to-step', 'update-answers'],
18 22
     data: () => ({
19
-        question: "{Name}, let's get started on your profile while we verify your account.",
23
+        question:
24
+            "{Name}, let's get started on your profile while we verify your account.",
20 25
     }),
21 26
     methods: {
22
-        handleSubmit(accountType){
27
+        handleSubmit(accountType) {
23 28
             let payload = {
24 29
                 key: 'AccountType',
25 30
                 question: this.question,
26
-                answer: accountType
31
+                answer: accountType,
27 32
             }
28 33
             this.$emit('update-answers', payload)
29 34
             this.$emit('go-to-step', this.currentStep + 1)
30
-        }
31
-    }
35
+        },
36
+    },
32 37
 }
33
-</script>
38
+</script>

+ 27
- 32
frontend/src/components/onboarding/Aspects.vue Voir le fichier

@@ -1,50 +1,45 @@
1 1
 <template lang="pug">
2
-form(@submit.prevent="this.$emit('handle-submit')").questionnaire
3
-    QuestionResponse(
4
-        v-for="question in aspectQuestions" 
5
-        :question="question" 
6
-        @updated="updateRadio"
7
-    )
8
-    w-button.ma1.grow(type="submit" bg-color="success")
9
-        w-icon.mr1 wi-check
10
-        | SUBMIT ANSWERS
2
+.aspects
3
+    form.questionnaire(@submit.prevent='this.$emit("handle-submit")')
4
+        QuestionResponse(
5
+            :question='question'
6
+            @updated='updateRadio'
7
+            v-for='question in aspectQuestions'
8
+        )
9
+        w-button.ma1.grow(bg-color='success' type='submit')
10
+            w-icon.mr1 wi-check
11
+            | SUBMIT ANSWERS
11 12
 </template>
12 13
 <script>
13 14
 import QuestionResponse from './QuestionResponse.vue'
15
+const answered = {}
14 16
 
15 17
 export default {
16 18
     name: 'Aspects',
17 19
     components: {
18
-        QuestionResponse
20
+        QuestionResponse,
19 21
     },
20 22
     props: {
21
-        aspectQuestions:{
23
+        aspectQuestions: {
22 24
             required: true,
23
-            type: Array
25
+            type: Array,
24 26
         },
25
-        currentStep:{
27
+        currentStep: {
26 28
             required: true,
27 29
             type: Number,
28
-            default: 0
29
-        }
30
+            default: 0,
31
+        },
30 32
     },
31 33
     emits: ['handle-submit', 'update-answers'],
32 34
     methods: {
33
-        updateRadio(newRadioSelection){
34
-            let old_answers = this.aspectQuestions.map(q=> q.answer)
35
-            console.log(old_answers)
36
-            console.log(newRadioSelection)
37
-            let new_answers = [...old_answers]
38
-            new_answers[newRadioSelection.id-1] = newRadioSelection.answer
39
-            console.log(new_answers)
40
-            // let payload = {
41
-            //     key: 'Aspects',
42
-            //     question: '?',
43
-            //     answer: new_answers
44
-            // }
45
-            // this.$emit('update-answers', payload)
46
-            // console.log(JSON.stringify(payload));
47
-        }
48
-    }
35
+        updateRadio(onRadioSelect) {
36
+            answered[onRadioSelect.id] = onRadioSelect.answer
37
+            this.$emit('update-answers', {
38
+                key: 'Aspects',
39
+                question: '?',
40
+                answer: answered,
41
+            })
42
+        },
43
+    },
49 44
 }
50
-</script>
45
+</script>

+ 18
- 13
frontend/src/components/onboarding/CompanyID.vue Voir le fichier

@@ -1,34 +1,39 @@
1 1
 <template lang="pug">
2
-h3 Company ID
3
-p {{question}}
4
-input(type="text" placeholder="Get this from your admin." v-model="companyID")
5
-w-button.ma1.grow(@click="handleSubmit") NEXT
2
+.company-id
3
+    h3 Company ID
4
+    p {{ question }}
5
+    input(
6
+        placeholder='Get this from your admin.'
7
+        type='text'
8
+        v-model='companyID'
9
+    )
10
+    w-button.ma1.grow(@click='handleSubmit') NEXT
6 11
 </template>
7 12
 <script>
8 13
 export default {
9 14
     name: 'CompanyID',
10 15
     props: {
11
-        currentStep:{
16
+        currentStep: {
12 17
             required: true,
13 18
             type: Number,
14
-            default: 0
15
-        }
19
+            default: 0,
20
+        },
16 21
     },
17 22
     emits: ['go-to-step', 'update-answers'],
18 23
     data: () => ({
19
-        companyID: null, 
24
+        companyID: null,
20 25
         question: 'PLEASE ENTER YOUR COMPANY ID#:',
21 26
     }),
22 27
     methods: {
23
-        handleSubmit(){
28
+        handleSubmit() {
24 29
             let payload = {
25 30
                 key: 'CompanyID',
26 31
                 question: this.question,
27
-                answer: this.companyID
32
+                answer: this.companyID,
28 33
             }
29 34
             this.$emit('update-answers', payload)
30 35
             this.$emit('go-to-step', this.currentStep + 1)
31
-        }
32
-    }
36
+        },
37
+    },
33 38
 }
34
-</script>
39
+</script>

+ 18
- 15
frontend/src/components/onboarding/Interests.vue Voir le fichier

@@ -1,38 +1,41 @@
1 1
 <template lang="pug">
2
-h3 Interests
3
-p {{question}}
4
-DynamicTagList(:tags="interests" :placeholder="'interest'")
5
-w-button.ma1.grow(@click="handleSubmit") NEXT
2
+.interests
3
+    h3 Interests
4
+    p {{ question }}
5
+    DynamicTagList(:placeholder='"interest"' :tags='interests')
6
+    w-button.ma1.grow(@click='handleSubmit') NEXT
6 7
 </template>
8
+
7 9
 <script>
8 10
 import DynamicTagList from '../DynamicTagList.vue'
9 11
 export default {
10 12
     name: 'Interests',
11
-    components:{
12
-        DynamicTagList
13
+    components: {
14
+        DynamicTagList,
13 15
     },
14 16
     props: {
15
-        currentStep:{
17
+        currentStep: {
16 18
             required: true,
17 19
             type: Number,
18
-            default: 0
19
-        }
20
+            default: 0,
21
+        },
20 22
     },
21 23
     emits: ['go-to-step', 'update-answers'],
22 24
     data: () => ({
23 25
         interests: [],
24
-        question: 'What are some interests you would like in your next candidates?'
26
+        question:
27
+            'What are some interests you would like in your next candidates?',
25 28
     }),
26 29
     methods: {
27
-        handleSubmit(){
30
+        handleSubmit() {
28 31
             let payload = {
29 32
                 key: 'Interests',
30 33
                 question: this.question,
31
-                answer: this.interests
34
+                answer: this.interests,
32 35
             }
33 36
             this.$emit('update-answers', payload)
34 37
             this.$emit('go-to-step', this.currentStep + 1)
35
-        }
36
-    }
38
+        },
39
+    },
37 40
 }
38
-</script>
41
+</script>

+ 19
- 15
frontend/src/components/onboarding/LicensesAndCertifications.vue Voir le fichier

@@ -1,38 +1,42 @@
1 1
 <template lang="pug">
2
-h3 Licenses & Certifications
3
-p {{question}}
4
-DynamicTagList(:tags="licensesAndCertifications" :placeholder="'requirement'")
5
-w-button.ma1.grow(@click="handleSubmit") NEXT
2
+.licenses-certifications
3
+    h3 Licenses &amp; Certifications
4
+    p {{ question }}
5
+    DynamicTagList(
6
+        :placeholder='"requirement"'
7
+        :tags='licensesAndCertifications'
8
+    )
9
+    w-button.ma1.grow(@click='handleSubmit') NEXT
6 10
 </template>
7 11
 <script>
8 12
 import DynamicTagList from '../DynamicTagList.vue'
9 13
 export default {
10 14
     name: 'LicensesAndCertifications',
11
-    components:{
12
-        DynamicTagList
15
+    components: {
16
+        DynamicTagList,
13 17
     },
14 18
     props: {
15
-        currentStep:{
19
+        currentStep: {
16 20
             required: true,
17 21
             type: Number,
18
-            default: 0
19
-        }
22
+            default: 0,
23
+        },
20 24
     },
21 25
     emits: ['go-to-step', 'update-answers'],
22 26
     data: () => ({
23 27
         licensesAndCertifications: [],
24
-        question: 'Are there any licenses and certification requirements?'
28
+        question: 'Are there any licenses and certification requirements?',
25 29
     }),
26 30
     methods: {
27
-        handleSubmit(){
31
+        handleSubmit() {
28 32
             let payload = {
29 33
                 key: 'LicensesAndCertifications',
30 34
                 question: this.question,
31
-                answer: this.licensesAndCertifications
35
+                answer: this.licensesAndCertifications,
32 36
             }
33 37
             this.$emit('update-answers', payload)
34 38
             this.$emit('go-to-step', this.currentStep + 1)
35
-        }
36
-    }
39
+        },
40
+    },
37 41
 }
38
-</script>
42
+</script>

+ 16
- 15
frontend/src/components/onboarding/Location.vue Voir le fichier

@@ -1,38 +1,39 @@
1 1
 <template lang="pug">
2
-h3 Location
3
-p {{question}}
4
-DynamicTagList(:tags="locations" :placeholder="'location'")
5
-w-button.ma1.grow(@click="handleSubmit") NEXT
2
+.location
3
+    h3 Location
4
+    p {{ question }}
5
+    DynamicTagList(:placeholder='"location"' :tags='locations')
6
+    w-button.ma1.grow(@click='handleSubmit') NEXT
6 7
 </template>
7 8
 <script>
8 9
 import DynamicTagList from '../DynamicTagList.vue'
9 10
 export default {
10 11
     name: 'Location',
11
-    components:{
12
-        DynamicTagList
12
+    components: {
13
+        DynamicTagList,
13 14
     },
14 15
     props: {
15
-        currentStep:{
16
+        currentStep: {
16 17
             required: true,
17 18
             type: Number,
18
-            default: 0
19
-        }
19
+            default: 0,
20
+        },
20 21
     },
21 22
     emits: ['go-to-step', 'update-answers'],
22 23
     data: () => ({
23 24
         locations: [],
24
-        question: 'Where would you like to select your candidates from?'
25
+        question: 'Where would you like to select your candidates from?',
25 26
     }),
26 27
     methods: {
27
-        handleSubmit(){
28
+        handleSubmit() {
28 29
             let payload = {
29 30
                 key: 'Location',
30 31
                 question: this.question,
31
-                answer: this.locations
32
+                answer: this.locations,
32 33
             }
33 34
             this.$emit('update-answers', payload)
34 35
             this.$emit('go-to-step', this.currentStep + 1)
35
-        }
36
-    }
36
+        },
37
+    },
37 38
 }
38
-</script>
39
+</script>

+ 17
- 18
frontend/src/components/onboarding/Role.vue Voir le fichier

@@ -1,41 +1,40 @@
1 1
 <template lang="pug">
2
-h3 ACTIVELY SEARCHING
3
-p {{question}}
4
-w-select.mt4(
5
-    v-model="selectedRole"
6
-    :items="items"
7
-    placeholder="i am")
8
-w-button.ma1.grow(@click="handleSubmit") NEXT
2
+.role
3
+    h3 ACTIVELY SEARCHING
4
+    p {{ question }}
5
+    w-select.mt4(:items='items' placeholder='i am' v-model='selectedRole')
6
+    w-button.ma1.grow(@click='handleSubmit') NEXT
9 7
 </template>
8
+
10 9
 <script>
11 10
 export default {
12 11
     name: 'Role',
13 12
     props: {
14
-        currentStep:{
13
+        currentStep: {
15 14
             required: true,
16 15
             type: Number,
17
-            default: 0
18
-        }
16
+            default: 0,
17
+        },
19 18
     },
20 19
     data: () => ({
21
-        items: [{label: 'RECRUITER'},{label: 'HIRING MANAGER'}],
20
+        items: [{ label: 'RECRUITER' }, { label: 'HIRING MANAGER' }],
22 21
         question: 'What is your role at your company?',
23 22
         selectedRole: null,
24 23
     }),
25 24
     methods: {
26
-        handleSubmit(){
27
-            if(!this.selectedRole) {
25
+        handleSubmit() {
26
+            if (!this.selectedRole) {
28 27
                 console.warn('Please select a role.')
29 28
                 return
30
-            } 
29
+            }
31 30
             let payload = {
32 31
                 key: 'Role',
33 32
                 question: this.question,
34
-                answer: this.selectedRole
33
+                answer: this.selectedRole,
35 34
             }
36 35
             this.$emit('update-answers', payload)
37 36
             this.$emit('go-to-step', this.currentStep + 1)
38
-        }
39
-    }
37
+        },
38
+    },
40 39
 }
41
-</script>
40
+</script>

+ 16
- 15
frontend/src/components/onboarding/Skills.vue Voir le fichier

@@ -1,38 +1,39 @@
1 1
 <template lang="pug">
2
-h3 RECRUITER
3
-p {{question}}
4
-DynamicTagList(:tags="skills" :placeholder="'skill'")
5
-w-button.ma1.grow(@click="handleSubmit") NEXT
2
+.skills
3
+    h3 RECRUITER
4
+    p {{ question }}
5
+    DynamicTagList(:placeholder='"skill"' :tags='skills')
6
+    w-button.ma1.grow(@click='handleSubmit') NEXT
6 7
 </template>
7 8
 <script>
8 9
 import DynamicTagList from '../DynamicTagList.vue'
9 10
 export default {
10 11
     name: 'Skills',
11
-    components:{
12
-        DynamicTagList
12
+    components: {
13
+        DynamicTagList,
13 14
     },
14 15
     props: {
15
-        currentStep:{
16
+        currentStep: {
16 17
             required: true,
17 18
             type: Number,
18
-            default: 0
19
-        }
19
+            default: 0,
20
+        },
20 21
     },
21 22
     emits: ['go-to-step', 'update-answers'],
22 23
     data: () => ({
23 24
         question: 'What are some skills you are looking for at your company?',
24
-        skills: []
25
+        skills: [],
25 26
     }),
26 27
     methods: {
27
-        handleSubmit(){
28
+        handleSubmit() {
28 29
             let payload = {
29 30
                 key: 'Skills',
30 31
                 question: this.question,
31
-                answer: this.skills
32
+                answer: this.skills,
32 33
             }
33 34
             this.$emit('update-answers', payload)
34 35
             this.$emit('go-to-step', this.currentStep + 1)
35
-        }
36
-    }
36
+        },
37
+    },
37 38
 }
38
-</script>
39
+</script>

+ 9
- 7
frontend/src/components/onboarding/Splash.vue Voir le fichier

@@ -1,17 +1,19 @@
1 1
 <template lang="pug">
2
-.splash-icon(style="width:347px; height:347px; background-color: red;")
3
-div(style="text-align:center;")
4
-    w-button.ma1.grow(@click="this.$emit('go-to-step', currentStep + 1)") GET STARTED
2
+.splash
3
+    .splash--icon(style='width: 347px; height: 347px; background-color: red')
4
+    div(style='text-align: center')
5
+        w-button.ma1.grow(@click='this.$emit("go-to-step", currentStep + 1)') GET STARTED
5 6
 </template>
7
+
6 8
 <script>
7 9
 export default {
8 10
     name: 'Splash',
9 11
     props: {
10
-        currentStep:{
12
+        currentStep: {
11 13
             required: true,
12 14
             type: Number,
13
-            default: 0
14
-        }
15
+            default: 0,
16
+        },
15 17
     },
16 18
 }
17
-</script>
19
+</script>

+ 0
- 39
frontend/src/utils/onboardingStepComponents.js Voir le fichier

@@ -1,39 +0,0 @@
1
-const OnboardingStepComponents = [
2
-    {
3
-        id: 0,
4
-        component:'Splash',
5
-    },
6
-    {
7
-        id: 1,
8
-        component:'AccountType',
9
-    },
10
-    {
11
-        id: 2,
12
-        component:'CompanyID',
13
-    },
14
-    {
15
-        id: 3,
16
-        component:'Role',
17
-    },
18
-    {
19
-        id: 4,
20
-        component:'Skills',
21
-    },
22
-    {
23
-        id: 5,
24
-        component:'Location',
25
-    },
26
-    {
27
-        id: 6,
28
-        component:'Interests',
29
-    },
30
-    {
31
-        id: 7,
32
-        component:'LicensesAndCertifications',
33
-    },
34
-    {
35
-        id: 8,
36
-        component:'Aspects',
37
-    }
38
-]
39
-export default OnboardingStepComponents

+ 20
- 22
frontend/src/views/OnboardingView.vue Voir le fichier

@@ -2,12 +2,12 @@
2 2
 main.view--onboarding
3 3
     article(style='display: flex; flex-direction: column; align-items: center')
4 4
         component(
5
-            :aspectQuestions='onboardingStep.component == "Aspects" ? aspectQuestions : null'
6
-            :currentStep='currentStep'
7
-            :is='onboardingStep.component'
5
+            :aspect-questions='steps[currentStep] == "Aspects" ? aspectQuestions : null'
6
+            :current-step='currentStep'
7
+            :is='steps[currentStep]'
8 8
             @go-to-step='goToStep'
9
-            @handle-submit="onSubmit"
10
-            @update-answers="updateAnswers"
9
+            @handle-submit='onSubmit'
10
+            @update-answers='updateAnswers'
11 11
         )
12 12
 </template>
13 13
 
@@ -15,9 +15,9 @@ main.view--onboarding
15 15
 import { surveyFactory } from '@/utils'
16 16
 import { allSteps, possible } from '@/utils/lang'
17 17
 import stepViews from '@/components/onboarding'
18
-import OnboardingStepComponents from '../utils/onboardingStepComponents'
19 18
 
20
-const SCORED = [1, 2, 3, 4, 5, 6] 
19
+const SCORED = [1, 2, 3, 4, 5, 6]
20
+
21 21
 const _isScored = id => SCORED.includes(id)
22 22
 
23 23
 const _makeCategoryFriendly = responseCategory => {
@@ -54,37 +54,35 @@ export default {
54 54
         answered: {},
55 55
         aspectQuestions: [],
56 56
         currentStep: 0,
57
-        onboardingStepComponents: [],
58
-        validSurvey: null,
57
+        steps: [
58
+            'Splash',
59
+            'AccountType',
60
+            'CompanyID',
61
+            'Role',
62
+            'Skills',
63
+            'Location',
64
+            'Interests',
65
+            'LicensesAndCertifications',
66
+            'Aspects',
67
+        ],
59 68
     }),
60
-    computed: {
61
-        onboardingStep() {
62
-            if (!this.onboardingStepComponents.length) return []
63
-            return this.onboardingStepComponents[this.currentStep]
64
-        },
65
-    },
66 69
     async created() {
67 70
         const survey = await surveyFactory.createSurvey(
68 71
             allSteps['usa'],
69 72
             possible['usa']['roles'],
70 73
         )
71 74
         this.aspectQuestions = _formatAspectQuestions(survey.steps)
72
-        this.onboardingStepComponents = OnboardingStepComponents
73 75
     },
74 76
     methods: {
75 77
         onSubmit() {
76 78
             console.log(JSON.stringify(this.answered))
77
-            // Object.values(this.answered).forEach(ans =>
78
-            //     console.log(ans.question, ans.answer),
79
-            // )
80 79
         },
81 80
         goToStep(num) {
82 81
             this.currentStep = num
83 82
         },
84
-        updateAnswers(payload){
83
+        updateAnswers(payload) {
85 84
             this.answered[payload.key] = payload.answer
86
-            console.log(`Updated answers: ${JSON.stringify(this.answered)}`);
87
-        }
85
+        },
88 86
     },
89 87
 }
90 88
 </script>

Chargement…
Annuler
Enregistrer