Do not search customers by default

This commit is contained in:
dominik-zeglen 2019-11-25 16:51:28 +01:00
parent bf0f5b4ef3
commit 5cb9529b1f
2 changed files with 4 additions and 14 deletions

View file

@ -3,10 +3,8 @@ import { IntlShape } from "react-intl";
import { UseNavigatorResult } from "@saleor/hooks/useNavigator";
import { OrderDraftCreate } from "@saleor/orders/types/OrderDraftCreate";
import { SearchCustomers_search_edges_node } from "@saleor/searches/types/SearchCustomers";
import { QuickSearchAction } from "../../types";
import { searchInCommands } from "../commands";
import { searchInCustomers } from "../customers";
import { sortScores } from "../utils";
import searchInViews from "./views";
@ -17,22 +15,15 @@ function getDefaultModeActions(
query: string,
intl: IntlShape,
navigate: UseNavigatorResult,
customers: SearchCustomers_search_edges_node[],
createOrder: MutationFunction<OrderDraftCreate, {}>
): QuickSearchAction[] {
const actions = [
return [
...searchInViews(query, intl, navigate),
...searchInCommands(query, intl, navigate, createOrder)
]
.filter(action => action.score >= threshold)
.sort(sortScores)
.slice(0, maxActions);
if (query !== "") {
return [...actions, ...searchInCustomers(intl, navigate, customers)];
}
return actions;
}
export default getDefaultModeActions;

View file

@ -101,12 +101,11 @@ function useQuickSearch(
if (mode === "catalog") {
searchCatalog(value);
}
setQuery(value);
}
if ((["customers", "default"] as QuickSearchMode[]).includes(mode)) {
if (mode === "customers") {
searchCustomers(value);
}
setQuery(value);
}
};
return [