import { apiClient } from '../client'; import type { ProductionBatchCreate, ProductionBatchStatusUpdate, ProductionBatchResponse, ProductionBatchListResponse, ProductionDashboardSummary, DailyProductionRequirements, ProductionScheduleData, ProductionCapacityStatus, ProductionRequirements, ProductionYieldMetrics, } from '../types/production'; export class ProductionService { private readonly baseUrl = '/production'; getDashboardSummary(tenantId: string): Promise { return apiClient.get(`/tenants/${tenantId}${this.baseUrl}/dashboard-summary`); } getDailyRequirements(tenantId: string, date?: string): Promise { const params = date ? { date } : {}; return apiClient.get(`/tenants/${tenantId}${this.baseUrl}/daily-requirements`, { params }); } getProductionRequirements(tenantId: string, date?: string): Promise { const params = date ? { date } : {}; return apiClient.get(`/tenants/${tenantId}${this.baseUrl}/requirements`, { params }); } createProductionBatch(tenantId: string, batchData: ProductionBatchCreate): Promise { return apiClient.post(`/tenants/${tenantId}${this.baseUrl}/batches`, batchData); } getActiveBatches(tenantId: string): Promise { return apiClient.get(`/tenants/${tenantId}${this.baseUrl}/batches/active`); } getBatchDetails(tenantId: string, batchId: string): Promise { return apiClient.get(`/tenants/${tenantId}${this.baseUrl}/batches/${batchId}`); } updateBatchStatus( tenantId: string, batchId: string, statusUpdate: ProductionBatchStatusUpdate ): Promise { return apiClient.put(`/tenants/${tenantId}${this.baseUrl}/batches/${batchId}/status`, statusUpdate); } getProductionSchedule( tenantId: string, startDate?: string, endDate?: string ): Promise { const params: Record = {}; if (startDate) params.start_date = startDate; if (endDate) params.end_date = endDate; return apiClient.get(`/tenants/${tenantId}${this.baseUrl}/schedule`, { params }); } getCapacityStatus(tenantId: string, date?: string): Promise { const params = date ? { date } : {}; return apiClient.get(`/tenants/${tenantId}${this.baseUrl}/capacity/status`, { params }); } getYieldMetrics( tenantId: string, startDate: string, endDate: string ): Promise { const params = { start_date: startDate, end_date: endDate }; return apiClient.get(`/tenants/${tenantId}${this.baseUrl}/metrics/yield`, { params }); } } export const productionService = new ProductionService();