Last active
January 4, 2018 16:45
-
-
Save jhurtadojerves/1f1bea7fa555b2a56e23f9f27b1d3e7f to your computer and use it in GitHub Desktop.
Reto de la clase de Redux, buscar en todas las playlist
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const data = ( state, action ) => { | |
switch (action.type) { | |
case 'SEARCH_VIDEO': { | |
let results = []; | |
if (action.payload.query) { | |
const categories = state.data.categories | |
categories.map(category => { | |
let tempResults = category.playlist.filter(item => { | |
return item.author.toLowerCase().includes(action.payload.query.toLowerCase()) | |
}) | |
results = results.concat(tempResults) | |
}) | |
} | |
return { | |
...state, | |
search: results | |
} | |
} | |
default: | |
return state | |
} | |
} | |
export default data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment