/**
 * Staff Logout API
 * Clears the staff session cookie
 */

import { NextRequest, NextResponse } from "next/server";
import { cookies } from "next/headers";
import { getStaffSession } from "@/lib/staff-session";
import { logger } from "@/lib/logger";

export async function POST(request: NextRequest) {
  try {
    // Get current session before clearing
    const user = await getStaffSession();

    // Clear the staff session cookie
    const cookieStore = cookies();
    cookieStore.delete("staff-session");

    // Log logout if we had a session
    if (user) {
    }

    return NextResponse.json({ success: true });
  } catch (error) {
    logger.error("Logout error", error);
    return NextResponse.json({ success: true }); // Still clear session even on error
  }
}
