getTicketView.ts 689 B

12345678910111213141516171819202122232425
  1. // Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. import { useSessionStore } from '@shared/stores/session'
  3. import type { TicketById } from '../types'
  4. export const getTicketView = (ticket: TicketById) => {
  5. const session = useSessionStore()
  6. const isTicketEditable = ticket?.policy.update ?? false
  7. const isTicketCustomer =
  8. session.hasPermission('ticket.customer') &&
  9. !session.hasPermission('ticket.agent')
  10. const isTicketAgent = session.hasPermission('ticket.agent')
  11. const ticketView = isTicketAgent ? ('agent' as const) : ('customer' as const)
  12. return {
  13. isTicketAgent,
  14. isTicketCustomer,
  15. isTicketEditable,
  16. ticketView,
  17. }
  18. }