aboutsummaryrefslogtreecommitdiff
path: root/web/pw-server/src
diff options
context:
space:
mode:
authorIlion Beyst <ilion.beyst@gmail.com>2022-05-23 21:13:09 +0200
committerIlion Beyst <ilion.beyst@gmail.com>2022-05-23 21:13:09 +0200
commit68853612046cda1bf78acfb479006a711683f831 (patch)
treea44376d0c28f96141a50b0e19c8f8529d6f7b1a4 /web/pw-server/src
parent4d6a9591d89b66bf6f6b5f4ecf129c9bdc4a46f2 (diff)
downloadplanetwars.dev-68853612046cda1bf78acfb479006a711683f831.tar.xz
planetwars.dev-68853612046cda1bf78acfb479006a711683f831.zip
show confirmation on succesful bot save
Diffstat (limited to 'web/pw-server/src')
-rw-r--r--web/pw-server/src/lib/components/SubmitPane.svelte17
1 files changed, 14 insertions, 3 deletions
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}
<div>Add your bot to the opponents list</div>
<input type="text" class="bot-name-input" placeholder="bot name" bind:value={botName} />
- {#if saveErrors.length > 0}
+ {#if saveSuccesful}
+ <div class="success-text">Bot saved succesfully</div>
+ {:else if saveErrors.length > 0}
<ul>
{#each saveErrors as errorText}
<li class="error-text">{errorText}</li>
@@ -151,6 +157,11 @@
color: red;
}
+ .success-text {
+ color: green;
+ margin: 0 8px;
+ }
+
.submit-button {
padding: 8px 16px;
border-radius: 8px;