// Copyright 2017-2026 @pezkuwi/app-staking authors & contributors // SPDX-License-Identifier: Apache-2.0 import type { Validator } from '../../types.js'; import type { UseHeartbeat } from '../types.js'; import React, { useMemo } from 'react'; import { Badge, styled } from '@pezkuwi/react-components'; import { useAccounts } from '@pezkuwi/react-hooks'; interface Props { className?: string; heartbeat?: UseHeartbeat; isChilled?: boolean; nominators?: string[]; validator: Validator; } function Status ({ className, heartbeat: { authoredBlocks, isOnline } = {}, isChilled, nominators, validator: { isElected, isPara } }: Props): React.ReactElement { const { allAccounts } = useAccounts(); const isNominating = useMemo( () => nominators && nominators.some((a) => allAccounts.includes(a)), [allAccounts, nominators] ); const emptyBadge = ( ); return ( {isNominating ? ( ) : emptyBadge } {isPara ? ( ) : emptyBadge } {isChilled ? ( ) : isElected ? ( ) : emptyBadge } {isOnline ? authoredBlocks ? ( {authoredBlocks} } /> ) : ( ) : emptyBadge } ); } const StyledDiv = styled.div` .authoredBlocks { vertical-align: top; font-size: var(--font-percent-tiny); } `; export default React.memo(Status);