This commit is contained in:
marzban-dev
2025-01-06 19:26:16 +03:30
parent 73d68810be
commit cdc0ebec26
13 changed files with 536 additions and 0 deletions
@@ -0,0 +1,32 @@
// imports
import { useMutation } from "@tanstack/vue-query";
import axios from "~/configs/axios.config";
import { API_ENDPOINTS } from "~/constants";
// types
export type MoveDocRequest = {
itemsToMove: number[] | string[],
parent: number | string
};
// methods
export const handleMoveDoc = async ({ itemsToMove, parent }: MoveDocRequest) => {
const apiUrl = `${API_ENDPOINTS.branch.moveDoc}?new_parent_id=${parent}&${itemsToMove.map(i => `patch_list=${i}&`)}`
const splittedUrl = apiUrl.split("");
splittedUrl.pop()
await axios.patch<MoveDocRequest>(splittedUrl.join("").replaceAll(",", ""));
};
// composable
const useMoveDoc = () => {
return useMutation({
mutationFn: (variables: MoveDocRequest) => handleMoveDoc(variables)
});
};
export default useMoveDoc;