You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123 lines
3.9 KiB

package templates
import "track-gopher/models"
import "fmt"
import "math"
// Public version of the final results page - no navigation, no group selection
templ FinalResultsPublic(results []models.FinalResult, groupName string, revealCount int) {
@LayoutPublic("Final Results") {
<div class="container mt-2">
<div class="text-center mb-2">
<h1 class="display-3">Final Results</h1>
<h2 class="text-primary display-4" hx-ext="sse" sse-connect="/api/admin/events" sse-swap="group-name">{ groupName }</h2>
</div>
<div class="card">
<div class="card-header bg-primary text-white">
<h3 class="mb-0 display-3">Final Standings</h3>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-striped table-hover">
<thead>
<tr>
<th class="display-5">Place</th>
<th class="display-5">Racer</th>
<th class="display-5">Car #</th>
// <th class="display-5">Times</th>
<th class="display-5">Final Time</th>
</tr>
</thead>
<tbody id="results-body" hx-ext="sse" sse-connect="/api/admin/events" sse-swap="results-reveal">
</tbody>
</table>
</div>
</div>
<div class="card-footer">
<small class="text-muted">Final time is the average of the fastest 3 times (discarding the slowest time if 4 runs completed)</small>
</div>
</div>
</div>
<style>
.reveal-animation {
animation: fadeIn 1s;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(20px); }
to { opacity: 1; transform: translateY(0); }
}
</style>
}
}
templ FinalResultsTable(results []models.FinalResult) {
for _, result := range results {
<tr class="reveal-animation">
<td class="display-5">{ fmt.Sprintf("%d", result.Place) }</td>
<td class="display-5">{ result.Racer.FirstName } { result.Racer.LastName }</td>
<td class="display-5">{ result.Racer.CarNumber }</td>
/* <td class="display-5">
<small>
for i, time := range result.Times {
if i > 0 {
,
}
if time >= 9.999 {
DNF
} else {
{ fmt.Sprintf("%.3f", time) }
}
}
</small>
</td>
*/ <td class="display-5">
if result.DNF {
<span class="text-danger">DNF</span>
} else {
<strong>{ fmt.Sprintf("%.3f - %.0f MPH", result.AverageTime, math.Round(416/result.AverageTime/17.6)) }</strong>
}
</td>
</tr>
}
}
// Admin version with group selection - kept for admin use
templ FinalResultsPage(groups []models.Group, selectedGroupID int64, results []models.FinalResult, selectedGroupName string) {
@Layout("Final Results") {
<div class="container mt-4">
<h1 class="mb-4">Final Results</h1>
<div class="row mb-4">
<div class="col-md-6">
<div class="card">
<div class="card-header">
<h5 class="mb-0">Select Group</h5>
</div>
<div class="card-body">
<form id="group-select-form" method="get" action="/results">
<div class="mb-3">
<label for="group_id" class="form-label">Racing Group</label>
<select class="form-select" id="group_id" name="group_id" onchange="this.form.submit()">
<option value="">Select a group...</option>
for _, group := range groups {
<option value={ fmt.Sprintf("%d", group.ID) } selected?={ group.ID == selectedGroupID }>
{ group.Name }
</option>
}
</select>
</div>
</form>
</div>
</div>
</div>
</div>
if selectedGroupID > 0 {
@FinalResults(results, selectedGroupName)
}
</div>
}
}