feat: add admin raffle with confetti and top-3/staff exclusion
This commit is contained in:
1 parent
5117a25372
commit
3e2f8ff0ed
14 files changed
+680
-2
No files matched your search
@@ -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> {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
Reference in new issue
Block a user