v1.0.2: Fix PDF generation (react-pdf v4), fix Next.js 15 async params in all API routes
This commit is contained in:
@@ -40,10 +40,11 @@ async function resolveLogoDataUri(rapport: any): Promise<string> {
|
||||
}
|
||||
|
||||
// GET: Generate and serve PDF for a rapport (public, token-based)
|
||||
export async function GET(req: NextRequest, { params }: { params: { token: string } }) {
|
||||
export async function GET(req: NextRequest, { params }: { params: Promise<{ token: string }> }) {
|
||||
try {
|
||||
const { token } = await params
|
||||
const rapport = await (prisma as any).rapport.findUnique({
|
||||
where: { token: params.token },
|
||||
where: { token },
|
||||
include: {
|
||||
tenant: { select: { name: true } },
|
||||
},
|
||||
@@ -68,10 +69,10 @@ export async function GET(req: NextRequest, { params }: { params: { token: strin
|
||||
const { RapportDocument } = await import('@/lib/rapport-pdf')
|
||||
|
||||
const buffer = await renderToBuffer(
|
||||
React.createElement(RapportDocument, { data: pdfData })
|
||||
React.createElement(RapportDocument, { data: pdfData }) as any
|
||||
)
|
||||
|
||||
return new NextResponse(buffer, {
|
||||
return new NextResponse(Buffer.from(buffer) as any, {
|
||||
headers: {
|
||||
'Content-Type': 'application/pdf',
|
||||
'Content-Disposition': `inline; filename="Rapport-${rapport.reportNumber}.pdf"`,
|
||||
|
||||
@@ -37,10 +37,11 @@ async function resolveLogoForClient(rapport: any): Promise<string> {
|
||||
}
|
||||
|
||||
// GET: Public access to rapport by token (no auth required)
|
||||
export async function GET(req: NextRequest, { params }: { params: { token: string } }) {
|
||||
export async function GET(req: NextRequest, { params }: { params: Promise<{ token: string }> }) {
|
||||
try {
|
||||
const { token } = await params
|
||||
const rapport = await (prisma as any).rapport.findUnique({
|
||||
where: { token: params.token },
|
||||
where: { token },
|
||||
include: {
|
||||
project: { select: { title: true, location: true } },
|
||||
tenant: { select: { name: true } },
|
||||
|
||||
@@ -4,8 +4,9 @@ import { getSession } from '@/lib/auth'
|
||||
import { sendEmail } from '@/lib/email'
|
||||
|
||||
// POST: Send rapport link via email
|
||||
export async function POST(req: NextRequest, { params }: { params: { token: string } }) {
|
||||
export async function POST(req: NextRequest, { params }: { params: Promise<{ token: string }> }) {
|
||||
try {
|
||||
const { token } = await params
|
||||
const user = await getSession()
|
||||
if (!user) return NextResponse.json({ error: 'Nicht autorisiert' }, { status: 401 })
|
||||
|
||||
@@ -13,7 +14,7 @@ export async function POST(req: NextRequest, { params }: { params: { token: stri
|
||||
if (!email) return NextResponse.json({ error: 'E-Mail-Adresse erforderlich' }, { status: 400 })
|
||||
|
||||
const rapport = await (prisma as any).rapport.findUnique({
|
||||
where: { token: params.token },
|
||||
where: { token },
|
||||
include: {
|
||||
tenant: { select: { name: true } },
|
||||
project: { select: { title: true, location: true } },
|
||||
|
||||
Reference in New Issue
Block a user