mirror of
https://github.com/pezkuwichain/pezkuwi-apps.git
synced 2026-06-15 10:21:07 +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,57 @@
|
||||
// Copyright 2017-2025 @pezkuwi/app-referenda authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { ApiPromise } from '@pezkuwi/api';
|
||||
import type { BN } from '@pezkuwi/util';
|
||||
import type { TrackDescription } from '../../types.js';
|
||||
import type { TrackOption } from './types.js';
|
||||
|
||||
import React, { useMemo } from 'react';
|
||||
|
||||
import { createNamedHook, useApi } from '@pezkuwi/react-hooks';
|
||||
import { bnToBn } from '@pezkuwi/util';
|
||||
|
||||
import { getTrackInfo, getTrackName } from '../../util.js';
|
||||
|
||||
function getTrackOptions (api: ApiPromise, specName: string, palletReferenda: string, tracks: TrackDescription[], include?: (BN | number)[], exclude?: (BN | number)[]): TrackOption[] {
|
||||
const includeBn = include?.map((v) => bnToBn(v));
|
||||
const excludeBn = exclude?.map((v) => bnToBn(v));
|
||||
|
||||
return tracks
|
||||
.filter(({ id }) =>
|
||||
(
|
||||
!includeBn ||
|
||||
includeBn.some((v) => v.eq(id))
|
||||
) && (
|
||||
!excludeBn ||
|
||||
!excludeBn.some((v) => v.eq(id))
|
||||
)
|
||||
)
|
||||
.map(({ id, info }): TrackOption => {
|
||||
const trackInfo = getTrackInfo(api, specName, palletReferenda, tracks, id.toNumber());
|
||||
const trackName = getTrackName(id, info);
|
||||
|
||||
return {
|
||||
text: trackInfo?.text
|
||||
? (
|
||||
<div className='trackOption'>
|
||||
<div className='normal'>{trackName}</div>
|
||||
<div className='faded'>{trackInfo.text}</div>
|
||||
</div>
|
||||
)
|
||||
: trackName,
|
||||
value: id.toNumber()
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function useTrackOptionsImpl (palletReferenda: string, tracks: TrackDescription[], include?: (BN | number)[], exclude?: (BN | number)[]): TrackOption[] {
|
||||
const { api, specName } = useApi();
|
||||
|
||||
return useMemo(
|
||||
() => getTrackOptions(api, specName, palletReferenda, tracks, include, exclude),
|
||||
[api, exclude, include, palletReferenda, specName, tracks]
|
||||
);
|
||||
}
|
||||
|
||||
export default createNamedHook('useTrackOptions', useTrackOptionsImpl);
|
||||
Reference in New Issue
Block a user