From a09f654c9326b5e03faae9c89d839cfeeb13b2c1 Mon Sep 17 00:00:00 2001 From: Neshura Date: Tue, 12 Sep 2023 19:01:58 +0200 Subject: [PATCH] Auto Fetch First Game Index --- src/routes/+layout.svelte | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 1b489c8..ad51ecf 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -3,20 +3,30 @@ import { LeanChellarisDataStore } from '$lib/stores/ChellarisData'; import Header from './Header.svelte'; import './styles.css'; + import AdminSelectedGameStore from '$lib/stores/admin-page/GameStore'; $: { fetch(apiBaseUrl + '/v3/ethics').then((res) => { res.json().then((data) => { - $LeanChellarisDataStore.ethics = data.ethics; - }) + $LeanChellarisDataStore.ethics = data.ethics; + }); }); fetch(apiBaseUrl + '/v3/phenotypes').then((res) => { res.json().then((data) => { - $LeanChellarisDataStore.phenotypes = data.phenotypes; - }) + $LeanChellarisDataStore.phenotypes = data.phenotypes; + }); }); - } + + fetch(apiBaseUrl + '/v3/games').then((res) => { + res.json().then((data) => { + if ($AdminSelectedGameStore == 1) { + $AdminSelectedGameStore = data[0].id; + } + + }); + }); + }