Files
hossein-por-shop/frontend/composables/api/documents/useEditDoc.ts
T
marzban-dev cdc0ebec26 Updated
2025-01-06 19:26:16 +03:30

30 lines
711 B
TypeScript

// imports
import { useMutation } from "@tanstack/vue-query";
import axios from "~/configs/axios.config";
import { API_ENDPOINTS } from "~/constants";
// types
export type EditDocRequest = {
id: number
};
// methods
export const handleEditDoc = async ({ id, name }: { id: string | undefined, name: string | undefined }) => {
await axios.patch<EditDocRequest>(`${API_ENDPOINTS.branch.getDoc}/${id}`, { name });
};
// composable
const useEditDoc = (id: Ref<string | undefined>) => {
return useMutation({
mutationFn: ({ name }: { name: Ref<string | undefined> }) => {
return handleEditDoc({ id: id.value, name: name.value });
}
});
};
export default useEditDoc;