This repository has no description
1import { useQuery } from '@tanstack/react-query';
2import { profileKeys } from '@/features/profile/lib/profileKeys';
3import { getProfile } from '@/features/profile/lib/dal';
4
5interface Props {
6 handle: string | undefined;
7 enabled?: boolean;
8}
9
10/**
11 * Fetches user profile data for graph node popups
12 * Wraps the profile query with graph-specific configuration
13 */
14export default function useGraphNodeUser({ handle, enabled = true }: Props) {
15 return useQuery({
16 queryKey: handle ? profileKeys.profile(handle) : ['graph', 'user', 'empty'],
17 queryFn: () => {
18 if (!handle) throw new Error('Handle is required');
19 return getProfile(handle);
20 },
21 enabled: enabled && !!handle,
22 staleTime: 5 * 60 * 1000, // 5 minutes - profiles don't change often
23 retry: 1, // Only retry once for popup data
24 });
25}