From 5cce78f40f17f4a8b5a070c411ebd93b811b8c79 Mon Sep 17 00:00:00 2001 From: clawd Date: Wed, 18 Feb 2026 19:09:20 +0000 Subject: [PATCH] fix: dice stays in category + new recipe MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 'Nochmal würfeln' stays in cook/bake category via ?type= param - Added: Hähnchen-Frischkäse-Röllchen (Airfryer) - Marc's recipe --- frontend/src/pages/HomePage.tsx | 4 ++-- frontend/src/pages/RecipePage.tsx | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/frontend/src/pages/HomePage.tsx b/frontend/src/pages/HomePage.tsx index 99f7e43..9073048 100644 --- a/frontend/src/pages/HomePage.tsx +++ b/frontend/src/pages/HomePage.tsx @@ -51,14 +51,14 @@ export function HomePage() { const handleRandomCook = async () => { try { const recipe = await fetchRandomRecipe(['mittag', 'abend', 'fruehstueck']) - if (recipe?.slug) navigate(`/recipe/${recipe.slug}?from=random`) + if (recipe?.slug) navigate(`/recipe/${recipe.slug}?from=random&type=cook`) } catch { /* no recipes */ } } const handleRandomBake = async () => { try { const recipe = await fetchRandomRecipe(['backen', 'torten', 'desserts']) - if (recipe?.slug) navigate(`/recipe/${recipe.slug}?from=random`) + if (recipe?.slug) navigate(`/recipe/${recipe.slug}?from=random&type=bake`) } catch { /* no recipes */ } } diff --git a/frontend/src/pages/RecipePage.tsx b/frontend/src/pages/RecipePage.tsx index 1c804f2..29dedf4 100644 --- a/frontend/src/pages/RecipePage.tsx +++ b/frontend/src/pages/RecipePage.tsx @@ -19,20 +19,25 @@ export function RecipePage() { const navigate = useNavigate() const [searchParams] = useSearchParams() const fromRandom = searchParams.get('from') === 'random' + const randomType = searchParams.get('type') // 'cook' or 'bake' const qc = useQueryClient() const [servingScale, setServingScale] = useState(null) const [noteText, setNoteText] = useState('') const [rerolling, setRerolling] = useState(false) const [showIngredientPicker, setShowIngredientPicker] = useState(false) + const COOK_CATEGORIES = ['mittag', 'abend', 'fruehstueck'] + const BAKE_CATEGORIES = ['backen', 'torten', 'desserts'] + const handleReroll = useCallback(async () => { setRerolling(true) try { - const r = await fetchRandomRecipe() - if (r?.slug) navigate(`/recipe/${r.slug}?from=random`, { replace: true }) + const categories = randomType === 'bake' ? BAKE_CATEGORIES : randomType === 'cook' ? COOK_CATEGORIES : undefined + const r = await fetchRandomRecipe(categories) + if (r?.slug) navigate(`/recipe/${r.slug}?from=random${randomType ? `&type=${randomType}` : ''}`, { replace: true }) } catch { /* ignore */ } setRerolling(false) - }, [navigate]) + }, [navigate, randomType]) const { data: recipe, isLoading } = useQuery({ queryKey: ['recipe', slug],