From e2bbe1d959548003d72f57f373c384a06926980a Mon Sep 17 00:00:00 2001 From: Jason Zhu Date: Tue, 11 Apr 2023 19:50:59 +1000 Subject: [PATCH] Implemented filteredPokemonList feature --- src/features/Pokedex/Pokedex.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/features/Pokedex/Pokedex.tsx b/src/features/Pokedex/Pokedex.tsx index 4bd00db..639b128 100644 --- a/src/features/Pokedex/Pokedex.tsx +++ b/src/features/Pokedex/Pokedex.tsx @@ -9,15 +9,23 @@ const Pokedex = () => { const isLoadingPokemons = useAppSelector( state => state.pokedex.isLoadingPokemons, ); + const selectedType = useAppSelector(state => state.pokedex.selectedType); + const selectedSort = useAppSelector(state => state.pokedex.selectedSort); + const pokemonList = useAppSelector(state => state.pokedex.pokemonList); + const filteredPokemonList = pokemonList.filter(pokemon => { + selectedType === 'All Types' || + pokemon.types.some(type => type.type.name === selectedType); + }); + return ( <> {isLoadingPokemons ? ( ) : ( - pokemonList.map(pokemon => ( + filteredPokemonList.map(pokemon => (