mirror of
https://github.com/pezkuwichain/pezkuwi-apps.git
synced 2026-06-15 05:41:08 +00:00
feat: initial Pezkuwi Apps rebrand from polkadot-apps
Rebranded terminology: - Polkadot → Pezkuwi - Kusama → Dicle - Westend → Zagros - Rococo → PezkuwiChain - Substrate → Bizinikiwi - parachain → teyrchain Custom logos with Kurdistan brand colors (#e6007a → #86e62a): - bizinikiwi-hexagon.svg - sora-bizinikiwi.svg - hezscanner.svg - heztreasury.svg - pezkuwiscan.svg - pezkuwistats.svg - pezkuwiassembly.svg - pezkuwiholic.svg
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
// Copyright 2017-2025 @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<Props> {
|
||||
const { t } = useTranslation();
|
||||
const { api } = useApi();
|
||||
const { value } = useParams<{ value: string }>();
|
||||
const [validatorId, setValidatorId] = useState<string | null>(value || null);
|
||||
const eras = useCall<INumber[]>(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 <Spinner />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={className}>
|
||||
<InputAddressSimple
|
||||
className='staking--queryInput'
|
||||
defaultValue={value}
|
||||
label={t('validator to query')}
|
||||
onChange={setValidatorId}
|
||||
onEnter={_onQuery}
|
||||
>
|
||||
<Button
|
||||
icon='play'
|
||||
isDisabled={!validatorId}
|
||||
onClick={_onQuery}
|
||||
/>
|
||||
</InputAddressSimple>
|
||||
{value && (
|
||||
<Validator
|
||||
labels={labels}
|
||||
validatorId={value}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default React.memo(Query);
|
||||
Reference in New Issue
Block a user