diff --git a/packages/page-council/src/Motions/ProposeExternal.tsx b/packages/page-council/src/Motions/ProposeExternal.tsx new file mode 100644 index 0000000000..e328321530 --- /dev/null +++ b/packages/page-council/src/Motions/ProposeExternal.tsx @@ -0,0 +1,90 @@ +// Copyright 2017-2020 @polkadot/ui-staking 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 { SubmittableExtrinsic } from '@polkadot/api/types'; + +import React, { useCallback, useEffect, useState } from 'react'; +import { Button, Input, InputAddress, Modal, TxButton } from '@polkadot/react-components'; +import { useApi, useToggle } from '@polkadot/react-hooks'; +import { isHex } from '@polkadot/util'; + +import { useTranslation } from '../translate'; + +interface Props { + className?: string; + isMember: boolean; + members: string[]; +} + +function ProposeExternal ({ className, isMember, members }: Props): React.ReactElement { + const { t } = useTranslation(); + const { api } = useApi(); + const [isVisible, toggleVisible] = useToggle(); + const [accountId, setAcountId] = useState(null); + const [proposal, setProposal] = useState | null>(null); + const [{ isHashValid, hash }, setHash] = useState<{ isHashValid: boolean; hash?: string }>({ isHashValid: false, hash: '' }); + const threshold = Math.ceil((members.length || 0) * 0.5); + + const _onChangeHash = useCallback( + (hash?: string): void => setHash({ isHashValid: isHex(hash, 256), hash }), + [] + ); + + useEffect((): void => { + if (isHashValid && hash) { + setProposal(() => api.tx.democracy.externalProposeMajority(hash)); + } else { + setProposal(null); + } + }, [hash, isHashValid]); + + return ( + <> +