useUserTicketsCount.ts 647 B

1234567891011121314151617181920212223
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import type { TicketCount } from '#shared/graphql/types.ts'
  3. interface RequiredUser {
  4. id: string
  5. internalId: number
  6. ticketsCount?: Maybe<TicketCount>
  7. }
  8. export const useUsersTicketsCount = () => {
  9. const getTicketData = (user?: Maybe<RequiredUser>) => {
  10. if (!user || !user.ticketsCount) return null
  11. return {
  12. count: user.ticketsCount,
  13. createLabel: __('Create new ticket for this user'),
  14. createLink: `/tickets/create?customer_id=${user.internalId}`,
  15. query: `customer.id: ${user.internalId}`,
  16. }
  17. }
  18. return { getTicketData }
  19. }