<script lang="ts">
	import { currencyVM } from "$lib/domains/currency/view/currency.vm.svelte";
	import { svTrpcApiStore, trpcApiStore } from "$lib/stores/api";
	import { sessionInfo, sessionUserInfo } from "$lib/stores/session.info";
	import { trpc, trpcRaw } from "$lib/trpc/trpc";
	import { onMount } from "svelte";
	import type { LayoutData } from "./$types";

	let {
		children,
		data,
	}: {
		children: any;
		data: LayoutData;
	} = $props();

	sessionUserInfo.set(data.user);
	sessionInfo.set(data.session);

	svTrpcApiStore.set(trpc());

	onMount(() => {
		trpcApiStore.set(trpcRaw());

		currencyVM.loadCachedSelection();
		setTimeout(() => {
			currencyVM.getCurrencies();
		}, 500);
	});
</script>

<div class="min-h-screen w-full">
	<main class="flex w-full flex-col">
		{@render children?.()}
	</main>
</div>
