diff --git a/bikeshop_project/assets/js/bikes/actions.js b/bikeshop_project/assets/js/bikes/actions.js index 174e7b2..f11a19e 100644 --- a/bikeshop_project/assets/js/bikes/actions.js +++ b/bikeshop_project/assets/js/bikes/actions.js @@ -4,4 +4,3 @@ export const fetchBikes = createAction('fetch bikes'); export const setBikes = createAction('set bikes'); export const setBikesIsFetching = createAction('set bikes.isFetching'); export const setBikesFetched = createAction('set bikes.fetched'); -export const setBike = createAction('set bike'); diff --git a/bikeshop_project/assets/js/bikes/components/BikeTable/index.jsx b/bikeshop_project/assets/js/bikes/components/BikeTable/index.jsx index 563f23e..fbd909d 100644 --- a/bikeshop_project/assets/js/bikes/components/BikeTable/index.jsx +++ b/bikeshop_project/assets/js/bikes/components/BikeTable/index.jsx @@ -68,7 +68,7 @@ class BikeTableComponent extends React.Component { render() { if (this.props.bikes.fetched) { - const bikeRows = renderBikes(Object.values(this.props.bikes.entities['bikes'] || [])); + const bikeRows = renderBikes(Object.values(this.props.bikes.entities)); return (
@@ -107,7 +107,7 @@ class BikeTableComponent extends React.Component { } const mapStateToProps = state => ({ - bikes: state.bikes.bikes, + bikes: state.bikes, }); const mapDispatchToProps = dispatch => ({ diff --git a/bikeshop_project/assets/js/bikes/reducers.js b/bikeshop_project/assets/js/bikes/reducers.js index 07182ca..0b0c956 100644 --- a/bikeshop_project/assets/js/bikes/reducers.js +++ b/bikeshop_project/assets/js/bikes/reducers.js @@ -1,27 +1,17 @@ -import { setBike, setBikes, setBikesIsFetching, setBikesFetched } from './actions'; +import { setBikes, setBikesFetched, setBikesIsFetching } from './actions'; import { handleActions } from 'redux-actions'; export default handleActions({ [setBikes]: (state, action) => ({ ...state, - bikes: action.payload, + entities: action.payload.entities.bikes, }), [setBikesIsFetching]: (state, action) => ({ ...state, - bikes: { - ...state.bikes, - isFetching: action.payload, - }, + isFetching: action.payload, }), [setBikesFetched]: (state, action) => ({ ...state, - bikes: { - ...state.bikes, - fetched: action.payload - } + fetched: action.payload, }), - [setBike]: (state, action) => ({ - ...state, - ...action.payload, - }), -}, { bikes: [], bike: undefined }); +}, { entities: {}, isFetching: false, fetched: false }); diff --git a/bikeshop_project/assets/js/bikes/sagas.js b/bikeshop_project/assets/js/bikes/sagas.js index 3f35b29..df158ec 100644 --- a/bikeshop_project/assets/js/bikes/sagas.js +++ b/bikeshop_project/assets/js/bikes/sagas.js @@ -11,7 +11,7 @@ function* fetchBikes(action) { yield put({ type: setBikesIsFetching.toString(), payload: true }); const bikes = yield call(Api.fetchBikes); yield put({ type: setBikes.toString(), payload: normalize(bikes, schema.bikes) }); - yield put({ type: setBikesFetched, payload: true }); + yield put({ type: setBikesFetched.toString(), payload: true }); } catch (e) { yield put({ type: 'BIKES_FETCH_FAILED', message: e.message }); throw e;