import { Link } from 'react-router' import { Heart, Clock } from 'lucide-react' import { useMutation, useQueryClient } from '@tanstack/react-query' import { toggleFavorite } from '../../api/recipes' import { useAuth } from '../../context/AuthContext' import type { Recipe } from '../../api/types' const gradients = [ 'from-primary/60 to-secondary/60', 'from-secondary/60 to-sage/60', 'from-primary-light to-primary/40', 'from-sage/40 to-secondary/60', ] export function RecipeCard({ recipe }: { recipe: Recipe }) { const { isAuthenticated } = useAuth() const qc = useQueryClient() const favMutation = useMutation({ mutationFn: () => toggleFavorite(recipe.id), onSuccess: () => qc.invalidateQueries({ queryKey: ['recipes'] }), }) const gradient = gradients[recipe.title.length % gradients.length] const totalTime = recipe.total_time_min || ((recipe.prep_time_min || 0) + (recipe.cook_time_min || 0)) return (
{recipe.image_url ? ( {recipe.title} ) : (
🍰
)}

{recipe.title}

{isAuthenticated && (
{totalTime > 0 && ( {totalTime} min )}
)}
) }