2023-09-12 19:23:08 +02:00
< script lang = "ts" >
2023-09-13 16:30:24 +02:00
import '../app.postcss';
import { Modal , autoModeWatcher , type ModalComponent , getModalStore , type ModalSettings , initializeStores } from '@skeletonlabs/skeleton';
2023-09-09 02:39:37 +02:00
import { apiBaseUrl } from '$lib/components/consts';
import { LeanChellarisDataStore } from '$lib/stores/ChellarisData';
2023-08-06 04:16:32 +02:00
import Header from './Header.svelte';
2023-09-13 16:30:24 +02:00
import { AppShell } from '@skeletonlabs/skeleton';
import Settings from './Settings.svelte';
2023-09-12 19:01:58 +02:00
import AdminSelectedGameStore from '$lib/stores/admin-page/GameStore';
2023-09-12 19:19:45 +02:00
import type { ChellarisGameInfo } from '$lib/types/chellaris';
2023-09-09 02:39:37 +02:00
2023-09-13 16:30:24 +02:00
initializeStores();
2023-09-09 02:39:37 +02:00
$: {
fetch(apiBaseUrl + '/v3/ethics').then((res) => {
res.json().then((data) => {
2023-09-12 19:01:58 +02:00
$LeanChellarisDataStore.ethics = data.ethics;
});
2023-09-09 02:39:37 +02:00
});
fetch(apiBaseUrl + '/v3/phenotypes').then((res) => {
res.json().then((data) => {
2023-09-12 19:01:58 +02:00
$LeanChellarisDataStore.phenotypes = data.phenotypes;
});
2023-09-09 02:39:37 +02:00
});
2023-09-12 19:01:58 +02:00
fetch(apiBaseUrl + '/v3/games').then((res) => {
2023-09-12 19:19:45 +02:00
res.json().then((data: { [ key : number ] : ChellarisGameInfo } ) => {
2023-09-12 19:01:58 +02:00
if ($AdminSelectedGameStore == 1) {
2023-09-12 19:19:45 +02:00
$AdminSelectedGameStore = Object.values(data)[0].id;
2023-09-12 19:01:58 +02:00
}
});
});
}
2023-09-13 16:30:24 +02:00
const modalComponentRegistry: Record< string , ModalComponent > = {
settingsModal: {
ref: Settings,
props: { background : 'bg-red-500' }
}
}
2023-08-06 04:16:32 +02:00
< / script >
2023-09-13 16:30:24 +02:00
< svelte:head > { @html `<script>$ { autoModeWatcher . toString ()} autoModeWatcher ();</ script > ` } </ svelte:head >
2023-08-06 04:16:32 +02:00
2023-09-13 16:30:24 +02:00
< Modal components = { modalComponentRegistry } / >
< AppShell regionPage = "relative" >
< svelte:fragment slot = "header" >
< Header / >
< / svelte:fragment >
<!-- (sidebarLeft) -->
<!-- (sidebarRight) -->
<!-- <svelte:fragment slot="pageHeader">Page Header</svelte:fragment> -->
<!-- Router Slot -->
2023-08-12 19:58:51 +02:00
< slot / >
2023-09-13 16:30:24 +02:00
<!-- - - - - / - - - - -->
<!-- (pageFooter) -->
<!-- (footer) -->
< / AppShell >