You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ProfileCardList.vue 3.7KB

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