From f33e14b1f41d5337085fead788b719de6700f047 Mon Sep 17 00:00:00 2001 From: felixtanhm Date: Fri, 3 May 2024 12:53:34 +0800 Subject: [PATCH] Feat | routing to individual pokemon page --- .../client/src/components/PokeCard.jsx | 24 +++++++++++++++---- .../client/src/components/PokeList.jsx | 4 ++-- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/full-stack-javascript/21-inventory-application/client/src/components/PokeCard.jsx b/full-stack-javascript/21-inventory-application/client/src/components/PokeCard.jsx index 1c97367..c4ce6b0 100644 --- a/full-stack-javascript/21-inventory-application/client/src/components/PokeCard.jsx +++ b/full-stack-javascript/21-inventory-application/client/src/components/PokeCard.jsx @@ -2,20 +2,34 @@ import capitalise from "../utils/capitalise"; import { HeartIcon as HeartIconOutline } from "@heroicons/react/24/outline"; import { HeartIcon as HeartIconSolid } from "@heroicons/react/24/solid"; import PokemonType from "./PokemonType"; +import { useNavigate } from "react-router-dom"; function PokeCard({ pokemon }) { - function handleClick(e) { + const navigate = useNavigate(); + function toggleFavorite(e, pokemonId) { + e.stopPropagation(); + console.log(pokemonId); + } + + function displayPokemon(e, pokemonId) { console.log(e); + console.log(pokemonId); + navigate(`/pokemon/${pokemonId}`); } return ( -
+
{ + displayPokemon(e, pokemon.id); + }} + >
-

+

{capitalise(pokemon.name)}

diff --git a/full-stack-javascript/21-inventory-application/client/src/components/PokeList.jsx b/full-stack-javascript/21-inventory-application/client/src/components/PokeList.jsx index 6c23aaa..ef671df 100644 --- a/full-stack-javascript/21-inventory-application/client/src/components/PokeList.jsx +++ b/full-stack-javascript/21-inventory-application/client/src/components/PokeList.jsx @@ -69,8 +69,8 @@ function PokeList() {