import { apiClient, withAuth } from "./client"; import { API_ENDPOINTS } from "../config/api"; export interface ScannedFoodProduct { barcode: string; name: string; brand: string | null; imageUrl: string | null; servingSize: string; caloriesPerServing: number; macros: { protein: number | null; carbs: number | null; fat: number | null; }; source: "openfoodfacts"; } interface FoodLookupResponse { success: boolean; data: ScannedFoodProduct; } export async function lookupFoodByBarcode( barcode: string, token: string | null, ): Promise { const normalized = barcode.replace(/\D/g, ""); const response = await apiClient.get( API_ENDPOINTS.FOOD.LOOKUP_BARCODE(normalized), withAuth(token), ); return response.data.data; }