mirror of
https://github.com/pezkuwichain/pezkuwi-apps.git
synced 2026-06-17 16:01:06 +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,65 @@
|
||||
// Copyright 2017-2025 @pezkuwi/app-teyrchains authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { BN } from '@pezkuwi/util';
|
||||
import type { LeasePeriod } from '../types.js';
|
||||
|
||||
import React, { useMemo } from 'react';
|
||||
|
||||
import { BN_ONE, formatNumber } from '@pezkuwi/util';
|
||||
|
||||
import LeaseBlocks from './LeaseBlocks.js';
|
||||
|
||||
interface Props {
|
||||
className?: string;
|
||||
fromFirst?: boolean;
|
||||
leasePeriod?: LeasePeriod;
|
||||
periods: number[];
|
||||
}
|
||||
|
||||
function getMapped (periods: number[], currentPeriod?: BN): string | undefined {
|
||||
return currentPeriod &&
|
||||
periods
|
||||
?.reduce((all: [BN, BN][], period): [BN, BN][] => {
|
||||
const bnp = currentPeriod.addn(period);
|
||||
|
||||
if (!all.length || all[all.length - 1][1].add(BN_ONE).lt(bnp)) {
|
||||
all.push([bnp, bnp]);
|
||||
} else {
|
||||
all[all.length - 1][1] = bnp;
|
||||
}
|
||||
|
||||
return all;
|
||||
}, [])
|
||||
.map(([a, b]) =>
|
||||
a.eq(b)
|
||||
? formatNumber(a)
|
||||
: `${formatNumber(a)} - ${formatNumber(b)}`
|
||||
)
|
||||
.join(', ');
|
||||
}
|
||||
|
||||
function Periods ({ className, fromFirst, leasePeriod, periods }: Props): React.ReactElement<Props> {
|
||||
const mapped = useMemo(
|
||||
() => getMapped(periods, leasePeriod?.currentPeriod),
|
||||
[leasePeriod?.currentPeriod, periods]
|
||||
);
|
||||
|
||||
return (
|
||||
<div className={className}>
|
||||
<div>{mapped}</div>
|
||||
{periods && (
|
||||
<LeaseBlocks
|
||||
leasePeriod={leasePeriod}
|
||||
value={
|
||||
fromFirst
|
||||
? periods[0]
|
||||
: periods[periods.length - 1] + 1
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default React.memo(Periods);
|
||||
Reference in New Issue
Block a user