import prismadb from "@/lib/prisma";
import { NextResponse } from "next/server";

import { getServerSession } from "next-auth";

export async function GET(
  req: Request,
  { params }: { params: { categorieSlug: string } }
) {
  try {

    if (!params.categorieSlug) {
      return new NextResponse("Catégorie requise", { status: 400 });
    }

    const category = await prismadb.category.findFirst({
      where: {
        slug: params.categorieSlug,
      },
      include: {
        billboard: true
      }
    });

    return NextResponse.json(category);
  } catch (error) {
    console.log('[CATEGORY_SLUG_GET]', error);
    return new NextResponse("Internal error", { status: 500 })
  }
};