-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
164 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<script lang="ts"> | ||
import { Label, Input } from 'flowbite-svelte'; | ||
import type { HttpError } from '@sveltejs/kit'; | ||
import { error, success } from '$lib/toast'; | ||
import { Matches } from '$lib/matches'; | ||
import { pushState } from '$app/navigation'; | ||
export let matchId: number; | ||
export let matches: Matches; | ||
let match = matches?.matches?.find((m) => m.id === matchId); | ||
async function updateMatch() { | ||
if (match) { | ||
try { | ||
// Need to convert string inputs to numbers | ||
match.team1_score = Number(match.team1_score); | ||
match.team2_score = Number(match.team2_score); | ||
match = await matches.put(match); | ||
success( | ||
`Match ${match.matches_team1_fkey.name} vs ${match.matches_team2_fkey.name} updated` | ||
); | ||
} catch (err) { | ||
error((err as HttpError).toString()); | ||
} | ||
} | ||
} | ||
function closeModal() { | ||
pushState('', { | ||
showModal: false | ||
}); | ||
} | ||
</script> | ||
|
||
{#if match} | ||
<div class="flex flex-col"> | ||
<Label for="team1-score-input">Team `{match.matches_team1_fkey.name}`:</Label> | ||
<Input | ||
id="team1-score-input" | ||
size="md" | ||
type="number" | ||
bind:value={match.team1_score} | ||
on:keydown={(e) => { | ||
if (e?.key === 'Enter') { | ||
updateMatch(); | ||
} else if (e?.key === 'Escape') { | ||
closeModal(); | ||
} | ||
}} | ||
/> | ||
|
||
<Label for="team2-score-input">Team `{match.matches_team2_fkey.name}`:</Label> | ||
<Input | ||
id="team2-score-input" | ||
size="sm" | ||
type="number" | ||
bind:value={match.team2_score} | ||
on:keydown={(e) => { | ||
if (e?.key === 'Enter') { | ||
updateMatch(); | ||
} else if (e?.key === 'Escape') { | ||
closeModal(); | ||
} | ||
}} | ||
/> | ||
</div> | ||
{/if} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<script lang="ts"> | ||
import { Tooltip } from 'flowbite-svelte'; | ||
import { page } from '$app/stores'; | ||
import { pushState } from '$app/navigation'; | ||
export let match: MatchRow; | ||
export let readOnly: boolean = false; | ||
export let showWinLoss: boolean = true; | ||
function showModal() { | ||
pushState('', { | ||
showModal: true, | ||
matchId: match.id | ||
}); | ||
} | ||
</script> | ||
|
||
<!-- svelte-ignore a11y-no-static-element-interactions --> | ||
<!-- svelte-ignore a11y-click-events-have-key-events --> | ||
<!-- svelte-ignore missing-declaration --> | ||
<!-- svelte-ignore a11y-click-events-have-key-events --> | ||
<div | ||
class="flex justify-center place-items-center" | ||
on:click={() => { | ||
if (!readOnly && !$page.state.showModal) { | ||
showModal(); | ||
} | ||
}} | ||
> | ||
<span | ||
class="p-1 rounded" | ||
class:bg-green-300={showWinLoss && | ||
match?.team1_score && | ||
match?.team2_score && | ||
match.team1_score > match.team2_score} | ||
class:bg-red-300={showWinLoss && | ||
match?.team1_score && | ||
match?.team2_score && | ||
match.team2_score > match.team1_score} | ||
> | ||
{match?.matches_team1_fkey?.name}</span | ||
> | ||
vs | ||
<span | ||
class="p-1 rounded" | ||
class:bg-green-300={showWinLoss && | ||
match?.team1_score && | ||
match?.team2_score && | ||
match?.team2_score > match?.team1_score} | ||
class:bg-red-300={showWinLoss && | ||
match?.team1_score && | ||
match?.team2_score && | ||
match?.team1_score > match?.team2_score}>{match?.matches_team2_fkey?.name}</span | ||
> | ||
</div> | ||
{#if match?.team1_score && match?.team2_score} | ||
<Tooltip>{match?.team1_score} to {match?.team2_score}</Tooltip> | ||
{/if} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters