This commit is contained in:
pavel 2026-04-08 21:42:09 +02:00
commit b918b92a4d
6 changed files with 702 additions and 0 deletions

View file

@ -140,6 +140,94 @@
</section>
{{ end }}
{{ define "lottery" }}
{{ $page := .Data }}
<section class="stack-section">
<div class="page-grid lottery-grid">
<div class="card lottery-hero">
<p class="eyebrow">Hourly pool</p>
<h1 class="lottery-title">Deposit into the pool and wait for the next draw.</h1>
<p class="lede">Each deposit joins the active round. When the draw deadline passes, the full pool is credited to one randomly selected ticket holder.</p>
<div class="lottery-stat-row">
<article class="lottery-stat">
<span>Your balance</span>
<strong>{{ money $page.User.BalanceMinor }}</strong>
</article>
<article class="lottery-stat">
<span>Current pool</span>
<strong>{{ if $page.Lottery.ActiveRound }}{{ money $page.Lottery.ActiveRound.PoolMinor }}{{ else }}0,00 CZK{{ end }}</strong>
</article>
</div>
{{ if $page.LastPayout }}
<div class="lottery-banner">
Latest draw paid <strong>{{ money $page.LastPayout.PoolMinor }}</strong> to <strong>{{ $page.LastPayout.WinnerUsername }}</strong>.
</div>
{{ end }}
</div>
<div class="card">
<h2>Join the round</h2>
<form method="post" action="/app/lottery/deposit" class="stack-form">
<input type="hidden" name="csrf_token" value="{{ $.CSRFToken }}">
<label>Amount in CZK<input type="text" name="amount" placeholder="100,00" required></label>
<button class="button primary" type="submit">Deposit to lottery</button>
</form>
<p class="muted lottery-note">Each deposit creates one ticket. More deposits mean more chances in the same hourly round.</p>
</div>
</div>
<div class="page-grid lottery-grid">
<div class="card">
<h2>Active round</h2>
{{ if $page.Lottery.ActiveRound }}
<dl class="stats-grid lottery-stats-grid">
<div>
<dt>Draw at</dt>
<dd>{{ dt $page.Lottery.ActiveRound.DrawAt }}</dd>
</div>
<div>
<dt>Participants</dt>
<dd>{{ $page.Lottery.ActiveRound.ParticipantCount }}</dd>
</div>
<div>
<dt>Total tickets</dt>
<dd>{{ $page.Lottery.ActiveRound.TicketCount }}</dd>
</div>
<div>
<dt>Your tickets</dt>
<dd>{{ $page.Lottery.ActiveRound.UserTicketCount }}</dd>
</div>
</dl>
<p class="meta-line">Your current contribution: <strong>{{ money $page.Lottery.ActiveRound.UserContributionMinor }}</strong></p>
{{ else }}
<p class="muted">No active round yet. The first deposit starts the next one-hour lottery window.</p>
{{ end }}
</div>
<div class="card">
<h2>Recent winners</h2>
<div class="table-wrap">
<table class="table">
<thead><tr><th>When</th><th>Winner</th><th>Pool</th><th>Tickets</th></tr></thead>
<tbody>
{{ range $page.Lottery.RecentPayouts }}
<tr>
<td>{{ dt .CompletedAt }}</td>
<td>{{ .WinnerUsername }}<div class="subtle">{{ .WinnerAccount }}</div></td>
<td>{{ money .PoolMinor }}</td>
<td>{{ .TicketCount }}</td>
</tr>
{{ else }}
<tr><td colspan="4" class="muted">No lottery winners yet.</td></tr>
{{ end }}
</tbody>
</table>
</div>
</div>
</div>
</section>
{{ end }}
{{ define "admin_dashboard" }}
{{ $page := .Data }}
<section class="stack-section">