---
import UserLayout from "../../../layouts/UserLayout.astro";
import DashboardAusweiseModule from "#modules/Dashboard/DashboardAusweiseModule.svelte";

import { validateAccessTokenServer } from "#server/lib/validateAccessToken";
import { createCaller } from "#lib/caller";

const accessTokenValid = await validateAccessTokenServer(Astro);

if (!accessTokenValid) {
	return Astro.redirect("/auth/login")
}

const caller = createCaller(Astro);

const user = await caller.v1.benutzer.self();
---

<UserLayout title="Dashboard">
	<DashboardAusweiseModule user={user} client:load></DashboardAusweiseModule>
</UserLayout>