Skip to content
Closed
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
1 change: 1 addition & 0 deletions .changelog/1466.trivial.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Account details: add link to validator details
44 changes: 35 additions & 9 deletions src/app/components/Account/ConsensusAccountDetailsView.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { FC } from 'react'
import { useTranslation } from 'react-i18next'
import { CardEmptyState } from '../CardEmptyState'
import { Account } from '../../../oasis-nexus/api'
import { Account, Validator } from '../../../oasis-nexus/api'
import { useScreenSize } from '../../hooks/useScreensize'
import { TextSkeleton } from '../Skeleton'
import { StyledDescriptionList, StyledListTitleWithAvatar } from '../StyledDescriptionList'
Expand All @@ -13,13 +13,15 @@ import { AccountSizeBadge } from '../AccountSizeBadge'
import { AccountLink } from './AccountLink'
import { CopyToClipboard } from '../CopyToClipboard'
import { getPreciseNumberFormat } from '../../../locales/getPreciseNumberFormat'
import { ValidatorLink } from '../Validators/ValidatorLink'

export const StyledListTitle = styled('dt')(({ theme }) => ({
marginLeft: theme.spacing(4),
}))

type ConsensusAccountDetailsViewProps = {
account?: Account
validator?: Validator
isError?: boolean
isLoading?: boolean
showLayer?: boolean
Expand All @@ -29,6 +31,7 @@ type ConsensusAccountDetailsViewProps = {

export const ConsensusAccountDetailsView: FC<ConsensusAccountDetailsViewProps> = ({
account,
validator,
isError,
isLoading,
showLayer,
Expand Down Expand Up @@ -57,14 +60,37 @@ export const ConsensusAccountDetailsView: FC<ConsensusAccountDetailsViewProps> =
<AccountSizeBadge size={account.size} />
</Box>
</StyledListTitleWithAvatar>
<dd>
<AccountLink
scope={account}
address={account.address}
highlightedPartOfName={highlightedPartOfName}
/>
<CopyToClipboard value={account.address} />
</dd>
{validator ? (
<>
<dd>
<strong>{validator.media?.name}</strong>
&nbsp;
<ValidatorLink
address={account.address}
network={account.network}
name={t('validator.viewProfile')}
/>
</dd>
<dt>{t('common.address')}</dt>
<dd>
<AccountLink
scope={account}
address={account.address}
highlightedPartOfName={highlightedPartOfName}
/>
<CopyToClipboard value={account.address} />
</dd>
</>
) : (
<dd>
<AccountLink
scope={account}
address={account.address}
highlightedPartOfName={highlightedPartOfName}
/>
<CopyToClipboard value={account.address} />
</dd>
)}
<dt>
<strong>{t('account.totalBalance')}</strong>
</dt>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import { FC } from 'react'
import { useTranslation } from 'react-i18next'
import { Account } from '../../../oasis-nexus/api'
import { Account, Validator } from '../../../oasis-nexus/api'
import { SubPageCard } from '../../components/SubPageCard'
import { ConsensusAccountDetailsView } from '../../components/Account/ConsensusAccountDetailsView'

type ConsensusAccountDetailsCardProps = {
account: Account | undefined
validator: Validator | undefined
isError: boolean
isLoading: boolean
highlightedPartOfName?: string | undefined
}

export const ConsensusAccountDetailsCard: FC<ConsensusAccountDetailsCardProps> = ({
account,
validator,
isError,
isLoading,
highlightedPartOfName,
Expand All @@ -25,6 +27,7 @@ export const ConsensusAccountDetailsCard: FC<ConsensusAccountDetailsCardProps> =
isError={isError}
isLoading={isLoading}
account={account}
validator={validator}
highlightedPartOfName={highlightedPartOfName}
/>
</SubPageCard>
Expand Down
5 changes: 4 additions & 1 deletion src/app/pages/ConsensusAccountDetailsPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { FC } from 'react'
import { useTranslation } from 'react-i18next'
import { useHref, useLoaderData } from 'react-router-dom'
import Grid from '@mui/material/Grid'
import { useGetConsensusAccountsAddress } from '../../../oasis-nexus/api'
import { useGetConsensusAccountsAddress, useGetConsensusValidatorsAddress } from '../../../oasis-nexus/api'
import { useScreenSize } from '../../hooks/useScreensize'
import { PageLayout } from '../../components/PageLayout'
import { AddressLoaderData } from '../../utils/route-utils'
Expand All @@ -22,13 +22,16 @@ export const ConsensusAccountDetailsPage: FC = () => {
const accountQuery = useGetConsensusAccountsAddress(network, address)
const { isError, isLoading, data } = accountQuery
const account = data?.data
const { data: validatorData } = useGetConsensusValidatorsAddress(network, address)
const validator = validatorData?.data
const transactionsLink = useHref('')
const context: ConsensusAccountDetailsContext = { scope, address }

return (
<PageLayout>
<ConsensusAccountDetailsCard
account={account}
validator={validator}
isError={isError}
isLoading={isLoading}
highlightedPartOfName={searchTerm}
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 @@ -679,6 +679,7 @@
"totalShare": "Total Share",
"undelegations": "Undelegations",
"uptime": "Uptime",
"viewProfile": "(View validator profile)",
"voting": "Voting %",
"votingPower": "Voting Power"
}
Expand Down