removing Player field thats specific for teams from indidiual turnaments
This commit is contained in:
parent
535c285a33
commit
06ba7fe85a
1 changed files with 90 additions and 80 deletions
|
|
@ -57,6 +57,7 @@
|
||||||
type FieldValueMap = Record<string, string>;
|
type FieldValueMap = Record<string, string>;
|
||||||
|
|
||||||
const signupConfig = normalizeSignupConfig(tournament.signup_config);
|
const signupConfig = normalizeSignupConfig(tournament.signup_config);
|
||||||
|
const entrySectionTitle = signupConfig.mode === 'team' ? 'Lag' : 'Spelare';
|
||||||
|
|
||||||
function formatDateTime(value: string | null) {
|
function formatDateTime(value: string | null) {
|
||||||
if (!value) return null;
|
if (!value) return null;
|
||||||
|
|
@ -348,7 +349,7 @@
|
||||||
{#if signupConfig.entry_fields.length > 0}
|
{#if signupConfig.entry_fields.length > 0}
|
||||||
<div class="space-y-3">
|
<div class="space-y-3">
|
||||||
<h3 class="text-sm font-semibold tracking-wide text-slate-400 uppercase">
|
<h3 class="text-sm font-semibold tracking-wide text-slate-400 uppercase">
|
||||||
Lag / deltagare
|
{entrySectionTitle}
|
||||||
</h3>
|
</h3>
|
||||||
<div class="grid gap-3 md:grid-cols-2">
|
<div class="grid gap-3 md:grid-cols-2">
|
||||||
{#each signupConfig.entry_fields as field}
|
{#each signupConfig.entry_fields as field}
|
||||||
|
|
@ -468,38 +469,42 @@
|
||||||
{/if}
|
{/if}
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class="space-y-3">
|
{#if signupConfig.mode === 'team'}
|
||||||
<h3 class="text-base font-semibold text-slate-100">Spelare</h3>
|
<section class="space-y-3">
|
||||||
{#if signupConfig.participant_fields.length === 0}
|
<h3 class="text-base font-semibold text-slate-100">Spelare</h3>
|
||||||
{#if signup.submittedParticipants.length === 0}
|
{#if signupConfig.participant_fields.length === 0}
|
||||||
|
{#if signup.submittedParticipants.length === 0}
|
||||||
|
<p class="text-sm text-slate-300">Inga spelare angivna.</p>
|
||||||
|
{:else}
|
||||||
|
<p class="text-sm text-slate-300">
|
||||||
|
Antal spelare: {signup.submittedParticipants.length}
|
||||||
|
</p>
|
||||||
|
{/if}
|
||||||
|
{:else if signup.submittedParticipants.length === 0}
|
||||||
<p class="text-sm text-slate-300">Inga spelare angivna.</p>
|
<p class="text-sm text-slate-300">Inga spelare angivna.</p>
|
||||||
{:else}
|
{:else}
|
||||||
<p class="text-sm text-slate-300">
|
<div class="space-y-3">
|
||||||
Antal spelare: {signup.submittedParticipants.length}
|
{#each signup.submittedParticipants as participant, index}
|
||||||
</p>
|
<div class="rounded-md border border-slate-800 bg-slate-900 px-4 py-3">
|
||||||
|
<p
|
||||||
|
class="text-xs font-semibold tracking-wide text-indigo-200 uppercase"
|
||||||
|
>
|
||||||
|
Spelare {index + 1}
|
||||||
|
</p>
|
||||||
|
<ul class="mt-2 space-y-1 text-sm text-slate-100">
|
||||||
|
{#each signupConfig.participant_fields as field}
|
||||||
|
<li>
|
||||||
|
<span class="font-medium text-slate-300">{field.label}:</span>
|
||||||
|
<span class="ml-1">{participant[field.id] || '—'}</span>
|
||||||
|
</li>
|
||||||
|
{/each}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
{:else if signup.submittedParticipants.length === 0}
|
</section>
|
||||||
<p class="text-sm text-slate-300">Inga spelare angivna.</p>
|
{/if}
|
||||||
{:else}
|
|
||||||
<div class="space-y-3">
|
|
||||||
{#each signup.submittedParticipants as participant, index}
|
|
||||||
<div class="rounded-md border border-slate-800 bg-slate-900 px-4 py-3">
|
|
||||||
<p class="text-xs font-semibold tracking-wide text-indigo-200 uppercase">
|
|
||||||
Spelare {index + 1}
|
|
||||||
</p>
|
|
||||||
<ul class="mt-2 space-y-1 text-sm text-slate-100">
|
|
||||||
{#each signupConfig.participant_fields as field}
|
|
||||||
<li>
|
|
||||||
<span class="font-medium text-slate-300">{field.label}:</span>
|
|
||||||
<span class="ml-1">{participant[field.id] || '—'}</span>
|
|
||||||
</li>
|
|
||||||
{/each}
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
{/each}
|
|
||||||
</div>
|
|
||||||
{/if}
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<div class="flex justify-center pt-2">
|
<div class="flex justify-center pt-2">
|
||||||
<a
|
<a
|
||||||
|
|
@ -514,10 +519,10 @@
|
||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<div class="space-y-3">
|
{#if signupConfig.mode === 'team'}
|
||||||
<div class="flex items-center justify-between">
|
<div class="space-y-3">
|
||||||
<h3 class="text-sm font-semibold tracking-wide text-slate-400 uppercase">Spelare</h3>
|
<div class="flex items-center justify-between">
|
||||||
{#if signupConfig.mode === 'team'}
|
<h3 class="text-sm font-semibold tracking-wide text-slate-400 uppercase">Spelare</h3>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onclick={addParticipant}
|
onclick={addParticipant}
|
||||||
|
|
@ -526,56 +531,61 @@
|
||||||
>
|
>
|
||||||
Lägg till spelare
|
Lägg till spelare
|
||||||
</button>
|
</button>
|
||||||
{/if}
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
{#if signup.participants.length > 0}
|
{#if signup.participants.length > 0}
|
||||||
<div class="space-y-4">
|
<div class="space-y-4">
|
||||||
{#each signup.participants as participant, index (index)}
|
{#each signup.participants as participant, index (index)}
|
||||||
<div class="space-y-3 rounded-md border border-slate-800 bg-slate-900/60 p-4">
|
<div class="space-y-3 rounded-md border border-slate-800 bg-slate-900/60 p-4">
|
||||||
<div class="flex items-center justify-between">
|
<div class="flex items-center justify-between">
|
||||||
<span class="text-sm font-semibold text-slate-200"
|
<span class="text-sm font-semibold text-slate-200">
|
||||||
>{participantDisplayName(index)}</span
|
{participantDisplayName(index)}
|
||||||
>
|
</span>
|
||||||
{#if signupConfig.mode === 'team' && canRemoveParticipant()}
|
{#if canRemoveParticipant()}
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onclick={() => removeParticipant(index)}
|
onclick={() => removeParticipant(index)}
|
||||||
disabled={signup.submitting}
|
disabled={signup.submitting}
|
||||||
class="rounded-full border border-red-300 px-3 py-1 text-xs font-semibold text-red-200 transition hover:border-red-400 hover:bg-red-500/10 disabled:cursor-not-allowed disabled:opacity-60"
|
class="rounded-full border border-red-300 px-3 py-1 text-xs font-semibold text-red-200 transition hover:border-red-400 hover:bg-red-500/10 disabled:cursor-not-allowed disabled:opacity-60"
|
||||||
>
|
>
|
||||||
Ta bort
|
Ta bort
|
||||||
</button>
|
</button>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{#if signupConfig.participant_fields.length > 0}
|
||||||
|
<div class="grid gap-3 md:grid-cols-2">
|
||||||
|
{#each signupConfig.participant_fields as field}
|
||||||
|
<label class="flex flex-col gap-1 text-sm font-medium text-slate-200">
|
||||||
|
<span>{field.label}</span>
|
||||||
|
<input
|
||||||
|
type={fieldInputType(field.field_type)}
|
||||||
|
required={field.required}
|
||||||
|
placeholder={field.placeholder ?? ''}
|
||||||
|
value={participant[field.id] ?? ''}
|
||||||
|
oninput={(event) =>
|
||||||
|
(participant[field.id] = (
|
||||||
|
event.currentTarget as HTMLInputElement
|
||||||
|
).value)}
|
||||||
|
class="rounded-md border border-slate-700 bg-slate-900 px-3 py-2 text-sm text-slate-100 focus:border-indigo-500 focus:ring focus:ring-indigo-500/40 focus:outline-none"
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
{:else}
|
||||||
|
<p class="text-xs text-slate-400">Inga spelarspecifika fält krävs.</p>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
{#if signupConfig.participant_fields.length > 0}
|
<p class="text-xs text-slate-400">
|
||||||
<div class="grid gap-3 md:grid-cols-2">
|
Du kan lägga till upp till {signupConfig.team_size.max} spelare per lag. Minst
|
||||||
{#each signupConfig.participant_fields as field}
|
{signupConfig.team_size.min} krävs.
|
||||||
<label class="flex flex-col gap-1 text-sm font-medium text-slate-200">
|
</p>
|
||||||
<span>{field.label}</span>
|
</div>
|
||||||
<input
|
{/if}
|
||||||
type={fieldInputType(field.field_type)}
|
|
||||||
required={field.required}
|
|
||||||
placeholder={field.placeholder ?? ''}
|
|
||||||
value={participant[field.id] ?? ''}
|
|
||||||
oninput={(event) =>
|
|
||||||
(participant[field.id] = (
|
|
||||||
event.currentTarget as HTMLInputElement
|
|
||||||
).value)}
|
|
||||||
class="rounded-md border border-slate-700 bg-slate-900 px-3 py-2 text-sm text-slate-100 focus:border-indigo-500 focus:ring focus:ring-indigo-500/40 focus:outline-none"
|
|
||||||
/>
|
|
||||||
</label>
|
|
||||||
{/each}
|
|
||||||
</div>
|
|
||||||
{:else}
|
|
||||||
<p class="text-xs text-slate-400">Inga spelarspecifika fält krävs.</p>
|
|
||||||
{/if}
|
|
||||||
</div>
|
|
||||||
{/each}
|
|
||||||
</div>
|
|
||||||
{/if}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="space-y-2 text-sm">
|
<div class="space-y-2 text-sm">
|
||||||
{#if signup.error}
|
{#if signup.error}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue