getTicketView.ts 668 B

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