import { useState, useEffect, useCallback } from 'react'; import { useDubs } from '../provider'; import type { ArcadePool } from '../types'; export interface UseArcadePoolsResult { pools: ArcadePool[]; loading: boolean; error: Error | null; refetch: () => void; } export function useArcadePools(gameSlug?: string): UseArcadePoolsResult { const { client } = useDubs(); const [pools, setPools] = useState([]); const [loading, setLoading] = useState(false); const [error, setError] = useState(null); const fetch = useCallback(async () => { setLoading(true); setError(null); try { const result = await client.getArcadePools({ gameSlug }); setPools(result); } catch (err) { setError(err instanceof Error ? err : new Error(String(err))); } finally { setLoading(false); } }, [client, gameSlug]); useEffect(() => { fetch(); }, [fetch]); return { pools, loading, error, refetch: fetch }; }