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
|
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) {
|
function formatDateTime(value: string | null) {
|
||||||
if (!value) return null;
|
if (!value) return null;
|
||||||
const date = new Date(value);
|
const date = new Date(value);
|
||||||
|
|
@ -500,11 +516,13 @@
|
||||||
</p>
|
</p>
|
||||||
{:else}
|
{:else}
|
||||||
<div class="mt-6 space-y-5">
|
<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">
|
<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">
|
<header class="flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between">
|
||||||
<div>
|
<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">
|
<p class="text-xs tracking-wide text-slate-500 uppercase">
|
||||||
Skapad {formatDateTime(registration.created_at) ?? registration.created_at}
|
Skapad {formatDateTime(registration.created_at) ?? registration.created_at}
|
||||||
</p>
|
</p>
|
||||||
|
|
@ -693,19 +711,12 @@
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<section class="space-y-2">
|
{#if participantFields().length > 0}
|
||||||
<h4 class="text-sm font-semibold text-slate-800">Spelare</h4>
|
<section class="space-y-2">
|
||||||
{#if participantFields().length === 0}
|
<h4 class="text-sm font-semibold text-slate-800">Spelare</h4>
|
||||||
{#if registration.participants.length === 0}
|
{#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>
|
<p class="text-xs text-slate-500">Inga spelare angivna.</p>
|
||||||
{:else}
|
{:else}
|
||||||
<div class="space-y-3">
|
<div class="space-y-3">
|
||||||
{#each registration.participants as participant, index}
|
{#each registration.participants as participant, index}
|
||||||
<div class="rounded-md border border-slate-200 bg-white p-3">
|
<div class="rounded-md border border-slate-200 bg-white p-3">
|
||||||
|
|
@ -723,8 +734,9 @@
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</section>
|
</section>
|
||||||
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
</article>
|
</article>
|
||||||
{/each}
|
{/each}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue