fix(symbol-groups): API + Frontend auf category-Objekt-Format umgestellt – zeigt jetzt alle Kategorien korrekt
Some checks failed
Build and Push Docker Image / build-and-push (push) Has been cancelled

This commit is contained in:
Pepe Ziberi
2026-05-21 15:25:12 +02:00
parent 9cba24aad8
commit 0cbea843ab
3 changed files with 23 additions and 27 deletions

View File

@@ -115,12 +115,12 @@ export async function GET() {
const groups = new Map<string | null, any[]>()
for (const sym of flatTenantSymbols) {
const key = sym.categoryId || null
const key = sym.categoryId || '__none__'
if (!groups.has(key)) groups.set(key, [])
groups.get(key)!.push(sym)
}
const catIds = Array.from(groups.keys()).filter(Boolean) as string[]
const catIds = Array.from(groups.keys()).filter(k => k !== '__none__') as string[]
let tenantCategories: any[] = []
if (catIds.length > 0) {
tenantCategories = await prisma.$queryRawUnsafe(
@@ -132,15 +132,12 @@ export async function GET() {
const catMap = new Map(tenantCategories.map((c: any) => [c.id, c]))
tenantSymbolGroups = Array.from(groups.entries()).map(([catId, symbols]) => {
const cat = catId ? catMap.get(catId) : null
const cat = catId !== '__none__' ? catMap.get(catId) : null
return {
categoryId: catId,
categoryName: cat ? cat.name || 'Kategorie' : 'Ohne Kategorie',
sortOrder: cat ? cat.sortOrder ?? 999 : 999,
category: cat ? { id: cat.id, name: cat.name } : null,
symbols,
}
})
tenantSymbolGroups.sort((a, b) => a.sortOrder - b.sortOrder)
}
} catch (err) {
console.error('Error fetching tenant symbols:', err)