/**
 * Staff Session API
 * Returns current staff user session
 */

import { NextResponse } from "next/server";
import { getStaffSession } from "@/lib/staff-session";
import { logger } from "@/lib/logger";
// Session route: JWT-based staff session validation stays as-is.
// Convex routing not applicable — session data comes from JWT cookie,
// not from a DB query. No data-source switch needed.

export async function GET() {
  try {
    const user = await getStaffSession();

    if (!user) {
      return NextResponse.json({ user: null }, { status: 200 });
    }

    return NextResponse.json({
      user: {
        id: user.id,
        name: user.name,
        email: user.email,
        username: user.username,
        role: user.role,
      },
    });
  } catch (error) {
    logger.error("Session check error", error);
    return NextResponse.json({ user: null }, { status: 200 });
  }
}
