**Untested! ** Add restore functionality for archived messages

- Added `RestoreMessageHandler` and route at `/account/messages/restore`
- Updated `users_messages` table to support `archived_at` reset
- Added restore button to archived messages template
- Ensures archived messages can be moved back into inbox
This commit is contained in:
2025-04-02 23:53:29 +01:00
parent db5352bc9c
commit 053ccf3845
13 changed files with 756 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
{{ define "content" }}
<div class="container py-5">
<h2>Your Syndicates</h2>
{{ if .ManagedSyndicates }}
<h4 class="mt-4">Managed</h4>
<ul class="list-group mb-3">
{{ range .ManagedSyndicates }}
<li class="list-group-item d-flex justify-content-between align-items-center">
<div>
<strong>{{ .Name }}</strong><br>
<small class="text-muted">{{ .Description }}</small>
</div>
<a href="/account/syndicates/view?id={{ .ID }}" class="btn btn-outline-primary btn-sm">Manage</a>
</li>
{{ end }}
</ul>
{{ end }}
{{ if .JoinedSyndicates }}
<h4 class="mt-4">Member</h4>
<ul class="list-group mb-3">
{{ range .JoinedSyndicates }}
<li class="list-group-item d-flex justify-content-between align-items-center">
<div>
<strong>{{ .Name }}</strong><br>
<small class="text-muted">{{ .Description }}</small>
</div>
<a href="/account/syndicates/view?id={{ .ID }}" class="btn btn-outline-secondary btn-sm">View</a>
</li>
{{ end }}
</ul>
{{ end }}
{{ if not .ManagedSyndicates | and (not .JoinedSyndicates) }}
<div class="alert alert-info">You are not part of any syndicates yet.</div>
{{ end }}
<a href="/account/syndicates/create" class="btn btn-primary mt-3">Create New Syndicate</a>
</div>
{{ end }}

View File

@@ -0,0 +1,18 @@
{{ define "content" }}
<div class="container py-5">
<h2>Invite Member to "{{ .Syndicate.Name }}"</h2>
{{ if .Flash }}
<div class="alert alert-info">{{ .Flash }}</div>
{{ end }}
<form method="POST">
{{ .CSRFField }}
<div class="mb-3">
<label for="username" class="form-label">Username to Invite</label>
<input type="text" class="form-control" id="username" name="username" required>
</div>
<button type="submit" class="btn btn-primary">Send Invite</button>
<a href="/account/syndicates/view?id={{ .Syndicate.ID }}" class="btn btn-secondary ms-2">Cancel</a>
</form>
</div>
{{ end }}

View File

@@ -0,0 +1,34 @@
{{ define "content" }}
<div class="container py-5">
<h2>Add Ticket for {{ .Syndicate.Name }}</h2>
<form method="POST">
{{ .CSRFField }}
<div class="mb-3">
<label for="game_type" class="form-label">Game Type</label>
<select class="form-select" id="game_type" name="game_type" required>
<option value="Thunderball">Thunderball</option>
<option value="Lotto">Lotto</option>
<!-- Add more as needed -->
</select>
</div>
<div class="mb-3">
<label for="draw_date" class="form-label">Draw Date</label>
<input type="date" class="form-control" id="draw_date" name="draw_date" required>
</div>
<div class="mb-3">
<label for="purchase_method" class="form-label">Purchase Method</label>
<input type="text" class="form-control" id="purchase_method" name="purchase_method">
</div>
<!-- Ball Inputs -->
{{ template "ballInputs" . }}
<button type="submit" class="btn btn-success">Submit Ticket</button>
<a href="/account/syndicates/view?id={{ .Syndicate.ID }}" class="btn btn-secondary ms-2">Cancel</a>
</form>
</div>
{{ end }}

View File

@@ -0,0 +1,42 @@
{{ define "content" }}
<div class="container py-4">
<h2>Syndicate Tickets</h2>
{{ if .Tickets }}
<table class="table table-striped">
<thead>
<tr>
<th>Game</th>
<th>Draw Date</th>
<th>Numbers</th>
<th>Matched</th>
<th>Prize</th>
</tr>
</thead>
<tbody>
{{ range .Tickets }}
<tr>
<td>{{ .GameType }}</td>
<td>{{ .DrawDate }}</td>
<td>
{{ .Ball1 }} {{ .Ball2 }} {{ .Ball3 }} {{ .Ball4 }} {{ .Ball5 }} {{ .Ball6 }}
{{ if .Bonus1 }}+{{ .Bonus1 }}{{ end }}
{{ if .Bonus2 }} {{ .Bonus2 }}{{ end }}
</td>
<td>{{ .MatchedMain }} + {{ .MatchedBonus }}</td>
<td>
{{ if .IsWinner }}
💷 {{ .PrizeLabel }}
{{ else }}
<span class="text-muted"></span>
{{ end }}
</td>
</tr>
{{ end }}
</tbody>
</table>
{{ else }}
<div class="alert alert-info">No tickets found for this syndicate.</div>
{{ end }}
</div>
{{ end }}

View File

@@ -0,0 +1,28 @@
{{ define "content" }}
<div class="container py-5">
<h2>{{ .Syndicate.Name }}</h2>
<p class="text-muted">{{ .Syndicate.Description }}</p>
<hr>
<h4>Members</h4>
<ul class="list-group mb-3">
{{ range .Members }}
<li class="list-group-item d-flex justify-content-between align-items-center">
<span>{{ .Username }}</span>
<small class="text-muted">Joined: {{ .JoinedAt.Format "02 Jan 2006" }}</small>
</li>
{{ end }}
</ul>
{{ if .IsManager }}
<div class="alert alert-warning">
<strong>Manager Controls</strong><br>
You can add or remove members, and manage tickets.
</div>
<a href="/account/syndicates/invite?id={{ .Syndicate.ID }}" class="btn btn-outline-primary">Invite Members</a>
{{ end }}
<a href="/account/syndicates" class="btn btn-secondary mt-3">← Back to Syndicates</a>
</div>
{{ end }}