mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 20:30:33 +00:00
feat: universal Search.
This commit is contained in:
50
client/src/components/UniversalSearch.js
Normal file
50
client/src/components/UniversalSearch.js
Normal file
@@ -0,0 +1,50 @@
|
||||
import React from 'react';
|
||||
|
||||
import { Omnibar } from '@blueprintjs/select';
|
||||
import { MenuItem, Spinner } from '@blueprintjs/core';
|
||||
import { FormattedMessage as T, Icon, ListSelect } from 'components';
|
||||
|
||||
import withSearch from 'containers/GeneralSearch/withSearch';
|
||||
|
||||
import { compose } from 'utils';
|
||||
|
||||
function UniversalSearch({
|
||||
results,
|
||||
onClose,
|
||||
|
||||
// withSearch
|
||||
globalSearchShow,
|
||||
closeGlobalSearch,
|
||||
...props
|
||||
}) {
|
||||
const SearchRenderer = (
|
||||
{ name, code, amount },
|
||||
{ handleClick, modifiers, query },
|
||||
) => {
|
||||
return (
|
||||
<MenuItem
|
||||
text={`${name} - ${code}`}
|
||||
label={amount}
|
||||
onClick={handleClick}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
const handleClose = () => {
|
||||
closeGlobalSearch(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<Omnibar
|
||||
className={'navbar--omnibar'}
|
||||
items={results}
|
||||
itemRenderer={SearchRenderer}
|
||||
noResults={<MenuItem disabled={true} text={<T id={'no_results'} />} />}
|
||||
resetOnSelect={true}
|
||||
onClose={handleClose}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export default compose(withSearch)(UniversalSearch);
|
||||
@@ -58,6 +58,7 @@ import AccountsSuggestField from './AccountsSuggestField';
|
||||
import MaterialProgressBar from './MaterialProgressBar';
|
||||
import { MoneyFieldCell } from './DataTableCells';
|
||||
import Card from './Card';
|
||||
import UniversalSearch from './UniversalSearch';
|
||||
|
||||
import { ItemsMultiSelect } from './Items';
|
||||
|
||||
@@ -131,5 +132,6 @@ export {
|
||||
MaterialProgressBar,
|
||||
MoneyFieldCell,
|
||||
ItemsMultiSelect,
|
||||
Card
|
||||
Card,
|
||||
UniversalSearch,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user