import {
  STORE_PERFORMANCE_DATA,
  getCommerceKpis,
  getOrdersTrendData,
  getPaymentBreakdownData,
  getRevenueTrendData,
  getTopProductsData,
} from '../services/commerceService';
import type {CommerceFilterState} from '../types/commerce';

export class CommerceRepository {
  async getAnalytics(filters: CommerceFilterState) {
    const storeId = filters.storeId || 'all';
    const range = filters.dateRange || '7d';

    return {
      kpis: getCommerceKpis(storeId, range),
      revenueTrend: getRevenueTrendData(storeId, range),
      ordersTrend: getOrdersTrendData(storeId, range),
      paymentBreakdown: getPaymentBreakdownData(storeId, range),
      storePerformance: STORE_PERFORMANCE_DATA,
      topProducts: getTopProductsData(storeId, range),
    };
  }
}

export const commerceRepository = new CommerceRepository();
