// Copyright 2017-2026 @pezkuwi/app-staking authors & contributors // SPDX-License-Identifier: Apache-2.0 import type { DeriveHeartbeats, DeriveStakingOverview } from '@pezkuwi/api-derive/types'; import type { StakerState } from '@pezkuwi/react-hooks/types'; import type { BN } from '@pezkuwi/util'; import type { NominatedByMap, SortedTargets } from '../types.js'; import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'; import { Button, ToggleGroup } from '@pezkuwi/react-components'; import { useApi, useBlockAuthors, useCall } from '@pezkuwi/react-hooks'; import { useTranslation } from '../translate.js'; import ActionsBanner from './ActionsBanner.js'; import CurrentList from './CurrentList.js'; import Summary from './Summary.js'; interface Props { className?: string; favorites: string[]; hasAccounts: boolean; hasQueries: boolean; minCommission?: BN; nominatedBy?: NominatedByMap; ownStashes?: StakerState[]; paraValidators?: Record; stakingOverview?: DeriveStakingOverview; targets: SortedTargets; toggleFavorite: (address: string) => void; toggleLedger?: () => void; toggleNominatedBy: () => void; } const EMPTY_PARA_VALS: Record = {}; const EMPTY_BY_AUTHOR: Record = {}; const EMPTY_ERA_POINTS: Record = {}; function Overview ({ className = '', favorites, hasAccounts, hasQueries, minCommission, nominatedBy, ownStashes, paraValidators, stakingOverview, targets, toggleFavorite, toggleLedger, toggleNominatedBy }: Props): React.ReactElement { const { t } = useTranslation(); const { api } = useApi(); const { byAuthor, eraPoints } = useBlockAuthors(); const [intentIndex, _setIntentIndex] = useState(0); const [typeIndex, setTypeIndex] = useState(1); const recentlyOnline = useCall(api.derive.imOnline?.receivedHeartbeats); const setIntentIndex = useCallback( (index: number): void => { index && toggleNominatedBy(); _setIntentIndex(index); }, [toggleNominatedBy] ); const filterOptions = useRef([ { text: t('Own validators'), value: 'mine' }, { text: t('All validators'), value: 'all' } ]); const intentOptions = useRef([ { text: t('Active'), value: 'active' }, { text: t('Waiting'), value: 'waiting' } ]); const ownStashIds = useMemo( () => ownStashes?.map(({ stashId }) => stashId), [ownStashes] ); useEffect((): void => { toggleLedger && toggleLedger(); }, [toggleLedger]); const isOwn = typeIndex === 0; return (
{hasAccounts && (ownStashes?.length === 0) && ( )}
); } export default React.memo(Overview);