useOrganizationTicketsCount.ts 757 B

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