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>;
|
||||
|
||||
const signupConfig = normalizeSignupConfig(tournament.signup_config);
|
||||
const entrySectionTitle = signupConfig.mode === 'team' ? 'Lag' : 'Spelare';
|
||||
|
||||
function formatDateTime(value: string | null) {
|
||||
if (!value) return null;
|
||||
|
|
@ -348,7 +349,7 @@
|
|||
{#if signupConfig.entry_fields.length > 0}
|
||||
<div class="space-y-3">
|
||||
<h3 class="text-sm font-semibold tracking-wide text-slate-400 uppercase">
|
||||
Lag / deltagare
|
||||
{entrySectionTitle}
|
||||
</h3>
|
||||
<div class="grid gap-3 md:grid-cols-2">
|
||||
{#each signupConfig.entry_fields as field}
|
||||
|
|
@ -468,38 +469,42 @@
|
|||
{/if}
|
||||
</section>
|
||||
|
||||
<section class="space-y-3">
|
||||
<h3 class="text-base font-semibold text-slate-100">Spelare</h3>
|
||||
{#if signupConfig.participant_fields.length === 0}
|
||||
{#if signup.submittedParticipants.length === 0}
|
||||
{#if signupConfig.mode === 'team'}
|
||||
<section class="space-y-3">
|
||||
<h3 class="text-base font-semibold text-slate-100">Spelare</h3>
|
||||
{#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>
|
||||
{:else}
|
||||
<p class="text-sm text-slate-300">
|
||||
Antal spelare: {signup.submittedParticipants.length}
|
||||
</p>
|
||||
<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}
|
||||
{:else if signup.submittedParticipants.length === 0}
|
||||
<p class="text-sm text-slate-300">Inga spelare angivna.</p>
|
||||
{: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>
|
||||
</section>
|
||||
{/if}
|
||||
|
||||
<div class="flex justify-center pt-2">
|
||||
<a
|
||||
|
|
@ -514,10 +519,10 @@
|
|||
{/if}
|
||||
{/if}
|
||||
|
||||
<div class="space-y-3">
|
||||
<div class="flex items-center justify-between">
|
||||
<h3 class="text-sm font-semibold tracking-wide text-slate-400 uppercase">Spelare</h3>
|
||||
{#if signupConfig.mode === 'team'}
|
||||
{#if signupConfig.mode === 'team'}
|
||||
<div class="space-y-3">
|
||||
<div class="flex items-center justify-between">
|
||||
<h3 class="text-sm font-semibold tracking-wide text-slate-400 uppercase">Spelare</h3>
|
||||
<button
|
||||
type="button"
|
||||
onclick={addParticipant}
|
||||
|
|
@ -526,56 +531,61 @@
|
|||
>
|
||||
Lägg till spelare
|
||||
</button>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{#if signup.participants.length > 0}
|
||||
<div class="space-y-4">
|
||||
{#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="flex items-center justify-between">
|
||||
<span class="text-sm font-semibold text-slate-200"
|
||||
>{participantDisplayName(index)}</span
|
||||
>
|
||||
{#if signupConfig.mode === 'team' && canRemoveParticipant()}
|
||||
<button
|
||||
type="button"
|
||||
onclick={() => removeParticipant(index)}
|
||||
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"
|
||||
>
|
||||
Ta bort
|
||||
</button>
|
||||
{#if signup.participants.length > 0}
|
||||
<div class="space-y-4">
|
||||
{#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="flex items-center justify-between">
|
||||
<span class="text-sm font-semibold text-slate-200">
|
||||
{participantDisplayName(index)}
|
||||
</span>
|
||||
{#if canRemoveParticipant()}
|
||||
<button
|
||||
type="button"
|
||||
onclick={() => removeParticipant(index)}
|
||||
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"
|
||||
>
|
||||
Ta bort
|
||||
</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}
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#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}
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
<p class="text-xs text-slate-400">
|
||||
Du kan lägga till upp till {signupConfig.team_size.max} spelare per lag. Minst
|
||||
{signupConfig.team_size.min} krävs.
|
||||
</p>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<div class="space-y-2 text-sm">
|
||||
{#if signup.error}
|
||||
|
|
|
|||
Loading…
Reference in a new issue