Skip to content

Commit

Permalink
Create NFTCollectionLink
Browse files Browse the repository at this point in the history
  • Loading branch information
buberdds committed Dec 1, 2023
1 parent 6b6b679 commit 8ed424f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/app/pages/AccountDetailsPage/AccountNFTCollectionCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { TablePagination } from '../../components/Table/TablePagination'
import { useAccountTokenInventory } from '../TokenDashboardPage/hook'
import { EvmNft } from 'oasis-nexus/api'
import { SearchScope } from '../../../types/searchScope'
import { NFTInstanceLink } from '../TokenDashboardPage/NFTLinks'
import { NFTCollectionLink, NFTInstanceLink } from '../TokenDashboardPage/NFTLinks'

export const accountTokenContainerId = 'nftCollection'

Expand Down Expand Up @@ -128,7 +128,7 @@ const AccountNFTCollection: FC<AccountNFTCollectionProps> = ({
<ImageListItem key={instance.id}>
<ImageListItemImage instance={instance} to={to} />
<ImageListItemBar
title={'TODO'}
title={<NFTCollectionLink instance={instance} scope={scope} />}
subtitle={<NFTInstanceLink instance={instance} scope={scope} />}
position="below"
/>
Expand Down
30 changes: 26 additions & 4 deletions src/app/pages/TokenDashboardPage/NFTLinks.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,40 @@
import { FC } from 'react'
import { Trans, useTranslation } from 'react-i18next'
import { Link as RouterLink } from 'react-router-dom'
import { EvmNft } from 'oasis-nexus/api'
import Link from '@mui/material/Link'
import Typography from '@mui/material/Typography'
import { RouteUtils } from '../../utils/route-utils'
import { EvmNft } from 'oasis-nexus/api'
import { SearchScope } from 'types/searchScope'
import { SearchScope } from '../../../types/searchScope'
import { trimLongString } from '../../utils/trimLongString'

type NFTInstanceLinkProps = {
type NFTLinkProps = {
scope: SearchScope
instance: EvmNft
}

export const NFTInstanceLink: FC<NFTInstanceLinkProps> = ({ scope, instance }) => {
export const NFTCollectionLink: FC<NFTLinkProps> = ({ scope, instance }) => {
const { t } = useTranslation()
const to = RouteUtils.getTokenRoute(scope, instance.token?.contract_addr)

return (
<Typography>
<Trans
i18nKey="nft.collectionLink"
t={t}
components={{
CollectionLink: (
<Link component={RouterLink} to={to}>
{instance.token?.name ?? trimLongString(instance.token?.eth_contract_addr, 5, 5)}
</Link>
),
}}
/>
</Typography>
)
}

export const NFTInstanceLink: FC<NFTLinkProps> = ({ scope, instance }) => {
const { t } = useTranslation()
const to = RouteUtils.getNFTInstanceRoute(scope, instance.token?.contract_addr, instance.id)

Expand Down
1 change: 1 addition & 0 deletions src/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
},
"nft": {
"accountCollection": "ERC-721 Tokens",
"collectionLink": "Collection: <CollectionLink />",
"instanceIdLink": "ID: <InstanceLink />",
"instanceTokenId": "Token ID",
"instanceTitleSuffix": "(NFT Instance)",
Expand Down

0 comments on commit 8ed424f

Please sign in to comment.