mirror of
https://github.com/strapi/strapi.git
synced 2025-09-19 21:38:05 +00:00
simplify match sorter
This commit is contained in:
parent
e37e588887
commit
c9e7e3bcb2
@ -3,7 +3,6 @@ import { useIntl } from 'react-intl';
|
||||
import { Helmet } from 'react-helmet';
|
||||
import { useQuery } from 'react-query';
|
||||
import matchSorter from 'match-sorter';
|
||||
import toLower from 'lodash/toLower';
|
||||
import {
|
||||
AnErrorOccurred,
|
||||
CheckPagePermissions,
|
||||
@ -25,12 +24,6 @@ import useFetchInstalledPlugins from '../../hooks/useFetchInstalledPlugins';
|
||||
import useFetchMarketplacePlugins from '../../hooks/useFetchMarketplacePlugins';
|
||||
import adminPermissions from '../../permissions';
|
||||
|
||||
const matchSearch = (plugins, search) => {
|
||||
return matchSorter(plugins, toLower(search), {
|
||||
keys: [item => toLower(item.attributes.name), item => toLower(item.attributes.description)],
|
||||
});
|
||||
};
|
||||
|
||||
const MarketPlacePage = () => {
|
||||
const { formatMessage } = useIntl();
|
||||
const { trackUsage } = useTracking();
|
||||
@ -111,7 +104,9 @@ const MarketPlacePage = () => {
|
||||
);
|
||||
}
|
||||
|
||||
const searchResults = matchSearch(marketplacePluginsResponse.data, searchQuery);
|
||||
const searchResults = matchSorter(marketplacePluginsResponse.data, searchQuery, {
|
||||
keys: ['attributes.name', 'attributes.description'],
|
||||
});
|
||||
|
||||
const displayedPlugins =
|
||||
searchResults.length && searchQuery.length ? searchResults : marketplacePluginsResponse.data;
|
||||
|
Loading…
x
Reference in New Issue
Block a user