mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 06:10:31 +00:00
chrone: sperate client and server to different repos.
This commit is contained in:
46
src/containers/Vendors/VendorsUniversalSearch.js
Normal file
46
src/containers/Vendors/VendorsUniversalSearch.js
Normal file
@@ -0,0 +1,46 @@
|
||||
import intl from 'react-intl-universal';
|
||||
|
||||
import { RESOURCES_TYPES } from '../../common/resourcesTypes';
|
||||
import withDrawerActions from '../Drawer/withDrawerActions';
|
||||
|
||||
/**
|
||||
* Vendor univesal search item select action.
|
||||
*/
|
||||
function VendorUniversalSearchSelectComponent({
|
||||
resourceType,
|
||||
resourceId,
|
||||
onAction,
|
||||
|
||||
// #withDrawerActions
|
||||
openDrawer,
|
||||
}) {
|
||||
if (resourceType === RESOURCES_TYPES.VENDOR) {
|
||||
openDrawer('vendor-details-drawer', { vendorId: resourceId });
|
||||
onAction && onAction();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
const VendorUniversalSearchSelectAction = withDrawerActions(
|
||||
VendorUniversalSearchSelectComponent,
|
||||
);
|
||||
|
||||
/**
|
||||
* Transformes vendor resource item to search.
|
||||
*/
|
||||
const vendorToSearch = (contact) => ({
|
||||
id: contact.id,
|
||||
text: contact.display_name,
|
||||
label: contact.balance > 0 ? contact.formatted_balance + '' : '',
|
||||
reference: contact,
|
||||
});
|
||||
|
||||
/**
|
||||
* Binds universal search invoice configure.
|
||||
*/
|
||||
export const universalSearchVendorBind = () => ({
|
||||
resourceType: RESOURCES_TYPES.VENDOR,
|
||||
optionItemLabel: intl.get('vendors'),
|
||||
selectItemAction: VendorUniversalSearchSelectAction,
|
||||
itemSelect: vendorToSearch,
|
||||
});
|
||||
Reference in New Issue
Block a user