fix: dice stays in category + new recipe

- 'Nochmal würfeln' stays in cook/bake category via ?type= param
- Added: Hähnchen-Frischkäse-Röllchen (Airfryer) - Marc's recipe
This commit is contained in:
clawd
2026-02-18 19:09:20 +00:00
parent 8c0ffc653f
commit 5cce78f40f
2 changed files with 10 additions and 5 deletions

View File

@@ -51,14 +51,14 @@ export function HomePage() {
const handleRandomCook = async () => { const handleRandomCook = async () => {
try { try {
const recipe = await fetchRandomRecipe(['mittag', 'abend', 'fruehstueck']) 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 */ } } catch { /* no recipes */ }
} }
const handleRandomBake = async () => { const handleRandomBake = async () => {
try { try {
const recipe = await fetchRandomRecipe(['backen', 'torten', 'desserts']) 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 */ } } catch { /* no recipes */ }
} }

View File

@@ -19,20 +19,25 @@ export function RecipePage() {
const navigate = useNavigate() const navigate = useNavigate()
const [searchParams] = useSearchParams() const [searchParams] = useSearchParams()
const fromRandom = searchParams.get('from') === 'random' const fromRandom = searchParams.get('from') === 'random'
const randomType = searchParams.get('type') // 'cook' or 'bake'
const qc = useQueryClient() const qc = useQueryClient()
const [servingScale, setServingScale] = useState<number | null>(null) const [servingScale, setServingScale] = useState<number | null>(null)
const [noteText, setNoteText] = useState('') const [noteText, setNoteText] = useState('')
const [rerolling, setRerolling] = useState(false) const [rerolling, setRerolling] = useState(false)
const [showIngredientPicker, setShowIngredientPicker] = useState(false) const [showIngredientPicker, setShowIngredientPicker] = useState(false)
const COOK_CATEGORIES = ['mittag', 'abend', 'fruehstueck']
const BAKE_CATEGORIES = ['backen', 'torten', 'desserts']
const handleReroll = useCallback(async () => { const handleReroll = useCallback(async () => {
setRerolling(true) setRerolling(true)
try { try {
const r = await fetchRandomRecipe() const categories = randomType === 'bake' ? BAKE_CATEGORIES : randomType === 'cook' ? COOK_CATEGORIES : undefined
if (r?.slug) navigate(`/recipe/${r.slug}?from=random`, { replace: true }) const r = await fetchRandomRecipe(categories)
if (r?.slug) navigate(`/recipe/${r.slug}?from=random${randomType ? `&type=${randomType}` : ''}`, { replace: true })
} catch { /* ignore */ } } catch { /* ignore */ }
setRerolling(false) setRerolling(false)
}, [navigate]) }, [navigate, randomType])
const { data: recipe, isLoading } = useQuery({ const { data: recipe, isLoading } = useQuery({
queryKey: ['recipe', slug], queryKey: ['recipe', slug],