<script lang="ts">
	import { onMount, type Snippet } from 'svelte';
	import { userStore } from './UserStore.svelte';

	let ready = $state(false);

	const { children, redirect }: { children: Snippet, redirect: string } = $props();

	onMount(() => {
		ready = userStore.checkLogin(redirect);
	});
</script>

{#if ready}
	{@render children()}
{/if}
