{pokemon && pokemon.types.map((type_, i) => {
const type_name = String(type_.type.name)
- console.log('TYPE IS', type_name)
+ //console.log('TYPE IS', type_name)
const TypeComponent = typeComponents[type_name];
return (}
diff --git a/src/components/pokelist.jsx b/src/components/pokelist.jsx
index 483df07..e12d1a0 100644
--- a/src/components/pokelist.jsx
+++ b/src/components/pokelist.jsx
@@ -8,7 +8,7 @@ import Button from '@mui/material/Button';
import Typography from '@mui/material/Typography';
import StarBorderSharpIcon from '@mui/icons-material/StarBorderSharp';
import StarIcon from '@mui/icons-material/Star';
-import List from '@mui/material/List';
+import { Stack } from '@mui/material';
import ListItem from '@mui/material/ListItem';
import ManageSearchIcon from '@mui/icons-material/ManageSearch';
import Chip from '@mui/material/Chip';
@@ -32,6 +32,7 @@ import { ReactComponent as Psychic } from '../img/psychic.svg'
import { ReactComponent as Rock } from '../img/rock.svg'
import { ReactComponent as Steel } from '../img/steel.svg'
import { ReactComponent as Water } from '../img/water.svg'
+
const typeComponents = {
'loading': Grass,
'undefined': Grass,
@@ -91,21 +92,9 @@ function Pokelist({ favs, data, page, pageSize, dispatch }) {
}
function handleClick(e) {
const id = e.currentTarget.value
- console.log('id', id)
+ //console.log('id', id)
navigateTo(`/${id}`);
}
- /* let typeOneColor
- let typeTwoColor
- const highestStat = Math.max(...pokemon.stats.map((item) => item.base_stat))
- console.log(highestStat)
-
- if (pokemon.types.length == 2) {
- typeOneColor = typeColors[String(pokemon.types[0].type.name)]
- typeTwoColor = typeColors[String(pokemon.types[1].type.name)]
- } else {
- typeOneColor = typeColors[String(pokemon.types[0].type.name)]
- typeTwoColor = typeColors[String(pokemon.types[0].type.name)]
- } */
return (
{pageData && pageData.map((pokemon, i) => {
@@ -120,15 +109,25 @@ function Pokelist({ favs, data, page, pageSize, dispatch }) {
sx={{objectFit: 'contain'}}
/>
-
- {upperFirstLetter(pokemon.name)}
-
-
+
+
+ {upperFirstLetter(pokemon.name)}
+
+
+ #{pokemon.id}
+
+
+
{pokemon.pokemon_v2_pokemontypes.map((type_, i) => {
const type_name = String(type_.pokemon_v2_type.name)
- console.log('TYPE IS', type_name)
+ // console.log('TYPE IS', type_name)
const TypeComponent = typeComponents[type_name];
- return (}
label={type_name}
key={"type" + i}
@@ -138,30 +137,49 @@ function Pokelist({ favs, data, page, pageSize, dispatch }) {
}
-
- {(() => {
+
+ {(() => {
if (favs.includes(pokemon.id)) {
return dispatch({ type: 'setFav', value: pokemon.id })} />
} else {
return dispatch({ type: 'setFav', value: pokemon.id })} />
}
})()}
-
+
-
+
-
-
+
+
-
+
+
+ #{pokemon.id}
+
+
{upperFirstLetter(pokemon.name)}
-
+
+
{pokemon.pokemon_v2_pokemontypes.map((type_, i) => {
const type_name = String(type_.pokemon_v2_type.name)
- console.log('TYPE IS', type_name)
+ //console.log('TYPE IS', type_name)
const TypeComponent = typeComponents[type_name];
- return (}
label={type_name}
key={"type" + i}
@@ -170,7 +188,14 @@ function Pokelist({ favs, data, page, pageSize, dispatch }) {
)
}
-
+
{(() => {
if (favs.includes(pokemon.id)) {
return dispatch({ type: 'setFav', value: pokemon.id })} />
@@ -178,12 +203,12 @@ function Pokelist({ favs, data, page, pageSize, dispatch }) {
return dispatch({ type: 'setFav', value: pokemon.id })} />
}
})()}
-
+
diff --git a/src/components/searchbar.jsx b/src/components/searchbar.jsx
index 58d8464..82b139b 100644
--- a/src/components/searchbar.jsx
+++ b/src/components/searchbar.jsx
@@ -47,7 +47,7 @@ const StyledInputBase = styled(InputBase)(({ theme }) => ({
}));
export default function SearchAppBar({searchValue, dispatch}) {
- console.log('search Value is', searchValue)
+ //console.log('search Value is', searchValue)
return (
diff --git a/src/hooks/reducer.js b/src/hooks/reducer.js
index dbc429f..d4d5f9e 100644
--- a/src/hooks/reducer.js
+++ b/src/hooks/reducer.js
@@ -2,11 +2,13 @@ import {getLocalStorageObj} from '../utils'
const [favs,] = getLocalStorageObj('favs',[])
const [favIds,] = getLocalStorageObj('favIds',[])
+const login = localStorage.getItem('login')
export const initialState = {
data: [],
favs: favs,
favIds: favIds,
+ login: login,
mainPage: {
currentData:[],
page: 1,
@@ -50,7 +52,7 @@ export const reducer = (state, action) => {
return {...state, favPage: {...state.favPage, page: action.page}}
case 'getPokemon':
const pokemon = action.pokemon;
- console.log('El pokemon es: ', pokemon.name)
+ //console.log('El pokemon es: ', pokemon.name)
return {...state, detailPage: {pokemon: pokemon}}
case 'setFav':
const id = action.value;
@@ -79,11 +81,19 @@ export const reducer = (state, action) => {
if (newType === state.filterState.type){
newType = 'all'
} else if(types_list.includes(newType)){
- console.log(newType)
+ //console.log(newType)
} else {
newType = 'all'
}
return {...state, filterState: {...state.filterState, type: newType}}
+ case 'login':
+ //console.log('login got to the reducer')
+ localStorage.setItem('login', 'true')
+ return {...state, login:'true'}
+ case 'logout':
+ //console.log('logout got to the reducer')
+ localStorage.removeItem('login')
+ return {...state, login:false}
// case 'gen':
// return {...state, filterState: {gen: action.value}}
// const generation = action.generation;
diff --git a/src/index.js b/src/index.js
index fc1ce98..b598861 100644
--- a/src/index.js
+++ b/src/index.js
@@ -5,10 +5,11 @@ import App from './App';
import reportWebVitals from './reportWebVitals';
import CssBaseline from '@mui/material/CssBaseline';
import { createTheme, ThemeProvider } from '@mui/material/styles';
-import { checkValue, validUser, validPass} from './utils'
+import { checkValue } from './utils'
const appName = 'pokedata'
const version = '0.15'
+
checkValue('appName', appName)
checkValue('version', version)
localStorage.setItem('appName', appName)
diff --git a/src/utils.js b/src/utils.js
index 705321e..7651f1b 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -1,20 +1,17 @@
-export const validUser = 'ash_ketchum'
-export const validPass = 'pikachu123'
-
export const getLocalStorageObj = (key, defaultVal) => {
try{
const item = JSON.parse(localStorage.getItem(key))
if (item===null){
localStorage.setItem(key, JSON.stringify(defaultVal))
- console.log(`item ${key} is null, setting to ${defaultVal}`)
+ //console.log(`item ${key} is null, setting to ${defaultVal}`)
return [defaultVal, false]
}else{
- console.log(`item ${key} retrieved from localStorage`)
+ //console.log(`item ${key} retrieved from localStorage`)
return [item, true]
}
} catch(error) {
localStorage.setItem(key, JSON.stringify(defaultVal))
- console.log(error)
+ //console.log(error)
console.log(`error getting item ${key} setting to ${defaultVal}`)
return [defaultVal, false]
}
@@ -23,26 +20,17 @@ export const getLocalStorageObj = (key, defaultVal) => {
export const checkValue = (key, expectedVal) => {
try{
const item = localStorage.getItem(key)
- console.log(item)
+ //console.log(item)
if (item===expectedVal){
- console.log(`item ${key} matches the desired ${expectedVal} value`)
+ //console.log(`item ${key} matches the desired ${expectedVal} value`)
}else{
- // localStorage.clear();
- console.log(`value ${key} did not match, clearing local storage`)
+ localStorage.clear();
+
+ //console.log(`value ${key} did not match, clearing local storage`)
}
} catch(error) {
- // localStorage.clear();
- console.log(`value ${key} error, clearing local storage`)
- console.log(error)
- }
-}
-
-export const checkLogin = (realUser, realPass) => {
- const user = localStorage.getItem('user')
- const pass = localStorage.getItem('pass')
- if (((user===realUser) && (pass===realPass))){
- return true
- } else{
- return false
+ localStorage.clear();
+ //console.log(`value ${key} error, clearing local storage`)
+ //console.log(error)
}
}
\ No newline at end of file