Nutri | -100g | -- serving{" "} - - | -
{NUTRIMENTS[nutrimentId] ?? nutrimentId} | -
-
- setValues((p) => ({
- ...p,
- [`${nutrimentId}_100g`]: {
- ...p[`${nutrimentId}_100g`],
- value: event.target.value,
- },
- }))
- }
- />
+
+ {NUTRIMENTS[nutrimentId] ?? nutrimentId}
+
+ );
+ })}
+
+ 100g
+ {nutrimentsDetected.map((nutrimentId) => {
+ const key = `${nutrimentId}_100g`;
+ const item = values[key];
+
+ return (
+
+
+ setValues((p) => ({
+ ...p,
+ [key]: {
+ ...p[key],
+ value: event.target.value,
+ },
+ }))
+ }
+ />
- {isValidUnit(values[`${nutrimentId}_100g`]?.unit) ? (
-
- ) : (
-
- {values[`${nutrimentId}_100g`]?.unit}
-
- )}
-
- |
-
-
- setValues((p) => ({
- ...p,
- [`${nutrimentId}_serving`]: {
- ...p[`${nutrimentId}_serving`],
- value: event.target.value,
- },
- }))
- }
- />
+ {UNITS.map((unit) => (
+
+ ))}
+
+ ) : (
+
+ {item?.unit}
+
+ )}
+
+
+ );
+ })}
+
+
+
+ serving{" "}
+
+
+ {nutrimentsDetected.map((nutrimentId) => {
+ const key = `${nutrimentId}_serving`;
+ const item = values[key];
- {isValidUnit(values[`${nutrimentId}_serving`]?.unit) ? (
-
- ) : (
-
- {values[`${nutrimentId}_serving`]?.unit}
-
- )}
+ return (
+
+
+ setValues((p) => ({
+ ...p,
+ [key]: {
+ ...p[key],
+ value: event.target.value,
+ },
+ }))
+ }
+ />
-
- |
-
- | - - | -- - | -
- {JSON.stringify(insight, null, 2)} -- )} - */} - + +