mirror of
https://github.com/pezkuwichain/pezkuwi-sdk-ui.git
synced 2026-06-13 17:31:13 +00:00
d949863789
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>
58 lines
1.4 KiB
TypeScript
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);
|