Skip to content

Commit

Permalink
Add support for displaying token search results
Browse files Browse the repository at this point in the history
  • Loading branch information
csillag committed Jul 1, 2023
1 parent 8b937a8 commit 84565de
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/app/pages/SearchResultsPage/SearchResultsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import { BlockDetailView } from '../BlockDetailPage'
import { RouteUtils } from '../../utils/route-utils'
import { TransactionDetailView } from '../TransactionDetailPage'
import { AccountDetailsView } from '../AccountDetailsPage'
import { AccountResult, BlockResult, SearchResults, TransactionResult } from './hooks'
import { AccountResult, BlockResult, SearchResults, TokenResult, TransactionResult } from './hooks'
import { getThemesForNetworks } from '../../../styles/theme'
import { Network } from '../../../types/network'
import { SubPageCard } from '../../components/SubPageCard'
import { AllTokenPrices } from '../../../coin-gecko/api'
import { ResultListFrame } from './ResultListFrame'
import { TokenDetails } from '../../components/Tokens/TokenDetails'

/**
* Component for displaying a list of search results
Expand Down Expand Up @@ -82,6 +83,14 @@ export const SearchResultsList: FC<{
link={acc => RouteUtils.getAccountRoute(acc, acc.address_eth ?? acc.address)}
linkLabel={t('search.results.accounts.viewLink')}
/>

<ResultsGroupByType
title={t('search.results.tokens.title')}
results={searchResults.filter((item): item is TokenResult => item.resultType === 'token')}
resultComponent={item => <TokenDetails token={item} showLayer />}
link={token => RouteUtils.getTokenRoute(token, token.eth_contract_addr ?? token.contract_addr)}
linkLabel={t('search.results.tokens.viewLink')}
/>
</SubPageCard>
</ResultListFrame>
)
Expand Down
4 changes: 4 additions & 0 deletions src/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,10 @@
"title": "Blocks",
"viewLink": "View Block"
},
"tokens": {
"title": "Tokens",
"viewLink": "View Token"
},
"transactions": {
"title": "Transactions",
"viewLink": "View Transaction"
Expand Down

0 comments on commit 84565de

Please sign in to comment.