- e2e/: full Playwright suite covering every spec case (staff auth/UI, welcome + session check-in, attendee access/gating, connections, profile visibility, speaker material, sponsor, feedback, E2E journeys, role security matrix). 46/46 passing. - apps/convivo: add data-testid attributes (gate, tabs, scanner, toggles) to support the E2E suite. - test_cases.md: spec-case-to-test coverage map (all cases fully covered). - .gitignore: ignore e2e node_modules/reports/test-results.
89 lines
2.8 KiB
TypeScript
89 lines
2.8 KiB
TypeScript
import { useState } from 'react';
|
|
import { useAuth } from '../context/AuthContext';
|
|
import { useEvent } from '../lib/useEvent';
|
|
import { submitFeedback } from '../lib/api';
|
|
import { Spinner } from '../components/ui';
|
|
import { useToast } from '../context/ToastContext';
|
|
|
|
export function Feedback({ sessionId, onDone }: { sessionId: string; onDone: () => void }) {
|
|
const { contact } = useAuth();
|
|
const { sessionById, loading } = useEvent();
|
|
const [rating, setRating] = useState(0);
|
|
const [comment, setComment] = useState('');
|
|
const [busy, setBusy] = useState(false);
|
|
const { toast } = useToast();
|
|
|
|
const session = sessionById.get(sessionId);
|
|
|
|
if (loading || !session) {
|
|
return (
|
|
<section className="screen no-tab">
|
|
<div className="center" style={{ flex: 1 }}>
|
|
<Spinner />
|
|
</div>
|
|
</section>
|
|
);
|
|
}
|
|
|
|
async function submit() {
|
|
if (rating === 0) return;
|
|
setBusy(true);
|
|
try {
|
|
const res = await submitFeedback(sessionId, rating, comment.trim());
|
|
toast(`Thanks! +${res.earned} pts ⭐`, 'ok');
|
|
onDone();
|
|
} catch (e) {
|
|
toast(e instanceof Error ? e.message : 'Could not submit feedback', 'err');
|
|
} finally {
|
|
setBusy(false);
|
|
}
|
|
}
|
|
|
|
return (
|
|
<section className="screen no-tab">
|
|
<div className="row" style={{ marginBottom: 14 }}>
|
|
<button className="btn ghost small" onClick={onDone}>← Back</button>
|
|
<div className="grow" style={{ textAlign: 'center' }}>
|
|
<div className="h2">Rate this session</div>
|
|
</div>
|
|
<span style={{ width: 60 }} />
|
|
</div>
|
|
|
|
<div className="card" style={{ textAlign: 'center' }}>
|
|
<div className="h2">{session.title}</div>
|
|
<div className="muted small" style={{ marginTop: 4 }}>{session.room} · {session.speakers}</div>
|
|
</div>
|
|
|
|
<div className="stars" style={{ justifyContent: 'center', margin: '20px 0' }}>
|
|
{[1, 2, 3, 4, 5].map((n) => (
|
|
<button
|
|
key={n}
|
|
data-testid={`feedback-star-${n}`}
|
|
className={`star ${n <= rating ? 'on' : ''}`}
|
|
onClick={() => setRating(n)}
|
|
aria-label={`${n} star${n > 1 ? 's' : ''}`}
|
|
>
|
|
★
|
|
</button>
|
|
))}
|
|
</div>
|
|
|
|
<textarea
|
|
className="input"
|
|
data-testid="feedback-comment"
|
|
placeholder="Add a comment (optional) — comments earn bonus points"
|
|
value={comment}
|
|
onChange={(e) => setComment(e.target.value)}
|
|
rows={4}
|
|
/>
|
|
|
|
<button className="btn primary" data-testid="feedback-submit" disabled={busy || rating === 0} onClick={submit}>
|
|
{busy ? 'Submitting…' : 'Submit feedback'}
|
|
</button>
|
|
<div className="muted small" style={{ textAlign: 'center', marginTop: 8 }}>
|
|
{contact ? `Signing in as ${contact.full_name}` : ''}
|
|
</div>
|
|
</section>
|
|
);
|
|
}
|