Fas 3 steg 3b: minimala efterfrågor + hushållsantagandeprofiler per ingrediens
This commit is contained in:
@@ -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>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user