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,31 @@
// imports
import { useQuery } from "@tanstack/vue-query";
import axios from "~/configs/axios.config";
import { API_ENDPOINTS, QUERY_KEYS } from "~/constants";
// types
export type GetUserBranchesResponse = Branch[];
// methods
export const handleGetUserBranches = async () => {
const { data } = await axios.get<GetUserBranchesResponse>(
`${API_ENDPOINTS.branch.getUserBranches}`
);
return data;
};
// composable
const useGetUserBranches = () => {
return useQuery({
staleTime: 60 * 1000,
queryKey: [QUERY_KEYS.userBranches],
queryFn: () => handleGetUserBranches(),
});
};
export default useGetUserBranches;