mirror of
https://github.com/pezkuwichain/pwap.git
synced 2026-06-26 12:51:02 +00:00
60a800b33e
- Clone Polkadot.js Apps repository - Update package.json with Pezkuwi branding - Add Pezkuwi endpoint to production chains (wss://pezkuwichain.app:9944) - Create comprehensive README for SDK UI - Set up project structure with all packages Next steps: - Apply Kurdistan colors (Kesk, Sor, Zer, Spi + Black) to UI theme - Replace logos with Pezkuwi branding - Test build and deployment
46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
// Copyright 2017-2025 @polkadot/react-components authors & contributors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
import type { DeriveAccountInfo } from '@polkadot/api-derive/types';
|
|
import type { AccountId, Address } from '@polkadot/types/interfaces';
|
|
|
|
import React, { useMemo } from 'react';
|
|
|
|
import { useDeriveAccountInfo, useSystemApi } from '@polkadot/react-hooks';
|
|
|
|
interface Props {
|
|
children?: React.ReactNode;
|
|
className?: string;
|
|
defaultValue?: string;
|
|
label?: React.ReactNode;
|
|
value?: string | AccountId | Address | null | Uint8Array;
|
|
}
|
|
|
|
function extractIndex ({ accountIndex }: Partial<DeriveAccountInfo> = {}): string | null {
|
|
return accountIndex
|
|
? accountIndex.toString()
|
|
: null;
|
|
}
|
|
|
|
function AccountIndex ({ children, className = '', defaultValue, label, value }: Props): React.ReactElement<Props> | null {
|
|
const api = useSystemApi();
|
|
const info = useDeriveAccountInfo(value);
|
|
|
|
const accountIndex = useMemo(
|
|
() => extractIndex(info),
|
|
[info]
|
|
);
|
|
|
|
if (!api?.query.indices) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<div className={`${className} ui--AccountIndex`}>
|
|
{label || ''}<div className='account-index'>{accountIndex || defaultValue || '-'}</div>{children}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export default React.memo(AccountIndex);
|