mirror of
https://github.com/pezkuwichain/pezkuwi-ui.git
synced 2026-04-22 09:07:56 +00:00
40 lines
918 B
TypeScript
40 lines
918 B
TypeScript
// Copyright 2017-2024 @polkadot/react-qr authors & contributors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
import type { HexString } from '@polkadot/util/types';
|
|
|
|
import React, { useCallback } from 'react';
|
|
|
|
import { QrScan } from './Scan.js';
|
|
|
|
interface ScanType {
|
|
signature: HexString;
|
|
}
|
|
|
|
interface Props {
|
|
className?: string;
|
|
onError?: (error: Error) => void;
|
|
onScan: (scanned: ScanType) => void;
|
|
size?: string | number;
|
|
style?: React.CSSProperties;
|
|
}
|
|
|
|
function ScanSignature ({ className, onError, onScan, size, style }: Props): React.ReactElement<Props> {
|
|
const _onScan = useCallback(
|
|
(signature: string | null) => signature && onScan({ signature: `0x${signature}` }),
|
|
[onScan]
|
|
);
|
|
|
|
return (
|
|
<QrScan
|
|
className={className}
|
|
onError={onError}
|
|
onScan={_onScan}
|
|
size={size}
|
|
style={style}
|
|
/>
|
|
);
|
|
}
|
|
|
|
export const QrScanSignature = React.memo(ScanSignature);
|