From e10e8f3fe278d96fff914ebafc17ea9805efbef7 Mon Sep 17 00:00:00 2001 From: clawd Date: Wed, 18 Feb 2026 20:12:45 +0000 Subject: [PATCH] feat: public/private view separation + profile favorites MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- frontend/src/components/recipe/RecipeCard.tsx | 36 +++++++------- frontend/src/pages/HomePage.tsx | 48 +++++++------------ frontend/src/pages/ProfilePage.tsx | 43 ++++++++++++++++- 3 files changed, 78 insertions(+), 49 deletions(-) diff --git a/frontend/src/components/recipe/RecipeCard.tsx b/frontend/src/components/recipe/RecipeCard.tsx index cbf74e5..15d3091 100644 --- a/frontend/src/components/recipe/RecipeCard.tsx +++ b/frontend/src/components/recipe/RecipeCard.tsx @@ -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 }) {

{recipe.title}

-
- {totalTime > 0 && ( - - {totalTime} min - - )} - -
+ {isAuthenticated && ( +
+ {totalTime > 0 && ( + + {totalTime} min + + )} + +
+ )} ) diff --git a/frontend/src/pages/HomePage.tsx b/frontend/src/pages/HomePage.tsx index 9073048..70450cb 100644 --- a/frontend/src/pages/HomePage.tsx +++ b/frontend/src/pages/HomePage.tsx @@ -8,13 +8,14 @@ import { fetchRecipes, fetchRandomRecipe } from '../api/recipes' import { fetchCategories } from '../api/categories' import { fetchTags } from '../api/tags' import { RecipeCard } from '../components/recipe/RecipeCard' -import { RecipeCardSmall } from '../components/recipe/RecipeCardSmall' import type { Recipe } from '../api/types' import { Badge } from '../components/ui/Badge' import { RecipeCardSkeleton } from '../components/ui/Skeleton' import { EmptyState } from '../components/ui/EmptyState' +import { useAuth } from '../context/AuthContext' export function HomePage() { + const { isAuthenticated, user } = useAuth() const [activeCategory, setActiveCategory] = useState() const [activeTag, setActiveTag] = useState() const navigate = useNavigate() @@ -34,14 +35,8 @@ export function HomePage() { queryFn: () => fetchRecipes({ category: activeCategory, sort: 'newest' }), }) - const { data: favoritesData } = useQuery({ - queryKey: ['recipes', { favorite: true }], - queryFn: () => fetchRecipes({ favorite: true }), - }) - const recipes = recipesData?.data ?? [] const totalCount = recipesData?.total ?? 0 - const favorites = favoritesData?.data ?? [] // Filter by tag client-side if active const filteredRecipes = activeTag @@ -69,11 +64,20 @@ export function HomePage() { {/* TopBar */}

🧁 Luna Recipes

-
👤
+
- {/* Recipe Counter */} - {totalCount > 0 && ( + {/* Recipe Counter (logged in only) */} + {isAuthenticated && totalCount > 0 && ( )} - {/* Random Recipe Buttons */} - {totalCount > 1 && ( + {/* Random Recipe Buttons (logged in only) */} + {isAuthenticated && totalCount > 1 && (