import { useEffect } from 'react'; import { QRCodeSVG } from 'qrcode.react'; import { X, AlertTriangle } from 'lucide-react'; import { useTranslation } from 'react-i18next'; import { Button } from './Button'; import { buildApiKeyQrPayload } from '../utils/apiKeyQr'; interface ApiKeyQRCodeModalProps { /** Raw API key string (only available in-memory right after creation). */ apiKey: string; /** Base URL a client uses to reach Bambuddy. Defaults to the current origin. */ baseUrl?: string; onClose: () => void; } export function ApiKeyQRCodeModal({ apiKey, baseUrl, onClose }: ApiKeyQRCodeModalProps) { const { t } = useTranslation(); const origin = baseUrl ?? window.location.origin; const payload = buildApiKeyQrPayload(origin, apiKey); // Close on Escape key useEffect(() => { const handleKeyDown = (e: KeyboardEvent) => { if (e.key === 'Escape') onClose(); }; window.addEventListener('keydown', handleKeyDown); return () => window.removeEventListener('keydown', handleKeyDown); }, [onClose]); return (
e.stopPropagation()} > {/* Header */}

{t('settings.apiKeyQrTitle')}

{/* Content */}

{t('settings.apiKeyQrCaption')}

{t('settings.apiKeyQrWarning')}
); }