Council submit candidacy (#2722)
* Council submit candidacy * Pass electionsInfo to SubmitCandidacy
This commit is contained in:
parent
1a6b173794
commit
53c9f5587f
@ -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}
|
||||
/>
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user