[web] Contest team logins

This commit is contained in:
orosmatthew 2023-05-08 14:54:00 -04:00
parent 19f49089e8
commit 4971fb4851
4 changed files with 54 additions and 0 deletions

View File

@ -1,5 +1,6 @@
<script lang="ts"> <script lang="ts">
import { enhance } from '$app/forms'; import { enhance } from '$app/forms';
import { page } from '$app/stores';
import type { Actions, PageData } from './$types'; import type { Actions, PageData } from './$types';
export let data: PageData; export let data: PageData;
@ -50,6 +51,7 @@
<div class="mt-3 row"> <div class="mt-3 row">
<div class="col-6"> <div class="col-6">
<h4>Teams</h4> <h4>Teams</h4>
<a href={`${$page.url}/logins`} class="mb-2 btn btn-outline-secondary">Printable Logins</a>
<div class="list-group"> <div class="list-group">
{#each data.teams as team} {#each data.teams as team}
<a href={`/admin/teams/${team.id}`} class="list-group-item list-group-item-action" <a href={`/admin/teams/${team.id}`} class="list-group-item list-group-item-action"

View File

@ -0,0 +1,31 @@
import { redirect } from '@sveltejs/kit';
import type { PageServerLoad } from './$types';
import { db } from '$lib/server/prisma';
export const load = (async ({ params }) => {
if (!params.contestId) {
throw redirect(302, '/admin/contests');
}
const contestId = parseInt(params.contestId);
if (isNaN(contestId)) {
throw redirect(302, '/admin/contests');
}
const contest = await db.contest.findUnique({
where: { id: contestId },
include: { teams: true }
});
if (!contest) {
throw redirect(302, '/admin/contests');
}
return {
teams: contest.teams.map((team) => {
return {
id: team.id,
name: team.name,
password: team.password
};
})
};
}) satisfies PageServerLoad;

View File

@ -0,0 +1,20 @@
<script lang="ts">
import type { PageData } from './$types';
export let data: PageData;
</script>
{#each data.teams as team}
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>ID</th>
<th>Team Name</th>
<th>Password</th></tr
>
</thead>
<tbody>
<tr><td>{team.id}</td><td>{team.name}</td><td>{team.password}</td></tr>
</tbody>
</table>
{/each}

View File

@ -0,0 +1 @@
export const csr = false;