From 4093f9fd9c31d76d4a16437070a2d3481f00b36d Mon Sep 17 00:00:00 2001
From: Hayden Hargreaves
Date: Mon, 1 Dec 2025 12:30:38 -0700
Subject: [PATCH] (FIX): Added click handler to profile recipe list items.
---
web/src/components/items/RecipeListItem.tsx | 27 +++++++++++++++++----
web/src/pages/Home.tsx | 1 -
2 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/web/src/components/items/RecipeListItem.tsx b/web/src/components/items/RecipeListItem.tsx
index ff321e6..defd44e 100644
--- a/web/src/components/items/RecipeListItem.tsx
+++ b/web/src/components/items/RecipeListItem.tsx
@@ -1,3 +1,6 @@
+import { useNavigate } from "react-router-dom";
+import { EngagementViewRecipe } from "../../services/EngagementService";
+import { isApiError } from "../../types/api/error";
import type { Recipe, Tag } from "../../types/recipe"
interface RecipeListItemProps {
@@ -26,12 +29,26 @@ function displayTags(tags: Tag[]): string {
}
export default function RecipeListItem({ recipe }: RecipeListItemProps) {
- // TODO: Click event
- return <>
+ const navigate = useNavigate();
+
+ // HANDLERS
+ const clickHandler = async () => {
+ if (!recipe) return;
+
+ // Navigate first, so it feels faster
+ await navigate(`/v2/web/recipe/${recipe.Id}`);
+
+ const result = await EngagementViewRecipe(recipe.Id);
+ if (isApiError(result)) {
+ console.error(result.message);
+ }
+ }
+
+ return (
-
+
void clickHandler()} className="text-base md:text-lg hover:text-blue-600 duration-100 cursor-pointer">
{recipe.Title}
-
+
Difficulty: {displayDifficulty(recipe.Difficulty)}
{" "} | Duration: {recipe.Duration.Total} min
@@ -52,5 +69,5 @@ export default function RecipeListItem({ recipe }: RecipeListItemProps) {
)}
- >
+ );
}
diff --git a/web/src/pages/Home.tsx b/web/src/pages/Home.tsx
index a97d537..d1d9c38 100644
--- a/web/src/pages/Home.tsx
+++ b/web/src/pages/Home.tsx
@@ -12,7 +12,6 @@ import { GetRecipeOfTheWeek } from "../services/RecipeService";
import { isApiError, type ApiError } from "../types/api/error";
import { AuthContext } from "../context/AuthContext";
import { GetAuthenticatedUserMadeRecipes, GetAuthenticateUserViewedRecipes } from "../services/UserService";
-import { type SearchFilters } from "../types/search";
export default function Home() {
// Context