From 68853612046cda1bf78acfb479006a711683f831 Mon Sep 17 00:00:00 2001 From: Ilion Beyst Date: Mon, 23 May 2022 21:13:09 +0200 Subject: show confirmation on succesful bot save --- web/pw-server/src/lib/components/SubmitPane.svelte | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'web/pw-server/src/lib/components/SubmitPane.svelte') diff --git a/web/pw-server/src/lib/components/SubmitPane.svelte b/web/pw-server/src/lib/components/SubmitPane.svelte index 740f2cf..82f752e 100644 --- a/web/pw-server/src/lib/components/SubmitPane.svelte +++ b/web/pw-server/src/lib/components/SubmitPane.svelte @@ -11,6 +11,8 @@ let availableBots: object[] = []; let selectedOpponent = undefined; let botName: string | undefined = undefined; + // whether to show the "save succesful" message + let saveSuccesful = false; let saveErrors: string[] = []; @@ -56,6 +58,9 @@ } async function saveBot() { + saveSuccesful = false; + saveErrors = []; + let response = await fetch("/api/save_bot", { method: "POST", headers: { @@ -77,8 +82,7 @@ if (!availableBots.find((bot) => bot["id"] == responseData["id"])) { availableBots = [...availableBots, responseData]; } - // clear errors - saveErrors = []; + saveSuccesful = true; } else { const error = responseData["error"]; if (error["type"] === "validation_failed") { @@ -113,7 +117,9 @@ {#if $currentUser}
Add your bot to the opponents list
- {#if saveErrors.length > 0} + {#if saveSuccesful} +
Bot saved succesfully
+ {:else if saveErrors.length > 0}