import { useState, useEffect } from "react"; import { useLocation } from "wouter"; import { useQuery } from "@tanstack/react-query"; import { ChefHat } from "lucide-react"; interface DailyRecipe { id: number; dateStr: string; name: string; intro?: string; imageUrl?: string | null; } export function RecipeWidget() { const [, navigate] = useLocation(); const [index, setIndex] = useState(0); const [paused, setPaused] = useState(false); const { data = [] } = useQuery({ queryKey: ["/api/recipes"], staleTime: 1000 * 60 * 30, }); const pool = data.filter((r) => r.imageUrl).slice(0, 10); useEffect(() => { if (paused || pool.length <= 1) return; const t = setInterval(() => setIndex((i) => (i + 1) % pool.length), 8000); return () => clearInterval(t); }, [paused, pool.length]); if (pool.length === 0) return null; const recipe = pool[index % pool.length]; return ( ); }