diff --git a/app/actions/trainer.js b/app/actions/trainer.js index 65d0fe8..8bb7579 100644 --- a/app/actions/trainer.js +++ b/app/actions/trainer.js @@ -223,8 +223,8 @@ function parseInventory(inventory) { // TODO use map speciesList.forEach((s) => { const pokemonSetting = pokemonSettings[s.pokemon_id - 1] - const candyToEvolve = pokemonSetting ? pokemonSetting.candy_to_evolve : 0 - s.evolves = utils.getEvolvesCount(candyToEvolve, s) + s.candyToEvolve = pokemonSetting ? pokemonSetting.candy_to_evolve : 0 + s.evolves = utils.getEvolvesCount(s.candyToEvolve, s.candy, s.count) }) return { diff --git a/app/screens/Detail/components/Nickname.js b/app/screens/Detail/components/Nickname.js index 8703d4d..9602e78 100644 --- a/app/screens/Detail/components/Nickname.js +++ b/app/screens/Detail/components/Nickname.js @@ -64,7 +64,7 @@ class Nickname extends React.Component { render() { const { editing, - newNickname + newNickname, } = this.state if (editing) { diff --git a/app/screens/Table/components/PokemonTableHead.js b/app/screens/Table/components/PokemonTableHead.js index 23d2d22..eaf1feb 100644 --- a/app/screens/Table/components/PokemonTableHead.js +++ b/app/screens/Table/components/PokemonTableHead.js @@ -38,7 +38,7 @@ class PokemonTableHead extends React.PureComponent { colSpan="1" aria-controls="pokemon-data" aria-label="Favorite: activate to sort column ascending" - onClick={this.handleSortPokemon.bind(this, 'favorite')} + onClick={this.createHandleSortPokemon('favorite')} > @@ -53,7 +53,7 @@ class PokemonTableHead extends React.PureComponent { colSpan="1" aria-controls="pokemon-data" aria-label="Name: activate to sort column ascending" - onClick={this.handleSortPokemon.bind(this, 'name')} + onClick={this.createHandleSortPokemon('name')} > Name @@ -64,7 +64,7 @@ class PokemonTableHead extends React.PureComponent { colSpan="1" aria-controls="pokemon-data" aria-label="Nickname: activate to sort column ascending" - onClick={this.handleSortPokemon.bind(this, 'nickname')} + onClick={this.createHandleSortPokemon('nickname')} > Nickname @@ -75,7 +75,7 @@ class PokemonTableHead extends React.PureComponent { colSpan="1" aria-controls="pokemon-data" aria-label="CP: activate to sort column ascending" - onClick={this.handleSortPokemon.bind(this, 'cp')} + onClick={this.createHandleSortPokemon('cp')} > CP @@ -86,7 +86,7 @@ class PokemonTableHead extends React.PureComponent { colSpan="1" aria-controls="pokemon-data" aria-label="Level: activate to sort column ascending" - onClick={this.handleSortPokemon.bind(this, 'level')} + onClick={this.createHandleSortPokemon('level')} > Level @@ -97,7 +97,7 @@ class PokemonTableHead extends React.PureComponent { colSpan="1" aria-controls="pokemon-data" aria-label="IV: activate to sort column ascending" - onClick={this.handleSortPokemon.bind(this, 'iv')} + onClick={this.createHandleSortPokemon('iv')} > IV @@ -115,10 +115,10 @@ class PokemonTableHead extends React.PureComponent { onCheckAll(species) } - handleSortPokemon = (sortBy) => { + createHandleSortPokemon = (sortBy) => () => { const { pokemonId, - sortPokemonBy + sortPokemonBy, } = this.props sortPokemonBy(sortBy, pokemonId - 1) @@ -127,7 +127,7 @@ class PokemonTableHead extends React.PureComponent { getSortDirectionClassName = (key) => { const { sortBy, - sortDir + sortDir, } = this.props if (sortBy === key) { diff --git a/app/screens/Table/components/Species.js b/app/screens/Table/components/Species.js index 5684d7c..df97b76 100644 --- a/app/screens/Table/components/Species.js +++ b/app/screens/Table/components/Species.js @@ -142,6 +142,20 @@ class Species extends React.Component { sortDir } = speciesState[specie.pokemon_id] + let extraCandyNeededSpan + + if (specie.evolves > 0) { + const totalCandyNeeded = specie.candyToEvolve * specie.count + const extraCandyNeeded = totalCandyNeeded - specie.candy + if (extraCandyNeeded > 0) { + extraCandyNeededSpan = ( + + {` +${extraCandyNeeded}`} + + ) + } + } + return ([