Do not search customers by default
This commit is contained in:
parent
bf0f5b4ef3
commit
5cb9529b1f
2 changed files with 4 additions and 14 deletions
|
@ -3,10 +3,8 @@ import { IntlShape } from "react-intl";
|
||||||
|
|
||||||
import { UseNavigatorResult } from "@saleor/hooks/useNavigator";
|
import { UseNavigatorResult } from "@saleor/hooks/useNavigator";
|
||||||
import { OrderDraftCreate } from "@saleor/orders/types/OrderDraftCreate";
|
import { OrderDraftCreate } from "@saleor/orders/types/OrderDraftCreate";
|
||||||
import { SearchCustomers_search_edges_node } from "@saleor/searches/types/SearchCustomers";
|
|
||||||
import { QuickSearchAction } from "../../types";
|
import { QuickSearchAction } from "../../types";
|
||||||
import { searchInCommands } from "../commands";
|
import { searchInCommands } from "../commands";
|
||||||
import { searchInCustomers } from "../customers";
|
|
||||||
import { sortScores } from "../utils";
|
import { sortScores } from "../utils";
|
||||||
import searchInViews from "./views";
|
import searchInViews from "./views";
|
||||||
|
|
||||||
|
@ -17,22 +15,15 @@ function getDefaultModeActions(
|
||||||
query: string,
|
query: string,
|
||||||
intl: IntlShape,
|
intl: IntlShape,
|
||||||
navigate: UseNavigatorResult,
|
navigate: UseNavigatorResult,
|
||||||
customers: SearchCustomers_search_edges_node[],
|
|
||||||
createOrder: MutationFunction<OrderDraftCreate, {}>
|
createOrder: MutationFunction<OrderDraftCreate, {}>
|
||||||
): QuickSearchAction[] {
|
): QuickSearchAction[] {
|
||||||
const actions = [
|
return [
|
||||||
...searchInViews(query, intl, navigate),
|
...searchInViews(query, intl, navigate),
|
||||||
...searchInCommands(query, intl, navigate, createOrder)
|
...searchInCommands(query, intl, navigate, createOrder)
|
||||||
]
|
]
|
||||||
.filter(action => action.score >= threshold)
|
.filter(action => action.score >= threshold)
|
||||||
.sort(sortScores)
|
.sort(sortScores)
|
||||||
.slice(0, maxActions);
|
.slice(0, maxActions);
|
||||||
|
|
||||||
if (query !== "") {
|
|
||||||
return [...actions, ...searchInCustomers(intl, navigate, customers)];
|
|
||||||
}
|
|
||||||
|
|
||||||
return actions;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default getDefaultModeActions;
|
export default getDefaultModeActions;
|
||||||
|
|
|
@ -101,12 +101,11 @@ function useQuickSearch(
|
||||||
if (mode === "catalog") {
|
if (mode === "catalog") {
|
||||||
searchCatalog(value);
|
searchCatalog(value);
|
||||||
}
|
}
|
||||||
|
if (mode === "customers") {
|
||||||
|
searchCustomers(value);
|
||||||
|
}
|
||||||
setQuery(value);
|
setQuery(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((["customers", "default"] as QuickSearchMode[]).includes(mode)) {
|
|
||||||
searchCustomers(value);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
|
Loading…
Reference in a new issue