Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix marketplace sorting display #2138

Merged
merged 1 commit into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions ui/marketplace/utils.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import type { NextRouter } from 'next/router';

import config from 'configs/app';
import getQueryParamString from 'lib/router/getQueryParamString';
import removeQueryParam from 'lib/router/removeQueryParam';
import type { TOption } from 'ui/shared/sort/Option';

const feature = config.features.marketplace;

export type SortValue = 'rating' | 'security_score';

export const SORT_OPTIONS: Array<TOption<SortValue>> = [
{ title: 'Default', id: undefined },
{ title: 'Rating', id: 'rating' },
{ title: 'Security score', id: 'security_score' },
];
(feature.isEnabled && feature.rating) && { title: 'Rating', id: 'rating' },
(feature.isEnabled && feature.securityReportsUrl) && { title: 'Security score', id: 'security_score' },
].filter(Boolean) as Array<TOption<SortValue>>;

export function getAppUrl(url: string | undefined, router: NextRouter) {
if (!url) {
Expand Down
6 changes: 4 additions & 2 deletions ui/pages/Marketplace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ const Marketplace = () => {
return null;
}

const showSort = SORT_OPTIONS.length > 1;

return (
<>
<PageTitle
Expand Down Expand Up @@ -201,7 +203,7 @@ const Marketplace = () => {
/>

<Flex gap={{ base: 2, lg: 3 }}>
{ feature.securityReportsUrl && (
{ showSort && (
<Sort
name="dapps_sorting"
options={ SORT_OPTIONS }
Expand All @@ -214,7 +216,7 @@ const Marketplace = () => {
onChange={ onSearchInputChange }
placeholder="Find app by name or keyword..."
isLoading={ isPlaceholderData }
size={ feature.securityReportsUrl ? 'xs' : 'sm' }
size={ showSort ? 'xs' : 'sm' }
w={{ base: '100%', lg: '350px' }}
/>
</Flex>
Expand Down
Loading