diff --git a/packages/apps-routing/src/society.ts b/packages/apps-routing/src/society.ts index 1b3edb5b5a..d9dfce775d 100644 --- a/packages/apps-routing/src/society.ts +++ b/packages/apps-routing/src/society.ts @@ -4,7 +4,7 @@ import { Route } from './types'; -import Component from '@polkadot/app-society'; +import Component, { useCounter } from '@polkadot/app-society'; export default function create (t: (key: string, text: string, options: { ns: string }) => T): Route { return { @@ -17,6 +17,7 @@ export default function create (t: (key: string, text: string, opti }, icon: 'hand-spock', name: 'society', - text: t('nav.society', 'Society', { ns: 'apps-routing' }) + text: t('nav.society', 'Society', { ns: 'apps-routing' }), + useCounter }; } diff --git a/packages/page-accounts/src/Accounts/modals/Delegate.tsx b/packages/page-accounts/src/Accounts/modals/Delegate.tsx index 672c2276b7..5cb3d8f2df 100644 --- a/packages/page-accounts/src/Accounts/modals/Delegate.tsx +++ b/packages/page-accounts/src/Accounts/modals/Delegate.tsx @@ -37,7 +37,7 @@ function Delegate ({ amount: _amount, conviction: _conviction, delegatedAccount: header= {t('Delegate democracy vote')} size='large' > - + ('Undelegate')} size='large' > - + { +function BidRow ({ index, value: { kind, value, who } }: Props): React.ReactElement { + const { t } = useTranslation(); + const { allAccounts } = useAccounts(); + const [isBidder, setIsBidder] = useState(false); + + useEffect((): void => { + const address = who.toString(); + + setIsBidder(allAccounts.some((accountId) => accountId === address)); + }, [allAccounts, who]); + return ( @@ -24,6 +38,16 @@ function BidRow ({ value: { kind, value, who } }: Props): React.ReactElement + + ('Unbid')} + params={[index]} + tx='society.unbid' + /> + ); } diff --git a/packages/page-society/src/Overview/BidNew.tsx b/packages/page-society/src/Overview/BidNew.tsx new file mode 100644 index 0000000000..3b2d70bef4 --- /dev/null +++ b/packages/page-society/src/Overview/BidNew.tsx @@ -0,0 +1,69 @@ +// Copyright 2017-2020 @polkadot/app-society 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 BN from 'bn.js'; +import React, { useState } from 'react'; +import { InputAddress, InputBalance, Modal, TxButton } from '@polkadot/react-components'; + +import { useTranslation } from '../translate'; + +interface Props { + onClose: () => void; +} + +function BidNew ({ onClose }: Props): React.ReactElement { + const { t } = useTranslation(); + const [amount, setAmount] = useState(); + const [accountId, setAccount] = useState(); + + return ( + ('Bid to join')} + size='large' + > + + + + ('The actual account you wish to sub,it the bid with')} + label={t('bid account')} + onChange={setAccount} + type='account' + /> + + +

{t('Your canidate/bid account. Once accepted this account will become a member.')}

+
+
+ + + ('The amount to associate with your bid, should be less than the pot.')} + label={t('bid amount')} + onChange={setAmount} + /> + + +

{t('The amount to tie to your bid. The lowest bidder moves forward.')}

+
+
+
+ + ('Bid')} + onStart={onClose} + params={[amount]} + tx='society.bid' + /> + +
+ ); +} + +export default React.memo(BidNew); diff --git a/packages/page-society/src/Overview/Bids.tsx b/packages/page-society/src/Overview/Bids.tsx index f55f02459b..90e88a3363 100644 --- a/packages/page-society/src/Overview/Bids.tsx +++ b/packages/page-society/src/Overview/Bids.tsx @@ -23,7 +23,8 @@ function Bids ({ className }: Props): React.ReactElement { const header = useMemo(() => [ [t('bids'), 'start'], [t('kind')], - [t('value')] + [t('value')], + [] ], [t]); return ( @@ -32,8 +33,9 @@ function Bids ({ className }: Props): React.ReactElement { empty={bids && t('No bids')} header={header} > - {bids?.map((bid): React.ReactNode => ( + {bids?.map((bid, index): React.ReactNode => ( diff --git a/packages/page-society/src/Overview/index.tsx b/packages/page-society/src/Overview/index.tsx index 4cb04fda5c..467338dfd0 100644 --- a/packages/page-society/src/Overview/index.tsx +++ b/packages/page-society/src/Overview/index.tsx @@ -6,27 +6,43 @@ import { DeriveSociety } from '@polkadot/api-derive/types'; import React from 'react'; import styled from 'styled-components'; -import { useApi, useCall } from '@polkadot/react-hooks'; +import { Button } from '@polkadot/react-components'; +import { useApi, useCall, useToggle } from '@polkadot/react-hooks'; import useMembers from '../useMembers'; +import BidNew from './BidNew'; import Bids from './Bids'; import Candidates from './Candidates'; import Defender from './Defender'; import Members from './Members'; import Summary from './Summary'; +import { useTranslation } from '../translate'; + interface Props { className?: string; } function Overview ({ className }: Props): React.ReactElement { + const { t } = useTranslation(); const { api } = useApi(); const info = useCall(api.derive.society.info, []); const { allMembers, isMember, ownMembers } = useMembers(); + const [isBidOpen, toggleBidOpen] = useToggle(); return (
+ +