Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 | 22x 14x 5x | /**
* useUserById Hook
*
* React Query hook for fetching a single user by ID with includes.
* Story 2.5.2: User Management Frontend
*/
import { useQuery } from '@tanstack/react-query';
import { getUserById } from '@/services/api/userManagementApi';
interface UseUserByIdOptions {
id: string | null;
includes?: string[];
enabled?: boolean;
}
export const useUserById = ({ id, includes, enabled = true }: UseUserByIdOptions) => {
return useQuery({
queryKey: ['users', 'detail', id, includes],
queryFn: () => getUserById(id!, includes),
staleTime: 5 * 60 * 1000, // 5 minutes
gcTime: 30 * 60 * 1000, // 30 minutes
enabled: enabled && !!id,
});
};
|