diff --git a/src/config/store.js b/src/config/store.js index 6a9c46290..29e24f311 100644 --- a/src/config/store.js +++ b/src/config/store.js @@ -9,6 +9,7 @@ import * as app from 'modules/app'; import * as pages from 'modules/pages'; import * as map from 'modules/map'; import * as dashboard from 'modules/dashboard'; +import * as search from 'modules/search'; import { queryState } from 'modules/query-state'; import router from './router'; @@ -20,7 +21,8 @@ const modules = [ { namespace: 'app', components: app }, { namespace: 'page', components: pages }, { namespace: 'map', components: map }, - { namespace: 'dashboard', components: dashboard } + { namespace: 'dashboard', components: dashboard }, + { namespace: 'search', components: search } ]; const { diff --git a/src/modules/search/actions.js b/src/modules/search/actions.js new file mode 100644 index 000000000..1249f374e --- /dev/null +++ b/src/modules/search/actions.js @@ -0,0 +1,11 @@ +import { createAction } from 'vizzuality-redux-tools'; + +export const setSearch = createAction('SEARCH/setSearch'); +export const setSearchTerm = createAction('SEARCH/setSearchTerm'); +export const setSearchResults = createAction('SEARCH/setSearchResults'); + +export default { + setSearch, + setSearchTerm, + setSearchResults +}; diff --git a/src/modules/search/index.js b/src/modules/search/index.js new file mode 100644 index 000000000..1e936b317 --- /dev/null +++ b/src/modules/search/index.js @@ -0,0 +1,5 @@ +import * as actions from './actions'; +import * as reducers from './reducers'; +import initialState from './initial-state'; + +export { actions, initialState, reducers }; diff --git a/src/modules/search/initial-state.js b/src/modules/search/initial-state.js new file mode 100644 index 000000000..3813a12c2 --- /dev/null +++ b/src/modules/search/initial-state.js @@ -0,0 +1,4 @@ +export default { + term: '', + results: [] +}; diff --git a/src/modules/search/reducers.js b/src/modules/search/reducers.js new file mode 100644 index 000000000..736b6ed88 --- /dev/null +++ b/src/modules/search/reducers.js @@ -0,0 +1,13 @@ +import * as actions from './actions'; + +const { + setSearch, + setSearchTerm, + setSearchResults +} = actions; + +export default { + [setSearch]: (state, { payload }) => ({ ...state, ...payload }), + [setSearchTerm]: (state, { payload }) => ({ ...state, term: payload }), + [setSearchResults]: (state, { payload }) => ({ ...state, results: payload }) +};