diff --git a/client/src/components/global-search/global-search.component.jsx b/client/src/components/global-search/global-search.component.jsx
index 42410ab72..ec07512a7 100644
--- a/client/src/components/global-search/global-search.component.jsx
+++ b/client/src/components/global-search/global-search.component.jsx
@@ -1,12 +1,13 @@
import { useLazyQuery } from "@apollo/react-hooks";
import { AutoComplete, Input } from "antd";
+import _ from "lodash";
import React from "react";
import { useTranslation } from "react-i18next";
import { Link } from "react-router-dom";
-import { logImEXEvent } from "../../firebase/firebase.utils";
import { GLOBAL_SEARCH_QUERY } from "../../graphql/search.queries";
import CurrencyFormatter from "../../utils/CurrencyFormatter";
import AlertComponent from "../alert/alert.component";
+
export default function GlobalSearch() {
const { t } = useTranslation();
@@ -14,27 +15,18 @@ export default function GlobalSearch() {
GLOBAL_SEARCH_QUERY
);
- const handleSearch = (searchTerm) => {
- logImEXEvent("global_search", { term: searchTerm });
+ const executeSearch = (v) => {
+ callSearch(v);
+ };
+ const debouncedExecuteSearch = _.debounce(executeSearch, 500);
- if (searchTerm.length > 0)
- callSearch({ variables: { search: searchTerm } });
+ const handleSearch = (value) => {
+ if (value && value !== "")
+ debouncedExecuteSearch({ variables: { search: value } });
};
const renderTitle = (title) => {
- return (
-
- {title}
-
- more
-
-
- );
+ return {title};
};
const options = data
@@ -155,8 +147,9 @@ export default function GlobalSearch() {
dropdownMatchSelectWidth={false}
style={{ width: 200 }}
options={options}
+ onSearch={handleSearch}
>
-