import { QrScanAddress } from '@polkadot/react-qr' import React, { useEffect, useState } from 'react' import { createAccountExternal } from '../../messaging/uiActions' import { addHeaderAction, cancelAndGoHomeHeaderAction, doneAndGoHomeHeaderAction, resetHeaderActions, } from '../../stores/headerActions' import { Address } from '../components/Address' import { H1 } from '../components/H1' interface QrAccount { isAddress: boolean content: string genesisHash: string name?: string } export const ImportQr = () => { const [scanned, setScanned] = useState([]) const onCreate = (account: QrAccount) => { const alreadyScanned = scanned.find( (a) => a.content === account.content && a.genesisHash === account.genesisHash ) if (alreadyScanned) return createAccountExternal( account.name || 'Unknown', account.content, account.genesisHash ) .then(() => setScanned((s) => [...s, account])) .catch(console.error) } useEffect(() => { scanned.length === 0 ? addHeaderAction(cancelAndGoHomeHeaderAction) : addHeaderAction(doneAndGoHomeHeaderAction) return () => resetHeaderActions() }, [scanned.length]) return (

Import
Signer
keys

{scanned.length} imported
{scanned.reverse().map((account) => (
))}
) }