Fix UI for inventory page 3

This commit is contained in:
Urtzi Alfaro
2025-09-16 12:21:15 +02:00
parent dd4016e217
commit 7aa26d51d3
15 changed files with 1660 additions and 2030 deletions

View File

@@ -172,15 +172,23 @@ export class InventoryService {
ingredientId?: string,
limit: number = 50,
offset: number = 0
): Promise<PaginatedResponse<StockMovementResponse>> {
): Promise<StockMovementResponse[]> {
const queryParams = new URLSearchParams();
if (ingredientId) queryParams.append('ingredient_id', ingredientId);
queryParams.append('limit', limit.toString());
queryParams.append('offset', offset.toString());
queryParams.append('skip', offset.toString()); // Backend expects 'skip' not 'offset'
return apiClient.get<PaginatedResponse<StockMovementResponse>>(
`${this.baseUrl}/${tenantId}/stock/movements?${queryParams.toString()}`
);
const url = `${this.baseUrl}/${tenantId}/stock/movements?${queryParams.toString()}`;
console.log('🔍 Frontend calling API:', url);
try {
const result = await apiClient.get<StockMovementResponse[]>(url);
console.log('✅ Frontend API response:', result);
return result;
} catch (error) {
console.error('❌ Frontend API error:', error);
throw error;
}
}
// Expiry Management