-
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.
feat(admin): provide better instructions on how to start drafts
- Loading branch information
Showing
4 changed files
with
75 additions
and
59 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<script> | ||
import { CalendarDays } from '@steeze-ui/heroicons'; | ||
import ErrorAlert from '$lib/alerts/Error.svelte'; | ||
import { Icon } from '@steeze-ui/svelte-icon'; | ||
import { assert } from '$lib/assert'; | ||
import { enhance } from '$app/forms'; | ||
import { getToastStore } from '@skeletonlabs/skeleton'; | ||
import { page } from '$app/stores'; | ||
const toast = getToastStore(); | ||
$: ({ status, error } = $page); | ||
</script> | ||
|
||
{#if status === 499} | ||
<div class="grid grid-cols-1 gap-4 sm:grid-cols-[auto_1fr]"> | ||
<div class="prose dark:prose-invert"> | ||
<h2>Start a New Draft</h2> | ||
<p> | ||
Welcome to the <strong>Draft Ranking Automated Processor</strong>! There are currently no drafts | ||
happening at the moment, but as an administrator, you have the authorization to start a new one. | ||
</p> | ||
<p> | ||
To begin, simply provide the the maximum number of rounds for the upcoming draft. This has historically | ||
been set to <strong>5</strong>. | ||
</p> | ||
</div> | ||
<form | ||
method="post" | ||
action="?/init" | ||
class="min-w-max" | ||
use:enhance={({ submitter }) => { | ||
assert(submitter !== null); | ||
assert(submitter instanceof HTMLButtonElement); | ||
submitter.disabled = true; | ||
return async ({ update, result }) => { | ||
submitter.disabled = false; | ||
await update(); | ||
switch (result.type) { | ||
case 'success': | ||
toast.trigger({ | ||
message: 'Successfully started a new draft.', | ||
background: 'variant-filled-success', | ||
}); | ||
break; | ||
case 'failure': | ||
toast.trigger({ | ||
message: 'Failed to start a new draft.', | ||
background: 'variant-filled-error', | ||
}); | ||
break; | ||
default: | ||
break; | ||
} | ||
}; | ||
}} | ||
> | ||
<label> | ||
<span>Number of Rounds</span> | ||
<div class="input-group input-group-divider grid-cols-[auto_1fr_auto]"> | ||
<div class="input-group-shim"><Icon src={CalendarDays} class="size-6" /></div> | ||
<input type="number" min="1" required name="rounds" placeholder="5" class="px-4 py-2" /> | ||
<button class="variant-filled-primary">Start</button> | ||
</div> | ||
</label> | ||
</form> | ||
</div> | ||
{:else if error !== null} | ||
<ErrorAlert><strong>{status}:</strong> {error.message}</ErrorAlert> | ||
{:else} | ||
<ErrorAlert><strong>{status}</strong></ErrorAlert> | ||
{/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.