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

This commit is contained in:
Lago committed 2026-10-15 21:39:57 +02:00
1 parent 5117a25372
commit 3e2f8ff0ed
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> {