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 (
+
Difficulty: {displayDifficulty(recipe.Difficulty)} {" "} | Duration: {recipe.Duration.Total} min @@ -52,5 +69,5 @@ export default function RecipeListItem({ recipe }: RecipeListItemProps) {
)}