mirror of
https://github.com/pezkuwichain/pezkuwi-apps.git
synced 2026-07-10 23:57:37 +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,80 @@
|
||||
// Copyright 2017-2025 @pezkuwi/app-democracy authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Compact } from '@pezkuwi/types';
|
||||
import type { Hash, Proposal, ProposalIndex } from '@pezkuwi/types/interfaces';
|
||||
import type { HexString } from '@pezkuwi/util/types';
|
||||
|
||||
import React from 'react';
|
||||
|
||||
import { styled } from '@pezkuwi/react-components';
|
||||
import { useApi, usePreimage } from '@pezkuwi/react-hooks';
|
||||
import { CallExpander } from '@pezkuwi/react-params';
|
||||
|
||||
import { useTranslation } from '../translate.js';
|
||||
import ExternalCell from './ExternalCell.js';
|
||||
import TreasuryCell from './TreasuryCell.js';
|
||||
|
||||
interface Props {
|
||||
className?: string;
|
||||
imageHash: Hash | HexString;
|
||||
isCollective?: boolean;
|
||||
proposal?: Proposal | null;
|
||||
}
|
||||
|
||||
const METHOD_EXTE = ['externalPropose', 'externalProposeDefault', 'externalProposeMajority', 'fastTrack'];
|
||||
const METHOD_TREA = ['approveProposal', 'rejectProposal'];
|
||||
|
||||
function ProposalCell ({ className = '', imageHash, isCollective, proposal }: Props): React.ReactElement<Props> {
|
||||
const { t } = useTranslation();
|
||||
const { api } = useApi();
|
||||
const preimage = usePreimage(imageHash);
|
||||
|
||||
// while we still have this endpoint, democracy will use it
|
||||
const displayProposal = isCollective
|
||||
? proposal
|
||||
: api.query.democracy?.preimages
|
||||
? proposal
|
||||
: preimage?.proposal;
|
||||
|
||||
if (!displayProposal) {
|
||||
const textHash = imageHash.toString();
|
||||
|
||||
return (
|
||||
<td className={`${className} all hash`}>
|
||||
<div className='shortHash'>{textHash}</div>
|
||||
</td>
|
||||
);
|
||||
}
|
||||
|
||||
const { method, section } = displayProposal.registry.findMetaCall(displayProposal.callIndex);
|
||||
const isTreasury = section === 'treasury' && METHOD_TREA.includes(method);
|
||||
const isExternal = section === 'democracy' && METHOD_EXTE.includes(method);
|
||||
|
||||
return (
|
||||
<StyledTd className={`${className} all`}>
|
||||
<CallExpander
|
||||
labelHash={t('proposal hash')}
|
||||
value={displayProposal}
|
||||
withHash={!isTreasury && !isExternal}
|
||||
>
|
||||
{isExternal && (
|
||||
<ExternalCell value={displayProposal.args[0] as Hash} />
|
||||
)}
|
||||
{isTreasury && (
|
||||
<TreasuryCell value={displayProposal.args[0] as Compact<ProposalIndex>} />
|
||||
)}
|
||||
</CallExpander>
|
||||
</StyledTd>
|
||||
);
|
||||
}
|
||||
|
||||
const StyledTd = styled.td`
|
||||
.shortHash {
|
||||
+ div {
|
||||
margin-left: 0.5rem;
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export default React.memo(ProposalCell);
|
||||
Reference in New Issue
Block a user