feat(admin): material column + inline material manager in the Sessions view
- Sessions table gains a Material column (uploaded pill with the clean filename in its tooltip, dash when none) - Expanded session row: shared MaterialPanel (open / download / delete with confirm) plus immediate upload/replace via MaterialUploadRow - Schedule session modal refactored onto the same MaterialPanel; its upload keeps the uploads-on-Save behavior - sessions-view e2e: new test pins the pill, panel buttons, clean filename, unlock hint and replace control Co-authored-by: Stephan Charles <[email protected]> Co-authored-by: Amelia Hernandez <[email protected]> Co-authored-by: Markus Franz <[email protected]> Co-authored-by: Sabrina Hota <[email protected]> Co-authored-by: Nilüfer Doğan <[email protected]>
This commit is contained in:
1 parent
22d2418125
commit
45ab567355
6 files changed
+210
-77
No files matched your search
@@ -2,21 +2,18 @@ import { useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { supabase } from '../lib/supabase';
|
||||
import {
|
||||
deleteEventSchedule,
|
||||
downloadSessionMaterial,
|
||||
getAllContacts,
|
||||
getAllSessionSpeakers,
|
||||
getActiveEvent,
|
||||
getSessions,
|
||||
getSlots,
|
||||
removeSessionMaterial,
|
||||
openSessionMaterial,
|
||||
sessionMaterialName,
|
||||
setSessionSpeakers,
|
||||
uploadSessionMaterial,
|
||||
} from '../lib/api';
|
||||
import type { Contact, Event, Session, SessionSpeaker, Slot, SlotType } from '../lib/types';
|
||||
import { useSilentRefresh } from '../lib/useSilentRefresh';
|
||||
import { useToast } from '../context/ToastContext';
|
||||
import { MaterialPanel } from '../components/MaterialPanel';
|
||||
import { Empty, Modal, Spinner, TypeBadge } from '../components/ui';
|
||||
|
||||
const SLOT_TYPES: SlotType[] = ['session', 'service_session'];
|
||||
@@ -470,8 +467,6 @@ function SessionModal({
|
||||
const [area, setArea] = useState(session?.area ?? '');
|
||||
const [speakerEmails, setSpeakerEmails] = useState<string[]>(currentSpeakers);
|
||||
const [material, setMaterial] = useState<File | null>(null);
|
||||
const [matBusy, setMatBusy] = useState(false);
|
||||
const [matError, setMatError] = useState<string | null>(null);
|
||||
const [busy, setBusy] = useState(false);
|
||||
|
||||
async function save() {
|
||||
@@ -580,66 +575,11 @@ function SessionModal({
|
||||
{session && (
|
||||
<div className="field" data-testid="session-material">
|
||||
<label>Material</label>
|
||||
{session.material_path ? (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
|
||||
<div className="muted small">📎 {sessionMaterialName(session.material_path)}</div>
|
||||
<div className="row" style={{ gap: 10, flexWrap: 'wrap' }}>
|
||||
<button
|
||||
className="btn small"
|
||||
disabled={busy || matBusy}
|
||||
onClick={async () => {
|
||||
setMatBusy(true);
|
||||
setMatError(null);
|
||||
try {
|
||||
await openSessionMaterial(session.material_path!);
|
||||
} catch (e) {
|
||||
setMatError(e instanceof Error ? e.message : 'Could not open material');
|
||||
} finally {
|
||||
setMatBusy(false);
|
||||
}
|
||||
}}
|
||||
>
|
||||
Open
|
||||
</button>
|
||||
<button
|
||||
className="btn small"
|
||||
disabled={busy || matBusy}
|
||||
onClick={async () => {
|
||||
setMatBusy(true);
|
||||
setMatError(null);
|
||||
try {
|
||||
await downloadSessionMaterial(session.material_path!);
|
||||
} catch (e) {
|
||||
setMatError(e instanceof Error ? e.message : 'Download failed');
|
||||
} finally {
|
||||
setMatBusy(false);
|
||||
}
|
||||
}}
|
||||
>
|
||||
⬇ Download
|
||||
</button>
|
||||
<button
|
||||
className="btn small danger"
|
||||
disabled={busy || matBusy}
|
||||
onClick={async () => {
|
||||
if (!confirm(`Delete material "${sessionMaterialName(session.material_path!)}"? Attendees and speakers lose access immediately.`)) return;
|
||||
setMatBusy(true);
|
||||
try {
|
||||
await removeSessionMaterial(session.id);
|
||||
onSaved('Material removed');
|
||||
} catch (e) {
|
||||
setMatBusy(false);
|
||||
setMatError(e instanceof Error ? e.message : 'Delete failed');
|
||||
}
|
||||
}}
|
||||
>
|
||||
Delete
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<span className="muted small">No material uploaded yet.</span>
|
||||
)}
|
||||
<MaterialPanel
|
||||
session={session}
|
||||
unlocksAt={slot ? `${fmtDate(slot.slot_date)}, ${fmtTime(slot.end_time)}` : null}
|
||||
onChanged={() => onSaved('Material removed')}
|
||||
/>
|
||||
<input
|
||||
className="input"
|
||||
type="file"
|
||||
@@ -650,14 +590,6 @@ function SessionModal({
|
||||
{session.material_path ? 'Replaces current file on Save' : 'Uploads on Save'}: {material.name}
|
||||
</span>
|
||||
)}
|
||||
{slot && (
|
||||
<span className="muted small">
|
||||
{session.material_path
|
||||
? `Attendees can download it once the session ends (${fmtDate(slot.slot_date)}, ${fmtTime(slot.end_time)}).`
|
||||
: `Once uploaded, attendees can download it when the session ends (${fmtDate(slot.slot_date)}, ${fmtTime(slot.end_time)}).`}
|
||||
</span>
|
||||
)}
|
||||
{matError && <span className="feedback-error small">{matError}</span>}
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
Reference in new issue
Block a user