import { NextResponse } from 'next/server';
import { getAllCategories } from '@/lib/utils/db';

export async function GET() {
  try {
    const categoriesDb = await getAllCategories();
    // Return only what is needed for the Navigation Manager lock rows
    const categories = categoriesDb.map((c: any) => ({
      id: c.slug,
      name: c.japanese,
      slug: c.slug,
    }));
    return NextResponse.json({ categories });
  } catch (error: any) {
    console.error('Error fetching categories for editor:', error);
    return NextResponse.json({ error: error.message }, { status: 500 });
  }
}
