// Vip Verification Card // Purpose: Defines the Vip Verification Card module and the local helpers/components used in this file. // Scope: Keeps behavior unchanged while isolating this concern into a clear, single-responsibility unit. import { useState } from 'react'; import NicknameForm from '../NicknameForm/index.jsx'; import CardFrame from '../CardFrame/index.jsx'; import { flowWrapClass, innerFlowClass, fieldClass } from './constants.js'; export default function VipVerificationCard({ pendingRequestId, currentStoredKey, nickname, requestVerification, applyIdentityKey, onMessage, fullWidth = false, }) { const [requestFlowStep, setRequestFlowStep] = useState(0); const [requestKeyInput, setRequestKeyInput] = useState(''); const [confirmNickname, setConfirmNickname] = useState(false); const [working, setWorking] = useState(false); const beginRequestFlow = () => { setRequestFlowStep(1); setRequestKeyInput(currentStoredKey); setConfirmNickname(false); onMessage?.(''); }; const cancelRequestFlow = () => { setRequestFlowStep(0); setConfirmNickname(false); }; const handleRequestSubmit = async (event) => { event.preventDefault(); if (!confirmNickname) { onMessage?.('Please confirm your nickname agreement before sending.'); return; } if (requestFlowStep < 3) { onMessage?.('Complete all request steps before sending.'); return; } setWorking(true); onMessage?.(''); try { const applied = await applyIdentityKey(requestKeyInput); await requestVerification?.(); setRequestKeyInput(applied); setRequestFlowStep(0); setConfirmNickname(false); onMessage?.('Verification request sent to lockdown admins.'); } catch (err) { onMessage?.(err.message || 'Failed to submit request.'); } finally { setWorking(false); } }; const wrapClass = fullWidth ? 'w-full' : flowWrapClass; if (pendingRequestId) { return (
Verification request pending: {pendingRequestId}
); } if (requestFlowStep === 0) { return (
); } return (

Step {requestFlowStep} of 3

{requestFlowStep === 1 ? (

Confirm your nickname, which is used as part of the verification process. You can edit it here before requesting.

Current nickname: {nickname || '(not set)'}
) : null} {requestFlowStep === 2 ? (

Save your identity key in a safe place. You can use it to restore your identity in another browser.

setRequestKeyInput(event.target.value.toLowerCase())} placeholder="Identity key for this request" />
) : null} {requestFlowStep === 3 ? (

Final step: confirm and send your verification request.

setRequestKeyInput(event.target.value.toLowerCase())} placeholder="Identity key for this request" />
) : null}
); }