mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 13:50:31 +00:00
feat: universal search.
This commit is contained in:
@@ -20,3 +20,36 @@ export function generalSearch(name, result) {
|
||||
result,
|
||||
};
|
||||
}
|
||||
|
||||
export function universalSearchSetResourceType(resourceType) {
|
||||
return {
|
||||
type: t.UNIVERSAL_SEARCH_SET_RESOURCE_TYPE,
|
||||
payload: {
|
||||
resourceType,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export function universalSearchResetResourceType() {
|
||||
return {
|
||||
type: t.UNIVERSAL_SEARCH_RESET_RESOURCE_TYPE,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
export function universalSearchSetSelectedItem(resourceType, resourceId) {
|
||||
return {
|
||||
type: t.UNIVERSAL_SEARCH_SET_ITEM_SELECT,
|
||||
payload: {
|
||||
resourceType,
|
||||
resourceId
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function universalSearchResetSelectedItem() {
|
||||
return {
|
||||
type: t.UNIVERSAL_SEARCH_RESET_ITEM_SELECT,
|
||||
payload: {}
|
||||
};
|
||||
}
|
||||
@@ -1,8 +1,12 @@
|
||||
import t from 'store/types';
|
||||
import { createReducer } from '@reduxjs/toolkit';
|
||||
|
||||
const DEFAULT_RESOURCE_TYPE = 'customer';
|
||||
|
||||
const initialState = {
|
||||
isOpen: false,
|
||||
defaultResourceType: DEFAULT_RESOURCE_TYPE,
|
||||
selectedItem: {},
|
||||
};
|
||||
|
||||
export default createReducer(initialState, {
|
||||
@@ -13,4 +17,23 @@ export default createReducer(initialState, {
|
||||
[t.CLOSE_SEARCH]: (state, action) => {
|
||||
state.isOpen = false;
|
||||
},
|
||||
|
||||
[t.UNIVERSAL_SEARCH_SET_RESOURCE_TYPE]: (state, action) => {
|
||||
state.defaultResourceType = action.payload.resourceType;
|
||||
},
|
||||
|
||||
[t.UNIVERSAL_SEARCH_RESET_RESOURCE_TYPE]: (state, action) => {
|
||||
state.defaultResourceType = DEFAULT_RESOURCE_TYPE;
|
||||
},
|
||||
|
||||
[t.UNIVERSAL_SEARCH_SET_ITEM_SELECT]: (state, action) => {
|
||||
state.selectedItem = {
|
||||
resourceId: action.payload.resourceId,
|
||||
resourceType: action.payload.resourceType,
|
||||
};
|
||||
},
|
||||
|
||||
[t.UNIVERSAL_SEARCH_RESET_ITEM_SELECT]: (state, action) => {
|
||||
state.selectedItem = {};
|
||||
},
|
||||
});
|
||||
|
||||
@@ -2,4 +2,8 @@ export default {
|
||||
SEARCH_TYPE: 'SEARCH_TYPE',
|
||||
OPEN_SEARCH: 'OPEN_SEARCH',
|
||||
CLOSE_SEARCH: 'CLOSE_SEARCH',
|
||||
UNIVERSAL_SEARCH_SET_RESOURCE_TYPE: 'UNIVERSAL_SEARCH_SET_RESOURCE_TYPE',
|
||||
UNIVERSAL_SEARCH_RESET_RESOURCE_TYPE: 'UNIVERSAL_SEARCH_RESET_RESOURCE_TYPE',
|
||||
UNIVERSAL_SEARCH_SET_ITEM_SELECT: 'UNIVERSAL_SEARCH_SET_ITEM_SELECT',
|
||||
UNIVERSAL_SEARCH_RESET_ITEM_SELECT: 'UNIVERSAL_SEARCH_RESET_ITEM_SELECT'
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user