export interface PlatformStats { orders: { completed: number; }; vendors: { total: number; }; transactions: { volume: number; averageOrderValue: number; }; } export async function fetchPlatformStats(): Promise { const BASE_API_URL = process.env.SERVER_API_URL || 'http://localhost:3001/api'; console.log('Fetching platform stats from:', BASE_API_URL); try { const response = await fetch(`${BASE_API_URL}/stats/platform`, { method: 'GET', headers: { 'Content-Type': 'application/json', }, cache: 'no-store' }); if (!response.ok) { throw new Error(`API error: ${response.status}`); } const data = await response.json(); console.log('Fetched stats:', data); return data; } catch (error) { console.error('Error fetching platform stats:', error); // Return fallback data if API fails return { orders: { completed: 15800 }, vendors: { total: 2400 }, transactions: { volume: 3200000, averageOrderValue: 220 } }; } }