useTicketChannel.ts 723 B

1234567891011121314151617181920212223
  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 = getTicketChannelPlugin(ticket.value?.initialChannel)
  7. const channelAlert = computed(() => {
  8. if (!ticket.value) return null
  9. return channelPlugin?.channelAlert(ticket.value)
  10. })
  11. const hasChannelAlert = computed(
  12. () => Boolean(channelAlert.value) && Boolean(channelAlert.value?.text),
  13. )
  14. return { channelPlugin, channelAlert, hasChannelAlert }
  15. }