// Copyright 2017-2019 @polkadot/app-democracy authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. import { I18nProps } from '@polkadot/ui-app/types'; import { SubjectInfo } from '@polkadot/ui-keyring/observable/types'; import BN from 'bn.js'; import React from 'react'; import { Button, Dropdown, InputAddress, Modal, TxButton } from '@polkadot/ui-app'; import accountObservable from '@polkadot/ui-keyring/observable/accounts'; import { withMulti, withObservable } from '@polkadot/ui-api'; import translate from '../translate'; interface Props extends I18nProps { allAccounts?: SubjectInfo; referendumId: BN | number; } interface State { accountId?: string; isVotingOpen: boolean; voteOptions: { text: React.ReactNode; value: boolean }[]; voteValue: boolean; } class Voting extends React.PureComponent { public state: State; public constructor (props: Props) { super(props); const { t } = props; this.state = { isVotingOpen: false, voteOptions: [ { text: t('Aye, I approve'), value: true }, { text: t('Nay, I do not approve'), value: false } ], voteValue: true }; } public render (): React.ReactNode { const { allAccounts, t } = this.props; const hasAccounts = allAccounts && Object.keys(allAccounts).length !== 0; if (!hasAccounts) { return null; } return ( <> {this.renderModal()}
); } private renderModal (): React.ReactNode { const { referendumId, t } = this.props; const { accountId, isVotingOpen, voteOptions, voteValue } = this.state; if (!isVotingOpen) { return null; } return ( {t('Vote on proposal')}