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:
@@ -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 */ }
|
||||
}
|
||||
|
||||
|
||||
@@ -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<number | null>(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],
|
||||
|
||||
Reference in New Issue
Block a user