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,33 @@
// imports
import { useQuery } from "@tanstack/vue-query";
import axios from "~/configs/axios.config";
import { API_ENDPOINTS, QUERY_KEYS } from "~/constants";
// types
export type GetDocResponse = DocumentStructure;
// methods
export const handleGetDoc = async (id : string | undefined) => {
const { data } = await axios.get<GetDocResponse>(`${API_ENDPOINTS.branch.getDoc}/${id}`);
return data;
};
// composable
const useGetDoc = (id: ComputedRef<string | undefined>) => {
const enabled = computed(() => {
return !!id.value
});
return useQuery({
enabled,
queryKey: [QUERY_KEYS.document, id],
queryFn: () => handleGetDoc(id.value)
});
};
export default useGetDoc;