Team.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. $emit('edit-team')
  39. $refs.options.tippy().hide()
  40. "
  41. />
  42. <SmartItem
  43. v-if="team.myRole === 'OWNER'"
  44. svg="trash-2"
  45. color="red"
  46. :label="$t('action.delete')"
  47. @click.native="
  48. deleteTeam()
  49. $refs.options.tippy().hide()
  50. "
  51. />
  52. <SmartItem
  53. v-if="!(team.myRole === 'OWNER' && team.ownersCount == 1)"
  54. svg="trash"
  55. :label="$t('team.exit')"
  56. @click.native="
  57. exitTeam()
  58. $refs.options.tippy().hide()
  59. "
  60. />
  61. </tippy>
  62. </span>
  63. </div>
  64. </template>
  65. <script>
  66. import { defineComponent } from "@nuxtjs/composition-api"
  67. import * as teamUtils from "~/helpers/teams/utils"
  68. export default defineComponent({
  69. props: {
  70. team: { type: Object, default: () => {} },
  71. teamID: { type: String, default: null },
  72. },
  73. methods: {
  74. deleteTeam() {
  75. if (!confirm(this.$t("confirm.remove_team"))) return
  76. // Call to the graphql mutation
  77. teamUtils
  78. .deleteTeam(this.$apollo, this.teamID)
  79. .then(() => {
  80. this.$toast.success(this.$t("team.deleted"), {
  81. icon: "done",
  82. })
  83. })
  84. .catch((e) => {
  85. this.$toast.error(this.$t("error.something_went_wrong"), {
  86. icon: "error_outline",
  87. })
  88. console.error(e)
  89. })
  90. },
  91. exitTeam() {
  92. if (!confirm("Are you sure you want to exit this team?")) return
  93. teamUtils
  94. .exitTeam(this.$apollo, this.teamID)
  95. .then(() => {
  96. this.$toast.success(this.$t("team.left"), {
  97. icon: "done",
  98. })
  99. })
  100. .catch((e) => {
  101. this.$toast.error(this.$t("error.something_went_wrong"), {
  102. icon: "error_outline",
  103. })
  104. console.error(e)
  105. })
  106. },
  107. },
  108. })
  109. </script>