fix: enhance RefEnd component with staking async APIs integration (#11970)
This commit is contained in:
parent
88fc36a1d6
commit
46ee0f2859
@ -5,7 +5,7 @@ import type { BN } from '@polkadot/util';
|
||||
|
||||
import React from 'react';
|
||||
|
||||
import { useBestNumberRelay } from '@polkadot/react-hooks';
|
||||
import { useBestNumberRelay, useStakingAsyncApis } from '@polkadot/react-hooks';
|
||||
import { BlockToTime } from '@polkadot/react-query';
|
||||
import { formatNumber } from '@polkadot/util';
|
||||
|
||||
@ -17,14 +17,19 @@ interface Props {
|
||||
|
||||
function RefEnd ({ className = '', label, when }: Props): React.ReactElement<Props> {
|
||||
const bestNumber = useBestNumberRelay();
|
||||
const { isStakingAsync, rcApi } = useStakingAsyncApis();
|
||||
|
||||
return (
|
||||
<td className={`${className} number`}>
|
||||
{bestNumber && when && (
|
||||
<>
|
||||
<div>{label}</div>
|
||||
{/* Remaining period should be decided based on Relay chain */}
|
||||
{when.gt(bestNumber) && (
|
||||
<BlockToTime value={when.sub(bestNumber)} />
|
||||
<BlockToTime
|
||||
api={isStakingAsync ? rcApi : undefined}
|
||||
value={when.sub(bestNumber)}
|
||||
/>
|
||||
)}
|
||||
<div>#{formatNumber(when)}</div>
|
||||
</>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user