Team.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <template>
  2. <div class="border border-dividerLight rounded flex flex-1 items-end">
  3. <div class="flex flex-1 items-start">
  4. <div class="p-4">
  5. <label
  6. class="cursor-pointer transition hover:text-secondaryDark"
  7. @click="team.myRole === 'OWNER' ? $emit('edit-team') : ''"
  8. >
  9. {{ team.name || $t("state.nothing_found") }}
  10. </label>
  11. <div class="flex -space-x-1 mt-2 overflow-hidden">
  12. <img
  13. v-for="(member, index) in team.members"
  14. :key="`member-${index}`"
  15. v-tippy="{ theme: 'tooltip' }"
  16. :title="member.user.displayName"
  17. :src="member.user.photoURL"
  18. :alt="member.user.displayName"
  19. class="rounded-full h-5 ring-primary ring-2 w-5 inline-block"
  20. />
  21. </div>
  22. </div>
  23. </div>
  24. <span>
  25. <tippy ref="options" interactive trigger="click" theme="popover" arrow>
  26. <template #trigger>
  27. <ButtonSecondary
  28. v-tippy="{ theme: 'tooltip' }"
  29. :title="$t('action.more')"
  30. svg="more-vertical"
  31. />
  32. </template>
  33. <SmartItem
  34. v-if="team.myRole === 'OWNER'"
  35. svg="edit"
  36. :label="$t('action.edit')"
  37. @click.native="
  38. () => {
  39. $emit('edit-team')
  40. $refs.options.tippy().hide()
  41. }
  42. "
  43. />
  44. <SmartItem
  45. v-if="team.myRole === 'OWNER'"
  46. svg="trash-2"
  47. color="red"
  48. :label="$t('action.delete')"
  49. @click.native="
  50. () => {
  51. deleteTeam()
  52. $refs.options.tippy().hide()
  53. }
  54. "
  55. />
  56. <SmartItem
  57. v-if="!(team.myRole === 'OWNER' && team.ownersCount == 1)"
  58. svg="trash"
  59. :label="$t('team.exit')"
  60. @click.native="
  61. () => {
  62. exitTeam()
  63. $refs.options.tippy().hide()
  64. }
  65. "
  66. />
  67. </tippy>
  68. </span>
  69. </div>
  70. </template>
  71. <script>
  72. import { defineComponent } from "@nuxtjs/composition-api"
  73. import * as teamUtils from "~/helpers/teams/utils"
  74. export default defineComponent({
  75. props: {
  76. team: { type: Object, default: () => {} },
  77. teamID: { type: String, default: null },
  78. },
  79. methods: {
  80. deleteTeam() {
  81. if (!confirm(this.$t("confirm.remove_team"))) return
  82. // Call to the graphql mutation
  83. teamUtils
  84. .deleteTeam(this.$apollo, this.teamID)
  85. .then(() => {
  86. this.$toast.success(this.$t("team.deleted"), {
  87. icon: "done",
  88. })
  89. })
  90. .catch((e) => {
  91. this.$toast.error(this.$t("error.something_went_wrong"), {
  92. icon: "error_outline",
  93. })
  94. console.error(e)
  95. })
  96. },
  97. exitTeam() {
  98. if (!confirm("Are you sure you want to exit this team?")) return
  99. teamUtils
  100. .exitTeam(this.$apollo, this.teamID)
  101. .then(() => {
  102. this.$toast.success(this.$t("team.left"), {
  103. icon: "done",
  104. })
  105. })
  106. .catch((e) => {
  107. this.$toast.error(this.$t("error.something_went_wrong"), {
  108. icon: "error_outline",
  109. })
  110. console.error(e)
  111. })
  112. },
  113. },
  114. })
  115. </script>