Small payout cleanups (#3384)

This commit is contained in:
Jaco Greeff 2020-08-10 21:26:24 +02:00 committed by GitHub
parent 2fbfb1d32e
commit 88d1806695
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View File

@ -3,6 +3,7 @@
// of the Apache-2.0 license. See the LICENSE file for details.
import { DeriveStakerReward } from '@polkadot/api-derive/types';
import { StakerState } from '@polkadot/react-hooks/types';
import { PayoutStash, PayoutValidator } from './types';
import BN from 'bn.js';
@ -24,7 +25,7 @@ import Validator from './Validator';
interface Props {
className?: string;
isInElection?: boolean;
stakerPayoutsAfter: BN;
ownValidators: StakerState;
}
interface Available {

View File

@ -4,6 +4,7 @@
import { DeriveStakingOverview } from '@polkadot/api-derive/types';
import { AppProps as Props } from '@polkadot/react-components/types';
import { StakerState } from '@polkadot/react-hooks/types';
import { ElectionStatus } from '@polkadot/types/interfaces';
import React, { useEffect, useMemo, useState } from 'react';
@ -38,6 +39,7 @@ function StakingApp ({ basePath, className = '' }: Props): React.ReactElement<Pr
const { hasAccounts } = useAccounts();
const { pathname } = useLocation();
const [{ next }, setValidators] = useState<Validators>({});
const [ownValidators, setOwnValidators] = useState<StakerState[]>([]);
const [favorites, toggleFavorite] = useFavorites(STORE_FAVS_BASE);
const allStashes = useStashIds();
const ownStashes = useOwnStashInfos();
@ -104,6 +106,12 @@ function StakingApp ({ basePath, className = '' }: Props): React.ReactElement<Pr
});
}, [allStashes, stakingOverview]);
useEffect((): void => {
ownStashes && setOwnValidators(
ownStashes.filter(({ isStashValidating }) => isStashValidating)
);
}, [ownStashes]);
return (
<main className={`staking--App ${className}`}>
<HelpOverlay md={basicMd as string} />
@ -122,7 +130,10 @@ function StakingApp ({ basePath, className = '' }: Props): React.ReactElement<Pr
/>
<Switch>
<Route path={`${basePath}/payout`}>
<Payouts isInElection={isInElection} />
<Payouts
isInElection={isInElection}
ownValidators={ownValidators}
/>
</Route>
<Route path={[`${basePath}/query/:value`, `${basePath}/query`]}>
<Query />