Explorar el Código

:recycle: more tweaks | using login to manage queue | stubbed out to manage survey and matches

tags/0.0.1
J hace 4 años
padre
commit
c28bd19962

+ 15
- 1
frontend/src/components/ProfileCardList.vue Ver fichero

2
 section.profile_card_list.w-full
2
 section.profile_card_list.w-full
3
     .profile_card_list_container.w-full
3
     .profile_card_list_container.w-full
4
         .swipe(
4
         .swipe(
5
+            v-if="!isGrid"
5
             :config='config'
6
             :config='config'
6
             :key='profile.pid'
7
             :key='profile.pid'
7
             @throwout='swipped(profile)'
8
             @throwout='swipped(profile)'
20
                     button.p-1(@click='hold') H
21
                     button.p-1(@click='hold') H
21
                     //- Pass
22
                     //- Pass
22
                     button.p-1(@click='pass') Pass
23
                     button.p-1(@click='pass') Pass
24
+        
25
+        .match-layout(
26
+            v-else
27
+            :key='profile.pid'
28
+            v-for='(profile, i) in profiles'
29
+        )
30
+                .card.b-solid.rounded.p-0.bg-cover(
31
+                    :style='{ "background-image": `url(${profile.avatar})` }'
32
+                )
33
+                .card__content
34
+                    h3.p-1.mv-0.b-solid.rounded {{ profile.pid  }} {{ profile.name }}
23
 </template>
35
 </template>
24
 
36
 
25
 <script setup>
37
 <script setup>
46
         type: Number,
58
         type: Number,
47
         default: 9999,
59
         default: 9999,
48
     },
60
     },
61
+    isGrid: {
62
+        type: Boolean
63
+    }
49
 })
64
 })
50
 // from the computed section
65
 // from the computed section
51
 const currentCard = computed(() => props.profiles[props.profiles.length - 1]);
66
 const currentCard = computed(() => props.profiles[props.profiles.length - 1]);
116
 .profile_card_list_container
131
 .profile_card_list_container
117
     display: flex
132
     display: flex
118
     justify-content: center
133
     justify-content: center
119
-    margin: 5vh 0 0 0
120
 
134
 
121
 .swipe
135
 .swipe
122
     position: absolute
136
     position: absolute

+ 1
- 0
frontend/src/entities/grouping/grouping.schema.js Ver fichero

20
         grouping_id: Joi.number().required(),
20
         grouping_id: Joi.number().required(),
21
         grouping_name: Joi.string(),
21
         grouping_name: Joi.string(),
22
         grouping_type: Joi.string(),
22
         grouping_type: Joi.string(),
23
+        profile: Joi.object()
23
     }),
24
     }),
24
     /** fields required before saving */
25
     /** fields required before saving */
25
     required: ['grouping_id'],
26
     required: ['grouping_id'],

+ 2
- 0
frontend/src/services/index.js Ver fichero

2
 export * from './grouping.service'
2
 export * from './grouping.service'
3
 export * from './survey.service'
3
 export * from './survey.service'
4
 export * from './queue.service'
4
 export * from './queue.service'
5
+export * from './chat.service'
6
+export * from './notification.service'

+ 10
- 5
frontend/src/services/queue.service.js Ver fichero

3
 
3
 
4
 // TODO: queue services
4
 // TODO: queue services
5
 const fetchQueueByProfileId = async profileId => {
5
 const fetchQueueByProfileId = async profileId => {
6
-    const queue = await db.get(
7
-        `/profile/${profileId}/queue?include_profile=true`,
8
-    )
6
+    let queue
9
     
7
     
10
-    if(!queue?.length) {
11
-        console.error('could not retrieve match queue. Please take the survey and rescore.')
8
+    try {
9
+        queue = await db.get(
10
+            `/profile/${profileId}/queue?include_profile=true`,
11
+        )
12
+        if(!queue?.length) {
13
+            throw 'could not retrieve match queue. Please take the survey and rescore.'
14
+        }
15
+    } catch (err) {
16
+        console.error(err)
12
     }
17
     }
13
 
18
 
14
     return queue ? queue.map(profileData => {
19
     return queue ? queue.map(profileData => {

+ 45
- 1
frontend/src/utils/login.js Ver fichero

1
+import { fetchQueueByProfileId } from '../services'
2
+
1
 class Login {
3
 class Login {
2
     constructor() {
4
     constructor() {
3
         this.currentProfileId = null
5
         this.currentProfileId = null
6
+        this.survey = null
7
+        this.queue = null
8
+        this.matches = null
9
+    }
10
+    hasSurvey() {
11
+        return this.survey.length ? true : false 
12
+    }
13
+    hasQueue() {
14
+        return this.queue.length ? true : false 
15
+    }
16
+    hasMatches() {
17
+        return this.matches.length ? true : false 
18
+    }
19
+
20
+    _setSurvey(survey) {
21
+        this.survey = []
4
     }
22
     }
23
+
24
+    async getQueue() {
25
+        try {
26
+            const queueList = await fetchQueueByProfileId(this.currentProfileId)
27
+            const formatted = this._reformatProfiles(queueList)
28
+            this._setQueue(formatted)
29
+        } catch (err) {
30
+            console.error('---')
31
+            this.queue = null
32
+            console.error(err)
33
+        }
34
+    }
35
+    _reformatProfiles(profiles) {
36
+        const formattedList = profiles.map(profile => {
37
+            return {
38
+                pid: profile.profile_id,
39
+                name: profile.user_name,
40
+                avatar: profile.user_media,
41
+            }
42
+        })
43
+        return formattedList
44
+    }
45
+    _setQueue(queue) {
46
+        this.queue = queue
47
+    }
48
+
5
     logout() {
49
     logout() {
6
         this.currentProfileId = null
50
         this.currentProfileId = null
7
     }
51
     }
8
-    login(pid) {
52
+    async login(pid) {
9
         this.currentProfileId = parseInt(pid)
53
         this.currentProfileId = parseInt(pid)
10
     }
54
     }
11
 }
55
 }

+ 35
- 3
frontend/src/views/Matches.vue Ver fichero

1
 <template lang="pug">
1
 <template lang="pug">
2
-sidebar
2
+sidebar(:pid="pid")
3
 main.f-col.start.w-full
3
 main.f-col.start.w-full
4
-    article.match
4
+    article.match(v-if='!loading')
5
         h1 Match Page
5
         h1 Match Page
6
+        profile-card-list(:profiles='profiles' :pid='parseInt(pid)' :is-grid="true")
6
     main-nav(:pid="pid")
7
     main-nav(:pid="pid")
7
 </template>
8
 </template>
8
 
9
 
9
 <script>
10
 <script>
10
 import sidebar from '../components/Sidebar.vue'
11
 import sidebar from '../components/Sidebar.vue'
11
 import mainNav from '../components/MainNav.vue'
12
 import mainNav from '../components/MainNav.vue'
13
+import profileCardList from '../components/ProfileCardList.vue'
12
 import { loginHandler } from '../utils'
14
 import { loginHandler } from '../utils'
15
+import { fetchMembershipsByProfileId } from '../services'
13
 
16
 
14
 // import icon from '@/components/icon.vue'
17
 // import icon from '@/components/icon.vue'
15
 // import card from '@/components/card.vue'
18
 // import card from '@/components/card.vue'
16
 
19
 
17
 export default {
20
 export default {
18
-    components: { sidebar, mainNav },
21
+    components: { profileCardList, sidebar, mainNav },
22
+    data: () => ({
23
+        matches: null,
24
+        loading: true
25
+    }),
19
     computed: {
26
     computed: {
27
+        profiles() {
28
+            if(this.loading || this.matches.length < 1) return []
29
+            return this.matches.map(m => {
30
+                return {
31
+                    pid: m.profile.profile_id,
32
+                    avatar: m.profile.user_media,
33
+                    name: m.profile.user_name,
34
+                }
35
+            })
36
+        },
20
         pid: () => {
37
         pid: () => {
21
             return loginHandler.currentProfileId
38
             return loginHandler.currentProfileId
22
         }
39
         }
23
     },
40
     },
41
+    methods: {
42
+        async getMatches() {
43
+            this.loading = true
44
+            try {
45
+                console.log('loginHandler.currentProfileId :', loginHandler.currentProfileId)
46
+                this.matches = await fetchMembershipsByProfileId(this.pid)
47
+            } catch (err) {
48
+                console.error(err)
49
+            }
50
+            this.loading = false
51
+        },
52
+    },
53
+    mounted() {
54
+        this.getMatches()
55
+    }
24
 }
56
 }
25
 </script>
57
 </script>
26
 
58
 

+ 2
- 2
frontend/src/views/Survey.vue Ver fichero

1
 <template lang="pug">
1
 <template lang="pug">
2
-sidebar
2
+sidebar(:pid="pid")
3
 main.f-col.start.w-full
3
 main.f-col.start.w-full
4
     article.match
4
     article.match
5
         h1 Survey Page
5
         h1 Survey Page
22
         }
22
         }
23
     },
23
     },
24
     computed: {
24
     computed: {
25
-        pid: () => {
25
+        pid() {
26
             return loginHandler.currentProfileId
26
             return loginHandler.currentProfileId
27
         }
27
         }
28
     },
28
     },

+ 7
- 25
frontend/src/views/home.vue Ver fichero

21
 import batch_20 from '../../../backend/db/generated/_batch_20.js.ref'
21
 import batch_20 from '../../../backend/db/generated/_batch_20.js.ref'
22
 import batch_30 from '../../../backend/db/generated/_batch_30.js.ref'
22
 import batch_30 from '../../../backend/db/generated/_batch_30.js.ref'
23
 
23
 
24
+const DEFAULT_PID = 45
25
+
24
 export default {
26
 export default {
25
     name: 'HomeView',
27
     name: 'HomeView',
26
     components: { profileCardList, sidebar, mainNav },
28
     components: { profileCardList, sidebar, mainNav },
31
     }),
33
     }),
32
     mounted() {
34
     mounted() {
33
         // Uncomment below to use API
35
         // Uncomment below to use API
34
-        let pid = null
36
+        let pid
35
         if(!loginHandler.currentProfileId) {
37
         if(!loginHandler.currentProfileId) {
36
-            pid  = authHandler.currentUser?.pid || 45
38
+            pid  = authHandler.currentUser?.pid || DEFAULT_PID
37
         } else {
39
         } else {
38
             pid = loginHandler.currentProfileId
40
             pid = loginHandler.currentProfileId
39
         }
41
         }
46
         this.setupToaster()
48
         this.setupToaster()
47
     },
49
     },
48
     methods: {
50
     methods: {
49
-        setupToaster() {
50
-            const t = new StonkAlert(this.pid)
51
-        },
52
-        setupChatter() {
53
-            const c = new Chatter()
54
-            const testAccountUUID = import.meta.env.VITE_TEST_ACCOUNT_UUID
55
-            c.setup(testAccountUUID)
56
-            console.log('---')
57
-        },
58
         setPid(pid) {
51
         setPid(pid) {
59
             loginHandler.login(pid)
52
             loginHandler.login(pid)
60
             this.pid = loginHandler.currentProfileId
53
             this.pid = loginHandler.currentProfileId
63
         async getQueue() {
56
         async getQueue() {
64
             this.loading = true
57
             this.loading = true
65
             try {
58
             try {
66
-                const queueList = await fetchQueueByProfileId(this.pid)
67
-                this.processQueue(queueList)
59
+                await loginHandler.getQueue()
60
+                this.swipables = loginHandler.queue
68
             } catch (err) {
61
             } catch (err) {
69
                 console.error(err)
62
                 console.error(err)
70
             }
63
             }
71
             this.loading = false
64
             this.loading = false
72
         },
65
         },
66
+        // For push notifications and chat 
73
         setupToaster() {
67
         setupToaster() {
74
             const t = new StonkAlert(this.pid)
68
             const t = new StonkAlert(this.pid)
75
         },
69
         },
79
             c.setup(testAccountUUID)
73
             c.setup(testAccountUUID)
80
             console.log('---')
74
             console.log('---')
81
         },
75
         },
82
-        processQueue(queueList) {
83
-            const formattedList = []
84
-            queueList.forEach(profile => {
85
-                const formatted = {
86
-                        pid: profile.profile_id,
87
-                        name: profile.user_name,
88
-                        avatar: profile.user_media,
89
-                    }
90
-                formattedList.push(formatted)
91
-            })
92
-            this.swipables = formattedList
93
-        },
94
         // For Batch Data Parsing & Processing
76
         // For Batch Data Parsing & Processing
95
         parseBatch(allBatches) {
77
         parseBatch(allBatches) {
96
             const finished = { profiles: [], users: [], responses: [] }
78
             const finished = { profiles: [], users: [], responses: [] }

Loading…
Cancelar
Guardar