v1.0.2: Fix PDF generation (react-pdf v4), fix Next.js 15 async params in all API routes

This commit is contained in:
Pepe Ziberi
2026-02-21 13:56:44 +01:00
parent 10464d34ff
commit 2b7a89174a
22 changed files with 263 additions and 348 deletions

View File

@@ -4,13 +4,14 @@ import { getSession } from '@/lib/auth'
import { getProjectWithTenantCheck } from '@/lib/tenant'
// POST: Add check item (or initialize from templates)
export async function POST(req: NextRequest, { params }: { params: { id: string } }) {
export async function POST(req: NextRequest, { params }: { params: Promise<{ id: string }> }) {
try {
const { id } = await params
const user = await getSession()
if (!user) return NextResponse.json({ error: 'Nicht autorisiert' }, { status: 401 })
if (user.role === 'VIEWER') return NextResponse.json({ error: 'Keine Berechtigung' }, { status: 403 })
const project = await getProjectWithTenantCheck(params.id, user)
const project = await getProjectWithTenantCheck(id, user)
if (!project) return NextResponse.json({ error: 'Projekt nicht gefunden' }, { status: 404 })
const body = await req.json()
@@ -18,7 +19,7 @@ export async function POST(req: NextRequest, { params }: { params: { id: string
// If 'initFromTemplates' is true, create check items from templates (only if none exist)
if (body.initFromTemplates) {
const existing = await (prisma as any).journalCheckItem.findMany({
where: { projectId: params.id },
where: { projectId: id },
})
if (existing.length > 0) {
return NextResponse.json(existing)
@@ -31,7 +32,7 @@ export async function POST(req: NextRequest, { params }: { params: { id: string
templates.map((tpl: any, i: number) =>
(prisma as any).journalCheckItem.create({
data: {
projectId: params.id,
projectId: id,
label: tpl.label,
sortOrder: i,
},
@@ -44,7 +45,7 @@ export async function POST(req: NextRequest, { params }: { params: { id: string
// Single item creation
const item = await (prisma as any).journalCheckItem.create({
data: {
projectId: params.id,
projectId: id,
label: body.label || '',
sortOrder: body.sortOrder || 0,
},