Преглед изворни кода

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

tags/0.0.1
J пре 4 година
родитељ
комит
c28bd19962

+ 15
- 1
frontend/src/components/ProfileCardList.vue Прегледај датотеку

@@ -2,6 +2,7 @@
2 2
 section.profile_card_list.w-full
3 3
     .profile_card_list_container.w-full
4 4
         .swipe(
5
+            v-if="!isGrid"
5 6
             :config='config'
6 7
             :key='profile.pid'
7 8
             @throwout='swipped(profile)'
@@ -20,6 +21,17 @@ section.profile_card_list.w-full
20 21
                     button.p-1(@click='hold') H
21 22
                     //- Pass
22 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 35
 </template>
24 36
 
25 37
 <script setup>
@@ -46,6 +58,9 @@ const props = defineProps({
46 58
         type: Number,
47 59
         default: 9999,
48 60
     },
61
+    isGrid: {
62
+        type: Boolean
63
+    }
49 64
 })
50 65
 // from the computed section
51 66
 const currentCard = computed(() => props.profiles[props.profiles.length - 1]);
@@ -116,7 +131,6 @@ const requests = []
116 131
 .profile_card_list_container
117 132
     display: flex
118 133
     justify-content: center
119
-    margin: 5vh 0 0 0
120 134
 
121 135
 .swipe
122 136
     position: absolute

+ 1
- 0
frontend/src/entities/grouping/grouping.schema.js Прегледај датотеку

@@ -20,6 +20,7 @@ const groupingSchema = {
20 20
         grouping_id: Joi.number().required(),
21 21
         grouping_name: Joi.string(),
22 22
         grouping_type: Joi.string(),
23
+        profile: Joi.object()
23 24
     }),
24 25
     /** fields required before saving */
25 26
     required: ['grouping_id'],

+ 2
- 0
frontend/src/services/index.js Прегледај датотеку

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

+ 10
- 5
frontend/src/services/queue.service.js Прегледај датотеку

@@ -3,12 +3,17 @@ import { Profile } from '../entities'
3 3
 
4 4
 // TODO: queue services
5 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 19
     return queue ? queue.map(profileData => {

+ 45
- 1
frontend/src/utils/login.js Прегледај датотеку

@@ -1,11 +1,55 @@
1
+import { fetchQueueByProfileId } from '../services'
2
+
1 3
 class Login {
2 4
     constructor() {
3 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 49
     logout() {
6 50
         this.currentProfileId = null
7 51
     }
8
-    login(pid) {
52
+    async login(pid) {
9 53
         this.currentProfileId = parseInt(pid)
10 54
     }
11 55
 }

+ 35
- 3
frontend/src/views/Matches.vue Прегледај датотеку

@@ -1,26 +1,58 @@
1 1
 <template lang="pug">
2
-sidebar
2
+sidebar(:pid="pid")
3 3
 main.f-col.start.w-full
4
-    article.match
4
+    article.match(v-if='!loading')
5 5
         h1 Match Page
6
+        profile-card-list(:profiles='profiles' :pid='parseInt(pid)' :is-grid="true")
6 7
     main-nav(:pid="pid")
7 8
 </template>
8 9
 
9 10
 <script>
10 11
 import sidebar from '../components/Sidebar.vue'
11 12
 import mainNav from '../components/MainNav.vue'
13
+import profileCardList from '../components/ProfileCardList.vue'
12 14
 import { loginHandler } from '../utils'
15
+import { fetchMembershipsByProfileId } from '../services'
13 16
 
14 17
 // import icon from '@/components/icon.vue'
15 18
 // import card from '@/components/card.vue'
16 19
 
17 20
 export default {
18
-    components: { sidebar, mainNav },
21
+    components: { profileCardList, sidebar, mainNav },
22
+    data: () => ({
23
+        matches: null,
24
+        loading: true
25
+    }),
19 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 37
         pid: () => {
21 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 57
 </script>
26 58
 

+ 2
- 2
frontend/src/views/Survey.vue Прегледај датотеку

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

+ 7
- 25
frontend/src/views/home.vue Прегледај датотеку

@@ -21,6 +21,8 @@ import batch_10 from '../../../backend/db/generated/_batch_10.js.ref'
21 21
 import batch_20 from '../../../backend/db/generated/_batch_20.js.ref'
22 22
 import batch_30 from '../../../backend/db/generated/_batch_30.js.ref'
23 23
 
24
+const DEFAULT_PID = 45
25
+
24 26
 export default {
25 27
     name: 'HomeView',
26 28
     components: { profileCardList, sidebar, mainNav },
@@ -31,9 +33,9 @@ export default {
31 33
     }),
32 34
     mounted() {
33 35
         // Uncomment below to use API
34
-        let pid = null
36
+        let pid
35 37
         if(!loginHandler.currentProfileId) {
36
-            pid  = authHandler.currentUser?.pid || 45
38
+            pid  = authHandler.currentUser?.pid || DEFAULT_PID
37 39
         } else {
38 40
             pid = loginHandler.currentProfileId
39 41
         }
@@ -46,15 +48,6 @@ export default {
46 48
         this.setupToaster()
47 49
     },
48 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 51
         setPid(pid) {
59 52
             loginHandler.login(pid)
60 53
             this.pid = loginHandler.currentProfileId
@@ -63,13 +56,14 @@ export default {
63 56
         async getQueue() {
64 57
             this.loading = true
65 58
             try {
66
-                const queueList = await fetchQueueByProfileId(this.pid)
67
-                this.processQueue(queueList)
59
+                await loginHandler.getQueue()
60
+                this.swipables = loginHandler.queue
68 61
             } catch (err) {
69 62
                 console.error(err)
70 63
             }
71 64
             this.loading = false
72 65
         },
66
+        // For push notifications and chat 
73 67
         setupToaster() {
74 68
             const t = new StonkAlert(this.pid)
75 69
         },
@@ -79,18 +73,6 @@ export default {
79 73
             c.setup(testAccountUUID)
80 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 76
         // For Batch Data Parsing & Processing
95 77
         parseBatch(allBatches) {
96 78
             const finished = { profiles: [], users: [], responses: [] }

Loading…
Откажи
Сачувај