import { NextRequest, NextResponse } from "next/server";
import prisma from "@/app/prisma";


export async function DELETE(request: NextRequest) {
    const searchParams = request.nextUrl.searchParams;
    const siteId = searchParams.get("siteId");

    try {
        const site = await prisma.site.delete({
            where: { id: Number(siteId) },
        });

        return NextResponse.json(site);
    } catch (error) {
        console.error(error);
        return NextResponse.json({ error: "Failed to delete site" }, { status: 500 });
    }
}