import {
  DataClient,
  type PlatformSummaryViewModel,
  type TopStrategiesByRoiViewModel,
  type TopStrategiesViewModel
} from '../generated/ManagingApi'

export interface PlatformData {
  platform: PlatformSummaryViewModel
  topStrategies: TopStrategiesViewModel
  topStrategiesByRoi: TopStrategiesByRoiViewModel
}

export const fetchPlatformData = async (apiUrl: string): Promise<PlatformData> => {
  const client = new DataClient({}, apiUrl)
  
  // Fetch all platform data in parallel
  const [platform, topStrategies, topStrategiesByRoi] = await Promise.all([
    client.data_GetPlatformSummary(),
    client.data_GetTopStrategies(),
    client.data_GetTopStrategiesByRoi()
  ])
  
  return {
    platform,
    topStrategies,
    topStrategiesByRoi
  }
}
