<script lang="ts">
	import { getContext, setContext } from 'svelte';
	import type { PageProps } from './$types';
	import { Container } from '$lib/container';
	import { LabelViewModel } from '$lib/label/adapter/presenter/labelViewModel';
	import { LabelLoadedStore } from '$lib/label/adapter/presenter/labelLoadedStore';
	import LabelContentDashboardPage from '$lib/label/framework/ui/LabelContentDashboardPage.svelte';

	const { data, params }: PageProps = $props();
	const { id } = params;
	const numericId = $derived(Number(id));

	const container = getContext<Container>(Container.name);

	const initialData = LabelViewModel.rehydrate(data.dehydratedData);
	const store = container.createLabelLoadedStore(initialData);
	setContext(LabelLoadedStore.name, store);
</script>

<LabelContentDashboardPage id={numericId} />
