redone admin

added branches
This commit is contained in:
2026-03-25 14:59:44 +01:00
parent 809a37a410
commit c29494dc0d
26 changed files with 1578 additions and 904 deletions

View File

@@ -8,6 +8,7 @@ import {
} from "../../../db/schema"
import {and, eq, inArray} from "drizzle-orm"
import { enrichProfilesWithBranches } from "../../utils/profileBranches"
export default async function tenantRoutesInternal(server: FastifyInstance) {
@@ -53,7 +54,7 @@ export default async function tenantRoutesInternal(server: FastifyInstance) {
.where(inArray(authUsers.id, userIds))
// 3) auth_profiles pro Tenant laden
const profiles = await server.db
const profileRows = await server.db
.select()
.from(authProfiles)
.where(
@@ -61,6 +62,7 @@ export default async function tenantRoutesInternal(server: FastifyInstance) {
eq(authProfiles.tenant_id, tenantId),
inArray(authProfiles.user_id, userIds)
))
const profiles = await enrichProfilesWithBranches(server, profileRows)
const combined = users.map(u => {
const profile = profiles.find(p => p.user_id === u.id)
@@ -91,12 +93,12 @@ export default async function tenantRoutesInternal(server: FastifyInstance) {
const tenantId = req.params.id
if (!tenantId) return reply.code(401).send({ error: "Unauthorized" })
const data = await server.db
const profileRows = await server.db
.select()
.from(authProfiles)
.where(eq(authProfiles.tenant_id, tenantId))
return data
return await enrichProfilesWithBranches(server, profileRows)
} catch (err) {
console.error("/tenant/profiles ERROR:", err)