Skip to content

Instantly share code, notes, and snippets.

@jhurtadojerves
Last active January 4, 2018 16:45
Show Gist options
  • Save jhurtadojerves/1f1bea7fa555b2a56e23f9f27b1d3e7f to your computer and use it in GitHub Desktop.
Save jhurtadojerves/1f1bea7fa555b2a56e23f9f27b1d3e7f to your computer and use it in GitHub Desktop.
Reto de la clase de Redux, buscar en todas las playlist
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