Skip to content

Commit

Permalink
Fix: Show question without logo to avoid false annotation (#393)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfauquette authored Dec 6, 2022
1 parent bcfc3e6 commit 2fb4e16
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions src/pages/logosValidator/LogoQuestionValidator.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const fetchData = async (insightId) => {
};

const LogoQuesitonCard = (props) => {
const { t } = useTranslation();
const { question, toggleSelection, checked, imageSize, zoomOnLogo } = props;

const [croppedImageUrl, setCroppedImageUrl] = React.useState("");
Expand Down Expand Up @@ -92,10 +93,6 @@ const LogoQuesitonCard = (props) => {
};
}, [question.insight_id, question.source_image_url, zoomOnLogo]);

if (!question.insight_id || !croppedImageUrl) {
return null;
}

return (
<Card
sx={{ width: imageSize, height: imageSize }}
Expand All @@ -110,7 +107,16 @@ const LogoQuesitonCard = (props) => {
onClick={toggleSelection(question.insight_id)}
tabIndex={-1}
>
<NutriscoreImage croppedImageUrl={croppedImageUrl} />
{croppedImageUrl ? (
<img
src={croppedImageUrl}
alt={t("nutriscore.image_alt")}
loading="lazy"
style={{ objectFit: "contain", width: "100%", height: "100%" }}
/>
) : (
<Typography>NOT A LOGO</Typography>
)}
<Checkbox
sx={{ position: "absolute", bottom: 10, right: 10 }}
checked={checked}
Expand All @@ -122,19 +128,6 @@ const LogoQuesitonCard = (props) => {
);
};

const NutriscoreImage = ({ croppedImageUrl }) => {
const { t } = useTranslation();

return (
<img
src={croppedImageUrl}
alt={t("nutriscore.image_alt")}
loading="lazy"
style={{ objectFit: "contain", width: "100%", height: "100%" }}
/>
);
};

export default function LogoQuestionValidator({ options }) {
const { t } = useTranslation();

Expand Down

0 comments on commit 2fb4e16

Please sign in to comment.