mirror of
https://github.com/pezkuwichain/pezkuwi-apps.git
synced 2026-08-08 06:55:43 +00:00
51 lines
1.3 KiB
TypeScript
51 lines
1.3 KiB
TypeScript
// Copyright 2017-2026 @pezkuwi/app-collator authors & contributors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
import type { Collator as CollatorType } from './types.js';
|
|
|
|
import React, { useMemo } from 'react';
|
|
|
|
import { AddressSmall, Badge, Table } from '@pezkuwi/react-components';
|
|
import { BalanceFree } from '@pezkuwi/react-query';
|
|
import { formatNumber } from '@pezkuwi/util';
|
|
|
|
interface Props {
|
|
className?: string;
|
|
info: CollatorType;
|
|
lastBlock?: string;
|
|
}
|
|
|
|
function Collator ({ className, info: { accountId, deposit, isInvulnerable, lastBlock: lastStateBlock }, lastBlock: lastGlobalBlock }: Props): React.ReactElement<Props> {
|
|
const lastBlock = useMemo(
|
|
() => lastStateBlock
|
|
? formatNumber(lastStateBlock)
|
|
: lastGlobalBlock,
|
|
[lastStateBlock, lastGlobalBlock]
|
|
);
|
|
|
|
return (
|
|
<tr className={className}>
|
|
<td className='badge number'>
|
|
{isInvulnerable && (
|
|
<Badge
|
|
color='green'
|
|
icon='shield'
|
|
/>
|
|
)}
|
|
</td>
|
|
<td className='address all'>
|
|
<AddressSmall value={accountId} />
|
|
</td>
|
|
<Table.Column.Balance value={deposit} />
|
|
<td className='number'>
|
|
<BalanceFree params={accountId} />
|
|
</td>
|
|
<td className='number'>
|
|
{lastBlock}
|
|
</td>
|
|
</tr>
|
|
);
|
|
}
|
|
|
|
export default React.memo(Collator);
|