saleor-dashboard/src/components/Navigator/modes/default/default.ts
2019-11-21 17:52:11 +01:00

19 lines
477 B
TypeScript

import { IntlShape } from "react-intl";
import { QuickSearchAction } from "../../types";
import searchInViews from "./views";
const threshold = 0.05;
const maxActions = 10;
function getDefaultModeActions(
query: string,
intl: IntlShape
): QuickSearchAction[] {
return [...searchInViews(query, intl)]
.filter(action => action.score >= threshold)
.sort((a, b) => (a.score <= b.score ? 1 : -1))
.slice(0, maxActions);
}
export default getDefaultModeActions;