feat: public/private view separation + profile favorites

- Hide time, favorites heart, recipe counter, random buttons for guests
- Move favorites section from HomePage to ProfilePage (personal)
- Make avatar button clickable → login (guest) / profile (logged in)
- Show user avatar in top bar when available
- Add Airfryer category
This commit is contained in:
clawd
2026-02-18 20:12:45 +00:00
parent 5cce78f40f
commit e10e8f3fe2
3 changed files with 78 additions and 49 deletions

View File

@@ -2,6 +2,7 @@ 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 = [
@@ -12,6 +13,7 @@ const gradients = [
]
export function RecipeCard({ recipe }: { recipe: Recipe }) {
const { isAuthenticated } = useAuth()
const qc = useQueryClient()
const favMutation = useMutation({
mutationFn: () => toggleFavorite(recipe.id),
@@ -36,22 +38,24 @@ export function RecipeCard({ recipe }: { recipe: Recipe }) {
<Link to={`/recipe/${recipe.slug}`}>
<h3 className="font-display text-base sm:text-lg text-espresso line-clamp-2">{recipe.title}</h3>
</Link>
<div className="flex items-center justify-between mt-2">
{totalTime > 0 && (
<span className="flex items-center gap-1 text-warm-grey text-xs">
<Clock size={14} /> {totalTime} min
</span>
)}
<button
onClick={(e) => { e.preventDefault(); e.stopPropagation(); favMutation.mutate() }}
className="ml-auto p-2 -mr-2 min-w-[44px] min-h-[44px] flex items-center justify-center active:scale-125 transition-transform"
>
<Heart
size={22}
className={recipe.is_favorite ? 'fill-primary text-primary' : 'text-warm-grey'}
/>
</button>
</div>
{isAuthenticated && (
<div className="flex items-center justify-between mt-2">
{totalTime > 0 && (
<span className="flex items-center gap-1 text-warm-grey text-xs">
<Clock size={14} /> {totalTime} min
</span>
)}
<button
onClick={(e) => { e.preventDefault(); e.stopPropagation(); favMutation.mutate() }}
className="ml-auto p-2 -mr-2 min-w-[44px] min-h-[44px] flex items-center justify-center active:scale-125 transition-transform"
>
<Heart
size={22}
className={recipe.is_favorite ? 'fill-primary text-primary' : 'text-warm-grey'}
/>
</button>
</div>
)}
</div>
</div>
)