Просмотр исходного кода

:recycle: reorg of app components | keeping pid at root level and trickle down

tags/0.0.1
toj 4 лет назад
Родитель
Сommit
2fb9f38a84

+ 200
- 5483
frontend/package-lock.json
Разница между файлами не показана из-за своего большого размера
Просмотреть файл


+ 35
- 2
frontend/src/App.vue Просмотреть файл

1
 <template lang="pug">
1
 <template lang="pug">
2
-router-view
2
+SideBar(v-if="showSidebar" :pid="pid" @updatePid="setPid" @hide="showSidebar = false")
3
+RouterView(:pid="pid" @show-sidebar="showSidebar = true")
3
 </template>
4
 </template>
4
 
5
 
5
 <script>
6
 <script>
6
 import * as sss from '@/sss/import.css'
7
 import * as sss from '@/sss/import.css'
7
 
8
 
9
+import SideBar from './components/SideBar.vue'
10
+
11
+import { Chatter, StonkAlert } from './services'
12
+
13
+const DEFAULT_PID = 45
14
+
8
 export default {
15
 export default {
9
-    name: 'app'
16
+    components: { SideBar },
17
+    data: () => ({
18
+        pid: null,
19
+        showSidebar: false
20
+    }),
21
+    created() {
22
+        this.setPid()
23
+        this.setupChatter()
24
+        this.setupToaster()
25
+    },
26
+    methods: {
27
+        setPid(pid) {
28
+            this.pid = pid ? parseInt(pid) : DEFAULT_PID
29
+        },
30
+
31
+        // For push notifications and chat 
32
+        setupToaster() {
33
+            const t = new StonkAlert(this.pid)
34
+        },
35
+        setupChatter() {
36
+            const c = new Chatter()
37
+            const testAccountUUID = import.meta.env.VITE_TEST_ACCOUNT_UUID
38
+            c.setup(testAccountUUID)
39
+            console.log('---')
40
+        },
41
+    },
42
+    
10
 }
43
 }
11
 </script>
44
 </script>
12
 
45
 

+ 5
- 3
frontend/src/components/MainNav.vue Просмотреть файл

1
 <template lang="pug">
1
 <template lang="pug">
2
 nav#main-header.w-full.f-row.around.p-2
2
 nav#main-header.w-full.f-row.around.p-2
3
-    router-link.header__icon.mobile--only(:to="`/matches?pid=${pid}`") {{pid}} matches
3
+    button(@click="$emit('show-sidebar')") show sidebar
4
+    router-link.header__icon.mobile--only(:to="`/matches`") matches
4
     router-link.header__icon(to='/') home
5
     router-link.header__icon(to='/') home
5
-    router-link.header__icon.mobile--only(:to="`/profile?pid=${pid}`") {{pid}} profile
6
-    router-link.header__icon.mobile--only(:to="`/survey?pid=${pid}`") {{pid}} survey
6
+    router-link.header__icon.mobile--only(:to="`/profile`") profile
7
+    router-link.header__icon.mobile--only(:to="`/survey`") survey
7
 </template>
8
 </template>
8
 
9
 
9
 <script>
10
 <script>
11
     name: 'MainNav',
12
     name: 'MainNav',
12
     props: {
13
     props: {
13
         pid: {
14
         pid: {
15
+            type: Number,
14
             required: true
16
             required: true
15
         }
17
         }
16
     }
18
     }

frontend/src/components/Sidebar.vue → frontend/src/components/SideBar.vue Просмотреть файл

1
 <template lang="pug">
1
 <template lang="pug">
2
 aside.sidebar.p-1.f-col.between
2
 aside.sidebar.p-1.f-col.between
3
     h3 Profile: {{ pid }}
3
     h3 Profile: {{ pid }}
4
-    .search
5
-        input
6
-        label search
7
-
4
+    button(@click="$emit('hide')") hide
8
     messages(:title="title" :users="users")
5
     messages(:title="title" :users="users")
9
     .spacer.f-grow
6
     .spacer.f-grow
10
     .temp-control-box.f-row.start.center
7
     .temp-control-box.f-row.start.center
19
     components: { messages }, 
16
     components: { messages }, 
20
     props: {
17
     props: {
21
         pid: {
18
         pid: {
22
-            required: true
19
+            required: true,
20
+            type: Number
23
         }
21
         }
24
     },
22
     },
25
     data: () => ({
23
     data: () => ({

+ 50
- 23
frontend/src/components/form.vue Просмотреть файл

12
             h3 {{ prompt.question }}?
12
             h3 {{ prompt.question }}?
13
             .response-wrapper(v-if='prompt.type === "input-string"')
13
             .response-wrapper(v-if='prompt.type === "input-string"')
14
                 label {{ prompt.type }}
14
                 label {{ prompt.type }}
15
-                input(v-model='answers[`${prompt.id}-${makeKebob(prompt.question)}`]')
15
+                input(v-model='answers[makeKey(prompt)]')
16
             .response-wrapper(v-else-if='prompt.type === "tag-cloud"')
16
             .response-wrapper(v-else-if='prompt.type === "tag-cloud"')
17
                 label {{ prompt.type }}
17
                 label {{ prompt.type }}
18
                 button.p-0(
18
                 button.p-0(
19
-                    :disabled='response == answers[`${prompt.id}-${makeKebob(prompt.question)}`]'
20
-                    :prompt-question='`${prompt.id}-${makeKebob(prompt.question)}`'
19
+                    :disabled='response == answers[makeKey(prompt)]'
20
+                    :prompt-question='makeKey(prompt)'
21
                     @click='respondFromTag'
21
                     @click='respondFromTag'
22
                     v-for='response in prompt.responses'
22
                     v-for='response in prompt.responses'
23
                 ) {{ response }}
23
                 ) {{ response }}
33
                         :name='response'
33
                         :name='response'
34
                         :true-value='response'
34
                         :true-value='response'
35
                         false-value=''
35
                         false-value=''
36
-                        v-model='answers[`${prompt.id}-${makeKebob(prompt.question)}`]')
36
+                        v-model='answers[makeKey(prompt)]')
37
                     label(:for='response') {{ response }}
37
                     label(:for='response') {{ response }}
38
             //- Slider from -3 to 0 to +3 (increments of 1)
38
             //- Slider from -3 to 0 to +3 (increments of 1)
39
-            .response-wrapper(v-else-if='prompt.type === "slide"')
39
+            .response-wrapper(v-else-if='prompt.type === "input-slide"')
40
                 label {{ prompt.type }}
40
                 label {{ prompt.type }}
41
                 input(
41
                 input(
42
                     type='range'
42
                     type='range'
43
                     min='-3'
43
                     min='-3'
44
                     max='3'
44
                     max='3'
45
-                    v-model='answers[`${prompt.id}-${makeKebob(prompt.question)}`]')
46
-                span {{ answers[`${prompt.id}-${makeKebob(prompt.question)}`] }}
45
+                    v-model='answers[makeKey(prompt)]')
46
+                span {{ answers[makeKey(prompt)] }}
47
 
47
 
48
     footer.f-row.w-full
48
     footer.f-row.w-full
49
         button.p-1(:disabled='state.step == 1' @click='back') back
49
         button.p-1(:disabled='state.step == 1' @click='back') back
50
         button.p-1(:disabled='state.step == form.length' @click='next') next
50
         button.p-1(:disabled='state.step == form.length' @click='next') next
51
         button.p-1(:disabled='state.step != form.length' @click='next') save
51
         button.p-1(:disabled='state.step != form.length' @click='next') save
52
         .f-grow
52
         .f-grow
53
-        p step: {{ state.step }} of {{ form.length }}
53
+        p step: {{ state.step }} of {{ form.length }} for {{ pid }}
54
 </template>
54
 </template>
55
 
55
 
56
 <script setup>
56
 <script setup>
57
 import Joi from 'joi'
57
 import Joi from 'joi'
58
 import { validatorMapping, makeKebob } from '@/utils'
58
 import { validatorMapping, makeKebob } from '@/utils'
59
-import { defineProps, reactive, ref } from 'vue'
60
-import { saveSurveyByProfileID, scoreSurveyByProfileId } from '../services/survey.service'
61
-
62
-const slidevalue = ref('0')
59
+import { defineProps, reactive } from 'vue'
60
+import { saveSurveyByProfileId, scoreSurveyByProfileId } from '../services/survey.service'
61
+import { scoreVals } from '../../../backend/db/data-generator/config.json'
63
 
62
 
64
 const props = defineProps({
63
 const props = defineProps({
65
     form: {
64
     form: {
67
         required: true,
66
         required: true,
68
     },
67
     },
69
     pid: {
68
     pid: {
70
-        required: true
69
+        required: true,
70
+        type: Number
71
     }
71
     }
72
 })
72
 })
73
+const makeKey = prompt => {
74
+    return `${prompt.id}-${prompt.type}-${makeKebob(prompt.question)}`
75
+}
76
+
73
 /**
77
 /**
74
  * Our form is comprised of steps, and each step has a series of questions
78
  * Our form is comprised of steps, and each step has a series of questions
75
  */
79
  */
101
     const schema = {}
105
     const schema = {}
102
     const answeredThisStep = {}
106
     const answeredThisStep = {}
103
     props.form[step].forEach(prompt => {
107
     props.form[step].forEach(prompt => {
104
-        const key = `${prompt.id}-${makeKebob(prompt.question)}`
108
+        const key = makeKey(prompt)
105
         schema[key] = validatorMapping[prompt.type]
109
         schema[key] = validatorMapping[prompt.type]
106
         answeredThisStep[key] = answers[key]
110
         answeredThisStep[key] = answers[key]
107
     })
111
     })
108
     return Joi.object(schema).validate(answeredThisStep)
112
     return Joi.object(schema).validate(answeredThisStep)
109
 }
113
 }
114
+/**
115
+ * Vary the final answer format by input type
116
+ */
117
+const formatAnswer = (inputType, answer) => {
118
+    let formattedAnswer = answer
119
+    if(inputType == 'slide')  {
120
+        const offset = (scoreVals.length - 1) / 2
121
+        formattedAnswer = scoreVals[offset + parseInt(answer)].toString()
122
+    }
123
+    return formattedAnswer
124
+}
110
 /**
125
 /**
111
  * Save or take the-nNext step in the form
126
  * Save or take the-nNext step in the form
112
  */
127
  */
128
+const getInputTypeFromKey = k => {
129
+    const inputIndex = k.split('-').indexOf('input')
130
+    return k.split('-')[inputIndex + 1]
131
+}
132
+
113
 const next = async e => {
133
 const next = async e => {
114
     const validity = isValid(state.step - 1)
134
     const validity = isValid(state.step - 1)
115
-    if (validity.error) return console.error(validity.error)
135
+    if (validity.error) console.error(validity.error)
136
+
116
     if (state.step === props.form.length) {
137
     if (state.step === props.form.length) {
138
+        // Make key map of each prompt.id
117
         const questiontoResponseKeyId = {}
139
         const questiontoResponseKeyId = {}
118
         props.form.forEach(step => {
140
         props.form.forEach(step => {
119
             step.forEach(prompt => {
141
             step.forEach(prompt => {
120
-                questiontoResponseKeyId[`${prompt.id}-${makeKebob(prompt.question)}`] = prompt.id
121
-                })
142
+                questiontoResponseKeyId[makeKey(prompt)] = prompt.id
143
+            })
122
         })
144
         })
123
-        const idWithResponseVal = []
124
-        Object.keys(answers).forEach(answerKey => {
125
-            idWithResponseVal.push({
145
+
146
+        const idWithResponseVal = Object.keys(answers).map(answerKey => {
147
+            return {
126
                 response_key_id: questiontoResponseKeyId[answerKey],
148
                 response_key_id: questiontoResponseKeyId[answerKey],
127
-                val: answers[answerKey],
128
-            })
149
+                val: formatAnswer(
150
+                    getInputTypeFromKey(answerKey),
151
+                    answers[answerKey]
152
+                )
153
+            }
129
         })
154
         })
130
 
155
 
131
         const maxDistance = 100
156
         const maxDistance = 100
132
         
157
         
133
         if(!props.pid) return console.error(`no pid: ${props.pid}`)
158
         if(!props.pid) return console.error(`no pid: ${props.pid}`)
134
 
159
 
135
-        saveSurveyByProfileID(idWithResponseVal, props.pid)
160
+        saveSurveyByProfileId(idWithResponseVal, props.pid)
136
         alert('Responses submitted!')
161
         alert('Responses submitted!')
162
+        
137
         resetAnswers()
163
         resetAnswers()
138
         scoreSurveyByProfileId(props.pid, maxDistance)
164
         scoreSurveyByProfileId(props.pid, maxDistance)
165
+
139
         state.step = 1
166
         state.step = 1
140
     } else if (state.step < props.form.length) {
167
     } else if (state.step < props.form.length) {
141
         state.step++
168
         state.step++

+ 5
- 1
frontend/src/main.js Просмотреть файл

2
 import App from './App.vue'
2
 import App from './App.vue'
3
 import router from './router'
3
 import router from './router'
4
 
4
 
5
+import MainNav from './components/MainNav.vue'
6
+
5
 router.beforeEach((to, from, next) => {
7
 router.beforeEach((to, from, next) => {
6
     const requiresAuth = false
8
     const requiresAuth = false
7
     const requiresProfile = true
9
     const requiresProfile = true
21
     // }
23
     // }
22
 })
24
 })
23
 
25
 
24
-createApp(App).use(router).mount('#app')
26
+const siimee = createApp(App).use(router)
27
+siimee.component('MainNav', MainNav)
28
+siimee.mount('#app')

+ 4
- 3
frontend/src/router/index.js Просмотреть файл

1
 import { createRouter, createWebHistory } from 'vue-router'
1
 import { createRouter, createWebHistory } from 'vue-router'
2
-import home from '../views/home.vue'
2
+
3
+import HomeView from '../views/HomeView.vue'
3
 import Profile from '../views/Profile.vue'
4
 import Profile from '../views/Profile.vue'
4
 import Matches from '../views/Matches.vue'
5
 import Matches from '../views/Matches.vue'
5
 import Chats from '../views/Chats.vue'
6
 import Chats from '../views/Chats.vue'
10
 const routes = [
11
 const routes = [
11
     {
12
     {
12
         path: '/',
13
         path: '/',
13
-        component: home,
14
+        component: HomeView,
14
         name: 'HomeView',
15
         name: 'HomeView',
15
-        meta: { requiresAuth: true, requiresProfile: true },
16
+        meta: { requiresAuth: true, requiresProfile: true }
16
     },
17
     },
17
     {
18
     {
18
         path: '/profile',
19
         path: '/profile',

+ 8
- 3
frontend/src/services/survey.service.js Просмотреть файл

22
     // Add the questions into each step, dividing into questionsPerStep
22
     // Add the questions into each step, dividing into questionsPerStep
23
     for (let i = 0; i < myquestions.length; i++) {
23
     for (let i = 0; i < myquestions.length; i++) {
24
         const question = myquestions[i]
24
         const question = myquestions[i]
25
+
26
+        // Set the input type based on category
27
+        const type = question.response_key_category == 'locationPref' ? 'input-string' : 'input-slide'
28
+        
25
         // Reformats myquestions into the format we want
29
         // Reformats myquestions into the format we want
26
         const reformatted = {
30
         const reformatted = {
27
             id: question.response_key_id,
31
             id: question.response_key_id,
28
-            type: 'input-string',
32
+            type,
29
             question: question.response_key_prompt,
33
             question: question.response_key_prompt,
30
             responses: null,
34
             responses: null,
31
             description: question.response_key_description,
35
             description: question.response_key_description,
38
         }
42
         }
39
     }
43
     }
40
     const mysurvey = new Survey(allsteps)
44
     const mysurvey = new Survey(allsteps)
45
+    console.log('mysurvey :>> ', mysurvey);
41
     return mysurvey
46
     return mysurvey
42
 }
47
 }
43
 
48
 
44
-const saveSurveyByProfileID = async (surveyResponses, profileId) => {
49
+const saveSurveyByProfileId = async (surveyResponses, profileId) => {
45
     surveyResponses.forEach(responseKeyIdwithVal => {
50
     surveyResponses.forEach(responseKeyIdwithVal => {
46
         const keyId = responseKeyIdwithVal.response_key_id
51
         const keyId = responseKeyIdwithVal.response_key_id
47
         const val = responseKeyIdwithVal.val
52
         const val = responseKeyIdwithVal.val
77
 
82
 
78
 export {
83
 export {
79
     fetchSurveyByProfileId,
84
     fetchSurveyByProfileId,
80
-    saveSurveyByProfileID,
85
+    saveSurveyByProfileId,
81
     updateSurveyByProfileId,
86
     updateSurveyByProfileId,
82
     scoreSurveyByProfileId,
87
     scoreSurveyByProfileId,
83
 }
88
 }

+ 0
- 28
frontend/src/utils/forms.js Просмотреть файл

1
-const profileForm = [
2
-    [
3
-        {
4
-            type: 'input-string',
5
-            id: 1,
6
-            responses: null,
7
-        },
8
-        {
9
-            type: 'tag-cloud',
10
-            id: 2,
11
-            responses: ['red', 'blue', 'green', 'white', 'black'],
12
-        },
13
-    ],
14
-    [
15
-        {
16
-            type: 'input-string',
17
-            id: 3,
18
-            responses: null,
19
-        },
20
-        {
21
-            type: 'input-string',
22
-            id: 4,
23
-            responses: null,
24
-        },
25
-    ],
26
-]
27
-
28
-export { profileForm }

+ 1
- 1
frontend/src/utils/index.js Просмотреть файл

9
     'input-string': Joi.string(),
9
     'input-string': Joi.string(),
10
     'tag-cloud': Joi.string(),
10
     'tag-cloud': Joi.string(),
11
     'checklist': Joi.string(),
11
     'checklist': Joi.string(),
12
-    'slide': Joi.string(),
12
+    'input-slide': Joi.string(),
13
 }
13
 }
14
 
14
 
15
 const makeKebob = input => {
15
 const makeKebob = input => {

+ 3
- 0
frontend/src/utils/login.js Просмотреть файл

2
 
2
 
3
 class Login {
3
 class Login {
4
     constructor() {
4
     constructor() {
5
+        this.loading = true
5
         this.currentProfileId = null
6
         this.currentProfileId = null
6
         this.survey = null
7
         this.survey = null
7
         this.queue = null
8
         this.queue = null
22
     }
23
     }
23
 
24
 
24
     async getQueue() {
25
     async getQueue() {
26
+        this.loading = true
25
         try {
27
         try {
26
             const queueList = await fetchQueueByProfileId(this.currentProfileId)
28
             const queueList = await fetchQueueByProfileId(this.currentProfileId)
27
             const formatted = this._reformatProfiles(queueList)
29
             const formatted = this._reformatProfiles(queueList)
28
             this._setQueue(formatted)
30
             this._setQueue(formatted)
31
+            this.loading = false
29
         } catch (err) {
32
         } catch (err) {
30
             console.error('---')
33
             console.error('---')
31
             this.queue = null
34
             this.queue = null

frontend/src/views/home.vue → frontend/src/views/HomeView.vue Просмотреть файл

1
 <template lang="pug">
1
 <template lang="pug">
2
-sidebar(v-if='!loading' :pid="pid" @updatePid="setPid")
3
 main.f-col.start.w-full
2
 main.f-col.start.w-full
4
-    article#home(v-if='!loading')
3
+    article#home(v-if="!loading")
5
         h1 Queue Page
4
         h1 Queue Page
6
-        profile-card-list(:profiles='swipables' :pid='parseInt(pid)' @reload-queue='getQueue')
5
+        ProfileCardList(:profiles="cards" :pid="pid" @reload-queue="getQueue")
7
     p(v-else) Loading...
6
     p(v-else) Loading...
8
-    main-nav(v-if='!loading' :pid="pid")
7
+    MainNav(:pid="pid" @show-sidebar="$emit('show-sidebar')")
9
 </template>
8
 </template>
10
 
9
 
11
 <script>
10
 <script>
12
-import sidebar from '../components/Sidebar.vue'
13
-import mainNav from '../components/MainNav.vue'
14
-import profileCardList from '../components/ProfileCardList.vue'
11
+import ProfileCardList from '../components/ProfileCardList.vue'
15
 
12
 
16
-import { Chatter, StonkAlert } from '../services'
17
-import { loginHandler, authHandler } from '../utils'
18
-
19
-import batch_10 from '../../../backend/db/generated/_batch_10.js.ref'
20
-import batch_20 from '../../../backend/db/generated/_batch_20.js.ref'
21
-import batch_30 from '../../../backend/db/generated/_batch_30.js.ref'
22
-
23
-const DEFAULT_PID = 45
13
+import { fetchQueueByProfileId } from '../services'
24
 
14
 
25
 export default {
15
 export default {
26
     name: 'HomeView',
16
     name: 'HomeView',
27
-    components: { profileCardList, sidebar, mainNav },
17
+    components: { ProfileCardList },
18
+    props: {
19
+        pid: {
20
+            type: Number,
21
+            required: true
22
+        }
23
+    },
28
     data: () => ({
24
     data: () => ({
29
-        swipables: [],
25
+        cards: [],
30
         loading: true,
26
         loading: true,
31
-        pid: null
32
     }),
27
     }),
33
-    mounted() {
34
-        // Uncomment below to use API
35
-        let pid
36
-        if(!loginHandler.currentProfileId) {
37
-            pid  = authHandler.currentUser?.pid || DEFAULT_PID
38
-        } else {
39
-            pid = loginHandler.currentProfileId
28
+    watch: {
29
+        pid() {
30
+            this.getQueue()
40
         }
31
         }
41
-        this.setPid(pid)
42
-
43
-        // Uncomment below to use for batch file data
44
-        // this.processProfilesFromBatch(this.parseBatch([batch_10, batch_20, batch_30]))
45
-
46
-        this.setupChatter()
47
-        this.setupToaster()
32
+    },
33
+    async created() {
34
+        await this.getQueue()
48
     },
35
     },
49
     methods: {
36
     methods: {
50
-        setPid(pid) {
51
-            loginHandler.login(pid)
52
-            this.pid = loginHandler.currentProfileId
53
-            this.getQueue()
37
+         _reformatProfiles(profiles) {
38
+            return profiles.map(profile => {
39
+                return {
40
+                    pid: profile.profile_id,
41
+                    name: profile.user_name,
42
+                    avatar: profile.user_media,
43
+                }
44
+            })
54
         },
45
         },
55
         async getQueue() {
46
         async getQueue() {
56
             this.loading = true
47
             this.loading = true
57
             try {
48
             try {
58
-                await loginHandler.getQueue()
59
-                this.swipables = loginHandler.queue
49
+                const queueList = await fetchQueueByProfileId(this.pid)
50
+                this.cards = this._reformatProfiles(queueList)
60
             } catch (err) {
51
             } catch (err) {
61
                 console.error(err)
52
                 console.error(err)
62
             }
53
             }
63
             this.loading = false
54
             this.loading = false
64
         },
55
         },
65
-        // For push notifications and chat 
66
-        setupToaster() {
67
-            const t = new StonkAlert(this.pid)
68
-        },
69
-        setupChatter() {
70
-            const c = new Chatter()
71
-            const testAccountUUID = import.meta.env.VITE_TEST_ACCOUNT_UUID
72
-            c.setup(testAccountUUID)
73
-            console.log('---')
74
-        },
56
+        
75
         // For Batch Data Parsing & Processing
57
         // For Batch Data Parsing & Processing
76
-        parseBatch(allBatches) {
58
+        _parseBatch(allBatches) {
77
             const finished = { profiles: [], users: [], responses: [] }
59
             const finished = { profiles: [], users: [], responses: [] }
78
             allBatches.forEach(batch => {
60
             allBatches.forEach(batch => {
79
                 const split = batch.value.split('\n')
61
                 const split = batch.value.split('\n')
87
             // console.log('parsed batch', finished)
69
             // console.log('parsed batch', finished)
88
             return finished
70
             return finished
89
         },
71
         },
90
-        processProfilesFromBatch(parsed) {
72
+        _processProfilesFromBatch(parsed) {
91
             const findUser = profile => {
73
             const findUser = profile => {
92
                 return parsed.users.filter(u => u.user_id == profile.user_id)[0]
74
                 return parsed.users.filter(u => u.user_id == profile.user_id)[0]
93
             }
75
             }

+ 10
- 14
frontend/src/views/Matches.vue Просмотреть файл

1
 <template lang="pug">
1
 <template lang="pug">
2
-sidebar(:pid="pid")
3
 main.f-col.start.w-full
2
 main.f-col.start.w-full
4
     article.match(v-if='!loading')
3
     article.match(v-if='!loading')
5
         h1 Match Page
4
         h1 Match Page
6
-        profile-card-list(:profiles='profiles' :pid='parseInt(pid)' :is-grid="true")
7
-    main-nav(:pid="pid")
5
+        ProfileCardList(:profiles='profiles' :pid='parseInt(pid)' :is-grid="true")
6
+    MainNav(:pid="pid" @show-sidebar="$emit('show-sidebar')")
8
 </template>
7
 </template>
9
 
8
 
10
 <script>
9
 <script>
11
-import sidebar from '../components/Sidebar.vue'
12
-import mainNav from '../components/MainNav.vue'
13
-import profileCardList from '../components/ProfileCardList.vue'
10
+import ProfileCardList from '../components/ProfileCardList.vue'
14
 import { loginHandler } from '../utils'
11
 import { loginHandler } from '../utils'
15
 import { fetchMembershipsByProfileId } from '../services'
12
 import { fetchMembershipsByProfileId } from '../services'
16
 
13
 
17
-// import icon from '@/components/icon.vue'
18
-// import card from '@/components/card.vue'
19
-
20
 export default {
14
 export default {
21
-    components: { profileCardList, sidebar, mainNav },
15
+    components: { ProfileCardList },
16
+    props: {
17
+        pid: {
18
+            type: Number,
19
+            required: true
20
+        }
21
+    },
22
     data: () => ({
22
     data: () => ({
23
         matches: null,
23
         matches: null,
24
         loading: true
24
         loading: true
33
                     name: m.profile.user_name,
33
                     name: m.profile.user_name,
34
                 }
34
                 }
35
             })
35
             })
36
-        },
37
-        pid: () => {
38
-            return loginHandler.currentProfileId
39
         }
36
         }
40
     },
37
     },
41
     methods: {
38
     methods: {
42
         async getMatches() {
39
         async getMatches() {
43
             this.loading = true
40
             this.loading = true
44
             try {
41
             try {
45
-                console.log('loginHandler.currentProfileId :', loginHandler.currentProfileId)
46
                 this.matches = await fetchMembershipsByProfileId(this.pid)
42
                 this.matches = await fetchMembershipsByProfileId(this.pid)
47
             } catch (err) {
43
             } catch (err) {
48
                 console.error(err)
44
                 console.error(err)

+ 6
- 11
frontend/src/views/Profile.vue Просмотреть файл

1
 <template lang="pug">
1
 <template lang="pug">
2
-sidebar
3
 main.f-col.start.w-full
2
 main.f-col.start.w-full
4
     article#profile
3
     article#profile
5
         h1 Profile Page
4
         h1 Profile Page
7
 </template>
6
 </template>
8
 
7
 
9
 <script>
8
 <script>
10
-import sidebar from '../components/Sidebar.vue'
11
-import mainNav from '../components/MainNav.vue'
12
-import { loginHandler } from '../utils'
13
-
14
 export default {
9
 export default {
15
     name: 'Profile',
10
     name: 'Profile',
16
-    components: { sidebar, mainNav },
11
+    props: {
12
+        pid: {
13
+            type: Number,
14
+            required: true
15
+        }
16
+    },
17
     data() {
17
     data() {
18
         return {
18
         return {
19
             requesting: false,
19
             requesting: false,
25
             },
25
             },
26
         }
26
         }
27
     },
27
     },
28
-    computed: {
29
-        pid: () => {
30
-            return loginHandler.currentProfileId
31
-        }
32
-    },
33
     created() {
28
     created() {
34
         this.getUser()
29
         this.getUser()
35
     },
30
     },

+ 12
- 15
frontend/src/views/Survey.vue Просмотреть файл

1
 <template lang="pug">
1
 <template lang="pug">
2
-sidebar(:pid="pid")
3
 main.f-col.start.w-full
2
 main.f-col.start.w-full
4
     article.match
3
     article.match
5
         h1 Survey Page
4
         h1 Survey Page
6
-        siimeform(v-if="validSurvey && validSurvey.steps" :form="validSurvey.steps" :pid="pid")
7
-    main-nav(:pid="pid")
5
+        SurveyForm(v-if="validSurvey && validSurvey.steps" :form="validSurvey.steps" :pid="pid")
6
+    MainNav(:pid="pid" @show-sidebar="$emit('show-sidebar')")
8
 </template>
7
 </template>
9
 
8
 
10
 <script>
9
 <script>
11
-import siimeform from '../components/form.vue'
12
-import sidebar from '../components/Sidebar.vue'
13
-import mainNav from '../components/MainNav.vue'
10
+import SurveyForm from '../components/form.vue'
14
 import { fetchSurveyByProfileId } from '../services'
11
 import { fetchSurveyByProfileId } from '../services'
15
-import { loginHandler } from '../utils'
16
 
12
 
17
 export default {
13
 export default {
18
-    components: { siimeform, sidebar, mainNav },
14
+    components: { SurveyForm },
15
+    props: {
16
+        pid: {
17
+            type: Number,
18
+            required: true
19
+        }
20
+    },
19
     data() {
21
     data() {
20
         return { 
22
         return { 
21
             validSurvey: null,
23
             validSurvey: null,
22
         }
24
         }
23
     },
25
     },
24
-    computed: {
25
-        pid() {
26
-            return loginHandler.currentProfileId
27
-        }
28
-    },
29
     async created() {
26
     async created() {
30
-        console.log('survey for:', this.$route.query.pid)
31
-        this.validSurvey = await fetchSurveyByProfileId(this.$route.query.pid)
27
+        console.log('survey for:', this.pid)
28
+        this.validSurvey = await fetchSurveyByProfileId(this.pid)
32
     },
29
     },
33
 }
30
 }
34
 </script>
31
 </script>

Загрузка…
Отмена
Сохранить