File size: 1,041 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
import type { ContributorDto } from "@reactive-resume/dto";
import { useQuery } from "@tanstack/react-query";
import { axios } from "@/client/libs/axios";
export const fetchGitHubContributors = async () => {
const response = await axios.get<ContributorDto[]>(`/contributors/github`);
return response.data;
};
export const fetchCrowdinContributors = async () => {
const response = await axios.get<ContributorDto[]>(`/contributors/crowdin`);
return response.data;
};
export const useContributors = () => {
const {
error: githubError,
isPending: githubLoading,
data: github,
} = useQuery({
queryKey: ["contributors", "github"],
queryFn: fetchGitHubContributors,
});
const {
error: crowdinError,
isPending: crowdinLoading,
data: crowdin,
} = useQuery({
queryKey: ["contributors", "crowdin"],
queryFn: fetchCrowdinContributors,
});
const error = githubError ?? crowdinError;
const loading = githubLoading || crowdinLoading;
return { github, crowdin, loading, error };
};
|