NotificationItem.vue 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { useOnlineNotificationActions } from '#shared/entities/online-notification/composables/useOnlineNotificationActions.ts'
  4. import type { OnlineNotification, Scalars } from '#shared/graphql/types.ts'
  5. import ActivityMessage from './ActivityMessage.vue'
  6. interface Props {
  7. activity: OnlineNotification
  8. }
  9. const props = defineProps<Props>()
  10. const emit = defineEmits<{
  11. remove: [id: Scalars['ID']['output']]
  12. seen: [id: Scalars['ID']['output']]
  13. }>()
  14. const { deleteNotification, deleteNotificationMutation } =
  15. useOnlineNotificationActions()
  16. const loading = deleteNotificationMutation.loading()
  17. const removeNotification = () => {
  18. emit('remove', props.activity.id)
  19. return deleteNotification(props.activity.id)
  20. }
  21. </script>
  22. <template>
  23. <div class="flex">
  24. <button
  25. class="flex items-center ltr:pr-2 rtl:pl-2"
  26. :class="{ 'cursor-pointer': !loading, 'opacity-50': loading }"
  27. :disabled="loading"
  28. @click="removeNotification()"
  29. >
  30. <CommonIcon name="delete" class="text-red" size="tiny" />
  31. </button>
  32. <div class="flex items-center ltr:pr-2 rtl:pl-2">
  33. <div
  34. role="status"
  35. class="h-3 w-3 rounded-full"
  36. :class="{ 'bg-blue': !activity.seen }"
  37. :aria-label="
  38. activity.seen ? $t('Notification read') : $t('Unread notification')
  39. "
  40. ></div>
  41. </div>
  42. <ActivityMessage :activity="activity" @seen="$emit('seen', activity.id)" />
  43. </div>
  44. </template>