ghost-portal/packages/page-democracy/src/Overview/ExternalCell.tsx
2021-01-03 11:33:39 +01:00

45 lines
1.1 KiB
TypeScript

// Copyright 2017-2021 @polkadot/app-democracy authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { DeriveProposalImage } from '@polkadot/api-derive/types';
import type { Hash } from '@polkadot/types/interfaces';
import React from 'react';
import { CallExpander } from '@polkadot/react-components';
import { useApi, useCall } from '@polkadot/react-hooks';
import { Holder } from '@polkadot/react-params';
import { useTranslation } from '../translate';
interface Props {
className?: string;
value: Hash;
}
function ExternalCell ({ className = '', value }: Props): React.ReactElement<Props> | null {
const { t } = useTranslation();
const { api } = useApi();
const preimage = useCall<DeriveProposalImage>(api.derive.democracy.preimage, [value]);
if (!preimage?.proposal) {
return null;
}
return (
<Holder
className={className}
withBorder
withPadding
>
<CallExpander
labelHash={t<string>('proposal hash')}
value={preimage.proposal}
withHash
/>
</Holder>
);
}
export default React.memo(ExternalCell);