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

export async function DELETE(request: NextRequest) {
    const searchParams = request.nextUrl.searchParams;
    const networkId = searchParams.get("networkId");
    
    try {
        await prisma.network.delete({
            where: {
                id: Number(networkId),
            },
        });
        
        return NextResponse.json({ message: "Network deleted successfully" });
    } catch (error) {
        console.error("Error deleting network:", error);
        return NextResponse.json({ error: "Failed to delete network" }, { status: 500 });
    }
}