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.

ProfileCardList.vue 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template lang="pug">
  2. section.profile-card-list.xs12.w-flex.column
  3. header.xs12.w-flex
  4. w-select(:items="['one', 'two', 'three']" outline) Label
  5. article
  6. ProfileCard.match-layout(
  7. v-for="(card, i) in cards"
  8. :key="`${card.pid}-${i}`"
  9. :card="card" :aspects="aspects" :bio="bio" :is-list="true"
  10. )
  11. </template>
  12. <script setup>
  13. import { ref } from 'vue'
  14. import { useRouter } from 'vue-router'
  15. import {
  16. updateQueueByProfileId,
  17. postMembershipByProfileId,
  18. currentProfile,
  19. } from '../services'
  20. import ProfileCard from './ProfileCard.vue'
  21. class Aspect {
  22. constructor({ name, labels, percentage = 50 }) {
  23. this.name = name
  24. this.labels = labels
  25. this.percentage = percentage
  26. }
  27. }
  28. const aspects = ref([
  29. new Aspect({ name: 'creativity', labels: ['creative', 'methodical'] }),
  30. new Aspect({ name: 'dynamism', labels: ['dynamic', 'ordered'] }),
  31. new Aspect({ name: 'precision', labels: ['precise', 'resourceful'] }),
  32. new Aspect({ name: 'vision', labels: ['visionary', 'implementer'] }),
  33. new Aspect({ name: 'focus', labels: ['big picture', 'focused'] }),
  34. new Aspect({ name: 'attention', labels: ['guided', 'self-managed'] }),
  35. ])
  36. const bio = ref(
  37. 'this is a long descriptionthis is a long descriptionthis is a long descriptionthis is a long descriptionthis is a long descriptionthis is a long descriptionthis is a long descriptionthis is a long descriptionthis is a long descriptionthis is a long descriptionthis is a long descriptionthis is a long descriptionthis is a long descriptionthis is a long descriptionthis is a long descriptionthis is a long descriptionthis is a long descriptionthis is a long descriptionthis is a long descriptionthis is a long descriptionthis is a long descriptionthis is a long descriptionthis is a long descriptionthis is a long descriptionthis is a long descriptionthis is a long descriptionthis is a long descriptionthis is a long descriptionthis is a long descriptionthis is a long descriptionthis is a long descriptionthis is a long descriptionthis is a long descriptionthis is a long descriptionthis is a long description',
  38. )
  39. const router = useRouter()
  40. const emit = defineEmits(['reload'])
  41. const props = defineProps({
  42. cards: {
  43. type: [Object, Array],
  44. default: () => [
  45. {
  46. pid: '1',
  47. name: 'Full Name',
  48. avatar: 'https://hips.hearstapps.com/hmg-prod.s3.amazonaws.com/images/newborn-baby-boy-sleeping-peacefully-wearing-knit-royalty-free-image-1589459736.jpg?crop=0.669xw:1.00xh;0.228xw,0&resize=640:*',
  49. metadata: { age: '21', rawMetadata: 'Some Text Here!' },
  50. },
  51. ],
  52. },
  53. pid: {
  54. type: Number,
  55. default: 9999,
  56. },
  57. isGrid: {
  58. type: Boolean,
  59. },
  60. })
  61. // AHP Button behavior
  62. const accept = async targetId => {
  63. if (targetId == props.pid) return
  64. // need to pass these arguments (profileId, targetId, status)
  65. // the url structure is
  66. // const charmander = await db.get(`/profile/{profile_id}/queue/{target_id}/delete?include_profile=true&reinsert=false`)
  67. // http://localhost:3001/api/profile/38/queue/9/delete?include_profile=true&reinsert=true
  68. const profileId = props.pid
  69. await updateQueueByProfileId(profileId, targetId, false)
  70. const { membershipMatch, groupingName } = await postMembershipByProfileId({
  71. profileId,
  72. targetId,
  73. })
  74. // Reuse old grouping name if theres a match
  75. let channel = groupingName
  76. if (membershipMatch?.hasMatch) {
  77. channel = membershipMatch.groupings[0].grouping_name
  78. }
  79. await subscribeToChannel(channel)
  80. emit('reload')
  81. }
  82. const view = pid => {
  83. router.push({ path: `/matches/${pid}` })
  84. }
  85. const subscribeToChannel = async channelName => {
  86. // create a chatter reference from the current profile
  87. const chatter = currentProfile.chatter
  88. /**
  89. * publish a new message to the chatter with the channel and the message & title is optional
  90. */
  91. // You MUST send chatter channels as an array in an object
  92. chatter.subscribe({ channels: [channelName] })
  93. const res = await chatter.publish(channelName, {
  94. title: 'New Message',
  95. description: `This is the checking to see if we are subscribed to the ${channelName} channel!`,
  96. })
  97. // PubNub response will be a timecode of when the message was published
  98. //router.push({ path: `/chat/${pid}` })
  99. }
  100. const pass = targetId => {
  101. if (targetId == props.pid) return
  102. updateQueueByProfileId(props.pid, targetId, true)
  103. emit('reload')
  104. }
  105. </script>