|
|
@@ -5,10 +5,11 @@ main.view--matches
|
|
5
|
5
|
.matches--paired(:class="currentTab =='paired' ? 'active':'idle'" @click="switchTab('paired')") Paired
|
|
6
|
6
|
|
|
7
|
7
|
article.pa12
|
|
|
8
|
+ //- TODO add and render appropriate lists for both tabs
|
|
8
|
9
|
template(v-if="currentTab=='pending'")
|
|
9
|
|
- p Pending Matches
|
|
|
10
|
+ PairsList(:list='pendingList')
|
|
10
|
11
|
template(v-else)
|
|
11
|
|
- p Paired Matches
|
|
|
12
|
+ PairsList(:list='pairedList')
|
|
12
|
13
|
//- template(v-if='matches.length && !loading')
|
|
13
|
14
|
//- h2 atches
|
|
14
|
15
|
//- ProfileCardList(:pid='pid' :profiles='matches' @reload='getCards')
|
|
|
@@ -20,14 +21,43 @@ main.view--matches
|
|
20
|
21
|
</template>
|
|
21
|
22
|
|
|
22
|
23
|
<script>
|
|
23
|
|
-import ProfileCardList from '../components/ProfileCardList.vue'
|
|
|
24
|
+// import ProfileCardList from '../components/ProfileCardList.vue'
|
|
|
25
|
+import PairsList from '../components/PairsList.vue'
|
|
24
|
26
|
|
|
25
|
|
-import { fetchMembershipsByProfileId } from '../services'
|
|
|
27
|
+import { fetchMembershipsByProfileId, fetchQueueByProfileId } from '../services'
|
|
26
|
28
|
import { mixins } from '../utils'
|
|
27
|
29
|
|
|
|
30
|
+const convertToCard = profile => {
|
|
|
31
|
+ if (profile.type !== 'profile') {
|
|
|
32
|
+ console.error(`Cannot convert ${profile} to Card. Invalid entity.`)
|
|
|
33
|
+ }
|
|
|
34
|
+ if (!profile.isValid()) {
|
|
|
35
|
+ console.warn(`Profile ${profile.profile_id} is not a valid profile.`)
|
|
|
36
|
+ }
|
|
|
37
|
+ return new Card({
|
|
|
38
|
+ pid: profile.profile_id,
|
|
|
39
|
+ name: profile.user_name,
|
|
|
40
|
+ avatar: profile.profile_media[0],
|
|
|
41
|
+ })
|
|
|
42
|
+}
|
|
|
43
|
+
|
|
|
44
|
+const converGroupingToCard = grouping => {
|
|
|
45
|
+ if (grouping.type !== 'grouping') {
|
|
|
46
|
+ console.error(`Cannot convert ${grouping} to Card. Invalid entity.`)
|
|
|
47
|
+ }
|
|
|
48
|
+ if (!grouping.profile.isValid()) {
|
|
|
49
|
+ console.warn(`Profile in ${grouping} is not a valid profile.`)
|
|
|
50
|
+ }
|
|
|
51
|
+ return new Card({
|
|
|
52
|
+ pid: grouping.profile.profile_id,
|
|
|
53
|
+ name: grouping.profile.user_name,
|
|
|
54
|
+ avatar: grouping.profile.profile_media[0],
|
|
|
55
|
+ })
|
|
|
56
|
+}
|
|
|
57
|
+
|
|
28
|
58
|
export default {
|
|
29
|
59
|
name: 'MatchView',
|
|
30
|
|
- components: { ProfileCardList },
|
|
|
60
|
+ components: { PairsList },
|
|
31
|
61
|
mixins: [mixins.pidMixin, mixins.cardMixin],
|
|
32
|
62
|
data: () => ({
|
|
33
|
63
|
currentTab: 'pending'
|
|
|
@@ -37,7 +67,10 @@ export default {
|
|
37
|
67
|
async getCards() {
|
|
38
|
68
|
this.loading = true
|
|
39
|
69
|
try {
|
|
40
|
|
- this.cards = await fetchMembershipsByProfileId(this.pid)
|
|
|
70
|
+ const pending = await fetchQueueByProfileId(this.pid)
|
|
|
71
|
+ this.pendingList = this._reformat(pending,converGroupingToCard)
|
|
|
72
|
+ const paired = await fetchMembershipsByProfileId(this.pid)
|
|
|
73
|
+ this.PairedList = this._reformat(paired,convertToCard)
|
|
41
|
74
|
} catch (err) {
|
|
42
|
75
|
console.error(err)
|
|
43
|
76
|
}
|