mirror of
https://github.com/pezkuwichain/pezkuwi-apps.git
synced 2026-06-21 02:51:05 +00:00
d21bfb1320
Rebranded terminology: - Polkadot → Pezkuwi - Kusama → Dicle - Westend → Zagros - Rococo → PezkuwiChain - Substrate → Bizinikiwi - parachain → teyrchain Custom logos with Kurdistan brand colors (#e6007a → #86e62a): - bizinikiwi-hexagon.svg - sora-bizinikiwi.svg - hezscanner.svg - heztreasury.svg - pezkuwiscan.svg - pezkuwistats.svg - pezkuwiassembly.svg - pezkuwiholic.svg
65 lines
1.6 KiB
TypeScript
65 lines
1.6 KiB
TypeScript
// Copyright 2017-2025 @pezkuwi/app-staking authors & contributors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
import type { BN } from '@pezkuwi/util';
|
|
import type { PayoutStash } from './types.js';
|
|
|
|
import React, { useEffect, useState } from 'react';
|
|
|
|
import { AddressSmall, Table } from '@pezkuwi/react-components';
|
|
import { BlockToTime } from '@pezkuwi/react-query';
|
|
import { BN_MILLION } from '@pezkuwi/util';
|
|
|
|
import useEraBlocks from './useEraBlocks.js';
|
|
import { createErasString } from './util.js';
|
|
|
|
interface Props {
|
|
className?: string;
|
|
historyDepth?: BN;
|
|
payout: PayoutStash;
|
|
}
|
|
|
|
interface EraInfo {
|
|
eraStr: React.ReactNode;
|
|
oldestEra?: BN;
|
|
}
|
|
|
|
function Stash ({ className = '', historyDepth, payout: { available, rewards, stashId } }: Props): React.ReactElement<Props> {
|
|
const [{ eraStr, oldestEra }, setEraInfo] = useState<EraInfo>({ eraStr: '' });
|
|
const eraBlocks = useEraBlocks(historyDepth, oldestEra);
|
|
|
|
useEffect((): void => {
|
|
rewards && setEraInfo({
|
|
eraStr: createErasString(rewards.map(({ era }) => era)),
|
|
oldestEra: rewards[0]?.era
|
|
});
|
|
}, [rewards]);
|
|
|
|
return (
|
|
<tr className={className}>
|
|
<td
|
|
className='address'
|
|
colSpan={2}
|
|
>
|
|
<AddressSmall value={stashId} />
|
|
</td>
|
|
<td className='start'>
|
|
<span className='payout-eras'>{eraStr}</span>
|
|
</td>
|
|
<Table.Column.Balance value={available} />
|
|
<td className='number'>
|
|
<BlockToTime
|
|
className={eraBlocks ? '' : '--tmp'}
|
|
value={eraBlocks || BN_MILLION}
|
|
/>
|
|
</td>
|
|
<td
|
|
className='button'
|
|
colSpan={3}
|
|
/>
|
|
</tr>
|
|
);
|
|
}
|
|
|
|
export default React.memo(Stash);
|