don't show save button when user is not logged in
This commit is contained in:
parent
1692eeb592
commit
2479d1ec1a
1 changed files with 14 additions and 6 deletions
|
@ -1,4 +1,7 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { get_session_token } from "$lib/auth";
|
||||||
|
|
||||||
|
import { currentUser } from "$lib/stores/current_user";
|
||||||
import { createEventDispatcher, onMount } from "svelte";
|
import { createEventDispatcher, onMount } from "svelte";
|
||||||
import Select from "svelte-select";
|
import Select from "svelte-select";
|
||||||
|
|
||||||
|
@ -54,6 +57,7 @@
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
|
"Authorization": `Bearer ${get_session_token()}`,
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
bot_name: botName,
|
bot_name: botName,
|
||||||
|
@ -94,12 +98,16 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="save-form">
|
<div class="save-form">
|
||||||
<h4>Save your bot</h4>
|
<h4>Save your bot</h4>
|
||||||
|
{#if $currentUser}
|
||||||
<div>Add your bot to the opponents list</div>
|
<div>Add your bot to the opponents list</div>
|
||||||
<input type="text" class="bot-name-input" placeholder="bot name" bind:value={botName} />
|
<input type="text" class="bot-name-input" placeholder="bot name" bind:value={botName} />
|
||||||
{#if saveErrorText}
|
{#if saveErrorText}
|
||||||
<div class="error-text">{saveErrorText}</div>
|
<div class="error-text">{saveErrorText}</div>
|
||||||
{/if}
|
{/if}
|
||||||
<button class="submit-button save-button" on:click={saveBot}>Save</button>
|
<button class="submit-button save-button" on:click={saveBot}>Save</button>
|
||||||
|
{:else}
|
||||||
|
Sign in to add your bot to the opponents list.
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue