From abd070428bda92b984285da5f779286105b979d0 Mon Sep 17 00:00:00 2001 From: Colin Megill Date: Wed, 4 Oct 2017 01:04:35 -0700 Subject: [PATCH] reducer & store setup --- src/reducers/cells.js | 27 +++++++++++++++++++++++++++ src/reducers/index.js | 10 ++++++++++ 2 files changed, 37 insertions(+) create mode 100644 src/reducers/cells.js create mode 100644 src/reducers/index.js diff --git a/src/reducers/cells.js b/src/reducers/cells.js new file mode 100644 index 00000000..d556bc1f --- /dev/null +++ b/src/reducers/cells.js @@ -0,0 +1,27 @@ +const Cells = (state = { + cells: null, + loading: null, + error: null, +}, action) => { + switch (action.type) { + case "REQUEST_CELLS": + return Object.assign({}, state, { + loading: true, + error: null + }); + case "RECEIVE_CELLS": + return Object.assign({}, state, { + error: null, + cells: action.data, + }); + case "CELLS_FETCH_ERROR": + return Object.assign({}, state, { + cells: null, + error: action.data + }); + default: + return state; + } +}; + +export default Cells; diff --git a/src/reducers/index.js b/src/reducers/index.js new file mode 100644 index 00000000..2b4e2f8c --- /dev/null +++ b/src/reducers/index.js @@ -0,0 +1,10 @@ +import { combineReducers, createStore } from 'redux' +import cells from './cells' + +const Reducer = combineReducers({ + cells, +}) + +let store = createStore(Reducer); + +export default store;