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
Some checks failed
Build and Push Docker Image / build-and-push (push) Has been cancelled
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user