28 lines
589 B
TypeScript
28 lines
589 B
TypeScript
// imports
|
|
|
|
import { useMutation } from "@tanstack/vue-query";
|
|
import axios from "~/configs/axios.config";
|
|
import { API_ENDPOINTS } from "~/constants";
|
|
|
|
// types
|
|
|
|
export type DeleteDocRequest = {
|
|
id: number
|
|
};
|
|
|
|
// methods
|
|
|
|
export const handleDeleteDoc = async ({ id }: { id: string | undefined }) => {
|
|
await axios.delete<DeleteDocRequest>(`${API_ENDPOINTS.branch.getDoc}/${id}`);
|
|
};
|
|
|
|
// composable
|
|
|
|
const useDeleteDoc = (id: Ref<string | undefined>) => {
|
|
return useMutation({
|
|
mutationFn: () => handleDeleteDoc({ id: id.value })
|
|
});
|
|
};
|
|
|
|
export default useDeleteDoc;
|