fixing administration of turnaments
This commit is contained in:
parent
bfd4aa10fb
commit
619b51e990
1 changed files with 27 additions and 15 deletions
|
|
@ -107,6 +107,22 @@
|
|||
signupConfig().mode === 'team' ? Math.max(1, signupConfig().team_size.max) : 0
|
||||
);
|
||||
|
||||
function registrationHeading(registration: TournamentRegistrationItem) {
|
||||
const entry = registration.entry ?? {};
|
||||
for (const field of entryFields()) {
|
||||
if (isAttendanceField(field)) continue;
|
||||
const value = entry[field.id];
|
||||
if (value && value.trim()) {
|
||||
return value.trim();
|
||||
}
|
||||
}
|
||||
const attendanceValue = entry[ATTENDANCE_FIELD_ID];
|
||||
if (attendanceValue && attendanceValue.trim()) {
|
||||
return `Anmälan för ID ${attendanceValue.trim()}`;
|
||||
}
|
||||
return 'Anmälan';
|
||||
}
|
||||
|
||||
function formatDateTime(value: string | null) {
|
||||
if (!value) return null;
|
||||
const date = new Date(value);
|
||||
|
|
@ -500,11 +516,13 @@
|
|||
</p>
|
||||
{:else}
|
||||
<div class="mt-6 space-y-5">
|
||||
{#each registrations as registration}
|
||||
{#each registrations as registration}
|
||||
<article class="space-y-4 rounded-lg border border-slate-200 bg-slate-50 p-4">
|
||||
<header class="flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between">
|
||||
<div>
|
||||
<h3 class="text-base font-semibold text-slate-900">Anmälan #{registration.id}</h3>
|
||||
<h3 class="text-base font-semibold text-slate-900">
|
||||
{registrationHeading(registration)}
|
||||
</h3>
|
||||
<p class="text-xs tracking-wide text-slate-500 uppercase">
|
||||
Skapad {formatDateTime(registration.created_at) ?? registration.created_at}
|
||||
</p>
|
||||
|
|
@ -693,19 +711,12 @@
|
|||
</div>
|
||||
{/if}
|
||||
|
||||
<section class="space-y-2">
|
||||
<h4 class="text-sm font-semibold text-slate-800">Spelare</h4>
|
||||
{#if participantFields().length === 0}
|
||||
{#if participantFields().length > 0}
|
||||
<section class="space-y-2">
|
||||
<h4 class="text-sm font-semibold text-slate-800">Spelare</h4>
|
||||
{#if registration.participants.length === 0}
|
||||
<p class="text-xs text-slate-500">Inga spelare angivna.</p>
|
||||
{:else}
|
||||
<p class="text-xs text-slate-500">
|
||||
Antal spelare: {registration.participants.length}
|
||||
</p>
|
||||
{/if}
|
||||
{:else if registration.participants.length === 0}
|
||||
<p class="text-xs text-slate-500">Inga spelare angivna.</p>
|
||||
{:else}
|
||||
{:else}
|
||||
<div class="space-y-3">
|
||||
{#each registration.participants as participant, index}
|
||||
<div class="rounded-md border border-slate-200 bg-white p-3">
|
||||
|
|
@ -723,8 +734,9 @@
|
|||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
</section>
|
||||
{/if}
|
||||
</section>
|
||||
{/if}
|
||||
{/if}
|
||||
</article>
|
||||
{/each}
|
||||
|
|
|
|||
Loading…
Reference in a new issue