Skip to content

Commit

Permalink
fix(user): prompt before sending lab rankings
Browse files Browse the repository at this point in the history
  • Loading branch information
BastiDood committed Jul 11, 2024
1 parent 64ba4f3 commit 950322f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/routes/dashboard/(draft)/ranks/+page.server.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const actions = {

const maxRounds = await db.getMaxRoundInDraft(draft);
if (maxRounds === null) error(404);
if (labs.length !== maxRounds) error(400);
if (labs.length > maxRounds) error(400);

if (await db.insertStudentRanking(draft, user.email, labs)) return;
return fail(403);
Expand Down
10 changes: 6 additions & 4 deletions src/routes/dashboard/(draft)/ranks/SubmitRankings.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@
<form
method="post"
class="space-y-4"
use:enhance={({ submitter }) => {
use:enhance={({ submitter, cancel }) => {
if (!confirm(`Are you sure you want to select ${selectedLabs.length} labs?`)) {
cancel();
return;
}
assert(submitter !== null);
assert(submitter instanceof HTMLButtonElement);
submitter.disabled = true;
Expand Down Expand Up @@ -106,9 +110,7 @@
You may no longer select any more labs.
{/if}
</p>
<button type="submit" disabled={hasRemaining} class="variant-filled-primary btn disabled:!variant-ghost-primary"
>Submit Lab Preferences</button
>
<button type="submit" class="variant-filled-primary btn">Submit Lab Preferences</button>
</div>
<hr class="!border-surface-400-500-token !border-t-4" />
{#each selectedLabs as { lab_id, lab_name }, idx (lab_id)}
Expand Down

0 comments on commit 950322f

Please sign in to comment.