added use delete attachment
This commit is contained in:
@@ -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;
|
||||||
Reference in New Issue
Block a user