import { NextResponse } from 'next/server'; import prisma from '../../../../../lib/prisma'; export async function POST(request: Request, context: { params: Promise<{ id: string }> }) { try { const params = await context.params; const data = await request.json(); const credential = await prisma.customerCredential.create({ data: { customerId: parseInt(params.id), title: data.title, username: data.username, password: data.password } }); return NextResponse.json(credential); } catch (error) { return NextResponse.json({ error: 'Erstellen fehlgeschlagen' }, { status: 500 }); } } export async function DELETE(request: Request, context: { params: Promise<{ id: string }> }) { try { const { searchParams } = new URL(request.url); const credId = searchParams.get('credId'); if (!credId) return NextResponse.json({ error: 'ID fehlt' }, { status: 400 }); await prisma.customerCredential.delete({ where: { id: parseInt(credId) } }); return NextResponse.json({ success: true }); } catch (error) { return NextResponse.json({ error: 'Löschen fehlgeschlagen' }, { status: 500 }); } }