Add named teams and per-user data visibility (own/team/org) with settings UI and org module.

This commit is contained in:
2026-09-26 17:15:09 +03:30
parent 499d13d1df
commit 1b160c8cd3
17 changed files with 1097 additions and 28 deletions
+5 -2
View File
@@ -403,13 +403,16 @@ export class SalesService {
actor: Actor,
filterUserId?: string,
): Prisma.SalesGoalWhereInput {
if (elevated(actor.role)) {
if (elevated(actor.role) || actor.dataVisibility === 'org' || actor.visibleUserIds === null) {
if (filterUserId === 'org') return { userId: null };
if (filterUserId) return { userId: filterUserId };
return {};
}
const ids = actor.visibleUserIds?.length
? actor.visibleUserIds
: [actor.userId];
return {
OR: [{ userId: actor.userId }, { userId: null }],
OR: [{ userId: { in: ids } }, { userId: null }],
};
}