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

Dapps modals #2490

Merged
merged 9 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from 7 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
7 changes: 4 additions & 3 deletions ui/marketplace/Rating/useRatings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,11 @@ export default function useRatings() {
}, [ address, toast ]);

useEffect(() => {
const { isPlaceholderData, data } = addressCountersQuery;
const canRate = address && !isPlaceholderData && Number(data?.transactions_count) >= MIN_TRANSACTION_COUNT;
const isPlaceholderData = addressCountersQuery?.isPlaceholderData;
const transactionsCount = addressCountersQuery?.data?.transactions_count;
const canRate = address && !isPlaceholderData && Number(transactionsCount || 0) >= MIN_TRANSACTION_COUNT;
setCanRate(canRate);
}, [ address, addressCountersQuery ]);
}, [ address, addressCountersQuery?.isPlaceholderData, addressCountersQuery?.data?.transactions_count ]);

const rateApp = useCallback(async(
appId: string,
Expand Down
9 changes: 9 additions & 0 deletions ui/marketplace/useMarketplace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { MarketplaceCategory } from 'types/client/marketplace';
import useDebounce from 'lib/hooks/useDebounce';
import * as mixpanel from 'lib/mixpanel/index';
import getQueryParamString from 'lib/router/getQueryParamString';
import removeQueryParam from 'lib/router/removeQueryParam';

import useRatings from './Rating/useRatings';
import useMarketplaceApps from './useMarketplaceApps';
Expand Down Expand Up @@ -106,6 +107,14 @@ export default function useMarketplace() {
// run only when data is loaded
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [ isPlaceholderData ]);
React.useEffect(() => {
const selectedAppId = getQueryParamString(router.query.selectedAppId);
if (selectedAppId) {
setSelectedAppId(selectedAppId);
setIsAppInfoModalOpen(true);
removeQueryParam(router, 'selectedAppId');
}
}, [ router.query.selectedAppId, router ]);

React.useEffect(() => {
if (isPlaceholderData) {
Expand Down
9 changes: 8 additions & 1 deletion ui/searchResults/SearchResultListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,14 @@ const SearchResultListItem = ({ data, searchTerm, isLoading, addressFormat }: Pr
/>
{ data.app.external ? (
<LinkExternal
href={ data.app.url }
href={
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not an external link anymore, need to change the link component as well

route({
pathname: '/apps',
query: {
selectedAppId: data.app.id,
},
})
}
fontWeight={ 700 }
wordBreak="break-all"
isLoading={ isLoading }
Expand Down
9 changes: 8 additions & 1 deletion ui/searchResults/SearchResultTableItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,14 @@ const SearchResultTableItem = ({ data, searchTerm, isLoading, addressFormat }: P
/>
{ data.app.external ? (
<LinkExternal
href={ data.app.url }
href={
route({
pathname: '/apps',
query: {
selectedAppId: data.app.id,
},
})
}
fontWeight={ 700 }
wordBreak="break-all"
isLoading={ isLoading }
Expand Down
8 changes: 6 additions & 2 deletions ui/snippets/searchBar/SearchBar.pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,12 @@ test.describe('with apps', () => {
await mockConfigResponse('NEXT_PUBLIC_MARKETPLACE_CONFIG_URL', MARKETPLACE_CONFIG_URL, appsMock);
await mockAssetResponse(appsMock[0].logo, './playwright/mocks/image_s.jpg');
await mockAssetResponse(appsMock[1].logo, './playwright/mocks/image_s.jpg');

await render(<SearchBar/>);
const hooksConfig = {
router: {
query: { q: 'o' },
},
};
await render(<SearchBar/>, { hooksConfig });
await page.getByPlaceholder(/search/i).fill('o');
await page.waitForResponse(apiUrl);

Expand Down
21 changes: 17 additions & 4 deletions ui/snippets/searchBar/SearchBarSuggest/SearchBarSuggestApp.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Image, Flex, Text, useColorModeValue } from '@chakra-ui/react';
isstuev marked this conversation as resolved.
Show resolved Hide resolved
import NextLink from 'next/link';
import router from 'next/router';
import React from 'react';

import type { MarketplaceAppOverview } from 'types/client/marketplace';
Expand All @@ -8,7 +9,6 @@ import highlightText from 'lib/highlightText';
import IconSvg from 'ui/shared/IconSvg';

import SearchBarSuggestItemLink from './SearchBarSuggestItemLink';

interface Props {
data: MarketplaceAppOverview;
isMobile: boolean | undefined;
Expand Down Expand Up @@ -96,9 +96,22 @@ const SearchBarSuggestApp = ({ data, isMobile, searchTerm, onClick }: Props) =>

if (data.external) {
return (
<SearchBarSuggestItemLink onClick={ onClick } href={ data.url } target="_blank">
{ content }
</SearchBarSuggestItemLink>
<NextLink
href={{
pathname: '/apps',
query: {
selectedAppId: data.id,
},
}}
passHref
shallow={ router.pathname === '/apps' }
tom2drum marked this conversation as resolved.
Show resolved Hide resolved
legacyBehavior
>
<SearchBarSuggestItemLink onClick={ onClick }>
{ content }
</SearchBarSuggestItemLink>
</NextLink>

);
}

Expand Down
Loading