Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

PairsView.vue 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <template lang="pug">
  2. main.view--pairs
  3. article
  4. template(v-if='isLoading')
  5. w-spinner(bounce)
  6. template(v-else)
  7. w-tabs(:items='tabs' fill-bar slider-color='yellow')
  8. template(#item-title='{ item }')
  9. span {{ item.title }}
  10. //- pending tab
  11. template(#item-content.1='{ item }')
  12. PairsList(:pairs='pending' tab-name='pending')
  13. //- paired tab
  14. template(#item-content.2='{ item }')
  15. PairsList(:pairs='paired' tab-name='paired')
  16. MainNav
  17. </template>
  18. <script>
  19. import { Card } from '../entities'
  20. import PairsList from '../components/PairsList.vue'
  21. import { currentProfile } from '../services'
  22. import { mixins } from '../utils'
  23. const convertGroupingToCard = grouping => {
  24. if (grouping.type !== 'grouping') {
  25. console.error(`Cannot convert ${grouping} to Card. Invalid entity.`)
  26. }
  27. if (!grouping.profile.isValid()) {
  28. console.warn(`Profile in ${grouping} is not a valid profile.`)
  29. }
  30. return {
  31. profile: new Card({
  32. pid: grouping.profile.profile_id,
  33. name: grouping.profile.user_name,
  34. avatar: grouping.profile.profile_media[0],
  35. }),
  36. grouping,
  37. }
  38. }
  39. export default {
  40. name: 'PairsView',
  41. components: { PairsList },
  42. mixins: [mixins.profileMixin],
  43. data: () => ({
  44. tabs: [{ title: 'Pending' }, { title: 'Paired' }],
  45. }),
  46. computed: {
  47. pending() {
  48. if (!this.isLoggedIn || !currentProfile.pendingGroupings) return []
  49. return this._reformat(
  50. currentProfile.pendingGroupings,
  51. convertGroupingToCard,
  52. )
  53. },
  54. paired() {
  55. if (!this.isLoggedIn || !currentProfile.pairedGroupings) return []
  56. return this._reformat(
  57. currentProfile.pairedGroupings,
  58. convertGroupingToCard,
  59. )
  60. },
  61. },
  62. methods: {
  63. _reformat(data, mapCb) {
  64. return data.map(mapCb)
  65. },
  66. },
  67. }
  68. </script>
  69. <style lang="sass">
  70. .view--pairs
  71. max-width: 450px
  72. width: 100%
  73. margin: 0 auto
  74. background-color: #1F2024
  75. .w-tabs
  76. &__bar-item
  77. height: 50px
  78. font-family: 'Century Gothic'
  79. color: #FFFFFF
  80. &.primary
  81. color: #F2CD5C
  82. .select--matches
  83. display: flex
  84. justify-content: space-between
  85. margin: 0 25px
  86. > div
  87. width: 100%
  88. text-align: center
  89. font-size: 16px
  90. line-height: 40px
  91. .active
  92. border-bottom: 3px solid #f2cd5c
  93. color: #f2cd5c
  94. .idle
  95. color: #bcc5d3
  96. </style>