mirror of
https://github.com/pezkuwichain/pezkuwi-apps.git
synced 2026-06-22 19:41:01 +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,60 @@
|
||||
// Copyright 2017-2025 @pezkuwi/app-staking authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { BN } from '@pezkuwi/util';
|
||||
|
||||
import React from 'react';
|
||||
|
||||
import { BN_ONE, formatNumber } from '@pezkuwi/util';
|
||||
|
||||
function isSingle (entry: BN | [BN, BN]): entry is BN {
|
||||
return !Array.isArray(entry);
|
||||
}
|
||||
|
||||
export function createErasString (eras: BN[]): React.ReactNode {
|
||||
if (!eras.length) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const parts = eras
|
||||
.sort((a, b) => a.cmp(b))
|
||||
.reduce((result: (BN | [BN, BN])[], era): (BN | [BN, BN])[] => {
|
||||
if (result.length === 0) {
|
||||
return [era];
|
||||
} else {
|
||||
const last = result[result.length - 1];
|
||||
|
||||
if (isSingle(last)) {
|
||||
if (last.add(BN_ONE).eq(era)) {
|
||||
result[result.length - 1] = [last, era];
|
||||
} else {
|
||||
result.push(era);
|
||||
}
|
||||
} else {
|
||||
if (last[1].add(BN_ONE).eq(era)) {
|
||||
last[1] = era;
|
||||
} else {
|
||||
result.push(era);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}, [])
|
||||
.map((entry) =>
|
||||
isSingle(entry)
|
||||
? formatNumber(entry)
|
||||
: `${formatNumber(entry[0])}-${formatNumber(entry[1])}`
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
{parts.map((section, index) => (
|
||||
<React.Fragment key={section}>
|
||||
{index !== 0 && ', '}
|
||||
<span>{section}</span>
|
||||
</React.Fragment>
|
||||
))}
|
||||
</>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user