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

export async function GET() {
  try {
    const icons = await db.iconAsset.findMany({
      orderBy: [{ category: { sortOrder: 'asc' } }, { name: 'asc' }],
      include: {
        category: true,
      },
    })

    return NextResponse.json({ icons })
  } catch (error) {
    console.error('Error fetching icons:', error)
    return NextResponse.json({ error: 'Interner Fehler' }, { status: 500 })
  }
}
