Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
ocitocit committed Oct 14, 2023
1 parent afe9d27 commit 2f060bc
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions app/api/reservations/[reservationId]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,19 @@ export async function DELETE(request: Request, { params }: { params: IParams })
if (!currentUser) {
return NextResponse.error();
}

const { reservationId } = params;

if (!reservationId || typeof reservationId !== 'string') {
throw new Error('Invalid ID');
}

const reservation = await prisma.reservation.deleteMany({
where: {
id: reservationId,
OR: [{ userId: currentUser.id }, { listing: { userId: currentUser.id } }]
}
});

return NextResponse.json(reservation);
}

0 comments on commit 2f060bc

Please sign in to comment.