// Copyright 2017-2023 @polkadot/app-staking authors & contributors // SPDX-License-Identifier: Apache-2.0 import type { Slash } from './types.js'; import React, { useCallback } from 'react'; import { AddressMini, AddressSmall, Badge, Checkbox, ExpanderScroll } from '@polkadot/react-components'; import { useApi } from '@polkadot/react-hooks'; import { FormatBalance } from '@polkadot/react-query'; import { formatNumber } from '@polkadot/util'; import { useTranslation } from '../translate.js'; interface Props { index: number; isSelected: boolean; onSelect?: (index: number) => void; slash: Slash; } function Row ({ index, isSelected, onSelect, slash: { era, isMine, slash: { others, own, payout, reporters, validator }, total, totalOther } }: Props): React.ReactElement { const { t } = useTranslation(); const { api } = useApi(); const _onSelect = useCallback( () => onSelect && onSelect(index), [index, onSelect] ); const renderOthers = useCallback( () => others.map(([accountId, balance], index): React.ReactNode => ( )), [others] ); return ( {isMine && ( )} {!!others.length && ( ('Nominators ({{count}})', { replace: { count: formatNumber(others.length) } })} /> )} {reporters.map((reporter, index): React.ReactNode => ( ))} {!api.query.staking.earliestUnappliedSlash && !!api.consts.staking.slashDeferDuration && ( {formatNumber(era)} )} ); } export default React.memo(Row);