From 7d53a968df01d43f0185a8a8ddb6aceb6ebe2bfc Mon Sep 17 00:00:00 2001 From: Alexandre Fauquette <45398769+alexfauquette@users.noreply.github.com> Date: Wed, 21 Feb 2024 23:45:55 +0100 Subject: [PATCH] Improve ingredients (#894) fixes --- package.json | 1 + src/off.ts | 20 ++--- src/pages/ingredients/IngeredientDisplay.tsx | 4 +- src/pages/ingredients/index.tsx | 86 +++++++++++++++----- src/pages/ingredients/useData.tsx | 6 +- yarn.lock | 11 +++ 6 files changed, 88 insertions(+), 40 deletions(-) diff --git a/package.json b/package.json index 21d3be19c..e4397251c 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "react": "^18.2.0", "react-dom": "^18.2.0", "react-i18next": "^12.3.1", + "react-map-interaction": "^2.1.0", "react-redux": "^8.1.3", "react-router-dom": "^6.18.0", "react-zoom-pan-pinch": "^2.5.0", diff --git a/src/off.ts b/src/off.ts index ba254d53d..019eef215 100644 --- a/src/off.ts +++ b/src/off.ts @@ -4,7 +4,6 @@ import { OFF_API_URL_V2, OFF_IMAGE_URL, OFF_SEARCH, - OFF_URL, } from "./const"; import axios from "axios"; import combineURLs from "axios/lib/helpers/combineURLs"; @@ -164,11 +163,12 @@ const offService = { console.error("setIngedrient: Missing text"); } - const urlParams = new URLSearchParams({ - code, - [`ingredients_text${lang ? `_${lang}` : ""}`]: text, - }); - return `${OFF_URL}/cgi/product_jqm2.pl?${urlParams.toString()}`; + return axios.patch( + `https://world.openfoodfacts.org/api/v3/product/${code}`, + { + product: { [`ingredients_text${lang ? `_${lang}` : ""}`]: text }, + }, + ); }, async getIngedrientParsing(editionParams: { text: string; lang: string }) { @@ -190,11 +190,3 @@ const offService = { }; export default offService; - -// Fetching products to annotate: - -// https://world.openfoodfacts.org/cgi/search.pl?page=0&page_size=25&json=true&action=process&fields=code,lang,image_ingredients_url,product_name,ingredient,images&tagtype_0=states&tag_contains_0=contains&tag_0=en%3Aingredients-to-be-completed&tagtype_1=states&tag_contains_1=contains&tag_1=en%3Aingredients-photo-selected - -// Getting prediction: -// https://robotoff.openfoodfacts.org/api/v1/predict/ingredient_list?ocr_url=https://images.openfoodfacts.org/images/products/505/382/713/9229/41.json -// https://images.openfoodfacts.org/images/products/505/382/713/9229/41.json diff --git a/src/pages/ingredients/IngeredientDisplay.tsx b/src/pages/ingredients/IngeredientDisplay.tsx index e2eabb013..b3b3d2cc2 100644 --- a/src/pages/ingredients/IngeredientDisplay.tsx +++ b/src/pages/ingredients/IngeredientDisplay.tsx @@ -271,9 +271,7 @@ export function IngredientAnotation(props) { {t("ingredients.parsing")}