Add procurement management logic
This commit is contained in:
@@ -18,6 +18,7 @@ import { RecipesService } from './recipes.service';
|
||||
import { ProductionService } from './production.service';
|
||||
import { OrdersService } from './orders.service';
|
||||
import { SuppliersService } from './suppliers.service';
|
||||
import { ProcurementService } from './procurement.service';
|
||||
|
||||
// Create service instances
|
||||
export const authService = new AuthService();
|
||||
@@ -33,6 +34,7 @@ export const recipesService = new RecipesService();
|
||||
export const productionService = new ProductionService();
|
||||
export const ordersService = new OrdersService();
|
||||
export const suppliersService = new SuppliersService();
|
||||
export const procurementService = new ProcurementService();
|
||||
|
||||
// Export the classes as well
|
||||
export {
|
||||
@@ -48,7 +50,8 @@ export {
|
||||
RecipesService,
|
||||
ProductionService,
|
||||
OrdersService,
|
||||
SuppliersService
|
||||
SuppliersService,
|
||||
ProcurementService
|
||||
};
|
||||
|
||||
// Import base client
|
||||
@@ -73,6 +76,7 @@ export const api = {
|
||||
production: productionService,
|
||||
orders: ordersService,
|
||||
suppliers: suppliersService,
|
||||
procurement: procurementService,
|
||||
} as const;
|
||||
|
||||
// Service status checking
|
||||
@@ -98,6 +102,7 @@ export class HealthService {
|
||||
{ name: 'Suppliers', endpoint: '/suppliers/health' },
|
||||
{ name: 'Forecasting', endpoint: '/forecasting/health' },
|
||||
{ name: 'Notification', endpoint: '/notifications/health' },
|
||||
{ name: 'Procurement', endpoint: '/procurement-plans/health' },
|
||||
];
|
||||
|
||||
const healthChecks = await Promise.allSettled(
|
||||
|
||||
135
frontend/src/api/services/procurement.service.ts
Normal file
135
frontend/src/api/services/procurement.service.ts
Normal file
@@ -0,0 +1,135 @@
|
||||
// ================================================================
|
||||
// frontend/src/api/services/procurement.service.ts
|
||||
// ================================================================
|
||||
/**
|
||||
* Procurement Service - API client for procurement planning endpoints
|
||||
*/
|
||||
|
||||
import { ApiClient } from '../client';
|
||||
import type {
|
||||
ProcurementPlan,
|
||||
GeneratePlanRequest,
|
||||
GeneratePlanResponse,
|
||||
DashboardData,
|
||||
ProcurementRequirement,
|
||||
PaginatedProcurementPlans
|
||||
} from '../types/procurement';
|
||||
|
||||
export class ProcurementService {
|
||||
constructor(private client: ApiClient) {}
|
||||
|
||||
// ================================================================
|
||||
// PROCUREMENT PLAN OPERATIONS
|
||||
// ================================================================
|
||||
|
||||
/**
|
||||
* Get the procurement plan for the current day
|
||||
*/
|
||||
async getCurrentPlan(): Promise<ProcurementPlan | null> {
|
||||
return this.client.get('/procurement-plans/current');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get procurement plan for a specific date
|
||||
*/
|
||||
async getPlanByDate(date: string): Promise<ProcurementPlan | null> {
|
||||
return this.client.get(`/procurement-plans/${date}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get procurement plan by ID
|
||||
*/
|
||||
async getPlanById(planId: string): Promise<ProcurementPlan | null> {
|
||||
return this.client.get(`/procurement-plans/id/${planId}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* List procurement plans with optional filters
|
||||
*/
|
||||
async listPlans(params?: {
|
||||
status?: string;
|
||||
startDate?: string;
|
||||
endDate?: string;
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
}): Promise<PaginatedProcurementPlans> {
|
||||
return this.client.get('/procurement-plans/', { params });
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a new procurement plan
|
||||
*/
|
||||
async generatePlan(request: GeneratePlanRequest): Promise<GeneratePlanResponse> {
|
||||
return this.client.post('/procurement-plans/generate', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update procurement plan status
|
||||
*/
|
||||
async updatePlanStatus(planId: string, status: string): Promise<ProcurementPlan> {
|
||||
return this.client.put(`/procurement-plans/${planId}/status`, null, {
|
||||
params: { status }
|
||||
});
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// REQUIREMENTS OPERATIONS
|
||||
// ================================================================
|
||||
|
||||
/**
|
||||
* Get all requirements for a specific procurement plan
|
||||
*/
|
||||
async getPlanRequirements(
|
||||
planId: string,
|
||||
params?: {
|
||||
status?: string;
|
||||
priority?: string;
|
||||
}
|
||||
): Promise<ProcurementRequirement[]> {
|
||||
return this.client.get(`/procurement-plans/${planId}/requirements`, { params });
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all critical priority requirements
|
||||
*/
|
||||
async getCriticalRequirements(): Promise<ProcurementRequirement[]> {
|
||||
return this.client.get('/procurement-plans/requirements/critical');
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// DASHBOARD OPERATIONS
|
||||
// ================================================================
|
||||
|
||||
/**
|
||||
* Get procurement dashboard data
|
||||
*/
|
||||
async getDashboardData(): Promise<DashboardData | null> {
|
||||
return this.client.get('/procurement-plans/dashboard/data');
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// UTILITY OPERATIONS
|
||||
// ================================================================
|
||||
|
||||
/**
|
||||
* Manually trigger the daily scheduler
|
||||
*/
|
||||
async triggerDailyScheduler(): Promise<{ success: boolean; message: string; tenant_id: string }> {
|
||||
return this.client.post('/procurement-plans/scheduler/trigger');
|
||||
}
|
||||
|
||||
/**
|
||||
* Health check for procurement service
|
||||
*/
|
||||
async healthCheck(): Promise<{
|
||||
status: string;
|
||||
service: string;
|
||||
procurement_enabled: boolean;
|
||||
timestamp: string;
|
||||
}> {
|
||||
return this.client.get('/procurement-plans/health');
|
||||
}
|
||||
}
|
||||
|
||||
// Export singleton instance
|
||||
export const procurementService = new ProcurementService(new ApiClient());
|
||||
Reference in New Issue
Block a user