Commit 963e4476 authored by Max Alekseenko's avatar Max Alekseenko

add sorting by rating

parent 8d1a9fe5
...@@ -109,6 +109,9 @@ export default function useMarketplaceApps( ...@@ -109,6 +109,9 @@ export default function useMarketplaceApps(
if (sorting === 'security_score') { if (sorting === 'security_score') {
return (b.securityReport?.overallInfo.securityScore || 0) - (a.securityReport?.overallInfo.securityScore || 0); return (b.securityReport?.overallInfo.securityScore || 0) - (a.securityReport?.overallInfo.securityScore || 0);
} }
if (sorting === 'rating') {
return (b.rating || 0) - (a.rating || 0);
}
return 0; return 0;
}) || []; }) || [];
}, [ selectedCategoryId, appsWithSecurityReportsAndRating, filter, favoriteApps, sorting ]); }, [ selectedCategoryId, appsWithSecurityReportsAndRating, filter, favoriteApps, sorting ]);
......
...@@ -4,10 +4,11 @@ import getQueryParamString from 'lib/router/getQueryParamString'; ...@@ -4,10 +4,11 @@ import getQueryParamString from 'lib/router/getQueryParamString';
import removeQueryParam from 'lib/router/removeQueryParam'; import removeQueryParam from 'lib/router/removeQueryParam';
import type { TOption } from 'ui/shared/sort/Option'; import type { TOption } from 'ui/shared/sort/Option';
export type SortValue = 'security_score'; export type SortValue = 'rating' | 'security_score';
export const SORT_OPTIONS: Array<TOption<SortValue>> = [ export const SORT_OPTIONS: Array<TOption<SortValue>> = [
{ title: 'Default', id: undefined }, { title: 'Default', id: undefined },
{ title: 'Rating', id: 'rating' },
{ title: 'Security score', id: 'security_score' }, { title: 'Security score', id: 'security_score' },
]; ];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment