// Copyright 2017-2025 @polkadot/app-explorer authors & contributors // SPDX-License-Identifier: Apache-2.0 import type { DeriveSessionProgress } from '@polkadot/api-derive/types'; import type { Forcing } from '@polkadot/types/interfaces'; import React from 'react'; import { CardSummary } from '@polkadot/react-components'; import { useApi, useCall } from '@polkadot/react-hooks'; import { Elapsed } from '@polkadot/react-query'; import { BN_THREE, BN_TWO, formatNumber } from '@polkadot/util'; import { useTranslation } from './translate.js'; interface Props { className?: string; withEra?: boolean; withSession?: boolean; } function SummarySession ({ className, withEra = true, withSession = true }: Props): React.ReactElement { const { t } = useTranslation(); const { api } = useApi(); const sessionInfo = useCall(api.derive.session?.progress); const forcing = useCall(api.query.staking?.forceEra); const eraLabel = t('era'); const sessionLabel = api.query.babe ? t('epoch') : t('session'); const activeEraStart = sessionInfo?.activeEraStart.unwrapOr(null); return ( <> {api.derive.session && ( <> {withSession && ( api.query.babe ? ( ) : ( #{sessionInfo ? formatNumber(sessionInfo.currentIndex) : 123} {withEra && activeEraStart &&
 
}
) )} {withEra && ( api.query.babe ? ( ) : ( #{sessionInfo ? formatNumber(sessionInfo.activeEra) : 123} {activeEraStart && (  {t('elapsed')} )} ) )} )} ); } export default React.memo(SummarySession);