---
import UserLayout from "../../../layouts/UserLayout.astro";
import { API_UID_COOKIE_NAME } from "../../../lib/constants";
import DashboardAusweiseModule from "#modules/Dashboard/DashboardAusweiseModule.svelte";
import { prisma } from "@ibcornelsen/database/server";

const uid = Astro.cookies.get(API_UID_COOKIE_NAME).value

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

const user = await prisma.benutzer.findUnique({
	where: {
		uid
	}
})

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

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