import { useState } from 'react'; import { PDFViewer, type ViewerConfig } from '@embedpdf/viewer-react'; const CHECKS = ['Parties', 'Dates', 'Payment', 'Signatures']; interface Review { done: string[]; status: 'review' | 'approved'; approve(): void; } // A constant: the commands read your state from `appState`, so nothing goes stale. const config: ViewerConfig = { commands: [ { id: 'acme:approve', label: 'Approve', icon: 'check', enabled: ({ appState }) => appState.done.length === CHECKS.length, active: ({ appState }) => appState.status === 'approved', run: ({ appState }) => appState.approve(), }, ], layout: (layout) => layout.add('acme:approve', { to: 'main', section: 'end' }), }; export function ReviewApp() { const [done, setDone] = useState([]); const [status, setStatus] = useState('review'); const toggle = (check: string) => setDone((done) => (done.includes(check) ? done.filter((c) => c !== check) : [...done, check])); return ( <>
{CHECKS.map((check) => ( ))}
setStatus('approved') }} style={{ height: '100vh' }} /> ); }