Public Access
fix: add validateExam to loadSample; use native button for dropzone accessibility
This commit is contained in:
1 parent
24d47e1830
commit
ef05f2c08b
1 file changed
+5
-2
@@ -41,6 +41,8 @@ export default function Landing({ onLoadExam, history, onResume, onClearHistory,
|
|||||||
try {
|
try {
|
||||||
const r = await fetch(path)
|
const r = await fetch(path)
|
||||||
const data = await r.json() as unknown
|
const data = await r.json() as unknown
|
||||||
|
const msg = validateExam(data)
|
||||||
|
if (msg) throw new Error(msg)
|
||||||
onLoadExam(parseExam(data))
|
onLoadExam(parseExam(data))
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setErr(`Could not load sample: ${(e as Error).message}`)
|
setErr(`Could not load sample: ${(e as Error).message}`)
|
||||||
@@ -59,7 +61,8 @@ export default function Landing({ onLoadExam, history, onResume, onClearHistory,
|
|||||||
|
|
||||||
<div className="landing-grid">
|
<div className="landing-grid">
|
||||||
<div>
|
<div>
|
||||||
<div
|
<button
|
||||||
|
type="button"
|
||||||
className={`dropzone${dragOver ? ' drag-over' : ''}`}
|
className={`dropzone${dragOver ? ' drag-over' : ''}`}
|
||||||
onClick={() => fileRef.current?.click()}
|
onClick={() => fileRef.current?.click()}
|
||||||
onDragOver={(e) => { e.preventDefault(); setDragOver(true) }}
|
onDragOver={(e) => { e.preventDefault(); setDragOver(true) }}
|
||||||
@@ -80,7 +83,7 @@ export default function Landing({ onLoadExam, history, onResume, onClearHistory,
|
|||||||
style={{ display: 'none' }}
|
style={{ display: 'none' }}
|
||||||
onChange={(e) => { const f = e.target.files?.[0]; if (f) void handleFile(f) }}
|
onChange={(e) => { const f = e.target.files?.[0]; if (f) void handleFile(f) }}
|
||||||
/>
|
/>
|
||||||
</div>
|
</button>
|
||||||
|
|
||||||
{err && (
|
{err && (
|
||||||
<div style={{ marginTop: 12, padding: '10px 14px', border: '1px solid var(--wrong)', borderRadius: 8, background: 'var(--wrong-weak)', color: 'var(--wrong)', fontSize: 13 }}>
|
<div style={{ marginTop: 12, padding: '10px 14px', border: '1px solid var(--wrong)', borderRadius: 8, background: 'var(--wrong-weak)', color: 'var(--wrong)', fontSize: 13 }}>
|
||||||
|
|||||||
Reference in new issue
Block a user