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;