import { useState, type ReactElement } from 'react'; import type { ClientMessage } from '../../shared/ws-protocol.js'; type Props = { sourceId: string; onSubmit: (msg: ClientMessage) => void; onClose: () => void; }; export function OtpModal({ sourceId, onSubmit, onClose }: Props): ReactElement { const [otp, setOtp] = useState(''); function handleSubmit() { if (!otp.trim()) return; onSubmit({ type: 'otp-submit', sourceId, otp: otp.trim() }); setOtp(''); } return (
Source: {sourceId}
setOtp(e.target.value)} onKeyDown={e => { if (e.key === 'Enter') handleSubmit(); }} autoFocus placeholder="Enter OTP…" style={{ width: '100%', padding: '6px 10px', fontSize: '1em', boxSizing: 'border-box' }} />