import { NextResponse } from "next/server";
import { auth } from "@/lib/auth";
import { eventRegistrationService } from "@/services/events/event-registration.service";

export async function GET(
  request: Request,
  { params }: { params: Promise<{ id: string }> }
) {
  try {
    const session = await auth();

    if (!session?.user?.id) {
      return NextResponse.json({ registered: false });
    }

    const { id: eventId } = await params;

    const isRegistered = await eventRegistrationService.checkUserRegistration(
      session.user.id,
      eventId
    );

    return NextResponse.json({ registered: isRegistered });
  } catch (error) {
    console.error("Check registration error:", error);
    return NextResponse.json({ registered: false });
  }
}
