feat: add admin raffle with confetti and top-3/staff exclusion

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:
committed 2026-10-15 21:39:57 +02:00
1 parent 4cf09cd739
commit 4ec03410ff
14 files changed
+680 -2

No files matched your search

+27
View File
@@ -14,6 +14,8 @@ import type {
PointsLogRow,
PretixOptions,
PretixSyncResult,
RafflePoolEntry,
RaffleWinner,
Registration,
ResetQrResult,
Session,
@@ -349,6 +351,31 @@ export async function adjustPoints(contactEmail: string, delta: number, reason:
await rpc('adjust_points', { p_contact_email: contactEmail, p_delta: delta, p_reason: reason });
}
// ---- Raffle ------------------------------------------------------------------
/** Eligible attendees for the active event: excludes staff/Admin, the
* leaderboard top 3, and everyone already drawn in the current run. */
export async function getRafflePool(): Promise<RafflePoolEntry[]> {
return rpc<RafflePoolEntry[]>('get_raffle_pool', {});
}
/** Winners already drawn in the current run (oldest first). */
export async function getRaffleWinners(): Promise<RaffleWinner[]> {
return all<RaffleWinner>('raffle_draws', { col: 'draw_number' });
}
/** Draw one random eligible attendee and record them as the next winner. */
export async function drawRaffleWinner(): Promise<RaffleWinner> {
const rows = await rpc<Omit<RaffleWinner, 'drawn_at'>[]>('draw_raffle_winner', {});
if (!rows[0]) throw new ApiError('No eligible attendees left to draw');
return { ...rows[0], drawn_at: new Date().toISOString() };
}
/** Clear the current run's winners so a new run can begin. */
export async function resetRaffle(): Promise<void> {
await rpc('reset_raffle', {});
}
// ---- Sessions: speakers, material, AI feedback -------------------------------
export async function setSessionSpeakers(sessionId: string, emails: string[]): Promise<void> {
+13
View File
@@ -330,3 +330,16 @@ export interface ResetQrResult {
email: string;
qr_token: string;
}
/** An eligible attendee returned by `get_raffle_pool` (admin raffle). */
export interface RafflePoolEntry {
contact_email: string;
full_name: string;
points: number;
}
/** A winner recorded by `draw_raffle_winner` / read from `raffle_draws`. */
export interface RaffleWinner extends RafflePoolEntry {
draw_number: number;
drawn_at: string;
}