export interface RVoteSpace { name: string slug: string _count?: { members: number } } export interface RVoteProposal { id: string title: string description?: string score: number status: string createdAt?: string } const PROXY_BASE = '/api/proxy/rvote' export async function fetchSpace(slug: string): Promise { const res = await fetch(`${PROXY_BASE}?endpoint=space&slug=${encodeURIComponent(slug)}`) if (!res.ok) { if (res.status === 404) throw new Error('Space not found') throw new Error(`Failed to fetch space: ${res.status}`) } return res.json() } export async function fetchPassedProposals(slug: string): Promise { const res = await fetch( `${PROXY_BASE}?endpoint=proposals&slug=${encodeURIComponent(slug)}&status=PASSED` ) if (!res.ok) { throw new Error(`Failed to fetch proposals: ${res.status}`) } const data = await res.json() const proposals = data.proposals || data.results || data || [] return Array.isArray(proposals) ? proposals : [] }