Skip to content

Commit

Permalink
Show if image is selected as a nutriment image (openfoodfacts#1101)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfauquette authored Dec 12, 2024
1 parent d26cc5e commit ad494f6
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/pages/nutrition/PictureSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ export default function PictureSection(props: PictureSectionProps) {

const imageTimestamp = product?.images?.[imageId]?.uploaded_t;

const selectedImagesIds = Object.keys(product?.images ?? {})
.filter((imageKey) => imageKey.startsWith("nutrition"))
.map((imageKey) => product?.images[imageKey].imgid);

return (
<React.Fragment>
<p>
Expand All @@ -50,6 +54,11 @@ export default function PictureSection(props: PictureSectionProps) {
})
: "..."}
</p>
<p>
{selectedImagesIds.includes(imageId)
? `Selected as nutriment image ✅`
: `Not selected as nutriment ❌`}
</p>
<IconButton onClick={() => setRotationIndex((p) => p - 1)}>
<RotateLeftIcon />
</IconButton>
Expand All @@ -64,7 +73,7 @@ export default function PictureSection(props: PictureSectionProps) {
alt=""
style={{
width: "100%",
maxHeight: "200vh",
maxHeight: "70vh",
rotate: `${90 * rotationIndex}deg`,
}}
/>
Expand Down

0 comments on commit ad494f6

Please sign in to comment.