Commit 88656055 authored by Max Alekseenko's avatar Max Alekseenko Committed by GitHub

Merge pull request #2138 from blockscout/fix-marketplace-sorting

Fix marketplace sorting display
parents c4cc9822 9da3114b
import type { NextRouter } from 'next/router'; import type { NextRouter } from 'next/router';
import config from 'configs/app';
import getQueryParamString from 'lib/router/getQueryParamString'; 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';
const feature = config.features.marketplace;
export type SortValue = 'rating' | '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' }, (feature.isEnabled && feature.rating) && { title: 'Rating', id: 'rating' },
{ title: 'Security score', id: 'security_score' }, (feature.isEnabled && feature.securityReportsUrl) && { title: 'Security score', id: 'security_score' },
]; ].filter(Boolean) as Array<TOption<SortValue>>;
export function getAppUrl(url: string | undefined, router: NextRouter) { export function getAppUrl(url: string | undefined, router: NextRouter) {
if (!url) { if (!url) {
......
...@@ -137,6 +137,8 @@ const Marketplace = () => { ...@@ -137,6 +137,8 @@ const Marketplace = () => {
return null; return null;
} }
const showSort = SORT_OPTIONS.length > 1;
return ( return (
<> <>
<PageTitle <PageTitle
...@@ -201,7 +203,7 @@ const Marketplace = () => { ...@@ -201,7 +203,7 @@ const Marketplace = () => {
/> />
<Flex gap={{ base: 2, lg: 3 }}> <Flex gap={{ base: 2, lg: 3 }}>
{ feature.securityReportsUrl && ( { showSort && (
<Sort <Sort
name="dapps_sorting" name="dapps_sorting"
options={ SORT_OPTIONS } options={ SORT_OPTIONS }
...@@ -214,7 +216,7 @@ const Marketplace = () => { ...@@ -214,7 +216,7 @@ const Marketplace = () => {
onChange={ onSearchInputChange } onChange={ onSearchInputChange }
placeholder="Find app by name or keyword..." placeholder="Find app by name or keyword..."
isLoading={ isPlaceholderData } isLoading={ isPlaceholderData }
size={ feature.securityReportsUrl ? 'xs' : 'sm' } size={ showSort ? 'xs' : 'sm' }
w={{ base: '100%', lg: '350px' }} w={{ base: '100%', lg: '350px' }}
/> />
</Flex> </Flex>
......
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