ghost-portal/packages/page-rpc/src/Rpc/Results.tsx
Jaco f512c1a539
Bump de & api (w/ __Unused on enum) (#6326)
* Bump de & api (w/ __Unused on enum)

* Linting fixes

* tsc adjustments

* Api bump
2021-10-17 16:37:57 +03:00

44 lines
1.1 KiB
TypeScript

// Copyright 2017-2021 @polkadot/app-rpc authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { QueueTx } from '@polkadot/react-components/Status/types';
import React from 'react';
import { Output } from '@polkadot/react-components';
import valueToText from '@polkadot/react-params/valueToText';
import { isUndefined } from '@polkadot/util';
interface Props {
queue: QueueTx[];
}
function Results ({ queue = [] }: Props): React.ReactElement<Props> | null {
const filtered = queue
.filter(({ error, result }) => !isUndefined(error) || !isUndefined(result))
.reverse();
if (!filtered.length) {
return null;
}
return (
<section className='rpc--Results'>
{filtered.map(({ error, id, result, rpc: { method, section } }): React.ReactNode => (
<Output
isError={!!error}
key={id}
label={`${id}: ${section}.${method}`}
value={
error
? error.message
: <pre>{valueToText('', result as null, false)}</pre>
}
/>
))}
</section>
);
}
export default React.memo(Results);