location hiarrch alteration done

This commit is contained in:
laxman h 2026-03-26 21:20:58 +05:30
parent a43d3efa68
commit 6edb5da84f
2 changed files with 4 additions and 2 deletions

View File

@ -379,7 +379,7 @@ export const updateUser = async (req: AuthRequest, res: Response) => {
await user.update(updates); await user.update(updates);
if (Array.isArray(assignments)) { if (Array.isArray(assignments)) {
await upsertUserAssignments(id, assignments, req.user?.id); await upsertUserAssignments(id as string, assignments, req.user?.id);
} else if (roleCode !== undefined || locationId !== undefined) { } else if (roleCode !== undefined || locationId !== undefined) {
const primaryRoleCode = roleCode || user.roleCode; const primaryRoleCode = roleCode || user.roleCode;
if (primaryRoleCode) { if (primaryRoleCode) {

View File

@ -331,7 +331,9 @@ export const getManagersByRole = async (req: Request, res: Response) => {
const asmAssignments = assignments.filter((a: any) => const asmAssignments = assignments.filter((a: any) =>
(a.role?.roleCode === 'ASM' || m.roleCode === 'ASM') && a.location?.type === 'area' (a.role?.roleCode === 'ASM' || m.roleCode === 'ASM') && a.location?.type === 'area'
); );
const asmCode = assignments.find((a: any) => a.managerCode)?.managerCode || null; const asmCode = assignments.find((a: any) =>
(a.role?.roleCode === 'ASM' || m.roleCode === 'ASM') && a.managerCode
)?.managerCode || null;
const result = m.toJSON(); const result = m.toJSON();
result.asmCode = asmCode; result.asmCode = asmCode;