Commit 8abd310c authored by Hendrik Garske's avatar Hendrik Garske

Fix: Next.js 16 async params in API routes

parent 4f78567b
Pipeline #4 failed with stages
in 24 seconds
......@@ -3,11 +3,12 @@ import { prisma } from "@/lib/prisma"
export async function GET(
request: NextRequest,
{ params }: { params: { id: string } }
{ params }: { params: Promise<{ id: string }> }
) {
try {
const { id } = await params
const customer = await prisma.customer.findUnique({
where: { id: params.id },
where: { id },
include: {
timeEntries: {
include: {
......@@ -33,9 +34,10 @@ export async function GET(
export async function PUT(
request: NextRequest,
{ params }: { params: { id: string } }
{ params }: { params: Promise<{ id: string }> }
) {
try {
const { id } = await params
const body = await request.json()
const { name, email, phone, company, address, notes } = body
......@@ -44,7 +46,7 @@ export async function PUT(
}
const customer = await prisma.customer.update({
where: { id: params.id },
where: { id },
data: {
name,
email: email || null,
......@@ -64,11 +66,12 @@ export async function PUT(
export async function DELETE(
request: NextRequest,
{ params }: { params: { id: string } }
{ params }: { params: Promise<{ id: string }> }
) {
try {
const { id } = await params
await prisma.customer.delete({
where: { id: params.id },
where: { id },
})
return NextResponse.json({ success: true })
......
......@@ -3,11 +3,12 @@ import { prisma } from "@/lib/prisma"
export async function DELETE(
request: NextRequest,
{ params }: { params: { id: string } }
{ params }: { params: Promise<{ id: string }> }
) {
try {
const { id } = await params
await prisma.timeEntry.delete({
where: { id: params.id },
where: { id },
})
return NextResponse.json({ success: true })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment