useWhatsapp.ts 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import { computed, type Ref } from 'vue'
  3. import type { TicketArticle } from '#shared/entities/ticket/types.ts'
  4. export const useWhatsapp = (article: Ref<TicketArticle>) => {
  5. const articleDeliveryStatus = computed(() => {
  6. if (article.value.preferences?.whatsapp?.timestamp_read) {
  7. return {
  8. message: __('read by the customer'),
  9. icon: 'read',
  10. }
  11. }
  12. // desktop has alias for check and check-double
  13. if (article.value.preferences?.whatsapp?.timestamp_delivered) {
  14. return { message: __('delivered to the customer'), icon: 'delivered' }
  15. }
  16. if (article.value.preferences?.whatsapp?.timestamp_sent) {
  17. return { message: __('sent to the customer'), icon: 'send' }
  18. }
  19. return undefined
  20. })
  21. const hasDeliveryStatus = computed(
  22. () =>
  23. !!(
  24. article.value?.preferences?.whatsapp?.timestamp_read ||
  25. article.value?.preferences?.whatsapp?.timestamp_delivered ||
  26. article.value?.preferences?.whatsapp?.timestamp_sent
  27. ),
  28. )
  29. return { articleDeliveryStatus, hasDeliveryStatus }
  30. }