Aktueller Stand

This commit is contained in:
2026-01-15 23:18:42 +01:00
parent 46eae2a2a9
commit dcf45bac3d
32 changed files with 2625 additions and 395 deletions

View File

@@ -55,3 +55,35 @@ export async function GET() {
return NextResponse.json(hydrated, { status: 201 });
}
export async function PATCH(request: Request) {
const { session } = await requireSession();
if (!session) {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
}
const body = await request.json();
const icalPastDays = Number(body?.icalPastDays);
if (!Number.isFinite(icalPastDays) || icalPastDays < 0 || icalPastDays > 365) {
return NextResponse.json(
{ error: "iCal-Rückblick ist ungültig." },
{ status: 400 }
);
}
const email = session.user?.email || "";
const view = await prisma.userView.findFirst({
where: { user: { email } }
});
if (!view) {
return NextResponse.json({ error: "Ansicht nicht gefunden." }, { status: 404 });
}
const updated = await prisma.userView.update({
where: { id: view.id },
data: { icalPastDays: Math.floor(icalPastDays) }
});
return NextResponse.json(updated);
}