Merge global search.

This commit is contained in:
Ahmed Bouhuolia
2020-04-14 19:23:43 +02:00
10 changed files with 90 additions and 88 deletions

View File

@@ -14,7 +14,7 @@ import financialStatements from './financialStatement/financialStatements.reduce
import itemCategories from './itemCategories/itemsCategory.reducer';
import settings from './settings/settings.reducer';
import manualJournals from './manualJournals/manualJournals.reducers';
import search from './search/search.reducer';
import globalSearch from './search/search.reducer';
export default combineReducers({
authentication,
@@ -31,5 +31,5 @@ export default combineReducers({
items,
itemCategories,
settings,
search,
globalSearch,
});

View File

@@ -1,5 +1,19 @@
import t from 'store/types';
export function openSearch(result) {
return {
type: t.OPEN_SEARCH,
result,
};
}
export function closeSearch(result) {
return {
type: t.ClOSE_SEARCH,
result,
};
}
export function generalSearch(name, result) {
return {
type: t.SEARCH_SUCCESS,

View File

@@ -8,26 +8,11 @@ const initialState = {
};
export default createReducer(initialState, {
[t.SEARCH_SUCCESS]: (state, action) => {
const _result = {};
action.searches.forEach((search) => {
_result[search.id] = search;
});
state.searches = {
...state.searches,
..._result,
};
[t.OPEN_SEARCH]: (state, action) => {
state.isOpen = true;
},
});
// return state = action.result;
// if (typeof state === 'undefined') {
// return initialState;
// }
// state.search[action.name] = {
// isOpen: true,
// payload: action.payload || {},
// };
[t.CLOSE_SEARCH]: (state, action) => {
state.isOpen = false;
}
});

View File

@@ -1,5 +1,5 @@
export default {
SEARCH_SUCCESS: 'SEARCH_SUCCESS',
SEARCH_FAILURE: 'SEARCH_FAILURE',
SEARCH_REQUEST: 'SEARCH_REQUEST',
SEARCH_SUCCESS:'SEARCH_SUCCESS',
OPEN_SEARCH: 'OPEN_SEARCH',
CLOSE_SEARCH: 'CLOSE_SEARCH',
};

View File

@@ -14,6 +14,7 @@ import financialStatements from './financialStatement/financialStatements.types'
import itemCategories from './itemCategories/itemsCategory.type';
import settings from './settings/settings.type';
import search from './search/search.type';
export default {
...authentication,
...accounts,