Redesign Phases 3-6: multi-event model, APPE Admin, Convivo App behaviors, APPE branding
- Phase 3: new migration 20260824000000_redesign.sql (contacts/events/registrations/sponsors, slot types, session speakers + feedback/material), seed rewrite - Phase 4: APPE Admin rebrand + Contacts/Registrations/Sponsors/Schedule/Activity/Events views - Phase 5: Convivo App (24h login, 5s polling, QR type badge, red dot, speaker material) - Phase 6: APPE favicon + PWA icons for both apps - Docs: schema/rpcs/rls/seed/screens/api-client/admin-app/architecture/next-steps/README/roadmap updated
This commit is contained in:
1 parent
5adb5785aa
commit
22f5f1d317
64 files changed
+4593
-1371
No files matched your search
@@ -1,41 +1,21 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useState } from 'react';
|
||||
import { useAuth } from '../context/AuthContext';
|
||||
import { useEvent } from '../lib/useEvent';
|
||||
import { getMyFeedback, submitFeedback } from '../lib/api';
|
||||
import { fmtRange } from '../lib/time';
|
||||
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 { refreshProfile } = useAuth();
|
||||
const { sessionById, slotById, loading } = useEvent();
|
||||
const { contact } = useAuth();
|
||||
const { sessionById, loading } = useEvent();
|
||||
const [rating, setRating] = useState(0);
|
||||
const [comment, setComment] = useState('');
|
||||
const [existing, setExisting] = useState<{ rating: number; comment: string | null } | null>(null);
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [done, setDone] = useState<{ earned: number } | null>(null);
|
||||
const { toast } = useToast();
|
||||
|
||||
const session = sessionById.get(sessionId);
|
||||
const slot = session ? slotById.get(session.slot_id) : undefined;
|
||||
|
||||
useEffect(() => {
|
||||
let active = true;
|
||||
(async () => {
|
||||
try {
|
||||
const fb = await getMyFeedback();
|
||||
const mine = fb.find((f) => f.session_id === sessionId);
|
||||
if (active && mine) setExisting({ rating: mine.rating, comment: mine.comment });
|
||||
} catch {
|
||||
/* non-fatal */
|
||||
}
|
||||
})();
|
||||
return () => {
|
||||
active = false;
|
||||
};
|
||||
}, [sessionId]);
|
||||
|
||||
if (loading || !session || !slot) {
|
||||
if (loading || !session) {
|
||||
return (
|
||||
<section className="screen no-tab">
|
||||
<div className="center" style={{ flex: 1 }}>
|
||||
@@ -46,12 +26,12 @@ export function Feedback({ sessionId, onDone }: { sessionId: string; onDone: ()
|
||||
}
|
||||
|
||||
async function submit() {
|
||||
if (rating < 1) return;
|
||||
if (rating === 0) return;
|
||||
setBusy(true);
|
||||
try {
|
||||
const res = await submitFeedback(sessionId, rating, comment.trim());
|
||||
await refreshProfile();
|
||||
setDone({ earned: res.earned });
|
||||
toast(`Thanks! +${res.earned} pts ⭐`, 'ok');
|
||||
onDone();
|
||||
} catch (e) {
|
||||
toast(e instanceof Error ? e.message : 'Could not submit feedback', 'err');
|
||||
} finally {
|
||||
@@ -59,47 +39,48 @@ export function Feedback({ sessionId, onDone }: { sessionId: string; onDone: ()
|
||||
}
|
||||
}
|
||||
|
||||
if (done) {
|
||||
return (
|
||||
<section className="screen no-tab">
|
||||
<div className="card success-box">
|
||||
<div className="emoji">🎉</div>
|
||||
<h3>{done.earned > 0 ? `+${done.earned} pts earned!` : 'Feedback updated!'}</h3>
|
||||
<p>Thanks for the feedback — it helps everyone pick better sessions.</p>
|
||||
<button className="btn primary" style={{ marginTop: 20 }} onClick={onDone}>Back to Home</button>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<section className="screen no-tab">
|
||||
<button className="btn ghost small" style={{ alignSelf: 'flex-start' }} onClick={onDone}>← Back</button>
|
||||
<div className="card" style={{ textAlign: 'center' }}>
|
||||
<div className="muted small">{slot.name} · {fmtRange(slot)} · {session.room}</div>
|
||||
<div className="h2" style={{ marginTop: 4 }}>{session.title}</div>
|
||||
<div className="h1" style={{ marginTop: 18, fontSize: 22 }}>How was it? ⭐</div>
|
||||
<div className="stars">
|
||||
{[1, 2, 3, 4, 5].map((n) => (
|
||||
<button key={n} className={`star ${rating >= n ? 'on' : ''}`} onClick={() => setRating(n)}>★</button>
|
||||
))}
|
||||
</div>
|
||||
<div className="muted small" style={{ marginBottom: 10 }}>
|
||||
{rating > 0 ? `${rating} star${rating > 1 ? 's' : ''}` : 'Tap a star'}
|
||||
</div>
|
||||
<textarea
|
||||
className="input"
|
||||
placeholder="What did you think? (bonus points for details)"
|
||||
value={comment}
|
||||
onChange={(e) => setComment(e.target.value)}
|
||||
/>
|
||||
<div className="muted small" style={{ marginTop: 10, textAlign: 'center' }}>
|
||||
Rating: <b>+5 pts</b> · With comments: <b>+10 pts</b>
|
||||
<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>
|
||||
<button className="btn primary" disabled={busy || rating < 1} onClick={submit}>
|
||||
{busy ? 'Submitting…' : existing ? 'Update feedback' : 'Submit feedback'}
|
||||
|
||||
<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}
|
||||
className={`star ${n <= rating ? 'on' : ''}`}
|
||||
onClick={() => setRating(n)}
|
||||
aria-label={`${n} star${n > 1 ? 's' : ''}`}
|
||||
>
|
||||
★
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<textarea
|
||||
className="input"
|
||||
placeholder="Add a comment (optional) — comments earn bonus points"
|
||||
value={comment}
|
||||
onChange={(e) => setComment(e.target.value)}
|
||||
rows={4}
|
||||
/>
|
||||
|
||||
<button className="btn primary" 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>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user