mirror of
https://github.com/pezkuwichain/pezkuwi-apps.git
synced 2026-06-13 22:11:08 +00:00
7a4bbeac25
- Update @pezkuwi/extension-inject to ^0.62.13 with proper /types exports - Update @pezkuwi/extension-dapp to ^0.62.13 - Update @pezkuwi/extension-compat-metamask to ^0.62.13 - Fix IconTheme type to include 'bizinikiwi' and 'pezkuwi' themes - Fix endpoint array issues (getTeleports -> direct array references) - Add type assertions for external package compatibility (acala, moonbeam, parallel) - Fix subspace.ts dynamic class typing - Fix conviction type in page-referenda - Update Pallet type names to Pezpallet prefix across codebase - Define InjectedExtension types locally for module resolution - Add styled-components DefaultTheme augmentation - Add react-copy-to-clipboard type declaration for React 18 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
106 lines
3.4 KiB
TypeScript
106 lines
3.4 KiB
TypeScript
// Copyright 2017-2026 @pezkuwi/app-teyrchains authors & contributors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
import type { u32 } from '@pezkuwi/types';
|
|
import type { Balance, BlockNumber } from '@pezkuwi/types/interfaces';
|
|
import type { AuctionInfo, Winning } from '../types.js';
|
|
|
|
import React from 'react';
|
|
|
|
import { CardSummary, SummaryBox } from '@pezkuwi/react-components';
|
|
import { useApi, useBestNumber, useCall } from '@pezkuwi/react-hooks';
|
|
import { FormatBalance } from '@pezkuwi/react-query';
|
|
import { BN_ONE, formatNumber } from '@pezkuwi/util';
|
|
|
|
import { useTranslation } from '../translate.js';
|
|
|
|
interface Props {
|
|
auctionInfo?: AuctionInfo;
|
|
className?: string;
|
|
lastWinners?: Winning;
|
|
}
|
|
|
|
function Summary ({ auctionInfo, className, lastWinners }: Props): React.ReactElement<Props> {
|
|
const { t } = useTranslation();
|
|
const { api } = useApi();
|
|
const bestNumber = useBestNumber();
|
|
const totalIssuance = useCall<Balance>(api.query.balances?.totalIssuance);
|
|
|
|
return (
|
|
<SummaryBox className={className}>
|
|
<section>
|
|
<CardSummary label={t('auctions')}>
|
|
{auctionInfo
|
|
? formatNumber(auctionInfo.numAuctions)
|
|
: <span className='--tmp'>99</span>}
|
|
</CardSummary>
|
|
<CardSummary label={t('active')}>
|
|
{auctionInfo
|
|
? auctionInfo.leasePeriod
|
|
? t('yes')
|
|
: t('no')
|
|
: <span className='--tmp'>{t('no')}</span>
|
|
}
|
|
</CardSummary>
|
|
</section>
|
|
{auctionInfo && (
|
|
<>
|
|
<section>
|
|
{auctionInfo.leasePeriod && (
|
|
<CardSummary label={t('first - last')}>
|
|
{formatNumber(auctionInfo.leasePeriod)} - {formatNumber(auctionInfo.leasePeriod.add(api.consts.auctions.leasePeriodsPerSlot as u32).isub(BN_ONE))}
|
|
</CardSummary>
|
|
)}
|
|
{totalIssuance && lastWinners && (
|
|
<CardSummary
|
|
label={t('total')}
|
|
progress={{
|
|
hideValue: true,
|
|
total: totalIssuance,
|
|
value: lastWinners.total,
|
|
withTime: true
|
|
}}
|
|
>
|
|
<FormatBalance
|
|
value={lastWinners.total}
|
|
withSi
|
|
/>
|
|
</CardSummary>
|
|
)}
|
|
</section>
|
|
<section>
|
|
{auctionInfo?.endBlock && bestNumber && (
|
|
bestNumber.lt(auctionInfo.endBlock)
|
|
? (
|
|
<CardSummary
|
|
label={t('end period at')}
|
|
progress={{
|
|
hideGraph: true,
|
|
total: auctionInfo.endBlock,
|
|
value: bestNumber,
|
|
withTime: true
|
|
}}
|
|
>
|
|
#{formatNumber(auctionInfo.endBlock)}
|
|
</CardSummary>
|
|
)
|
|
: (
|
|
<CardSummary
|
|
label={t('ending period')}
|
|
progress={{
|
|
total: api.consts.auctions?.endingPeriod as BlockNumber,
|
|
value: bestNumber.sub(auctionInfo.endBlock),
|
|
withTime: true
|
|
}}
|
|
></CardSummary>
|
|
)
|
|
)}
|
|
</section>
|
|
</>
|
|
)}
|
|
</SummaryBox>
|
|
);
|
|
}
|
|
|
|
export default React.memo(Summary);
|