mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 21:30:31 +00:00
Config With Seacrh
This commit is contained in:
8
client/src/store/search/search.actions.js
Normal file
8
client/src/store/search/search.actions.js
Normal file
@@ -0,0 +1,8 @@
|
||||
import t from 'store/types';
|
||||
|
||||
export function generalSearch(name, result) {
|
||||
return {
|
||||
type: t.SEARCH_SUCCESS,
|
||||
result,
|
||||
};
|
||||
}
|
||||
33
client/src/store/search/search.reducer.js
Normal file
33
client/src/store/search/search.reducer.js
Normal file
@@ -0,0 +1,33 @@
|
||||
import t from 'store/types';
|
||||
import { createReducer } from '@reduxjs/toolkit';
|
||||
|
||||
const initialState = {
|
||||
searches: {},
|
||||
searchTitle: 'Title',
|
||||
isOpen: false,
|
||||
};
|
||||
|
||||
export default createReducer(initialState, {
|
||||
[t.SEARCH_SUCCESS]: (state, action) => {
|
||||
const _result = {};
|
||||
|
||||
action.searches.forEach((search) => {
|
||||
_result[search.id] = search;
|
||||
});
|
||||
|
||||
state.searches = {
|
||||
...state.searches,
|
||||
..._result,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
// return state = action.result;
|
||||
// if (typeof state === 'undefined') {
|
||||
// return initialState;
|
||||
// }
|
||||
|
||||
// state.search[action.name] = {
|
||||
// isOpen: true,
|
||||
// payload: action.payload || {},
|
||||
// };
|
||||
5
client/src/store/search/search.type.js
Normal file
5
client/src/store/search/search.type.js
Normal file
@@ -0,0 +1,5 @@
|
||||
export default {
|
||||
SEARCH_SUCCESS: 'SEARCH_SUCCESS',
|
||||
SEARCH_FAILURE: 'SEARCH_FAILURE',
|
||||
SEARCH_REQUEST: 'SEARCH_REQUEST',
|
||||
};
|
||||
Reference in New Issue
Block a user