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

@@ -5,9 +5,10 @@ import { getSession, isAdmin } from '@/lib/auth'
// GET: Fetch journal suggestions for a tenant (global + tenant dictionary merged)
export async function GET(
req: NextRequest,
{ params }: { params: { tenantId: string } }
{ params }: { params: Promise<{ tenantId: string }> }
) {
try {
const { tenantId } = await params
const user = await getSession()
if (!user) return NextResponse.json({ error: 'Nicht autorisiert' }, { status: 401 })
@@ -18,11 +19,11 @@ export async function GET(
select: { word: true },
}).catch(() => []),
(prisma as any).dictionaryEntry.findMany({
where: { scope: 'TENANT', tenantId: params.tenantId },
where: { scope: 'TENANT', tenantId },
select: { word: true },
}).catch(() => []),
(prisma as any).tenant.findUnique({
where: { id: params.tenantId },
where: { id: tenantId },
select: { journalSuggestions: true },
}),
])
@@ -46,16 +47,17 @@ export async function GET(
// PUT: Replace all journal suggestions for a tenant (admin only)
export async function PUT(
req: NextRequest,
{ params }: { params: { tenantId: string } }
{ params }: { params: Promise<{ tenantId: string }> }
) {
try {
const { tenantId } = await params
const user = await getSession()
if (!user || !isAdmin(user.role)) {
return NextResponse.json({ error: 'Nicht autorisiert' }, { status: 403 })
}
// TENANT_ADMIN can only edit their own tenant
if (user.role !== 'SERVER_ADMIN' && user.tenantId !== params.tenantId) {
if (user.role !== 'SERVER_ADMIN' && user.tenantId !== tenantId) {
return NextResponse.json({ error: 'Keine Berechtigung' }, { status: 403 })
}
@@ -65,7 +67,7 @@ export async function PUT(
: []
await (prisma as any).tenant.update({
where: { id: params.tenantId },
where: { id: tenantId },
data: { journalSuggestions: suggestions },
})