|
|
@@ -1,21 +1,25 @@
|
|
1
|
1
|
<template lang="pug">
|
|
2
|
|
-main.view--home
|
|
3
|
|
- header
|
|
4
|
|
- h2 home - profile: {{ pid }}
|
|
5
|
|
-
|
|
|
2
|
+main.view--home(style="display:flex; flex-direction:column; gap: 40px; margin-top: 1em;")
|
|
|
3
|
+ h2 Match Queue
|
|
6
|
4
|
article(v-if="cards.length && !loading")
|
|
7
|
5
|
ProfileCardList(:profiles="cards" :pid="pid" @reload="getCards")
|
|
8
|
6
|
|
|
9
|
7
|
p(v-else) Loading...
|
|
10
|
8
|
|
|
11
|
|
- MainNav(@show-sidebar="$emit('show-sidebar')")
|
|
|
9
|
+ h2 Matches
|
|
|
10
|
+ article(v-if="matches.length && !loading")
|
|
|
11
|
+ ProfileCardList(:profiles="matches" :pid="pid" @reload="getCards")
|
|
|
12
|
+
|
|
|
13
|
+ p(v-else-if="matches.length===0") No matches.
|
|
|
14
|
+ p(v-else) Loading...
|
|
|
15
|
+
|
|
12
|
16
|
</template>
|
|
13
|
17
|
|
|
14
|
18
|
<script>
|
|
15
|
19
|
import ProfileCardList from '../components/ProfileCardList.vue'
|
|
16
|
20
|
|
|
17
|
21
|
import { Card } from '../entities'
|
|
18
|
|
-import { fetchQueueByProfileId } from '../services'
|
|
|
22
|
+import { fetchQueueByProfileId, fetchMembershipsByProfileId } from '../services'
|
|
19
|
23
|
import { mixins } from '../utils'
|
|
20
|
24
|
|
|
21
|
25
|
/** Callback used to format incoming into card */
|
|
|
@@ -33,6 +37,20 @@ const convertToCard = profile => {
|
|
33
|
37
|
})
|
|
34
|
38
|
}
|
|
35
|
39
|
|
|
|
40
|
+const converGroupingToCard = grouping => {
|
|
|
41
|
+ if (grouping.type !== 'grouping') {
|
|
|
42
|
+ console.error(`Cannot convert ${grouping} to Card. Invalid entity.`)
|
|
|
43
|
+ }
|
|
|
44
|
+ if (!grouping.profile.isValid()) {
|
|
|
45
|
+ console.warn(`Profile in ${grouping} is not a valid profile.`)
|
|
|
46
|
+ }
|
|
|
47
|
+ return new Card({
|
|
|
48
|
+ pid: grouping.profile.profile_id,
|
|
|
49
|
+ name: grouping.profile.user_name,
|
|
|
50
|
+ avatar: grouping.profile.profile_media[0],
|
|
|
51
|
+ })
|
|
|
52
|
+}
|
|
|
53
|
+
|
|
36
|
54
|
export default {
|
|
37
|
55
|
name: 'HomeView',
|
|
38
|
56
|
components: { ProfileCardList },
|
|
|
@@ -44,6 +62,8 @@ export default {
|
|
44
|
62
|
try {
|
|
45
|
63
|
const queueList = await fetchQueueByProfileId(this.pid)
|
|
46
|
64
|
this.cards = this._reformat(queueList, convertToCard)
|
|
|
65
|
+ const matchList = await fetchMembershipsByProfileId(this.pid)
|
|
|
66
|
+ this.matches = this._reformat(matchList, converGroupingToCard)
|
|
47
|
67
|
} catch (err) {
|
|
48
|
68
|
console.error(err)
|
|
49
|
69
|
}
|