Files
Convivo/apps/convivo/src/screens/EventFeedback.tsx
T
0b6d1f2b6f Post-event reporting + talk networking incentives
- Talk networking: per-event talk_networking_bonus awarded when two people
  who shared a checked-in talk accept a connection (accept_connection
  re-created, shared_talk flag, get_talk_cohort RPC, points_log category
  check widened); Convivo Networking sub-tab inside the Connect screen
  (Home quick action deep-links in; Connect button reflects existing
  connection state and is disabled for sent/connected/declined); admin
  Events view bonus input (0-10).
- Reports: sidecar POST /export (CSV / multi-sheet XLSX / PDF report via
  new pdfkit dep); APPE Admin Reports view (any event: on-screen summary,
  session feedback summary, top-5, CSV/Excel/PDF downloads); Activity
  session-feedback per-session aggregate header.
- Also carried: @appe.at admin trigger + default password, bulk contact
  delete, session level/area + event-level feedback, agenda level/area
  filters, admin password self-service, schedule level/area fields.
- 18/18 RPC tests; both apps build; exports verified end-to-end.

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]>
2026-09-21 22:34:25 +02:00

122 lines
3.7 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { useEffect, useState } from 'react';
import { useAuth } from '../context/AuthContext';
import { useEvent } from '../lib/useEvent';
import { getMyEventFeedback, submitEventFeedback } from '../lib/api';
import { Spinner } from '../components/ui';
import { useToast } from '../context/ToastContext';
/**
* Event-level feedback (distinct from the per-session Feedback screen).
* Any registered participant can rate the event overall (1–5) + leave a
* comment. Idempotent: one row per (event, contact) — re-submitting updates
* the existing row.
*/
export function EventFeedback({ onDone }: { onDone: () => void }) {
const { contact } = useAuth();
const { event, loading } = useEvent();
const [rating, setRating] = useState(0);
const [comment, setComment] = useState('');
const [busy, setBusy] = useState(false);
const [submitted, setSubmitted] = useState(false);
const { toast } = useToast();
// Pre-fill with the user's existing event feedback (if any).
useEffect(() => {
let active = true;
(async () => {
try {
const existing = await getMyEventFeedback();
if (!active || !existing) return;
setRating(existing.rating);
setComment(existing.comment ?? '');
setSubmitted(true);
} catch {
/* non-fatal */
}
})();
return () => {
active = false;
};
}, []);
if (loading || !event) {
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 {
await submitEventFeedback(rating, comment.trim());
toast('Thanks for your feedback! ⭐', 'ok');
setSubmitted(true);
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 event</div>
</div>
<span style={{ width: 60 }} />
</div>
<div className="card" style={{ textAlign: 'center' }}>
<div className="h2">{event.name}</div>
<div className="muted small" style={{ marginTop: 4 }}>
{event.location ? `${event.location} · ` : ''}
{event.start_date}
</div>
</div>
<div className="stars" style={{ justifyContent: 'center', margin: '20px 0' }}>
{[1, 2, 3, 4, 5].map((n) => (
<button
key={n}
data-testid={`event-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="event-feedback-comment"
placeholder="Share your thoughts about the event (optional)"
value={comment}
onChange={(e) => setComment(e.target.value)}
rows={4}
/>
<button
className="btn primary"
data-testid="event-feedback-submit"
disabled={busy || rating === 0}
onClick={submit}
>
{busy ? 'Submitting…' : submitted ? 'Update feedback' : 'Submit feedback'}
</button>
<div className="muted small" style={{ textAlign: 'center', marginTop: 8 }}>
{contact ? `Signing in as ${contact.full_name}` : ''}
</div>
</section>
);
}