Files
pezkuwi-sdk-ui/packages/page-explorer/src/BlockHeaders.tsx
pezkuwichain d949863789 Initial commit: Pezkuwi SDK UI
Comprehensive web interface for interacting with Pezkuwi blockchain.

Features:
- Blockchain explorer
- Wallet management
- Staking interface
- Governance participation
- Developer tools

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 13:55:36 +03:00

58 lines
1.4 KiB
TypeScript

// Copyright 2017-2026 @pezkuwi/app-explorer authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { AugmentedBlockHeader } from '@pezkuwi/react-hooks/ctx/types';
import React, { useMemo, useRef } from 'react';
import { Table } from '@pezkuwi/react-components';
import BlockHeader from './BlockHeader.js';
import { useTranslation } from './translate.js';
interface Props {
headers: AugmentedBlockHeader[];
}
function BlockHeaders ({ headers }: Props): React.ReactElement<Props> {
const { t } = useTranslation();
const headerRef = useRef<([React.ReactNode?, string?, number?] | false)[]>([
[t('recent blocks'), 'start', 4]
]);
const groupedByTimestamp = useMemo(() => {
return headers.reduce((acc, product) => {
const timestamp = product.timestamp.toString();
if (!acc[timestamp]) {
acc[timestamp] = [];
}
acc[timestamp].push(product);
return acc;
}, {} as Record<string, AugmentedBlockHeader[]>);
}, [headers]);
return (
<Table
empty={t('No blocks available')}
header={headerRef.current}
>
{Object
.entries(groupedByTimestamp)
.map(([timestamp, headers]): React.ReactNode => {
return (
<BlockHeader
headers={headers.filter((e) => !!e)}
key={timestamp}
/>
);
})}
</Table>
);
}
export default React.memo(BlockHeaders);