Skip to content

Commit

Permalink
basic redux setup with new design pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyubinhan committed Jun 19, 2018
1 parent b1ef459 commit 7fdb745
Show file tree
Hide file tree
Showing 100 changed files with 635 additions and 6,957 deletions.
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"lodash.debounce": "^4.0.8",
"moment": "^2.21.0",
"node-sass-chokidar": "^0.0.3",
"normalizr": "^3.2.4",
"npm-run-all": "^4.1.2",
"pikaday": "^1.7.0",
"prop-types": "^15.6.0",
Expand Down
42 changes: 42 additions & 0 deletions src/actionCreators/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// import axios from 'axios';
import { normalize } from 'normalizr';
import * as schema from './schema';
import * as api from '../api';
import { request, successPagenated, error, storeAgreement } from '../actions';
import { getAgreementsIsFetching } from '../reducers/rootReducer';
import * as reducerTypes from '../constants/reducerTypes';

export const searchAgreements = filter => (dispatch, getState) => {
if (getAgreementsIsFetching(getState(), filter)) {
return Promise.resolve();
}
dispatch(request(reducerTypes.SEARCH_AGREEMENTS));

// dispatch({
// type: 'FETCH_TODOS_REQUEST',
// filter,
// });

return api.fetchAgreements(filter).then(
(response) => {
dispatch(successPagenated(reducerTypes.SEARCH_AGREEMENTS, response));
dispatch(storeAgreement(normalize(response.agreements, schema.arrayOfAgreements)));

// dispatch({
// type: 'FETCH_TODOS_SUCCESS',
// filter,
// response: normalize(response, schema.arrayOfTodos),
// });
},
(err) => {
dispatch(error(reducerTypes.SEARCH_AGREEMENTS, err.message));
// dispatch({
// type: 'FETCH_TODOS_FAILURE',
// filter,
// message: error.message || 'Something went wrong.',
// });
},
);
};

export const s = () => {};
4 changes: 4 additions & 0 deletions src/actionCreators/schema.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { schema } from 'normalizr';

export const agreement = new schema.Entity('agreements');
export const arrayOfAgreements = new schema.Array(agreement);
67 changes: 0 additions & 67 deletions src/actions/agreementActions.js

This file was deleted.

115 changes: 0 additions & 115 deletions src/actions/authActions.js

This file was deleted.

16 changes: 0 additions & 16 deletions src/actions/authActions.test.js

This file was deleted.

99 changes: 0 additions & 99 deletions src/actions/commonActions.js

This file was deleted.

Loading

0 comments on commit 7fdb745

Please sign in to comment.