import { useEffect, useState } from 'react'; import { Download } from 'lucide-react'; import QRCode from 'qrcode'; interface QrDisplayProps { value: string; } export const QrDisplay: React.FC = ({ value }) => { const [dataUrl, setDataUrl] = useState(''); useEffect(() => { if (value) { QRCode.toDataURL(value, { errorCorrectionLevel: 'M', type: 'image/png', width: 512, margin: 4, color: { dark: '#000000', light: '#FFFFFF' } }) .then(setDataUrl) .catch(console.error); } }, [value]); const handleDownload = () => { if (!dataUrl) return; // Generate filename: SeedPGP_YYYY-MM-DD_HHMMSS.png const now = new Date(); const date = now.toISOString().split('T')[0]; // YYYY-MM-DD const time = now.toTimeString().split(' ')[0].replace(/:/g, ''); // HHMMSS const filename = `SeedPGP_${date}_${time}.png`; // Create download link const link = document.createElement('a'); link.href = dataUrl; link.download = filename; document.body.appendChild(link); link.click(); document.body.removeChild(link); }; if (!dataUrl) return null; return (
SeedPGP QR Code

Downloads as: SeedPGP_2026-01-28_231645.png

); };