Dashboard

This commit is contained in:
Moritz Utcke
2025-02-21 23:57:46 +11:00
parent d6e137d50f
commit 6a51b0b02f
35 changed files with 648 additions and 274 deletions

View File

@@ -0,0 +1,59 @@
---
import { createCaller } from "../../../astro-typesafe-api-caller.js";
import { validateAccessTokenServer } from "#server/lib/validateAccessToken";
import DashboardModule from "#modules/Dashboard/DashboardModule.svelte";
import { API_ACCESS_TOKEN_COOKIE_NAME } from "#lib/constants.js";
import Layout from "#layouts/Layout.astro";
import { prisma } from "@ibcornelsen/database/server";
import UserLayout from "#layouts/DashboardLayout.astro";
import DashboardAufnahmeModule from "#modules/Dashboard/DashboardAufnahmeModule.svelte";
const { uid } = Astro.params;
const accessTokenValid = await validateAccessTokenServer(Astro);
if (!accessTokenValid) {
return Astro.redirect("/auth/login")
}
const caller = createCaller(Astro);
const user = await caller.user.self.GET.fetch(undefined, {
headers: {
"Authorization": `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
}
});
if (!user) {
return Astro.redirect("/auth/login")
}
const aufnahme = await prisma.aufnahme.findUnique({
where: {
benutzer: {
uid: user.uid
},
uid
},
include: {
objekt: true,
bilder: true,
unterlagen: true,
bedarfsausweise_wohnen: true,
verbrauchsausweise_gewerbe: true,
verbrauchsausweise_wohnen: true,
bedarfsausweise_gewerbe: true,
geg_nachweise_gewerbe: true,
geg_nachweise_wohnen: true,
events: true
}
})
if (!aufnahme) {
return Astro.redirect("/dashboard")
}
---
<UserLayout title="Dashboard" {user}>
<DashboardAufnahmeModule {user} {aufnahme} objekt={aufnahme.objekt} client:only/>
</UserLayout>