|
@@ -11,7 +11,7 @@ import BN from 'bn.js';
|
|
|
import React, { useContext, useEffect, useState } from 'react';
|
|
|
import styled from 'styled-components';
|
|
|
import { ApiContext, withCalls, withMulti } from '@polkadot/react-api';
|
|
|
-import { AddressCard, AddressMini, Badge, Icon } from '@polkadot/react-components';
|
|
|
+import { AddressCard, AddressMini, Badge, Expander, Icon } from '@polkadot/react-components';
|
|
|
import { classes } from '@polkadot/react-components/util';
|
|
|
import keyring from '@polkadot/ui-keyring';
|
|
|
import { formatNumber } from '@polkadot/util';
|
|
@@ -48,7 +48,6 @@ const WITH_VALIDATOR_PREFS = { validatorPayment: true };
|
|
|
function Address ({ address, authorsMap, className, currentElected, defaultName, filter, lastAuthors, points, recentlyOnline, stakingInfo, t, withNominations = true }: Props): React.ReactElement<Props> | null {
|
|
|
const { isSubstrateV2 } = useContext(ApiContext);
|
|
|
const [extraInfo, setExtraInfo] = useState<[React.ReactNode, React.ReactNode][] | undefined>();
|
|
|
- const [isNominationsOpen, setIsNominationsOpen] = useState(false);
|
|
|
const [{ balanceOpts, controllerId, hasNominators, isNominatorMe, isSelected, nominators, sessionId, stashId }, setStakingState] = useState<StakingState>({
|
|
|
balanceOpts: { bonded: true },
|
|
|
hasNominators: false,
|
|
@@ -118,13 +117,6 @@ function Address ({ address, authorsMap, className, currentElected, defaultName,
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- const _toggleNominations = (event: React.SyntheticEvent): void => {
|
|
|
- event.preventDefault();
|
|
|
- event.stopPropagation();
|
|
|
-
|
|
|
- setIsNominationsOpen(!isNominationsOpen);
|
|
|
- };
|
|
|
-
|
|
|
const lastBlockNumber = authorsMap[stashId];
|
|
|
const isAuthor = lastAuthors && lastAuthors.includes(stashId);
|
|
|
|
|
@@ -184,15 +176,14 @@ function Address ({ address, authorsMap, className, currentElected, defaultName,
|
|
|
withValidatorPrefs={WITH_VALIDATOR_PREFS}
|
|
|
>
|
|
|
{withNominations && hasNominators && (
|
|
|
- <details open={isNominationsOpen}>
|
|
|
- <summary onClick={_toggleNominations}>
|
|
|
- {t('Nominators ({{count}})', {
|
|
|
- replace: {
|
|
|
- count: nominators.length
|
|
|
- }
|
|
|
- })}
|
|
|
- </summary>
|
|
|
- {isNominationsOpen && nominators.map(([who, bonded]): React.ReactNode =>
|
|
|
+ <Expander
|
|
|
+ summary={t('Nominators ({{count}})', {
|
|
|
+ replace: {
|
|
|
+ count: nominators.length
|
|
|
+ }
|
|
|
+ })}
|
|
|
+ >
|
|
|
+ {nominators.map(([who, bonded]): React.ReactNode =>
|
|
|
<AddressMini
|
|
|
bonded={bonded}
|
|
|
key={who.toString()}
|
|
@@ -200,7 +191,7 @@ function Address ({ address, authorsMap, className, currentElected, defaultName,
|
|
|
withBonded
|
|
|
/>
|
|
|
)}
|
|
|
- </details>
|
|
|
+ </Expander>
|
|
|
)}
|
|
|
</AddressCard>
|
|
|
);
|