Skip to content

Commit

Permalink
feat(Vizzuality#12): Create search schema.
Browse files Browse the repository at this point in the history
  • Loading branch information
Migsar Navarro committed Jun 5, 2019
1 parent bb2ad58 commit 9672963
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/config/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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 {
Expand Down
11 changes: 11 additions & 0 deletions src/modules/search/actions.js
Original file line number Diff line number Diff line change
@@ -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
};
5 changes: 5 additions & 0 deletions src/modules/search/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import * as actions from './actions';
import * as reducers from './reducers';
import initialState from './initial-state';

export { actions, initialState, reducers };
4 changes: 4 additions & 0 deletions src/modules/search/initial-state.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default {
term: '',
results: []
};
13 changes: 13 additions & 0 deletions src/modules/search/reducers.js
Original file line number Diff line number Diff line change
@@ -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 })
};

0 comments on commit 9672963

Please # to comment.