forked from bcgov/range-web
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
basic redux setup with new design pattern
- Loading branch information
Kyubinhan
committed
Jun 19, 2018
1 parent
b1ef459
commit 7fdb745
Showing
100 changed files
with
635 additions
and
6,957 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = () => {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.