mirror of
https://github.com/soconnor0919/hristudio.git
synced 2025-12-11 22:54:45 -05:00
Remove delete routes
This commit is contained in:
@@ -1,32 +0,0 @@
|
||||
import { eq } from "drizzle-orm";
|
||||
import { NextResponse } from "next/server";
|
||||
import { auth } from "@clerk/nextjs/server";
|
||||
import { db } from "~/db";
|
||||
import { participants } from "~/db/schema";
|
||||
|
||||
|
||||
export async function DELETE(request: Request, { params }: any) {
|
||||
const { userId } = await auth();
|
||||
|
||||
if (!userId) {
|
||||
return new NextResponse("Unauthorized", { status: 401 });
|
||||
}
|
||||
|
||||
const participantId = parseInt(params.id);
|
||||
|
||||
try {
|
||||
const result = await db
|
||||
.delete(participants)
|
||||
.where(eq(participants.id, participantId))
|
||||
.execute();
|
||||
|
||||
if (result.rowCount === 0) {
|
||||
return new NextResponse("Not Found", { status: 404 });
|
||||
}
|
||||
|
||||
return new NextResponse(null, { status: 204 }); // No content for successful deletion
|
||||
} catch (error) {
|
||||
console.error("Error deleting participant:", error);
|
||||
return new NextResponse("Internal Server Error", { status: 500 });
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
import { eq } from "drizzle-orm";
|
||||
import { NextResponse } from "next/server";
|
||||
import { auth } from "@clerk/nextjs/server";
|
||||
import { db } from "~/db";
|
||||
import { studyTable } from "~/db/schema";
|
||||
|
||||
export async function DELETE(request: Request, { params }: { params: { id: string } }) {
|
||||
const { userId } = await auth();
|
||||
|
||||
if (!userId) {
|
||||
return new NextResponse("Unauthorized", { status: 401 });
|
||||
}
|
||||
|
||||
const { id } = await params;
|
||||
const studyId = parseInt(id);
|
||||
|
||||
try {
|
||||
const result = await db
|
||||
.delete(studyTable)
|
||||
.where(eq(studyTable.id, studyId))
|
||||
.execute();
|
||||
|
||||
if (result.rowCount === 0) {
|
||||
return new NextResponse("Not Found", { status: 404 });
|
||||
}
|
||||
|
||||
return new NextResponse(null, { status: 204 });
|
||||
} catch (error) {
|
||||
console.error("Error deleting study:", error);
|
||||
return new NextResponse("Internal Server Error", { status: 500 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user