Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 | 'use client' import { useState } from 'react' import { css } from '../../../styled-system/css' import { AbacusQRCode } from '../common/AbacusQRCode' interface QRCodeDisplayProps { sessionId: string uploadCount: number uploads: Array<{ id: string status: 'pending' | 'processing' | 'completed' | 'failed' uploadedAt: Date }> } /** * QR code display for batch upload workflow * * Shows QR code that links to camera upload page * Displays real-time list of uploads as phone sends them */ export function QRCodeDisplay({ sessionId, uploadCount, uploads }: QRCodeDisplayProps) { const [copied, setCopied] = useState(false) // Generate upload URL for smartphone const uploadUrl = `${typeof window !== 'undefined' ? window.location.origin : ''}/upload/${sessionId}/camera` const copyUrl = async () => { try { await navigator.clipboard.writeText(uploadUrl) setCopied(true) setTimeout(() => setCopied(false), 2000) } catch (err) { console.error('Failed to copy URL:', err) } } return ( <div data-component="qr-code-display" className={css({ display: 'flex', flexDirection: 'column', gap: 4, alignItems: 'center', })} > {/* Instructions */} <div className={css({ textAlign: 'center', color: 'gray.700', })} > <h3 className={css({ fontSize: 'lg', fontWeight: 'bold', mb: 2, })} > Scan with your phone </h3> <p className={css({ fontSize: 'sm', color: 'gray.600' })}> Camera will open automatically. Take multiple photos to batch upload. </p> </div> {/* QR Code */} <div data-element="qr-code" className={css({ p: 4, bg: 'white', borderRadius: 'lg', border: '2px solid', borderColor: 'gray.200', })} > <AbacusQRCode value={uploadUrl} size={200} className={css({ display: 'block', })} /> </div> {/* URL with copy button */} <div className={css({ display: 'flex', gap: 2, alignItems: 'center', width: '100%', maxW: 'md', })} > <input type="text" value={uploadUrl} readOnly className={css({ flex: 1, px: 3, py: 2, bg: 'gray.50', border: '1px solid', borderColor: 'gray.300', borderRadius: 'md', fontSize: 'xs', fontFamily: 'mono', color: 'gray.700', })} /> <button data-action="copy-url" onClick={copyUrl} className={css({ px: 4, py: 2, bg: copied ? 'green.500' : 'blue.500', color: 'white', borderRadius: 'md', fontSize: 'sm', fontWeight: 'medium', cursor: 'pointer', transition: 'background 0.2s', _hover: { bg: copied ? 'green.600' : 'blue.600', }, })} > {copied ? 'Copied!' : 'Copy'} </button> </div> {/* Upload count */} <div data-element="upload-count" className={css({ fontSize: 'sm', fontWeight: 'medium', color: 'gray.600', })} > Worksheets uploaded: <span className={css({ fontWeight: 'bold' })}>{uploadCount}</span> </div> {/* Upload list */} {uploads.length > 0 && ( <div data-section="upload-list" className={css({ width: '100%', maxW: 'md', maxH: '300px', overflowY: 'auto', border: '1px solid', borderColor: 'gray.200', borderRadius: 'md', bg: 'gray.50', })} > {uploads.map((upload, index) => ( <div key={upload.id} data-element="upload-item" className={css({ p: 3, borderBottom: '1px solid', borderColor: 'gray.200', display: 'flex', justifyContent: 'space-between', alignItems: 'center', _last: { borderBottom: 'none', }, })} > <div className={css({ display: 'flex', alignItems: 'center', gap: 2, })} > <span className={css({ fontWeight: 'medium', color: 'gray.700' })}> Worksheet {index + 1} </span> <StatusBadge status={upload.status} /> </div> <a href={`/worksheets/attempts/${upload.id}`} className={css({ px: 3, py: 1, bg: 'blue.500', color: 'white', borderRadius: 'md', fontSize: 'xs', fontWeight: 'medium', textDecoration: 'none', cursor: 'pointer', _hover: { bg: 'blue.600' }, })} > View </a> </div> ))} </div> )} </div> ) } function StatusBadge({ status }: { status: 'pending' | 'processing' | 'completed' | 'failed' }) { const colors = { pending: { bg: 'yellow.100', color: 'yellow.700', text: 'Pending' }, processing: { bg: 'blue.100', color: 'blue.700', text: 'Grading...' }, completed: { bg: 'green.100', color: 'green.700', text: 'Done' }, failed: { bg: 'red.100', color: 'red.700', text: 'Failed' }, } const style = colors[status] return ( <span data-status={status} className={css({ px: 2, py: 0.5, bg: style.bg, color: style.color, borderRadius: 'sm', fontSize: 'xs', fontWeight: 'medium', })} > {style.text} </span> ) } |