Cleanup some submission modals (#2439)
* Housekeeping, rename copyright headers * Cleanup some submission modals
This commit is contained in:
parent
118efb960a
commit
55b8a60889
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2020 @polkadot/ui-staking authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/app-council authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2020 @polkadot/ui-staking authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/app-council authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2020 @polkadot/ui-staking authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/app-council authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2020 @polkadot/ui-staking authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/app-council authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@ -1,50 +1,54 @@
|
||||
// Copyright 2017-2020 @polkadot/ui-staking authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/app-council 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 { ApiProps } from '@polkadot/react-api/types';
|
||||
import { ComponentProps } from './types';
|
||||
import React, { useState } from 'react';
|
||||
import { Button, InputAddress, Modal, TxButton } from '@polkadot/react-components';
|
||||
import { useApi, useModal } from '@polkadot/react-hooks';
|
||||
|
||||
import React from 'react';
|
||||
import { withApi } from '@polkadot/react-api/hoc';
|
||||
import { Button } from '@polkadot/react-components';
|
||||
import TxModal, { TxModalState as State, TxModalProps } from '@polkadot/react-components/TxModal';
|
||||
import { useTranslation } from '../translate';
|
||||
|
||||
import translate from '../translate';
|
||||
function SubmitCandidacy (): React.ReactElement {
|
||||
const { api } = useApi();
|
||||
const { t } = useTranslation();
|
||||
const [accountId, setAcountId] = useState<string | null>(null);
|
||||
const { isOpen, onOpen, onClose } = useModal();
|
||||
|
||||
interface Props extends ApiProps, ComponentProps, TxModalProps {}
|
||||
|
||||
class SubmitCandidacy extends TxModal<Props, State> {
|
||||
protected headerText = (): string => this.props.t('Submit your council candidacy');
|
||||
|
||||
protected accountLabel = (): string => this.props.t('Candidate account');
|
||||
|
||||
protected accountHelp = (): string => this.props.t('This account will be nominated to fill the council slot you specify.');
|
||||
|
||||
protected txMethod = (): string =>
|
||||
this.props.api.tx.electionsPhragmen
|
||||
? 'electionsPhragmen.submitCandidacy'
|
||||
: 'elections.submitCandidacy';
|
||||
|
||||
protected txParams = (): [] => [];
|
||||
|
||||
protected isDisabled = (): boolean => {
|
||||
const { accountId } = this.state;
|
||||
|
||||
return !accountId;
|
||||
}
|
||||
|
||||
protected renderTrigger = (): React.ReactNode => {
|
||||
const { t } = this.props;
|
||||
|
||||
return (
|
||||
return (
|
||||
<>
|
||||
{isOpen && (
|
||||
<Modal
|
||||
header={t('Submit your council candidacy')}
|
||||
onClose={onClose}
|
||||
>
|
||||
<Modal.Content>
|
||||
<InputAddress
|
||||
help={t('Select the account you wish to submit for candidacy.')}
|
||||
label={t('candidate account')}
|
||||
onChange={setAcountId}
|
||||
type='account'
|
||||
/>
|
||||
</Modal.Content>
|
||||
<Modal.Actions onCancel={onClose}>
|
||||
<TxButton
|
||||
accountId={accountId}
|
||||
onStart={onClose}
|
||||
tx={
|
||||
api.tx.electionsPhragmen
|
||||
? 'electionsPhragmen.submitCandidacy'
|
||||
: 'elections.submitCandidacy'
|
||||
}
|
||||
/>
|
||||
</Modal.Actions>
|
||||
</Modal>
|
||||
)}
|
||||
<Button
|
||||
label={t('Submit candidacy')}
|
||||
icon='add'
|
||||
onClick={this.showModal}
|
||||
onClick={onOpen}
|
||||
/>
|
||||
);
|
||||
}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default translate(withApi(SubmitCandidacy));
|
||||
export default React.memo(SubmitCandidacy);
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2020 @polkadot/ui-staking authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/app-council authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@ -74,7 +74,7 @@ function Overview ({ className, prime }: Props): React.ReactElement<Props> {
|
||||
electionsInfo={electionsInfo}
|
||||
/>
|
||||
<Button.Group>
|
||||
<SubmitCandidacy electionsInfo={electionsInfo} />
|
||||
<SubmitCandidacy />
|
||||
<Button.Or />
|
||||
<Vote electionsInfo={electionsInfo} />
|
||||
</Button.Group>
|
||||
|
||||
@ -21,7 +21,7 @@ const ONE_MIN = (1 * 60) / 6;
|
||||
const DEF_DELAY = new BN(ONE_MIN);
|
||||
const DEF_VOTING = new BN(ONE_MIN * 60 * 3);
|
||||
|
||||
function Fasttrack ({ hash }: Props): React.ReactElement<Props> | null {
|
||||
function Fasttrack ({ hash, threshold }: Props): React.ReactElement<Props> | null {
|
||||
const { t } = useTranslation();
|
||||
const { api } = useApi();
|
||||
const { isMember, members } = useMembers('technicalCommittee');
|
||||
@ -37,8 +37,8 @@ function Fasttrack ({ hash }: Props): React.ReactElement<Props> | null {
|
||||
);
|
||||
|
||||
useEffect((): void => {
|
||||
setAllowFast(isMember); // && threshold.isSimplemajority);
|
||||
}, [isMember]);
|
||||
setAllowFast(isMember && threshold.isSimplemajority);
|
||||
}, [isMember, threshold]);
|
||||
|
||||
useEffect((): void => {
|
||||
setProposal(
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/* eslint-disable @typescript-eslint/camelcase */
|
||||
// Copyright 2017-2020 @polkadot/ui-staking authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/app-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.
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2020 @polkadot/ui-staking authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/app-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.
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2020 @polkadot/ui-staking authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/app-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.
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2020 @polkadot/ui-staking authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/app-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.
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2020 @polkadot/ui-staking authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/app-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.
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2020 @polkadot/ui-staking authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/app-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.
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2020 @polkadot/ui-staking authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/app-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.
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2020 @polkadot/ui-staking authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/app-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.
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2020 @polkadot/ui-staking authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/app-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.
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/* eslint-disable @typescript-eslint/camelcase */
|
||||
// Copyright 2017-2020 @polkadot/ui-staking authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/app-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.
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2020 @polkadot/ui-staking authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/app-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.
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2020 @polkadot/ui-staking authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/app-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.
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2020 @polkadot/ui-staking authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/app-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.
|
||||
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
/* eslint-disable @typescript-eslint/camelcase */
|
||||
// Copyright 2017-2020 @polkadot/app-tech-comm authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
@ -9,10 +9,11 @@ import React from 'react';
|
||||
import Members from './Members';
|
||||
import Summary from './Summary';
|
||||
|
||||
export default function Overview ({ className, members, prime, proposals }: Props): React.ReactElement<Props> {
|
||||
export default function Overview ({ className, isMember, members, prime, proposals }: Props): React.ReactElement<Props> {
|
||||
return (
|
||||
<div className={className}>
|
||||
<Summary
|
||||
isMember={isMember}
|
||||
members={members}
|
||||
proposals={proposals}
|
||||
/>
|
||||
|
||||
@ -1,82 +1,93 @@
|
||||
// Copyright 2017-2020 @polkadot/ui-staking authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/app-tech-comm 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 { TxSource, TxDef } from '@polkadot/react-hooks/types';
|
||||
import { Proposal } from '@polkadot/types/interfaces';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { registry } from '@polkadot/react-api';
|
||||
import { Extrinsic, InputNumber, TxModalNew as TxModal } from '@polkadot/react-components';
|
||||
import { useApi, useTx } from '@polkadot/react-hooks';
|
||||
import { createType } from '@polkadot/types';
|
||||
import React, { useCallback, useState } from 'react';
|
||||
import { Button, Extrinsic, InputAddress, InputNumber, Modal, TxButton } from '@polkadot/react-components';
|
||||
import { useApi, useModal } from '@polkadot/react-hooks';
|
||||
|
||||
import { useTranslation } from '../translate';
|
||||
|
||||
interface Props {
|
||||
memberCount?: number;
|
||||
onClose: () => void;
|
||||
isMember: boolean;
|
||||
members: string[];
|
||||
}
|
||||
|
||||
export default function Propose ({ onClose, memberCount = 0 }: Props): React.ReactElement<Props> {
|
||||
function Propose ({ isMember, members }: Props): React.ReactElement<Props> {
|
||||
const { t } = useTranslation();
|
||||
const { apiDefaultTxSudo } = useApi();
|
||||
const [proposal, setProposal] = useState<Proposal | null>(null);
|
||||
const { isOpen, onOpen, onClose } = useModal();
|
||||
const [accountId, setAcountId] = useState<string | null>(null);
|
||||
const [proposal, setProposal] = useState<SubmittableExtrinsic<'promise'> | null>(null);
|
||||
const [[threshold, hasThreshold], setThreshold] = useState<[BN | null, boolean]>([
|
||||
new BN(memberCount / 2 + 1),
|
||||
new BN(members.length / 2 + 1),
|
||||
true
|
||||
]);
|
||||
|
||||
// FIXME Rework this, unless you know, you can never figure out what all these options mean here
|
||||
const txState = useTx(
|
||||
(): TxSource<TxDef> => [
|
||||
[
|
||||
'technicalCommittee.propose',
|
||||
[threshold, proposal]
|
||||
],
|
||||
!!proposal && hasThreshold
|
||||
],
|
||||
[memberCount, proposal, threshold, hasThreshold],
|
||||
{}
|
||||
const _hasThreshold = useCallback(
|
||||
(threshold?: BN | null): boolean =>
|
||||
!!threshold && !threshold.isZero() && threshold.lten(members.length),
|
||||
[members]
|
||||
);
|
||||
|
||||
const _hasThreshold = (threshold?: BN | null): boolean =>
|
||||
!!threshold && !threshold.isZero() && threshold.lten(memberCount);
|
||||
|
||||
useEffect((): void => {
|
||||
setThreshold([threshold, _hasThreshold(threshold)]);
|
||||
}, [memberCount]);
|
||||
|
||||
const _onChangeExtrinsic = (method?: SubmittableExtrinsic<'promise'>): void =>
|
||||
setProposal(method ? createType(registry, 'Proposal', method) : null);
|
||||
setProposal(() => method || null);
|
||||
const _onChangeThreshold = (threshold?: BN): void =>
|
||||
setThreshold([threshold || null, _hasThreshold(threshold)]);
|
||||
|
||||
return (
|
||||
<TxModal
|
||||
isOpen
|
||||
onClose={onClose}
|
||||
{...txState}
|
||||
header={t('Propose a committee motion')}
|
||||
>
|
||||
<InputNumber
|
||||
className='medium'
|
||||
label={t('threshold')}
|
||||
help={t('The minimum number of committee votes required to approve this motion')}
|
||||
isError={!hasThreshold}
|
||||
onChange={_onChangeThreshold}
|
||||
onEnter={txState.sendTx}
|
||||
placeholder={t('Positive number between 1 and {{memberCount}}', { replace: { memberCount } })}
|
||||
value={threshold || undefined}
|
||||
<>
|
||||
{isOpen && (
|
||||
<Modal
|
||||
onClose={onClose}
|
||||
header={t('Propose a committee motion')}
|
||||
>
|
||||
<Modal.Content>
|
||||
<InputAddress
|
||||
filter={members}
|
||||
help={t('Select the account you wish to make the proposal with.')}
|
||||
label={t('propose from account')}
|
||||
onChange={setAcountId}
|
||||
type='account'
|
||||
withLabel
|
||||
/>
|
||||
<InputNumber
|
||||
className='medium'
|
||||
label={t('threshold')}
|
||||
help={t('The minimum number of committee votes required to approve this motion')}
|
||||
isError={!hasThreshold}
|
||||
onChange={_onChangeThreshold}
|
||||
placeholder={t('Positive number between 1 and {{count}}', { replace: { count: members.length } })}
|
||||
value={threshold || undefined}
|
||||
/>
|
||||
<Extrinsic
|
||||
defaultValue={apiDefaultTxSudo}
|
||||
label={t('proposal')}
|
||||
onChange={_onChangeExtrinsic}
|
||||
/>
|
||||
</Modal.Content>
|
||||
<Modal.Actions onCancel={onClose}>
|
||||
<TxButton
|
||||
accountId={accountId}
|
||||
isDisabled={!hasThreshold || !proposal}
|
||||
onStart={onClose}
|
||||
params={[threshold, proposal]}
|
||||
tx='technicalCommittee.propose'
|
||||
/>
|
||||
</Modal.Actions>
|
||||
</Modal>
|
||||
)}
|
||||
<Button
|
||||
icon='plus'
|
||||
isDisabled={!isMember}
|
||||
label={t('Submit proposal')}
|
||||
onClick={onOpen}
|
||||
/>
|
||||
<Extrinsic
|
||||
defaultValue={apiDefaultTxSudo}
|
||||
label={t('proposal')}
|
||||
onChange={_onChangeExtrinsic}
|
||||
onEnter={txState.sendTx}
|
||||
/>
|
||||
</TxModal>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default React.memo(Propose);
|
||||
|
||||
@ -6,30 +6,21 @@ import { Hash } from '@polkadot/types/interfaces';
|
||||
import { ComponentProps as Props } from '../types';
|
||||
|
||||
import React from 'react';
|
||||
import { Button, Table } from '@polkadot/react-components';
|
||||
import { useToggle } from '@polkadot/react-hooks';
|
||||
import { Table, Button } from '@polkadot/react-components';
|
||||
|
||||
import { useTranslation } from '../translate';
|
||||
import Proposal from './Proposal';
|
||||
import Propose from './Propose';
|
||||
|
||||
export default function Proposals ({ className, members, prime, proposals }: Props): React.ReactElement<Props> {
|
||||
export default function Proposals ({ className, isMember, members, prime, proposals }: Props): React.ReactElement<Props> {
|
||||
const { t } = useTranslation();
|
||||
const [isProposeOpen, togglePropose] = useToggle(false);
|
||||
|
||||
return (
|
||||
<div className={className}>
|
||||
{isProposeOpen && (
|
||||
<Propose
|
||||
memberCount={members.length}
|
||||
onClose={togglePropose}
|
||||
/>
|
||||
)}
|
||||
<Button.Group>
|
||||
<Button
|
||||
label={t('Submit proposal')}
|
||||
icon='add'
|
||||
onClick={togglePropose}
|
||||
<Propose
|
||||
isMember={isMember}
|
||||
members={members}
|
||||
/>
|
||||
</Button.Group>
|
||||
{proposals?.length
|
||||
|
||||
@ -19,10 +19,10 @@ export { default as useCounter } from './useCounter';
|
||||
|
||||
interface Props extends AppProps, BareProps {}
|
||||
|
||||
export default function TechCommApp ({ basePath, className }: Props): React.ReactElement<Props> {
|
||||
function TechCommApp ({ basePath, className }: Props): React.ReactElement<Props> {
|
||||
const { t } = useTranslation();
|
||||
const { api } = useApi();
|
||||
const { members } = useMembers('technicalCommittee');
|
||||
const { isMember, members } = useMembers('technicalCommittee');
|
||||
const prime = useCall<AccountId | null>(api.query.technicalCommittee.prime, [], {
|
||||
transform: (result: Option<AccountId>): AccountId | null => result.unwrapOr(null)
|
||||
}) || null;
|
||||
@ -50,6 +50,7 @@ export default function TechCommApp ({ basePath, className }: Props): React.Reac
|
||||
<Switch>
|
||||
<Route path={`${basePath}/proposals`}>
|
||||
<Proposals
|
||||
isMember={isMember}
|
||||
members={members}
|
||||
prime={prime}
|
||||
proposals={proposals}
|
||||
@ -57,6 +58,7 @@ export default function TechCommApp ({ basePath, className }: Props): React.Reac
|
||||
</Route>
|
||||
<Route path={basePath}>
|
||||
<Overview
|
||||
isMember={isMember}
|
||||
members={members}
|
||||
prime={prime}
|
||||
proposals={proposals}
|
||||
@ -66,3 +68,5 @@ export default function TechCommApp ({ basePath, className }: Props): React.Reac
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
export default React.memo(TechCommApp);
|
||||
|
||||
@ -6,6 +6,7 @@ import { AccountId, Hash } from '@polkadot/types/interfaces';
|
||||
|
||||
export interface ComponentProps {
|
||||
className?: string;
|
||||
isMember: boolean;
|
||||
prime?: AccountId | null;
|
||||
proposals?: Hash[];
|
||||
members: string[];
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
|
||||
import { AccountId, Balance } from '@polkadot/types/interfaces';
|
||||
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useAccounts, useApi, useCall } from '@polkadot/react-hooks';
|
||||
|
||||
interface Result {
|
||||
@ -11,27 +12,28 @@ interface Result {
|
||||
members: string[];
|
||||
}
|
||||
|
||||
function getResult (allAccounts: string[], members: string[]): Result {
|
||||
return {
|
||||
isMember: members.some((accountId): boolean => allAccounts.includes(accountId)),
|
||||
members
|
||||
};
|
||||
}
|
||||
|
||||
export default function useMembers (collective: 'council' | 'technicalCommittee'): Result {
|
||||
const { api } = useApi();
|
||||
const { allAccounts } = useAccounts();
|
||||
const state = (
|
||||
const [state, setState] = useState<Result>({ isMember: false, members: [] });
|
||||
const retrieved = (
|
||||
collective === 'council'
|
||||
? useCall<Result>(api.query.electionsPhragmen?.members || api.query.elections.members, [], {
|
||||
transform: (accounts: [AccountId, Balance][]): Result =>
|
||||
getResult(allAccounts, accounts.map(([accountId]) => accountId.toString()))
|
||||
? useCall<string[]>(api.query.electionsPhragmen?.members || api.query.elections.members, [], {
|
||||
transform: (accounts: [AccountId, Balance][]): string[] =>
|
||||
accounts.map(([accountId]) => accountId.toString())
|
||||
})
|
||||
: useCall<Result>(api.query.technicalCommittee.members, [], {
|
||||
transform: (accounts: AccountId[]): Result =>
|
||||
getResult(allAccounts, accounts.map((accountId) => accountId.toString()))
|
||||
: useCall<string[]>(api.query.technicalCommittee.members, [], {
|
||||
transform: (accounts: AccountId[]): string[] =>
|
||||
accounts.map((accountId) => accountId.toString())
|
||||
})
|
||||
) || { isMember: false, members: [] };
|
||||
);
|
||||
|
||||
useEffect((): void => {
|
||||
retrieved && setState({
|
||||
isMember: retrieved.some((accountId): boolean => allAccounts.includes(accountId)),
|
||||
members: retrieved
|
||||
});
|
||||
}, [allAccounts, retrieved]);
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user