ghost-portal/packages/page-democracy/src/Overview/DispatchQueue.tsx
Jaco Greeff 315995d6bf
Rename app-* folders to page-* (#2318)
* Rename app-* folders to page-*

* Cleanup test paths
2020-03-01 19:56:31 +01:00

50 lines
1.4 KiB
TypeScript

// Copyright 2017-2020 @polkadot/app-democracy 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 { 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 { useTranslation } from '../translate';
import DispatchEntry from './DispatchEntry';
interface Props {
className?: string;
}
export default function DispatchQueue ({ className }: Props): React.ReactElement<Props> | null {
const { t } = useTranslation();
const { api } = useApi();
const queued = useCall<[BlockNumber, Hash, ReferendumIndex][]>(api.query.democracy.dispatchQueue, []);
if (!queued?.length) {
return null;
}
return (
<div className={className}>
<h1>{t('dispatch queue')}</h1>
{queued?.length
? (
<Table>
<Table.Body>
{queued.map(([blockNumber, hash, referendumIndex]): React.ReactNode => (
<DispatchEntry
blockNumber={blockNumber}
hash={hash}
key={referendumIndex.toString()}
referendumIndex={referendumIndex}
/>
))}
</Table.Body>
</Table>
)
: t('nothing queued to be executed')
}
</div>
);
}