fix: enhance RefEnd component with staking async APIs integration (#11970)

This commit is contained in:
Arjun Porwal 2025-11-05 13:31:40 +05:30 committed by GitHub
parent 88fc36a1d6
commit 46ee0f2859
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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>
</>