Global

Members

(constant) filterPokemons

Selector: Filters the Pokemon based on search query and filters.
Source:

filteredPokemonsElements

Renders the filtered Pokemon cards if the search exists and returns search results. It the search exists, but returns no results, the user is notified.
Source:

(constant) initialState

Initial state
Source:

(constant) persistConfig

Configuration object for redux-persist. Only objects on the whitelist are stored.
Source:

(constant) persistedReducer

Persisted reducer
Source:

(constant) persistor

The Redux persistor for persisting store state.
Source:

(constant) pokemonsAdapter

Entity adapter
Source:

pokemonsElements

Renders the Pokemon cards.
Source:

(constant) pokemonsSelectors

Creates a selector object for working with the entity data, e.g. selectEntities.
Source:

(constant) searchExists

To check if a search exists
Source:

(constant) store

The Redux store.
Source:

Methods

abilitiesElements(abilities) → {Array}

Creates the JSX elements of the Pokemon's abilities
Parameters:
Name Type Description
abilities Object Containg data on the Pokemon's abilities.
Source:
Returns:
- Containing JSX elements with the Pokemon's abilities.
Type
Array

extraReducers()

Handles the async actions for fetching Pokemon.
Source:

(async) fetchPokemons() → {Promise:.<Array:.<Object:>>}

Fetches the Pokemon data from the API.
Source:
Throws:
If there is an error fetching the data.
Type
Error
Returns:
The array of Pokemon data.
Type
Promise:.<Array:.<Object:>>

fetchPokemonsThunk()

Fetches the Pokemon with a thunk function
Source:

filterByAbility(abilityFilter, pokemon) → {boolean}

Filters Pokemons by ability based on the ability filter.
Parameters:
Name Type Description
abilityFilter string The ability filter string.
pokemon Object The Pokemon object to filter.
Source:
Returns:
Whether the Pokemon has the ability or not.
Type
boolean

filterByQuery(searchQuery, pokemons) → {Array}

Filters Pokemons by name based on the search query.
Parameters:
Name Type Description
searchQuery string The search query string.
pokemons Array The array of Pokemons to filter.
Source:
Returns:
The filtered array of Pokemons.
Type
Array

filterByType(typeFilter, pokemon) → {boolean}

Filters Pokemons by type based on the type filter.
Parameters:
Name Type Description
typeFilter string The type filter string.
pokemon Object The Pokemon object to filter.
Source:
Returns:
Whether the Pokemon matches the type filter or not.
Type
boolean

handleAbilityFilterChange(event)

Dispatches the action to update ability filter and performs the filtering by ability.
Parameters:
Name Type Description
event Object The event to get the value from the selected ability.
Source:

handleKeyDownNameForm()

Handles when the user presses Enter instead of "Save" button. Prevents the default action of submitting the form, causing a refresh.
Source:

handleOnKeyDownSearchForm()

Prevents the default submitting of the form if the user presses Enter.
Source:

handleQueryChange(event)

Dispatches the action to update the search query and performs the search.
Parameters:
Name Type Description
event Object The event to get the value in the form.
Source:

handleResetFilters()

Dispatches actions to reset all the filters.
Source:

handleRetry()

Handles the retry action when fetching Pokemon fails.
Source:

handleSavePokemon()

Dispatches the action to save/delete a Pokemon when the user clicks on the save/delete icon.
Source:

handleSortByHP()

Dispatches the action to sort by HP(high to low).
Source:

handleSortByName()

Dispatches the action to sort alphabetically.
Source:

handleSubmitNewName()

Dispatches action for updating the Pokemon's name.
Source:

handleTypeFilterChange(event)

Dispatches the action to update type filter and performs the filtering by type.
Parameters:
Name Type Description
event Object The event to get the value from the selected type.
Source:

pokemonSlice()

Slice containing the reducers and actions. Generates action creators and action types.
Source:

savedPokemonsElements() → {Array:.<JSX.Element:>}

Renders the saved Pokemon cards.
Source:
Returns:
The array of rendered Pokemon cards.
Type
Array:.<JSX.Element:>

selectAllPokemons()

Selector: Selects all Pokemon that are not saved by the user.
Source:

selectAllPokemons()

Selector: Selects all Pokemon that are saved by the user.
Source:

sortPokemons(sortBy, pokemons) → {Array}

Sorts Pokemons based on the given sort criteria.
Parameters:
Name Type Description
sortBy string The sort criteria (e.g., 'name', 'hp').
pokemons Array The array of Pokemons to sort.
Source:
Returns:
The sorted array of Pokemons.
Type
Array

toggleEditNameForm()

Sets the local state to show/hide the edit name form.
Source:

toggleSavePokemon()

Reducer: Toggles the save state for pokemons (myPokemon)
Parameters:
Type Description
Object
Source:

updateAbilityFilter(state, action)

Reducer: Updates the ability filter and filters Pokemon by chosen ability.
Parameters:
Name Type Description
state Object Current state.
action Object Action containing the ability to filter by, e.g. "Run-Away"
Source:

updatePokemonName()

Reducer: Updates the name of a saved pokemon.
Parameters:
Type Description
Object
Source:

updateSearchQuery(state, action)

Reducer: Updates the search query and filters the Pokemon based on the query.
Parameters:
Name Type Description
state Object Current state.
action Object Action containing the search query.
Source:

updateSortBy(state, action)

Reducer: Updates the sort by in state and sorts either alphabetically or by HP.
Parameters:
Name Type Description
state Object Current state.
action Object Action containing either "name" or "hp".
Source:

updateTypeFilter(state, action)

Reducer: Updates the type filter and filters Pokemon based on chosen type.
Parameters:
Name Type Description
state Object Current state.
action Object Action containing the Pokemon type, e.g. "Grass".
Source:

Type Definitions

PokemonData

Type:
  • Object
Properties:
Name Type Description
name string The name of the Pokemon.
url string The URL of the Pokemon's details.
image string The URL of the Pokemon's image.
hp number The HPof the Pokemon.
abilities Array:.<Object:> The abilities of the Pokemon.
id number The ID of the Pokemon.
type string The type of the Pokemon.
backgroundColor string The background color for the Pokemon's type.
icon string The icon for with the Pokemon's type.
myPokemon boolean To save/delete Pokemon from the user's list.
Source: