2024-08-12 11:00:25 +02:00
|
|
|
<script lang="ts">
|
|
|
|
|
import { browser } from '$app/environment';
|
|
|
|
|
import ConfirmDialog from '$lib/components/confirm-dialog/confirm-dialog.svelte';
|
|
|
|
|
import Error from '$lib/components/error.svelte';
|
|
|
|
|
import Header from '$lib/components/header/header.svelte';
|
|
|
|
|
import { Toaster } from '$lib/components/ui/sonner';
|
2024-09-09 10:29:41 +02:00
|
|
|
import appConfigStore from '$lib/stores/application-configuration-store';
|
2024-08-12 11:00:25 +02:00
|
|
|
import userStore from '$lib/stores/user-store';
|
|
|
|
|
import { ModeWatcher } from 'mode-watcher';
|
|
|
|
|
import type { Snippet } from 'svelte';
|
|
|
|
|
import '../app.css';
|
|
|
|
|
import type { LayoutData } from './$types';
|
|
|
|
|
|
|
|
|
|
let {
|
|
|
|
|
data,
|
|
|
|
|
children
|
|
|
|
|
}: {
|
|
|
|
|
data: LayoutData;
|
|
|
|
|
children: Snippet;
|
|
|
|
|
} = $props();
|
|
|
|
|
|
2024-09-09 10:29:41 +02:00
|
|
|
const { user, appConfig } = data;
|
2024-08-12 11:00:25 +02:00
|
|
|
|
|
|
|
|
if (browser && user) {
|
|
|
|
|
userStore.setUser(user);
|
|
|
|
|
}
|
2024-09-09 10:29:41 +02:00
|
|
|
if (appConfig) {
|
|
|
|
|
appConfigStore.set(appConfig);
|
2024-08-12 11:00:25 +02:00
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
2024-09-09 10:29:41 +02:00
|
|
|
{#if !appConfig}
|
2024-08-12 11:00:25 +02:00
|
|
|
<Error
|
2025-03-18 12:54:39 +01:00
|
|
|
message="A critical error occurred. Please contact your administrator."
|
2024-08-12 11:00:25 +02:00
|
|
|
showButton={false}
|
|
|
|
|
/>
|
|
|
|
|
{:else}
|
|
|
|
|
<Header />
|
|
|
|
|
{@render children()}
|
|
|
|
|
{/if}
|
|
|
|
|
<Toaster />
|
|
|
|
|
<ConfirmDialog />
|
|
|
|
|
<ModeWatcher />
|