mirror of
https://github.com/pezkuwichain/pwap.git
synced 2026-06-17 18:11:01 +00:00
971df8edba
- Remove all 3rd party parachain configurations from endpoints: - productionRelayPolkadot.ts: Keep only system parachains - productionRelayDicle.ts: Keep only system parachains - testingRelayZagros.ts: Keep only system parachains - testingRelayTeyrChain.ts: Keep only system parachains - Update domain references: - polkadot.js.org → pezkuwichain.app - wiki.polkadot.network → wiki.pezkuwichain.io - dotapps.io → pezkuwichain.app - statement.polkadot.network → docs.pezkuwichain.io/statement - support.polkadot.network → docs.pezkuwichain.io - Update repository references: - github.com/pezkuwi-js/apps → github.com/pezkuwichain/pwap - Rename system parachains to Pezkuwi ecosystem: - PolkadotAssetHub → PezkuwiAssetHub - polkadotBridgeHub → pezkuwiBridgeHub - polkadotCollectives → pezkuwiCollectives - polkadotCoretime → pezkuwiCoretime - polkadotPeople → pezkuwiPeople - Update network name in claims utility: - Polkadot → Pezkuwi
103 lines
3.0 KiB
TypeScript
103 lines
3.0 KiB
TypeScript
// Copyright 2017-2026 @pezkuwi/app-tech-comm authors & contributors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
import type { DeriveCollectiveProposal } from '@pezkuwi/api-derive/types';
|
|
import type { CollectiveType } from '@pezkuwi/react-hooks/types';
|
|
import type { Hash } from '@pezkuwi/types/interfaces';
|
|
|
|
import React from 'react';
|
|
|
|
import ProposalCell from '@pezkuwi/app-democracy/Overview/ProposalCell';
|
|
import { AddressMini, Table } from '@pezkuwi/react-components';
|
|
import { useApi, useCall, useCollectiveInstance, useVotingStatus } from '@pezkuwi/react-hooks';
|
|
import { BlockToTime } from '@pezkuwi/react-query';
|
|
import { formatNumber } from '@pezkuwi/util';
|
|
|
|
import Close from './Close.js';
|
|
import Voting from './Voting.js';
|
|
|
|
interface Props {
|
|
className?: string;
|
|
imageHash: Hash;
|
|
isMember: boolean;
|
|
members: string[];
|
|
prime?: string | null;
|
|
type: CollectiveType;
|
|
}
|
|
|
|
function Proposal ({ className = '', imageHash, isMember, members, prime, type }: Props): React.ReactElement<Props> | null {
|
|
const { api } = useApi();
|
|
const derive = useCall<DeriveCollectiveProposal>(api.derive[type as 'technicalCommittee'].proposal, [imageHash]);
|
|
const { hasFailed, isCloseable, isVoteable, remainingBlocks } = useVotingStatus(derive?.votes, members.length, type);
|
|
const modLocation = useCollectiveInstance(type);
|
|
|
|
if (!modLocation || !derive?.votes) {
|
|
return null;
|
|
}
|
|
|
|
const { ayes, end, index, nays, threshold } = derive.votes;
|
|
|
|
return (
|
|
<tr className={className}>
|
|
<Table.Column.Id value={index} />
|
|
<ProposalCell
|
|
imageHash={imageHash}
|
|
isCollective
|
|
proposal={derive.proposal}
|
|
/>
|
|
<td className='number'>
|
|
{formatNumber(ayes.length)}/{formatNumber(threshold)}
|
|
</td>
|
|
<td className='number together'>
|
|
{remainingBlocks && end && (
|
|
<>
|
|
<BlockToTime value={remainingBlocks} />
|
|
#{formatNumber(end)}
|
|
</>
|
|
)}
|
|
</td>
|
|
<td className='address'>
|
|
{ayes.map((address, index): React.ReactNode => (
|
|
<AddressMini
|
|
key={`${index}:${address.toHex()}`}
|
|
value={address}
|
|
withBalance={false}
|
|
/>
|
|
))}
|
|
</td>
|
|
<td className='address'>
|
|
{nays.map((address, index): React.ReactNode => (
|
|
<AddressMini
|
|
key={`${index}:${address.toHex()}`}
|
|
value={address}
|
|
withBalance={false}
|
|
/>
|
|
))}
|
|
</td>
|
|
<td className='button'>
|
|
{isVoteable && !isCloseable && (
|
|
<Voting
|
|
hash={imageHash}
|
|
isMember={isMember}
|
|
members={members}
|
|
prime={prime}
|
|
proposalId={index}
|
|
type={type}
|
|
/>
|
|
)}
|
|
{isCloseable && (
|
|
<Close
|
|
hasFailed={hasFailed}
|
|
hash={imageHash}
|
|
idNumber={index}
|
|
proposal={derive.proposal}
|
|
type={type}
|
|
/>
|
|
)}
|
|
</td>
|
|
</tr>
|
|
);
|
|
}
|
|
|
|
export default React.memo(Proposal);
|