From 4e09bc81b213f6efe28fb1904be87d8a3095d14b Mon Sep 17 00:00:00 2001 From: Mamalizz Date: Sun, 23 Feb 2025 23:25:04 +0330 Subject: [PATCH] added use delete attachment --- .../api/tickets/useDeleteAttachment.ts | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 frontend/composables/api/tickets/useDeleteAttachment.ts diff --git a/frontend/composables/api/tickets/useDeleteAttachment.ts b/frontend/composables/api/tickets/useDeleteAttachment.ts new file mode 100644 index 0000000..12f06b3 --- /dev/null +++ b/frontend/composables/api/tickets/useDeleteAttachment.ts @@ -0,0 +1,36 @@ +// imports + +import { useMutation } from "@tanstack/vue-query"; +import { API_ENDPOINTS } from "~/constants"; + +// types + +export type DeleteAttachmentRequest = { + id: number | string; +}; + +// methods + +export const handleDeleteAttachment = async ({ + id, +}: DeleteAttachmentRequest) => { + // state + + const { $axios: axios } = useNuxtApp(); + + const { data } = await axios.delete( + `${API_ENDPOINTS.tickets.delete_attachment}/${id}` + ); + return data; +}; + +// composable + +const useDeleteAttachment = () => { + return useMutation({ + mutationFn: (data: DeleteAttachmentRequest) => + handleDeleteAttachment({ ...data }), + }); +}; + +export default useDeleteAttachment;