Assignee picker: return only ADMIN/AGENT (exclude collaborators/managers)
This commit is contained in:
parent
51d92b230e
commit
2607ca5ce3
1 changed files with 6 additions and 5 deletions
|
|
@ -2,7 +2,10 @@ import { mutation, query } from "./_generated/server";
|
|||
import { ConvexError, v } from "convex/values";
|
||||
import { requireAdmin } from "./rbac";
|
||||
|
||||
const STAFF_ROLES = new Set(["ADMIN", "MANAGER", "AGENT", "COLLABORATOR"]);
|
||||
// All roles that have staff-level access in some areas. Do NOT include COLLABORATOR here
|
||||
// to avoid leaking collaborators into staff pickers such as "responsável".
|
||||
const STAFF_ROLES = new Set(["ADMIN", "MANAGER", "AGENT"]);
|
||||
const INTERNAL_STAFF_ROLES = new Set(["ADMIN", "AGENT"]);
|
||||
|
||||
export const ensureUser = mutation({
|
||||
args: {
|
||||
|
|
@ -81,11 +84,9 @@ export const listAgents = query({
|
|||
.withIndex("by_tenant", (q) => q.eq("tenantId", tenantId))
|
||||
.collect();
|
||||
|
||||
// Only internal staff (ADMIN/AGENT) should appear as responsáveis
|
||||
return users
|
||||
.filter((user) => {
|
||||
const normalizedRole = (user.role ?? "AGENT").toUpperCase();
|
||||
return STAFF_ROLES.has(normalizedRole);
|
||||
})
|
||||
.filter((user) => INTERNAL_STAFF_ROLES.has((user.role ?? "AGENT").toUpperCase()))
|
||||
.sort((a, b) => a.name.localeCompare(b.name, "pt-BR"));
|
||||
},
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue