mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 04:40:32 +00:00
chrone: sperate client and server to different repos.
This commit is contained in:
49
src/containers/Items/ItemsUniversalSearch.js
Normal file
49
src/containers/Items/ItemsUniversalSearch.js
Normal file
@@ -0,0 +1,49 @@
|
||||
import intl from 'react-intl-universal';
|
||||
import { RESOURCES_TYPES } from '../../common/resourcesTypes';
|
||||
import withDrawerActions from '../Drawer/withDrawerActions';
|
||||
|
||||
/**
|
||||
* Item univrsal search item select action.
|
||||
*/
|
||||
function ItemUniversalSearchSelectComponent({
|
||||
// #ownProps
|
||||
resourceType,
|
||||
resourceId,
|
||||
onAction,
|
||||
|
||||
// #withDrawerActions
|
||||
openDrawer,
|
||||
}) {
|
||||
if (resourceType === RESOURCES_TYPES.ITEM) {
|
||||
openDrawer('item-detail-drawer', { itemId: resourceId });
|
||||
onAction && onAction();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
export const ItemUniversalSearchSelectAction = withDrawerActions(
|
||||
ItemUniversalSearchSelectComponent,
|
||||
);
|
||||
|
||||
/**
|
||||
* Transformes items to search.
|
||||
* @param {*} item
|
||||
* @returns
|
||||
*/
|
||||
const transfromItemsToSearch = (item) => ({
|
||||
id: item.id,
|
||||
text: item.name,
|
||||
subText: item.code,
|
||||
label: item.type,
|
||||
reference: item,
|
||||
});
|
||||
|
||||
/**
|
||||
* Binds universal search invoice configure.
|
||||
*/
|
||||
export const universalSearchItemBind = () => ({
|
||||
resourceType: RESOURCES_TYPES.ITEM,
|
||||
optionItemLabel: intl.get('items'),
|
||||
selectItemAction: ItemUniversalSearchSelectAction,
|
||||
itemSelect: transfromItemsToSearch,
|
||||
});
|
||||
Reference in New Issue
Block a user