mirror of
https://github.com/pezkuwichain/pezkuwi-apps.git
synced 2026-06-19 13:31:16 +00:00
d21bfb1320
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
95 lines
3.0 KiB
TypeScript
95 lines
3.0 KiB
TypeScript
// Copyright 2017-2025 @pezkuwi/app-council authors & contributors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
import type { AccountId, Hash, Proposal, ProposalIndex } from '@pezkuwi/types/interfaces';
|
|
|
|
import React, { useState } from 'react';
|
|
|
|
import { Button, MarkWarning, Modal, TxButton, VoteAccount } from '@pezkuwi/react-components';
|
|
import { useAccounts, useApi, useCollectiveInstance, useToggle } from '@pezkuwi/react-hooks';
|
|
import { ProposedAction } from '@pezkuwi/react-params';
|
|
|
|
import { useTranslation } from '../translate.js';
|
|
|
|
interface Props {
|
|
hash: Hash;
|
|
idNumber: ProposalIndex;
|
|
isDisabled: boolean;
|
|
members: string[];
|
|
prime?: AccountId | null;
|
|
proposal: Proposal | null;
|
|
}
|
|
|
|
function Voting ({ hash, idNumber, isDisabled, members, prime, proposal }: Props): React.ReactElement<Props> | null {
|
|
const { t } = useTranslation();
|
|
const { api } = useApi();
|
|
const { hasAccounts } = useAccounts();
|
|
const [isVotingOpen, toggleVoting] = useToggle();
|
|
const [accountId, setAccountId] = useState<string | null>(null);
|
|
const modLocation = useCollectiveInstance('council');
|
|
|
|
if (!hasAccounts || !modLocation) {
|
|
return null;
|
|
}
|
|
|
|
const isPrime = prime?.toString() === accountId;
|
|
|
|
return (
|
|
<>
|
|
{isVotingOpen && (
|
|
<Modal
|
|
header={t('Vote on proposal')}
|
|
onClose={toggleVoting}
|
|
size='large'
|
|
>
|
|
<Modal.Content>
|
|
<Modal.Columns hint={t('The proposal that is being voted on. It will pass when the threshold is reached.')}>
|
|
<ProposedAction
|
|
idNumber={idNumber}
|
|
proposal={proposal}
|
|
/>
|
|
</Modal.Columns>
|
|
<Modal.Columns hint={t('The council account for this vote. The selection is filtered by the current members.')}>
|
|
<VoteAccount
|
|
filter={members}
|
|
onChange={setAccountId}
|
|
/>
|
|
{isPrime && (
|
|
<MarkWarning content={t('You are voting with this collective\'s prime account. The vote will be the default outcome in case of any abstentions.')} />
|
|
)}
|
|
</Modal.Columns>
|
|
</Modal.Content>
|
|
<Modal.Actions>
|
|
<TxButton
|
|
accountId={accountId}
|
|
icon='ban'
|
|
isDisabled={isDisabled}
|
|
label={t('Vote Nay')}
|
|
onStart={toggleVoting}
|
|
params={[hash, idNumber, false]}
|
|
tx={api.tx[modLocation].vote}
|
|
/>
|
|
<TxButton
|
|
accountId={accountId}
|
|
icon='check-to-slot'
|
|
isDisabled={isDisabled}
|
|
label={t('Vote Aye')}
|
|
onStart={toggleVoting}
|
|
params={[hash, idNumber, true]}
|
|
tx={api.tx[modLocation].vote}
|
|
/>
|
|
</Modal.Actions>
|
|
</Modal>
|
|
)}
|
|
<Button
|
|
icon='check-to-slot'
|
|
isDisabled={isDisabled}
|
|
label={t('Vote')}
|
|
onClick={toggleVoting}
|
|
/>
|
|
</>
|
|
);
|
|
}
|
|
|
|
export default React.memo(Voting);
|