implemented redux for state management

This commit is contained in:
andres alcocer
2019-03-30 16:30:05 -04:00
parent 8e22fc06d2
commit b5a263e46a
25 changed files with 699 additions and 301 deletions

View File

@@ -0,0 +1,23 @@
import { combineReducers } from 'redux';
import TrendingReducer from './reducerTrending';
import NetflixOriginalsReducer from './reducerNetflixOriginals';
import TopRatedReducer from './reducerTopRated';
import ActionMoviesReducer from './reducerActionMovies';
import ComedyMoviesReducer from './reducerComedyMovies';
import HorrorMoviesReducer from './reducerHorrorMovies';
import RomanceMoviesReducer from './reducerRomanceMovies';
import DocumentaryReducer from './reducerDocumentary';
const rootReducer = combineReducers({
trending: TrendingReducer,
netflixOriginals: NetflixOriginalsReducer,
topRated: TopRatedReducer,
action: ActionMoviesReducer,
comedy: ComedyMoviesReducer,
horror: HorrorMoviesReducer,
romance: RomanceMoviesReducer,
documentary: DocumentaryReducer
});
export default rootReducer;

View File

@@ -0,0 +1,11 @@
import { FETCH_ACTION_MOVIES } from '../actions/index';
export default function (state = {}, action) {
switch (action.type) {
case FETCH_ACTION_MOVIES:
const data = action.payload.data.results;
return { ...state, data }
default:
return state;
}
}

View File

@@ -0,0 +1,11 @@
import { FETCH_COMEDY_MOVIES } from '../actions/index';
export default function (state = {}, action) {
switch (action.type) {
case FETCH_COMEDY_MOVIES:
const data = action.payload.data.results;
return { ...state, data }
default:
return state;
}
}

View File

@@ -0,0 +1,11 @@
import { FETCH_DOCUMENTARIES } from '../actions/index';
export default function (state = {}, action) {
switch (action.type) {
case FETCH_DOCUMENTARIES:
const data = action.payload.data.results;
return { ...state, data }
default:
return state;
}
}

View File

@@ -0,0 +1,11 @@
import { FETCH_HORROR_MOVIES } from '../actions/index';
export default function (state = {}, action) {
switch (action.type) {
case FETCH_HORROR_MOVIES:
const data = action.payload.data.results;
return { ...state, data }
default:
return state;
}
}

View File

@@ -0,0 +1,11 @@
import { FETCH_NETFLIX_ORIGINALS } from '../actions/index';
export default function (state = {}, action) {
switch (action.type) {
case FETCH_NETFLIX_ORIGINALS:
const data = action.payload.data.results;
return { ...state, data }
default:
return state;
}
}

View File

@@ -0,0 +1,11 @@
import { FETCH_ROMANCE_MOVIES } from '../actions/index';
export default function (state = {}, action) {
switch (action.type) {
case FETCH_ROMANCE_MOVIES:
const data = action.payload.data.results;
return { ...state, data }
default:
return state;
}
}

View File

@@ -0,0 +1,11 @@
import { FETCH_TOP_RATED } from '../actions/index';
export default function (state = {}, action) {
switch (action.type) {
case FETCH_TOP_RATED:
const data = action.payload.data.results;
return { ...state, data }
default:
return state;
}
}

View File

@@ -0,0 +1,11 @@
import { FETCH_TRENDING } from '../actions/index';
export default function (state = {}, action) {
switch (action.type) {
case FETCH_TRENDING:
const data = action.payload.data.results;
return { ...state, data }
default:
return state;
}
}