Fas 3 steg 3b: minimala efterfrågor + hushållsantagandeprofiler per ingrediens

This commit is contained in:
Sven (AAMOS AI)
2026-08-07 03:56:41 +07:00
parent 44f6385dce
commit e46281b9b5
24 changed files with 10130 additions and 5 deletions
+56
View File
@@ -49,6 +49,8 @@ export default function CookingScreen() {
const timerRef = useRef<ReturnType<typeof setInterval> | null>(null);
const [finishing, setFinishing] = useState(false);
const [mealBoxPortions, setMealBoxPortions] = useState(0);
const [actualPortionsEaten, setActualPortionsEaten] = useState<number | null>(null);
const [leftoverEstimatePortions, setLeftoverEstimatePortions] = useState<number | null>(null);
const query = useQuery({
queryKey: ["recipe", id],
@@ -100,6 +102,9 @@ export default function CookingScreen() {
};
if (finishing) {
const defaultEaten = actualPortionsEaten ?? Math.max(0, portionsCooked - mealBoxPortions);
const defaultLeftovers = leftoverEstimatePortions ?? mealBoxPortions;
return (
<Screen>
<Heading>{t("cooked.title")}</Heading>
@@ -127,6 +132,44 @@ export default function CookingScreen() {
</Row>
</Row>
</Card>
<Card>
<Body>{t("cooked.actualPortionsEaten")}</Body>
<Row>
<Button
label=""
variant="ghost"
onPress={() => setActualPortionsEaten(Math.max(0, defaultEaten - 1))}
/>
<Body>{defaultEaten}</Body>
<Button
label="+"
variant="ghost"
onPress={() => setActualPortionsEaten(Math.min(portionsCooked, defaultEaten + 1))}
/>
</Row>
<Small>{t("cooked.actualPortionsEatenHint")}</Small>
</Card>
<Card>
<Body>{t("cooked.leftoverEstimatePortions")}</Body>
<Row>
<Button
label=""
variant="ghost"
onPress={() => setLeftoverEstimatePortions(Math.max(0, defaultLeftovers - 1))}
/>
<Body>{defaultLeftovers}</Body>
<Button
label="+"
variant="ghost"
onPress={() =>
setLeftoverEstimatePortions(
Math.min(portionsCooked - defaultEaten, defaultLeftovers + 1),
)
}
/>
</Row>
<Small>{t("cooked.leftoverEstimateHint")}</Small>
</Card>
<Small>{t("cooked.deductPantryNote")}</Small>
<Spacer size={spacing.sm} />
<Button
@@ -136,12 +179,25 @@ export default function CookingScreen() {
cook.mutate({
portionsCooked,
mealBoxPortions,
actualPortionsEaten: actualPortionsEaten ?? defaultEaten,
leftoverEstimatePortions: leftoverEstimatePortions ?? defaultLeftovers,
mealBoxFrozen: false,
deductInventory: true,
mealType: "dinner",
})
}
/>
<Button label={t("common.skip")} variant="ghost" onPress={() =>
cook.mutate({
portionsCooked,
mealBoxPortions,
actualPortionsEaten: defaultEaten,
leftoverEstimatePortions: defaultLeftovers,
mealBoxFrozen: false,
deductInventory: true,
mealType: "dinner",
})
} />
<Button label={t("common.back")} variant="ghost" onPress={() => setFinishing(false)} />
</Screen>
);