import { apiClient } from "./client";

/**
 * Export batch cards in specified format
 * @param batchId - The ID of the batch to export
 * @param format - The export format (xlsx or csv)
 * @returns - The exported file data
 */
export async function exportBatchCards(batchId: number, format: 'xlsx' | 'csv'): Promise<Blob | string> {
  try {
    const response = await apiClient.get(`/card/batches/${batchId}/export/${format}/`, {
      responseType: format === 'xlsx' ? 'blob' : 'text',
      // 注意：不需要手动添加token，拦截器会自动处理
    });
    
    return response.data;
  } catch (error) {
    console.error(`导出批次卡片失败 (格式: ${format}):`, error);
    throw error;
  }
} 