Files
pezkuwi-apps/packages/page-society/src/Candidates/CandidateVoting.tsx
T
pezkuwichain d21bfb1320 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
2026-01-07 13:05:27 +03:00

72 lines
1.9 KiB
TypeScript

// Copyright 2017-2025 @pezkuwi/app-society authors & contributors
// SPDX-License-Identifier: Apache-2.0
import React, { useRef, useState } from 'react';
import { Button, Dropdown, InputAddress, Modal, TxButton } from '@pezkuwi/react-components';
import { useApi, useToggle } from '@pezkuwi/react-hooks';
import { useTranslation } from '../translate.js';
interface Props {
candidateId: string;
isMember: boolean;
ownMembers: string[];
}
function CandidateVoting ({ candidateId, isMember, ownMembers }: Props): React.ReactElement<Props> {
const { t } = useTranslation();
const { api } = useApi();
const [isVisible, toggleVisible] = useToggle();
const [vote, setVote] = useState(true);
const [accountId, setAccountId] = useState<string | null>(null);
const voteOptsRef = useRef([
{ text: t('Aye, I approve'), value: true },
{ text: t('Nay, I do not approve'), value: false }
]);
return (
<>
{isVisible && (
<Modal
header={t('Vote for candidate')}
onClose={toggleVisible}
>
<Modal.Content>
<InputAddress
filter={ownMembers}
label={t('vote from account')}
onChange={setAccountId}
/>
<Dropdown
label={t('vote for candidate')}
onChange={setVote}
options={voteOptsRef.current}
value={vote}
/>
</Modal.Content>
<Modal.Actions>
<TxButton
accountId={accountId}
icon='check'
label={t('Vote')}
onStart={toggleVisible}
params={[candidateId, vote]}
tx={api.tx.society.vote}
/>
</Modal.Actions>
</Modal>
)}
<Button
icon='check'
isDisabled={!isMember}
label={t('Vote')}
onClick={toggleVisible}
/>
</>
);
}
export default React.memo(CandidateVoting);