Council submit candidacy (#2722)

* Council submit candidacy

* Pass electionsInfo to SubmitCandidacy
This commit is contained in:
Jaco Greeff 2020-05-12 15:43:47 +02:00 committed by GitHub
parent 1a6b173794
commit 53c9f5587f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 6 deletions

View File

@ -2,17 +2,20 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { ComponentProps as Props } from './types';
import React, { useState } from 'react';
import { Button, InputAddress, Modal, TxButton } from '@polkadot/react-components';
import { useApi, useModal } from '@polkadot/react-hooks';
import { useTranslation } from '../translate';
function SubmitCandidacy (): React.ReactElement {
function SubmitCandidacy ({ electionsInfo }: Props): React.ReactElement<Props> {
const { api } = useApi();
const { t } = useTranslation();
const [accountId, setAcountId] = useState<string | null>(null);
const { isOpen, onClose, onOpen } = useModal();
const modLocation = api.tx.electionsPhragmen ? 'electionsPhragmen' : 'elections';
return (
<>
@ -40,18 +43,21 @@ function SubmitCandidacy (): React.ReactElement {
<Modal.Actions onCancel={onClose}>
<TxButton
accountId={accountId}
isDisabled={!electionsInfo}
onStart={onClose}
tx={
api.tx.electionsPhragmen
? 'electionsPhragmen.submitCandidacy'
: 'elections.submitCandidacy'
params={
api.tx[modLocation].submitCandidacy.meta.args.length === 1
? [electionsInfo?.candidates.length]
: []
}
tx={`${modLocation}.submitCandidacy`}
/>
</Modal.Actions>
</Modal>
)}
<Button
icon='add'
isDisabled={!electionsInfo}
label={t('Submit candidacy')}
onClick={onOpen}
/>

View File

@ -51,7 +51,7 @@ function Overview ({ className, prime }: Props): React.ReactElement<Props> {
electionsInfo={electionsInfo}
/>
<Button.Group>
<SubmitCandidacy />
<SubmitCandidacy electionsInfo={electionsInfo} />
<Vote electionsInfo={electionsInfo} />
</Button.Group>
<Members