useTicketEditTitle.ts 989 B

123456789101112131415161718192021222324252627282930313233
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import {
  3. NotificationTypes,
  4. useNotifications,
  5. } from '#shared/components/CommonNotifications/index.ts'
  6. import { useTicketUpdateMutation } from '#shared/entities/ticket/graphql/mutations/update.api.ts'
  7. import { MutationHandler } from '#shared/server/apollo/handler/index.ts'
  8. import type { ComputedRef } from 'vue'
  9. export const useTicketEditTitle = (ticketId: ComputedRef<string>) => {
  10. const { notify } = useNotifications()
  11. const mutationUpdate = new MutationHandler(useTicketUpdateMutation())
  12. const updateTitle = async (title: string) => {
  13. return mutationUpdate
  14. .send({
  15. ticketId: ticketId.value,
  16. input: { title },
  17. meta: {},
  18. })
  19. .then(() => {
  20. notify({
  21. type: NotificationTypes.Success,
  22. id: 'ticket-updated-successfully',
  23. message: __('Ticket updated successfully.'),
  24. })
  25. })
  26. }
  27. return { updateTitle }
  28. }