import { NextResponse } from "next/server";
import { getSessionPayload } from "@/lib/auth/session";
import { getLicitationRecommendationsForUser } from "@/lib/licitations/recommendations";

export async function GET(request: Request) {
  const session = await getSessionPayload();

  if (!session) {
    return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
  }

  const url = new URL(request.url);
  const profileId = url.searchParams.get("profile_id");
  const payload = await getLicitationRecommendationsForUser(session.userId, profileId);

  return NextResponse.json(payload);
}
