mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 13:50:31 +00:00
re-structure to monorepo.
This commit is contained in:
56
packages/webapp/src/store/search/search.actions.tsx
Normal file
56
packages/webapp/src/store/search/search.actions.tsx
Normal file
@@ -0,0 +1,56 @@
|
||||
// @ts-nocheck
|
||||
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,
|
||||
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: {}
|
||||
};
|
||||
}
|
||||
40
packages/webapp/src/store/search/search.reducer.tsx
Normal file
40
packages/webapp/src/store/search/search.reducer.tsx
Normal file
@@ -0,0 +1,40 @@
|
||||
// @ts-nocheck
|
||||
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, {
|
||||
[t.OPEN_SEARCH]: (state, action) => {
|
||||
state.isOpen = true;
|
||||
},
|
||||
|
||||
[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 = {};
|
||||
},
|
||||
});
|
||||
10
packages/webapp/src/store/search/search.type.tsx
Normal file
10
packages/webapp/src/store/search/search.type.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
// @ts-nocheck
|
||||
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