import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'; import { authApi } from '../api'; export function useCurrentUser() { return useQuery({ queryKey: ['user'], queryFn: authApi.getCurrentUser, retry: false, }); } export function useUserRepos() { return useQuery({ queryKey: ['userRepos'], queryFn: authApi.getUserRepos, retry: false, }); } export function useLogout() { const queryClient = useQueryClient(); return useMutation({ mutationFn: authApi.logout, onSuccess: () => { queryClient.clear(); window.location.href = '/'; }, }); }