mirror of
https://github.com/pezkuwichain/pezkuwi-ui.git
synced 2026-04-22 06:47:59 +00:00
40 lines
896 B
TypeScript
40 lines
896 B
TypeScript
// Copyright 2017-2021 @polkadot/react-qr authors & contributors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
import type { NetworkSpecsStruct } from '@polkadot/ui-settings/types';
|
|
|
|
import React, { useMemo } from 'react';
|
|
|
|
import { QrDisplay } from './Display';
|
|
import { encodeString } from './util';
|
|
|
|
interface Props {
|
|
className?: string;
|
|
networkSpecs: NetworkSpecsStruct;
|
|
size?: string | number;
|
|
style?: React.CSSProperties;
|
|
}
|
|
|
|
function DisplayNetworkSpecs ({ className, networkSpecs, size, style }: Props): React.ReactElement<Props> | null {
|
|
const data = useMemo(
|
|
() => encodeString(JSON.stringify(networkSpecs)),
|
|
[networkSpecs]
|
|
);
|
|
|
|
if (!data) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<QrDisplay
|
|
className={className}
|
|
size={size}
|
|
skipEncoding
|
|
style={style}
|
|
value={data}
|
|
/>
|
|
);
|
|
}
|
|
|
|
export const QrNetworkSpecs = React.memo(DisplayNetworkSpecs);
|