Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

ProfileCard.vue 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <template lang="pug">
  2. w-card.profile-card-list--card.xs12
  3. header.xs12.w-flex.column.center
  4. NamePlate(
  5. :is-list='isList'
  6. :is-paired='isPaired'
  7. :name='card.name'
  8. :pid='card.pid'
  9. :pronouns='card.pronouns'
  10. :role='card.role'
  11. )
  12. template(v-if='!isList')
  13. w-button.text-upper.xs12.pa6(v-if='currentTab == 0 && isPaired')
  14. w-icon.mr1(xl) mdi mdi-chat
  15. | start chat
  16. SummaryBar(
  17. :aspects='aspects'
  18. :is-tab='isPaired'
  19. :tab-content='card.summary'
  20. @tab-change='onTab'
  21. )
  22. TagList(v-if='!isPaired || isList')
  23. article.xs12.w-flex.column.justify-space-between
  24. AspectBar(
  25. :key='aspect.name'
  26. :labels='aspect.labels'
  27. :percentage='aspect.percentage'
  28. v-for='aspect in aspects'
  29. v-if='!isPaired || isList'
  30. )
  31. footer
  32. .pa12(v-if='!isPaired && !isList')
  33. p {{ card.summary.about.tab }}
  34. PairingButton(@pair='onPair' @pass='onPass' v-if='!isPaired')
  35. w-button.text-upper.xs12.pa6(v-else-if='currentTab != 0')
  36. w-icon.mr1(xl) mdi mdi-chat
  37. | start chat
  38. </template>
  39. <script setup>
  40. import { ref } from 'vue'
  41. import { useRouter } from 'vue-router'
  42. import {
  43. updateQueueByProfileId,
  44. postMembershipByProfileId,
  45. currentProfile,
  46. } from '../services'
  47. import NamePlate from './NamePlate.vue'
  48. import AspectBar from './AspectBar.vue'
  49. import SummaryBar from './SummaryBar.vue'
  50. import TagList from './TagList.vue'
  51. import PairingButton from './PairingButton.vue'
  52. const router = useRouter()
  53. // const isPaired = ref(true)
  54. const isPaired = ref(false)
  55. const props = defineProps({
  56. card: {
  57. type: Object,
  58. required: true,
  59. },
  60. aspects: {
  61. type: Array,
  62. required: true,
  63. },
  64. isList: {
  65. type: Boolean,
  66. required: false,
  67. default: true,
  68. },
  69. })
  70. /**
  71. * Track tab state for conditional rendering
  72. */
  73. const currentTab = ref(0)
  74. const onTab = tabIndex => {
  75. if (currentTab.value == tabIndex) return
  76. currentTab.value = tabIndex
  77. }
  78. /**
  79. * Attempt to pair with target profile
  80. * Creates a grouping, and a membership
  81. * for both profileId and targetId
  82. */
  83. const onPair = async () => {
  84. const group = await postMembershipByProfileId({
  85. profileId: currentProfile.id.value,
  86. targetId: props.card.pid,
  87. })
  88. updateQueueByProfileId(currentProfile.id.value, props.card.pid, false)
  89. currentProfile.getGroupings()
  90. console.warn('created grouping:', group)
  91. let goToRoute = { name: 'HomeView' }
  92. // if (group.membershipMatch.hasMatch) {
  93. // goToRoute = { name: 'PairsView' }
  94. // }
  95. router.push(goToRoute)
  96. }
  97. /**
  98. * Send to the back of the matchQueue
  99. * and forward back home
  100. */
  101. const onPass = async () => {
  102. updateQueueByProfileId(currentProfile.id.value, props.card.pid, true)
  103. router.push({ name: 'HomeView' })
  104. }
  105. </script>
  106. <style lang="sass">
  107. .profile-card-list--card
  108. background-color: #000
  109. color: #fff
  110. header > .w-button
  111. background-color: #116006
  112. color: #fff
  113. </style>