Added Teams
Minor Rework of Plantafel
This commit is contained in:
@@ -9,6 +9,7 @@ import {
|
||||
|
||||
import {and, eq, inArray} from "drizzle-orm"
|
||||
import { enrichProfilesWithBranches } from "../../utils/profileBranches"
|
||||
import { enrichProfilesWithTeams } from "../../utils/profileTeams"
|
||||
|
||||
|
||||
export default async function tenantRoutesInternal(server: FastifyInstance) {
|
||||
@@ -62,7 +63,8 @@ export default async function tenantRoutesInternal(server: FastifyInstance) {
|
||||
eq(authProfiles.tenant_id, tenantId),
|
||||
inArray(authProfiles.user_id, userIds)
|
||||
))
|
||||
const profiles = await enrichProfilesWithBranches(server, profileRows)
|
||||
const profilesWithBranches = await enrichProfilesWithBranches(server, profileRows)
|
||||
const profiles = await enrichProfilesWithTeams(server, profilesWithBranches)
|
||||
|
||||
const combined = users.map(u => {
|
||||
const profile = profiles.find(p => p.user_id === u.id)
|
||||
@@ -98,7 +100,8 @@ export default async function tenantRoutesInternal(server: FastifyInstance) {
|
||||
.from(authProfiles)
|
||||
.where(eq(authProfiles.tenant_id, tenantId))
|
||||
|
||||
return await enrichProfilesWithBranches(server, profileRows)
|
||||
const profilesWithBranches = await enrichProfilesWithBranches(server, profileRows)
|
||||
return await enrichProfilesWithTeams(server, profilesWithBranches)
|
||||
|
||||
} catch (err) {
|
||||
console.error("/tenant/profiles ERROR:", err)
|
||||
|
||||
Reference in New Issue
Block a user