ghost-portal/packages/page-staking/src/MaxBadge.tsx
2021-01-03 11:33:39 +01:00

31 lines
669 B
TypeScript

// Copyright 2017-2021 @polkadot/app-staking authors & contributors
// SPDX-License-Identifier: Apache-2.0
import React from 'react';
import { Badge } from '@polkadot/react-components';
import { useApi } from '@polkadot/react-hooks';
interface Props {
numNominators?: number;
}
function MaxBadge ({ numNominators }: Props): React.ReactElement<Props> | null {
const { api } = useApi();
const max = api.consts.staking?.maxNominatorRewardedPerValidator;
if (!numNominators || !max || max.gten(numNominators)) {
return null;
}
return (
<Badge
color='red'
icon='balance-scale-right'
/>
);
}
export default React.memo(MaxBadge);