From a85abdf8962dc742a32b32f16ca8faac1d4d41c0 Mon Sep 17 00:00:00 2001
From: Alexandre Fauquette
Date: Sun, 31 Jul 2022 11:05:32 +0200
Subject: [PATCH 1/4] improve nutriscore game
---
src/components/ResponsiveAppBar.jsx | 90 ++++++++++---------
src/i18n/common.json | 3 +-
src/i18n/en.json | 3 +-
src/pages/nutriscoreValidator/index.jsx | 114 ++++++++++++++++--------
4 files changed, 125 insertions(+), 85 deletions(-)
diff --git a/src/components/ResponsiveAppBar.jsx b/src/components/ResponsiveAppBar.jsx
index 6857049dee..0604a63369 100644
--- a/src/components/ResponsiveAppBar.jsx
+++ b/src/components/ResponsiveAppBar.jsx
@@ -11,7 +11,7 @@ import Button from "@mui/material/Button";
import MenuItem from "@mui/material/MenuItem";
import ListSubheader from "@mui/material/ListSubheader";
import MuiLink from "@mui/material/Link";
-import SettingsIcon from '@mui/icons-material/Settings';
+import SettingsIcon from "@mui/icons-material/Settings";
import DevModeContext from "../contexts/devMode";
import logo from "../assets/logo.png";
@@ -26,7 +26,8 @@ const pages = [
{ url: "logos", translationKey: "menu.logos" },
{ url: "eco-score", translationKey: "menu.eco-score" },
{ translationKey: "menu.manage" },
- { url: "insights", translationKey: "menu.insights" },
+ { url: "insights", translationKey: "menu.insights", devModeOnly: true },
+ { url: "nutriscore", translationKey: "menu.nutriscore", devModeOnly: true },
// { url: "settings", translationKey: "menu.settings" },
];
@@ -44,9 +45,7 @@ const ResponsiveAppBar = () => {
const { devMode: isDevMode } = React.useContext(DevModeContext);
- const displayedPages = pages.filter(
- (page) => page.url !== "insights" || isDevMode
- );
+ const displayedPages = pages.filter((page) => !page.devModeOnly || isDevMode);
return (
@@ -127,45 +126,45 @@ const ResponsiveAppBar = () => {
display: { xs: "none", md: "flex" },
flexDirection: "row",
alignItems: "center",
- width: '100%',
- justifyContent: 'space-between'
- }}
- >
-
-
-
-
-
- Hunger Games
-
+
+
+
+
+ Hunger Games
+
{displayedPages.map((page) =>
page.url ? (
@@ -173,21 +172,24 @@ const ResponsiveAppBar = () => {
color="inherit"
key={page.url}
onClick={handleCloseNavMenu}
- sx={{ my: 2, display: "block"}}
+ sx={{ my: 2, display: "block" }}
component={Link}
to={`/${page.url}`}
>
- {page.url === 'settings' ? : t(page.translationKey)}
+ {page.url === "settings" ? (
+
+ ) : (
+ t(page.translationKey)
+ )}
) : null
)}
-
-
+
- {t("questions.countries")}: {!productData?.countriesTags?null:`${productData.countriesTags.join(", ")}.`}
+ {t("questions.countries")}:{" "}
+ {!productData?.countriesTags
+ ? null
+ : `${productData.countriesTags.join(", ")}.`}
diff --git a/src/pages/questions/QuestionDisplay.jsx b/src/pages/questions/QuestionDisplay.jsx
index d2a7b5b3ac..c87a388498 100644
--- a/src/pages/questions/QuestionDisplay.jsx
+++ b/src/pages/questions/QuestionDisplay.jsx
@@ -63,9 +63,8 @@ const QuestionDisplay = ({ question, answerQuestion, resetFilters }) => {
const valueTagExamplesURL = getValueTagExamplesURL(question);
React.useEffect(() => {
-
function handleShortCut(event) {
- const preventShortCut = event.target.tagName.toUpperCase() === 'INPUT'
+ const preventShortCut = event.target.tagName.toUpperCase() === "INPUT";
if (question && !preventShortCut) {
switch (event.keyCode) {
case 75:
@@ -80,11 +79,12 @@ const QuestionDisplay = ({ question, answerQuestion, resetFilters }) => {
default:
break;
}
- }}
+ }
+ }
- window.addEventListener( 'keydown', handleShortCut)
- return () => window.removeEventListener('keydown', handleShortCut)
- }, [question, answerQuestion])
+ window.addEventListener("keydown", handleShortCut);
+ return () => window.removeEventListener("keydown", handleShortCut);
+ }, [question, answerQuestion]);
if (question === NO_QUESTION_LEFT) {
return (
@@ -144,12 +144,7 @@ const QuestionDisplay = ({ question, answerQuestion, resetFilters }) => {
/>
-
+
answerQuestion({ value: 0, insightId: question.insight_id })
diff --git a/src/pages/questions/UserData.jsx b/src/pages/questions/UserData.jsx
index dbfb4a43e1..c6ed55bff3 100644
--- a/src/pages/questions/UserData.jsx
+++ b/src/pages/questions/UserData.jsx
@@ -27,7 +27,9 @@ const UserData = ({ remainingQuestionNb = 0, answers = [] }) => {
return (
- {t("questions.remaining_annotations")}: {remainingQuestionNb}
+
+ {t("questions.remaining_annotations")}: {remainingQuestionNb}
+
{displayedAnswers.map(
({ insight_id, barcode, value, insight_type, validationValue }) => (
diff --git a/src/pages/settings/index.jsx b/src/pages/settings/index.jsx
index ecbdcf1cef..87b39f0bf8 100644
--- a/src/pages/settings/index.jsx
+++ b/src/pages/settings/index.jsx
@@ -11,8 +11,7 @@ import MuiLink from "@mui/material/Link";
import { useTranslation } from "react-i18next";
import DevModeContext from "../../contexts/devMode";
-import { localSettings,localSettingsKeys } from "../../localeStorageManager";
-
+import { localSettings, localSettingsKeys } from "../../localeStorageManager";
export default function Settings() {
const { t, i18n } = useTranslation();
@@ -62,12 +61,12 @@ export default function Settings() {
/>
-
- {t("settings.reportIssue")}
-
+
+ {t("settings.reportIssue")}
+
);
From af7a5c962a4aa10c497b6db075250a35e357bbee Mon Sep 17 00:00:00 2001
From: Alexandre Fauquette <45398769+alexfauquette@users.noreply.github.com>
Date: Sun, 7 Aug 2022 19:40:54 +0200
Subject: [PATCH 3/4] Apply suggestions from code review
---
src/pages/nutriscoreValidator/index.jsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/pages/nutriscoreValidator/index.jsx b/src/pages/nutriscoreValidator/index.jsx
index 01e71450fa..b1f8a4d11f 100644
--- a/src/pages/nutriscoreValidator/index.jsx
+++ b/src/pages/nutriscoreValidator/index.jsx
@@ -77,7 +77,7 @@ export default function NutriscoreValidator() {
Image sizes
setImageSize(newValue)}
valueLabelDisplay="auto"
From 9fb98e3e29bdc398674fe5e4fa807807d1a68826 Mon Sep 17 00:00:00 2001
From: Alexandre Fauquette
Date: Wed, 10 Aug 2022 21:58:15 +0200
Subject: [PATCH 4/4] last modifications
---
src/pages/nutriscoreValidator/index.jsx | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/src/pages/nutriscoreValidator/index.jsx b/src/pages/nutriscoreValidator/index.jsx
index b1f8a4d11f..9c25b7349b 100644
--- a/src/pages/nutriscoreValidator/index.jsx
+++ b/src/pages/nutriscoreValidator/index.jsx
@@ -1,8 +1,8 @@
import * as React from "react";
import { useQuestionBuffer } from "../questions/useQuestionBuffer";
-import Divider from "@mui/material/Divider";
+import Divider from "@mui/material/Divider";
import Stack from "@mui/material/Stack";
import Button from "@mui/material/Button";
import Box from "@mui/material/Box";
@@ -53,7 +53,7 @@ export default function NutriscoreValidator() {
);
};
- const { buffer, answerQuestion } = useQuestionBuffer(
+ const { buffer, answerQuestion, remainingQuestionNb } = useQuestionBuffer(
filterState,
PAGE_SIZE,
BUFFER_THRESHOLD
@@ -61,6 +61,14 @@ export default function NutriscoreValidator() {
return (
+
+ Annotate nutriscore logo detection by batch.
+
+ To do so select all the images showing the correct/wrong nutriscore
+ value (nutriscore {nutriscoreGrade.toUpperCase()}), and click on the
+ bottom buttons to say if you selected a set correct or wrong ones.
+
+
Nutriscore D
+
+ Still {remainingQuestionNb} to annotate
+
Image sizes