// Copyright 2017-2026 @pezkuwi/app-staking authors & contributors // SPDX-License-Identifier: Apache-2.0 import type { INumber } from '@pezkuwi/types/types'; import React, { useCallback, useMemo, useState } from 'react'; import { useParams } from 'react-router-dom'; import { Button, InputAddressSimple, Spinner } from '@pezkuwi/react-components'; import { useApi, useCall } from '@pezkuwi/react-hooks'; import { useTranslation } from '../translate.js'; import Validator from './Validator.js'; interface Props { basePath: string, className?: string; } function doQuery (basePath: string, validatorId?: string | null): void { if (validatorId) { window.location.hash = `${basePath}/query/${validatorId}`; } } function Query ({ basePath, className }: Props): React.ReactElement { const { t } = useTranslation(); const { api } = useApi(); const { value } = useParams<{ value: string }>(); const [validatorId, setValidatorId] = useState(value || null); const eras = useCall(api.derive.staking.erasHistoric); const labels = useMemo( () => eras?.map((e) => e.toHuman() as string), [eras] ); const _onQuery = useCallback( () => doQuery(basePath, validatorId), [basePath, validatorId] ); if (!labels) { return ; } return (
); } export default React.memo(Query);