diff --git a/packages/app-democracy/src/Overview/DispatchEntry.tsx b/packages/app-democracy/src/Overview/DispatchEntry.tsx index df3f61ef2cb..0656a34953a 100644 --- a/packages/app-democracy/src/Overview/DispatchEntry.tsx +++ b/packages/app-democracy/src/Overview/DispatchEntry.tsx @@ -2,7 +2,6 @@ // 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/react-components/types'; import { AccountId, Balance, BlockNumber, Hash, Proposal, ReferendumIndex } from '@polkadot/types/interfaces'; import { ITuple } from '@polkadot/types/types'; @@ -11,16 +10,17 @@ import { useApi, useCall } from '@polkadot/react-hooks'; import { Bytes, Option } from '@polkadot/types'; import { formatNumber } from '@polkadot/util'; -import translate from '../translate'; +import { useTranslation } from '../translate'; import ProposalCell from './ProposalCell'; -interface Props extends I18nProps { +interface Props { blockNumber?: BlockNumber; hash: Hash; referendumIndex: ReferendumIndex; } -function DispatchEntry ({ blockNumber, hash, referendumIndex, t }: Props): React.ReactElement { +export default function DispatchEntry ({ blockNumber, hash, referendumIndex }: Props): React.ReactElement { + const { t } = useTranslation(); const { api } = useApi(); const preimage = useCall> >(api.query.democracy.preimages, [hash]); @@ -50,5 +50,3 @@ function DispatchEntry ({ blockNumber, hash, referendumIndex, t }: Props): React ); } - -export default translate(DispatchEntry); diff --git a/packages/app-democracy/src/Overview/DispatchQueue.tsx b/packages/app-democracy/src/Overview/DispatchQueue.tsx index adaca2d7c01..073fd91c22b 100644 --- a/packages/app-democracy/src/Overview/DispatchQueue.tsx +++ b/packages/app-democracy/src/Overview/DispatchQueue.tsx @@ -2,17 +2,21 @@ // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import { I18nProps as Props } from '@polkadot/react-components/types'; import { BlockNumber, Hash, ReferendumIndex } from '@polkadot/types/interfaces'; import React from 'react'; import { Table } from '@polkadot/react-components'; import { useApi, useCall } from '@polkadot/react-hooks'; -import translate from '../translate'; +import { useTranslation } from '../translate'; import DispatchEntry from './DispatchEntry'; -function DispatchQueue ({ className, t }: Props): React.ReactElement | null { +interface Props { + className?: string; +} + +export default function DispatchQueue ({ className }: Props): React.ReactElement | null { + const { t } = useTranslation(); const { api } = useApi(); const queued = useCall<[BlockNumber, Hash, ReferendumIndex][]>(api.query.democracy.dispatchQueue, []); @@ -43,5 +47,3 @@ function DispatchQueue ({ className, t }: Props): React.ReactElement | nu ); } - -export default translate(DispatchQueue); diff --git a/packages/app-democracy/src/Overview/Externals.tsx b/packages/app-democracy/src/Overview/Externals.tsx index 7b229fbe206..3744e457cf6 100644 --- a/packages/app-democracy/src/Overview/Externals.tsx +++ b/packages/app-democracy/src/Overview/Externals.tsx @@ -4,7 +4,6 @@ import { AccountId, Balance, BlockNumber, Hash, Proposal, VoteThreshold } from '@polkadot/types/interfaces'; import { ITuple } from '@polkadot/types/types'; -import { I18nProps as Props } from '@polkadot/react-components/types'; import React, { useEffect, useState } from 'react'; import { AddressSmall, Table } from '@polkadot/react-components'; @@ -12,10 +11,15 @@ import { useApi, useCall } from '@polkadot/react-hooks'; import { FormatBalance } from '@polkadot/react-query'; import { Bytes, Option } from '@polkadot/types'; -import translate from '../translate'; +import { useTranslation } from '../translate'; import ProposalCell from './ProposalCell'; -function Externals ({ className, t }: Props): React.ReactElement | null { +interface Props { + className?: string; +} + +export default function Externals ({ className }: Props): React.ReactElement | null { + const { t } = useTranslation(); const { api } = useApi(); const external = useCall>>(api.query.democracy.nextExternal, []); const [hash, setHash] = useState(null); @@ -72,5 +76,3 @@ function Externals ({ className, t }: Props): React.ReactElement | null { ); } - -export default translate(Externals); diff --git a/packages/app-democracy/src/Overview/Proposal.tsx b/packages/app-democracy/src/Overview/Proposal.tsx index 06360e5fcf4..893ad89db61 100644 --- a/packages/app-democracy/src/Overview/Proposal.tsx +++ b/packages/app-democracy/src/Overview/Proposal.tsx @@ -3,7 +3,6 @@ // of the Apache-2.0 license. See the LICENSE file for details. import { DeriveProposal } from '@polkadot/api-derive/types'; -import { I18nProps } from '@polkadot/react-components/types'; import React from 'react'; import styled from 'styled-components'; @@ -11,15 +10,17 @@ import { AddressMini, AddressSmall } from '@polkadot/react-components'; import { FormatBalance } from '@polkadot/react-query'; import { formatNumber } from '@polkadot/util'; -import translate from '../translate'; +import { useTranslation } from '../translate'; import ProposalCell from './ProposalCell'; import Seconding from './Seconding'; -interface Props extends I18nProps { +interface Props { + className?: string; value: DeriveProposal; } -function Proposal ({ className, t, value: { balance, hash, index, proposal, proposer, seconds } }: Props): React.ReactElement { +function Proposal ({ className, value: { balance, hash, index, proposal, proposer, seconds } }: Props): React.ReactElement { + const { t } = useTranslation(); const seconding = seconds.filter((_address, index): boolean => index !== 0); return ( @@ -64,20 +65,18 @@ function Proposal ({ className, t, value: { balance, hash, index, proposal, prop ); } -export default translate( - styled(Proposal)` - .identityIcon { - &:first-child { - padding-top: 0; - } - - &:last-child { - margin-bottom: 4px; - } +export default styled(Proposal)` + .identityIcon { + &:first-child { + padding-top: 0; } - .seconding { - padding-top: 1.1rem; + &:last-child { + margin-bottom: 4px; } - ` -); + } + + .seconding { + padding-top: 1.1rem; + } +`; diff --git a/packages/app-democracy/src/Overview/ProposalCell.tsx b/packages/app-democracy/src/Overview/ProposalCell.tsx index 399a33c7a96..fa19454d794 100644 --- a/packages/app-democracy/src/Overview/ProposalCell.tsx +++ b/packages/app-democracy/src/Overview/ProposalCell.tsx @@ -3,20 +3,22 @@ // of the Apache-2.0 license. See the LICENSE file for details. import { Hash, Proposal } from '@polkadot/types/interfaces'; -import { I18nProps } from '@polkadot/react-components/types'; import React from 'react'; import { registry } from '@polkadot/react-api'; import { Call } from '@polkadot/react-components'; -import translate from '../translate'; +import { useTranslation } from '../translate'; -interface Props extends I18nProps { +interface Props { + className?: string; proposal?: Proposal | null; proposalHash: Hash | string; } -function ProposalCell ({ className, proposal, proposalHash, t }: Props): React.ReactElement { +export default function ProposalCell ({ className, proposal, proposalHash }: Props): React.ReactElement { + const { t } = useTranslation(); + if (!proposal) { return ( @@ -42,5 +44,3 @@ function ProposalCell ({ className, proposal, proposalHash, t }: Props): React.R ); } - -export default translate(ProposalCell); diff --git a/packages/app-democracy/src/Overview/Proposals.tsx b/packages/app-democracy/src/Overview/Proposals.tsx index 15ab65914ee..e18fa6ab8ae 100644 --- a/packages/app-democracy/src/Overview/Proposals.tsx +++ b/packages/app-democracy/src/Overview/Proposals.tsx @@ -3,16 +3,20 @@ // of the Apache-2.0 license. See the LICENSE file for details. import { DeriveProposal } from '@polkadot/api-derive/types'; -import { I18nProps as Props } from '@polkadot/react-components/types'; import React from 'react'; import { Table } from '@polkadot/react-components'; import { useApi, useCall } from '@polkadot/react-hooks'; import ProposalDisplay from './Proposal'; -import translate from '../translate'; +import { useTranslation } from '../translate'; -function Proposals ({ className, t }: Props): React.ReactElement { +interface Props { + className?: string; +} + +export default function Proposals ({ className }: Props): React.ReactElement { + const { t } = useTranslation(); const { api } = useApi(); const proposals = useCall(api.derive.democracy.proposals, []); @@ -37,5 +41,3 @@ function Proposals ({ className, t }: Props): React.ReactElement { ); } - -export default translate(Proposals); diff --git a/packages/app-democracy/src/Overview/Propose.tsx b/packages/app-democracy/src/Overview/Propose.tsx index c37b0204b0b..b52f943d57e 100644 --- a/packages/app-democracy/src/Overview/Propose.tsx +++ b/packages/app-democracy/src/Overview/Propose.tsx @@ -2,21 +2,21 @@ // 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/react-components/types'; - import BN from 'bn.js'; import React, { useState } from 'react'; import { Button, Input, InputAddress, InputBalance, Modal, TxButton } from '@polkadot/react-components'; import { Available } from '@polkadot/react-query'; import { isHex } from '@polkadot/util'; -import translate from '../translate'; +import { useTranslation } from '../translate'; -interface Props extends I18nProps { +interface Props { + className?: string; onClose: () => void; } -function Propose ({ className, onClose, t }: Props): React.ReactElement { +export default function Propose ({ className, onClose }: Props): React.ReactElement { + const { t } = useTranslation(); const [accountId, setAccountId] = useState(null); const [balance, setBalance] = useState(); const [{ isHashValid, hash }, setHash] = useState<{ isHashValid: boolean; hash?: string }>({ isHashValid: false, hash: '' }); @@ -78,5 +78,3 @@ function Propose ({ className, onClose, t }: Props): React.ReactElement { ); } - -export default translate(Propose); diff --git a/packages/app-democracy/src/Overview/Referendum.tsx b/packages/app-democracy/src/Overview/Referendum.tsx index 9d42bee6dfd..6cd171371ac 100644 --- a/packages/app-democracy/src/Overview/Referendum.tsx +++ b/packages/app-democracy/src/Overview/Referendum.tsx @@ -4,7 +4,6 @@ // of the Apache-2.0 license. See the LICENSE file for details. import { DerivedReferendumVote, DerivedReferendum } from '@polkadot/api-derive/types'; -import { I18nProps } from '@polkadot/react-components/types'; import { BlockNumber } from '@polkadot/types/interfaces'; import BN from 'bn.js'; @@ -14,11 +13,12 @@ import { formatNumber } from '@polkadot/util'; import { useApi, useCall } from '@polkadot/react-hooks'; import { FormatBalance } from '@polkadot/react-query'; -import translate from '../translate'; +import { useTranslation } from '../translate'; import ProposalCell from './ProposalCell'; import Voting from './Voting'; -interface Props extends I18nProps { +interface Props { + className?: string; idNumber: BN; value: DerivedReferendum; } @@ -32,7 +32,8 @@ interface State { votedTotal: BN; } -function Referendum ({ className, idNumber, t, value }: Props): React.ReactElement | null { +function Referendum ({ className, idNumber, value }: Props): React.ReactElement | null { + const { t } = useTranslation(); const { api } = useApi(); const bestNumber = useCall(api.derive.chain.bestNumber, []); const votesFor = useCall(api.derive.democracy.referendumVotesFor as any, [idNumber]); @@ -114,14 +115,12 @@ function Referendum ({ className, idNumber, t, value }: Props): React.ReactEleme ); } -export default translate( - styled(Referendum)` - .democracy--Referendum-results { - margin-bottom: 1em; +export default styled(Referendum)` + .democracy--Referendum-results { + margin-bottom: 1em; - &.chart { - text-align: center; - } + &.chart { + text-align: center; } - ` -); + } +`; diff --git a/packages/app-democracy/src/Overview/Referendums.tsx b/packages/app-democracy/src/Overview/Referendums.tsx index 18b0a533ac4..e933e9e0fbd 100644 --- a/packages/app-democracy/src/Overview/Referendums.tsx +++ b/packages/app-democracy/src/Overview/Referendums.tsx @@ -3,16 +3,20 @@ // of the Apache-2.0 license. See the LICENSE file for details. import { DerivedReferendum } from '@polkadot/api-derive/types'; -import { I18nProps as Props } from '@polkadot/react-components/types'; import React from 'react'; import { Table } from '@polkadot/react-components'; import { useApi, useCall } from '@polkadot/react-hooks'; import Referendum from './Referendum'; -import translate from '../translate'; +import { useTranslation } from '../translate'; -function Referendums ({ className, t }: Props): React.ReactElement { +interface Props { + className?: string; +} + +export default function Referendums ({ className }: Props): React.ReactElement { + const { t } = useTranslation(); const { api } = useApi(); const referendums = useCall(api.derive.democracy.referendums, []); @@ -38,5 +42,3 @@ function Referendums ({ className, t }: Props): React.ReactElement { ); } - -export default translate(Referendums); diff --git a/packages/app-democracy/src/Overview/Seconding.tsx b/packages/app-democracy/src/Overview/Seconding.tsx index f97317ccf29..eca0ddf6441 100644 --- a/packages/app-democracy/src/Overview/Seconding.tsx +++ b/packages/app-democracy/src/Overview/Seconding.tsx @@ -3,21 +3,22 @@ // of the Apache-2.0 license. See the LICENSE file for details. import { AccountId } from '@polkadot/types/interfaces'; -import { I18nProps } from '@polkadot/react-components/types'; import BN from 'bn.js'; import React, { useState } from 'react'; import { Button, InputAddress, Modal, TxButton } from '@polkadot/react-components'; import { useAccounts } from '@polkadot/react-hooks'; -import translate from '../translate'; +import { useTranslation } from '../translate'; -interface Props extends I18nProps { +interface Props { + className?: string; depositors: AccountId[]; proposalId: BN | number; } -function Seconding ({ depositors, proposalId, t }: Props): React.ReactElement | null { +export default function Seconding ({ depositors, proposalId }: Props): React.ReactElement | null { + const { t } = useTranslation(); const { hasAccounts } = useAccounts(); const [accountId, setAccountId] = useState(null); const [isSecondingOpen, setIsSecondingOpen] = useState(false); @@ -78,5 +79,3 @@ function Seconding ({ depositors, proposalId, t }: Props): React.ReactElement ); } - -export default translate(Seconding); diff --git a/packages/app-democracy/src/Overview/Voting.tsx b/packages/app-democracy/src/Overview/Voting.tsx index 910bfd4371f..1961c745dfc 100644 --- a/packages/app-democracy/src/Overview/Voting.tsx +++ b/packages/app-democracy/src/Overview/Voting.tsx @@ -2,21 +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 { I18nProps } from '@polkadot/react-components/types'; - import BN from 'bn.js'; import React, { useState } from 'react'; import { Button, Modal, VoteAccount, VoteActions, VoteToggle } from '@polkadot/react-components'; import { useAccounts } from '@polkadot/react-hooks'; import { isBoolean } from '@polkadot/util'; -import translate from '../translate'; +import { useTranslation } from '../translate'; -interface Props extends I18nProps { +interface Props { referendumId: BN | number; } -function Voting ({ referendumId, t }: Props): React.ReactElement | null { +export default function Voting ({ referendumId }: Props): React.ReactElement | null { + const { t } = useTranslation(); const { hasAccounts } = useAccounts(); const [accountId, setAccountId] = useState(null); const [isVotingOpen, setIsVotingOpen] = useState(false); @@ -61,5 +60,3 @@ function Voting ({ referendumId, t }: Props): React.ReactElement | null { ); } - -export default translate(Voting); diff --git a/packages/app-democracy/src/Overview/index.tsx b/packages/app-democracy/src/Overview/index.tsx index ea3f5b61066..a53a4e5a11c 100644 --- a/packages/app-democracy/src/Overview/index.tsx +++ b/packages/app-democracy/src/Overview/index.tsx @@ -2,13 +2,11 @@ // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import { I18nProps as Props } from '@polkadot/react-components/types'; - import React, { useState } from 'react'; import styled from 'styled-components'; import { Button } from '@polkadot/react-components'; -import translate from '../translate'; +import { useTranslation } from '../translate'; import DispatchQueue from './DispatchQueue'; import Externals from './Externals'; import Proposals from './Proposals'; @@ -17,7 +15,12 @@ import Summary from './Summary'; import PreImage from './PreImage'; import Propose from './Propose'; -function Overview ({ className, t }: Props): React.ReactElement { +interface Props { + className?: string; +} + +function Overview ({ className }: Props): React.ReactElement { + const { t } = useTranslation(); const [isPreimageOpen, setIsPreimageOpen] = useState(false); const [isProposeOpen, setIsProposeOpen] = useState(false); @@ -56,10 +59,8 @@ function Overview ({ className, t }: Props): React.ReactElement { ); } -export default translate( - styled(Overview)` - .proposalSection { - margin-bottom: 1.5rem; - } - ` -); +export default styled(Overview)` + .proposalSection { + margin-bottom: 1.5rem; + } +`; diff --git a/packages/app-democracy/src/index.tsx b/packages/app-democracy/src/index.tsx index bea9a5ffb29..b2c9b3b2025 100644 --- a/packages/app-democracy/src/index.tsx +++ b/packages/app-democracy/src/index.tsx @@ -2,7 +2,7 @@ // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import { AppProps, BareProps, I18nProps } from '@polkadot/react-components/types'; +import { AppProps, BareProps } from '@polkadot/react-components/types'; import React from 'react'; import { Route, Switch } from 'react-router'; @@ -11,17 +11,19 @@ import uiSettings from '@polkadot/ui-settings'; import basicMd from './md/basic.md'; import Overview from './Overview'; -import translate from './translate'; +import { useTranslation } from './translate'; export { default as useCounter } from './useCounter'; -interface Props extends AppProps, BareProps, I18nProps {} +interface Props extends AppProps, BareProps {} const hidden = uiSettings.uiMode === 'full' ? [] : ['propose']; -function DemocracyApp ({ basePath, t }: Props): React.ReactElement { +export default function DemocracyApp ({ basePath }: Props): React.ReactElement { + const { t } = useTranslation(); + return (
@@ -44,5 +46,3 @@ function DemocracyApp ({ basePath, t }: Props): React.ReactElement {
); } - -export default translate(DemocracyApp); diff --git a/packages/app-society/src/Overview/Candidate.tsx b/packages/app-society/src/Overview/Candidate.tsx index 96d8c04d293..6a99d25acc5 100644 --- a/packages/app-society/src/Overview/Candidate.tsx +++ b/packages/app-society/src/Overview/Candidate.tsx @@ -14,7 +14,7 @@ interface Props { value: DeriveSocietyCandidate; } -export default function Candidate ({ value: { accountId, isSuspended, kind, value } }: Props): React.ReactElement { +export default function Candidate ({ value: { accountId, kind, value } }: Props): React.ReactElement { const { t } = useTranslation(); return ( @@ -32,10 +32,6 @@ export default function Candidate ({ value: { accountId, isSuspended, kind, valu value={value} /> - - - {isSuspended ? t('Yes') : t('No')} - ); } diff --git a/packages/app-society/src/Overview/Member.tsx b/packages/app-society/src/Overview/Member.tsx index 64636f6ab32..3a5a23e5af8 100644 --- a/packages/app-society/src/Overview/Member.tsx +++ b/packages/app-society/src/Overview/Member.tsx @@ -13,7 +13,7 @@ interface Props { value: DeriveSocietyMember; } -export default function Member ({ value: { accountId, isSuspended, strikes } }: Props): React.ReactElement { +export default function Member ({ value: { accountId, strikes } }: Props): React.ReactElement { const { t } = useTranslation(); return ( @@ -25,10 +25,6 @@ export default function Member ({ value: { accountId, isSuspended, strikes } }: {strikes.toString()} - - - {isSuspended ? t('Yes') : t('No')} - ); } diff --git a/packages/app-staking/src/Actions/Account/index.tsx b/packages/app-staking/src/Actions/Account/index.tsx index 7dde5c34fa0..65e32c96577 100644 --- a/packages/app-staking/src/Actions/Account/index.tsx +++ b/packages/app-staking/src/Actions/Account/index.tsx @@ -89,7 +89,7 @@ function getStakeState (allAccounts: string[], allStashes: string[] | undefined, function Account ({ allStashes, className, isOwnStash, next, onUpdateType, stakingOverview, stashId }: Props): React.ReactElement { const { t } = useTranslation(); - const { api, isSubstrateV2 } = useApi(); + const { api } = useApi(); const { allAccounts } = useAccounts(); const validateInfo = useCall(api.query.staking.validators, [stashId]); const balancesAll = useCall(api.derive.balances.all as any, [stashId]); @@ -209,7 +209,7 @@ function Account ({ allStashes, className, isOwnStash, next, onUpdateType, staki @@ -269,7 +269,7 @@ function Account ({ allStashes, className, isOwnStash, next, onUpdateType, staki ) : ( - {(!sessionIds.length || (isSubstrateV2 && hexSessionIdNext === '0x')) + {(!sessionIds.length || hexSessionIdNext === '0x') ? (