feat: polish speaker material upload control

This commit is contained in:
Lago committed 2026-10-07 19:58:00 +02:00
1 parent 8d8d3ae4b8
commit ef0121a3e4
6 files changed
+180 -10

No files matched your search

+12 -8
View File
@@ -1,5 +1,6 @@
import { useEffect, useState, type FormEvent } from 'react';
import type { Session } from '@supabase/supabase-js';
import { LoaderCircle, Paperclip } from 'lucide-react';
import { supabase } from '../lib/supabase';
import { getSpeakerPortalSessions, speakerPortalSession, type SpeakerSession } from '../lib/speakerPortal';
import { removeSessionMaterial, sessionMaterialUrl, uploadSessionMaterial } from '../lib/api';
@@ -110,13 +111,16 @@ export function SpeakerPortal() {
<h3 className="h2">{talk.title}</h3>
<p className="small">{talk.slot_date} · {talk.start_time.slice(0, 5)} - {talk.end_time.slice(0, 5)}{talk.room && ` · ${talk.room}`}</p>
{talk.material_path ? <a className="speaker-download" href={sessionMaterialUrl(talk.material_path)} target="_blank" rel="noreferrer">Download material</a> : <p className="small muted">No material uploaded</p>}
<label className="small" htmlFor={`material-${talk.session_id}`}>{talk.material_path ? 'Replace material' : 'Upload material'}</label>
<input className="input" id={`material-${talk.session_id}`} aria-label={`${talk.material_path ? 'Replace' : 'Upload'} material for ${talk.title}`} type="file" accept={FILE_TYPES} disabled={!!workingTalk || busy} onChange={(event) => {
const file = event.target.files?.[0];
event.target.value = '';
if (file) void changeMaterial(talk, file);
}} />
<p className="small muted">PDF, PowerPoint, ODP, ZIP, TXT · Max 50 MB</p>
<label className="speaker-upload" htmlFor={`material-${talk.session_id}`}>
{workingTalk === talk.session_id ? <LoaderCircle aria-hidden="true" className="speaker-upload-spinner" /> : <Paperclip aria-hidden="true" />}
<span>{workingTalk === talk.session_id ? 'Saving material...' : talk.material_path ? 'Replace material' : 'Upload material'}</span>
<input className="input" id={`material-${talk.session_id}`} aria-label={`${talk.material_path ? 'Replace' : 'Upload'} material for ${talk.title}`} aria-describedby={`material-help-${talk.session_id}`} type="file" accept={FILE_TYPES} disabled={!!workingTalk || busy} onChange={(event) => {
const file = event.target.files?.[0];
event.target.value = '';
if (file) void changeMaterial(talk, file);
}} />
</label>
<p id={`material-help-${talk.session_id}`} className="small muted">PDF, PowerPoint, ODP, ZIP, TXT · Max 50 MB</p>
{workingTalk === talk.session_id && <><progress aria-label="Saving material" /><p role="status">Saving material...</p></>}
{talk.material_path && <button className="btn small danger" disabled={!!workingTalk || busy} onClick={() => void changeMaterial(talk)}>Remove material</button>}
</article>)}
@@ -126,4 +130,4 @@ export function SpeakerPortal() {
<button className="btn primary" type="submit" disabled={busy}>{busy ? 'Sending...' : 'Send sign-in link'}</button>
</form>}
</main></div>;
}
}