Skip to content

Commit 726ecc7

Browse files
JiroMusikclaude
andcommitted
Fix: targetDate defaults to today if saved date is in the past
localStorage cached an old date (2026-03-24), causing all new recipes to be added to that date instead of today. Now compares saved date against today and uses today if saved date is in the past. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 4708e68 commit 726ecc7

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/pages/Recipes.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@ export default function Recipes() {
1818
const [loading, setLoading] = useState(false);
1919
const [preferences, setPreferences] = useState(() => localStorage.getItem('recipePreferences') || '');
2020
const [portions, setPortions] = useState(() => parseInt(localStorage.getItem('recipePortions') || '2'));
21-
const [targetDate, setTargetDate] = useState(() => localStorage.getItem('recipeTargetDate') || new Date().toISOString().split('T')[0]);
21+
const [targetDate, setTargetDate] = useState(() => {
22+
const saved = localStorage.getItem('recipeTargetDate');
23+
const today = new Date().toISOString().split('T')[0];
24+
// Never use a date in the past
25+
return (saved && saved >= today) ? saved : today;
26+
});
2227
const [mode, setMode] = useState<'single' | 'weekly'>(() => (localStorage.getItem('recipeMode') as 'single' | 'weekly') || 'single');
2328
const [expandedDay, setExpandedDay] = useState<number | null>(null);
2429
const [cookedResult, setCookedResult] = useState<any>(null);

0 commit comments

Comments
 (0)