useTicketChannel.ts 753 B

12345678910111213141516171819202122232425
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import { computed, type Ref } from 'vue'
  3. import { type TicketById } from '#shared/entities/ticket/types.ts'
  4. import { getTicketChannelPlugin } from '../channel/plugins/index.ts'
  5. export const useTicketChannel = (ticket: Ref<TicketById | undefined>) => {
  6. const channelPlugin = computed(() =>
  7. getTicketChannelPlugin(ticket.value?.initialChannel),
  8. )
  9. const channelAlert = computed(() => {
  10. if (!ticket.value) return null
  11. return channelPlugin.value?.channelAlert(ticket.value)
  12. })
  13. const hasChannelAlert = computed(
  14. () => Boolean(channelAlert.value) && Boolean(channelAlert.value?.text),
  15. )
  16. return { channelPlugin, channelAlert, hasChannelAlert }
  17. }