Skip to content

Commit

Permalink
t
Browse files Browse the repository at this point in the history
  • Loading branch information
craigkai committed Jun 19, 2024
1 parent 6c459f6 commit 1bfcd64
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 9 deletions.
5 changes: 3 additions & 2 deletions src/components/Bracket.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
matches: Matches;
bracket: Brackets;
teams: Teams;
readonly: Boolean;
readOnly: Boolean;
} = $props();
let rounds: Record<number, Round> = $state({});
let numRounds = 0;
let numRounds = $state(0);
function determineRounds() {
const newRounds: Record<number, Round> = {};
Expand Down Expand Up @@ -73,6 +73,7 @@
error('Failed to create matches');
} else {
subscribeToMatches();
await bracket.load();
}
} catch (err) {
error((err as HttpError).toString());
Expand Down
7 changes: 6 additions & 1 deletion src/components/Teams.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
let { teams = $bindable() }: { teams: Teams } = $props();
async function createTeam() {
if (teams.teams.findIndex((team) => team.name === newTeamName) !== -1) {
error('Team already exists');
return;
}
try {
const newTeam: Partial<TeamRow> = {
name: newTeamName,
Expand Down Expand Up @@ -44,7 +49,7 @@
<div class="block text-gray-700 dark:text-gray-300 text-sm font-bold mb-2">Teams:</div>

<Table.Root class="min-w-full bg-white dark:bg-gray-800">
<Table.Caption>A list of your recent invoices.</Table.Caption>
<Table.Caption>A list of your teams.</Table.Caption>
<Table.Body>
{#each teams?.teams as team}
<Table.Row>
Expand Down
28 changes: 22 additions & 6 deletions src/routes/protected-routes/events/[slug]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import { closeModal } from '$lib/helper.svelte';
let { data = $bindable() }: { data: PageData } = $props();
let { tournament, bracket, teams, matches, defaultTeam } = $state(data);
let open = $state($page.state.showModal);
Expand All @@ -35,9 +34,9 @@
>
<AlertDialog.Content>
{#if $page.state.type === 'pool'}
<EditMatch matchId={$page.state.matchId as number} bind:matches />
<EditMatch matchId={$page.state.matchId as number} bind:matches={data.matches} />
{:else}
<EditMatch matchId={$page.state.matchId as number} bind:matches={bracket} />
<EditMatch matchId={$page.state.matchId as number} bind:matches={data.bracket} />
{/if}
</AlertDialog.Content>
</AlertDialog.Root>
Expand Down Expand Up @@ -82,7 +81,13 @@
<Card.Description>Update pool play match results</Card.Description>
</Card.Header>
<Card.Content class="space-y-2">
<Matches bind:tournament bind:matches {teams} {defaultTeam} readonly={false} />
<Matches
bind:tournament={data.tournament}
bind:matches={data.matches}
teams={data.teams}
defaultTeam={data.defaultTeam}
readonly={false}
/>
</Card.Content>
</Card.Root>
</Tabs.Content>
Expand All @@ -93,7 +98,12 @@
<Card.Description>Current standings based on pool play results</Card.Description>
</Card.Header>
<Card.Content class="space-y-2">
<Standings event={data} {matches} {teams} {defaultTeam} />
<Standings
event={data}
bind:matches={data.matches}
teams={data.teams}
defaultTeam={data.defaultTeam}
/>
</Card.Content>
</Card.Root>
</Tabs.Content>
Expand All @@ -104,7 +114,13 @@
<Card.Description>Single/Double elim bracket</Card.Description>
</Card.Header>
<Card.Content class="space-y-2">
<Bracket {tournament} {bracket} {teams} {matches} readOnly={false} />
<Bracket
tournament={data.tournament}
bind:bracket={data.bracket}
bind:matches={data.matches}
teams={data.teams}
readOnly={false}
/>
</Card.Content>
</Card.Root>
</Tabs.Content>
Expand Down

0 comments on commit 1bfcd64

Please sign in to comment.