Merge branch 'main' into feat/observability-metrics-monitoring
Run Tests on Branches / Run Tests (push) Failing after 3h11m0s

This commit is contained in:
2026-07-13 23:08:19 +00:00
13 changed files with 1156 additions and 72 deletions
+53
View File
@@ -0,0 +1,53 @@
import api from './api';
export interface Product {
id: string;
source: 'cima' | 'openfoodfacts';
name: string;
brand: string;
category: string;
image_url: string | null;
active_ingredient?: string;
dosage?: string;
form?: string;
prescription?: string;
commercialized?: boolean;
photos?: { tipo: string; url: string }[];
docs?: { tipo: number; url: string }[];
nutriscore?: string;
ingredients?: string;
nova_group?: number;
eco_score?: string;
}
export interface ProductSearchResponse {
results: Product[];
total: number;
sources: {
cima: number;
openfoodfacts: number;
};
}
export async function searchProducts(query: string): Promise<Product[]> {
if (!query || query.trim().length < 2) return [];
try {
const { data } = await api.get<ProductSearchResponse>('/products/search', {
params: { q: query }
});
return data.results || [];
} catch (error) {
console.error('[Products] Search error:', error);
return [];
}
}
export async function getProduct(source: string, id: string): Promise<Product | null> {
try {
const { data } = await api.get<Product>(`/products/${source}/${id}`);
return data;
} catch (error) {
console.error('[Products] Detail error:', error);
return null;
}
}