Files
hossein-por-shop/frontend/composables/api/tickets/useDeleteAttachment.ts
T
2025-02-23 23:25:04 +03:30

37 lines
703 B
TypeScript

// 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;