diff --git a/components/FeedSackCountingPage.tsx b/components/FeedSackCountingPage.tsx index 059e8d6..7ecd4ea 100644 --- a/components/FeedSackCountingPage.tsx +++ b/components/FeedSackCountingPage.tsx @@ -69,9 +69,9 @@ const FeedSackCountingPage: React.FC<{ onSettings: () => void }> = ({ onSettings const latestManual = sortedManualRows.find((row) => row.date === displayDate) ?? null; const currentDay = useMemo(() => { if (!selectedCycle) return 0; - const rawDay = cycleDayForDate(selectedCycle.start_date, displayDate); - return Math.min(rawDay, Math.max(0, selectedCycle.total_days - 1)); - }, [selectedCycle, displayDate]); + const boundDate = selectedCycle.end_date ?? selectedCycle.visible_through_date ?? todayIso(); + return cycleDayForDate(selectedCycle.start_date, boundDate); + }, [selectedCycle]); const handleSync = useCallback(async () => { if (!selectedCycle) return;