don't show save button when user is not logged in

This commit is contained in:
Ilion Beyst 2022-03-24 20:43:27 +01:00
parent 1692eeb592
commit 2479d1ec1a

View file

@ -1,5 +1,8 @@
<script lang="ts"> <script lang="ts">
import { createEventDispatcher, onMount } from "svelte"; import { get_session_token } from "$lib/auth";
import { currentUser } from "$lib/stores/current_user";
import { createEventDispatcher, onMount } from "svelte";
import Select from "svelte-select"; import Select from "svelte-select";
export let editSession; export let editSession;
@ -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>
<div>Add your bot to the opponents list</div> {#if $currentUser}
<input type="text" class="bot-name-input" placeholder="bot name" bind:value={botName} /> <div>Add your bot to the opponents list</div>
{#if saveErrorText} <input type="text" class="bot-name-input" placeholder="bot name" bind:value={botName} />
<div class="error-text">{saveErrorText}</div> {#if saveErrorText}
<div class="error-text">{saveErrorText}</div>
{/if}
<button class="submit-button save-button" on:click={saveBot}>Save</button>
{:else}
Sign in to add your bot to the opponents list.
{/if} {/if}
<button class="submit-button save-button" on:click={saveBot}>Save</button>
</div> </div>
</div> </div>