mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-11 17:27:31 +02:00
Make managers see orders from their assigned store automatically
Update manager role logic in routes.ts to automatically use the first assigned store for orders and deliveries, and handle cases where no stores are assigned. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 0ec86cdf-a5be-4b0e-84a3-07b926f5cc80 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/0ec86cdf-a5be-4b0e-84a3-07b926f5cc80/PHXoZau
This commit is contained in:
1 parent
1a21876978
commit
172541c2b7
1 file changed
+32
-16
+32
-16
@@ -384,15 +384,23 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
return res.json([]);
|
||||
}
|
||||
} else {
|
||||
// For manager role, when no specific store is selected, show orders from all their assigned groups
|
||||
// For manager role, automatically use their assigned store
|
||||
if (user.role === 'manager') {
|
||||
groupIds = userGroupIds.length > 0 ? userGroupIds : undefined;
|
||||
console.log('🔍 Manager orders - showing all accessible stores:', {
|
||||
userId: user.id,
|
||||
role: user.role,
|
||||
userGroups: userGroupIds,
|
||||
groupIds
|
||||
});
|
||||
if (userGroupIds.length > 0) {
|
||||
groupIds = [userGroupIds[0]]; // Use first assigned store automatically
|
||||
console.log('🔍 Manager orders - using assigned store automatically:', {
|
||||
userId: user.id,
|
||||
role: user.role,
|
||||
assignedStore: userGroupIds[0],
|
||||
allUserGroups: userGroupIds
|
||||
});
|
||||
} else {
|
||||
console.log('🚫 Manager has no assigned stores:', {
|
||||
userId: user.id,
|
||||
role: user.role
|
||||
});
|
||||
return res.json([]);
|
||||
}
|
||||
} else {
|
||||
// For employee role, require explicit store selection
|
||||
console.log('🔍 Employee orders - no store selection, returning empty:', {
|
||||
@@ -707,15 +715,23 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
return res.json([]);
|
||||
}
|
||||
} else {
|
||||
// For manager role, when no specific store is selected, show deliveries from all their assigned groups
|
||||
// For manager role, automatically use their assigned store
|
||||
if (user.role === 'manager') {
|
||||
groupIds = userGroupIds.length > 0 ? userGroupIds : undefined;
|
||||
console.log('🔍 Manager deliveries - showing all accessible stores:', {
|
||||
userId: user.id,
|
||||
role: user.role,
|
||||
userGroups: userGroupIds,
|
||||
groupIds
|
||||
});
|
||||
if (userGroupIds.length > 0) {
|
||||
groupIds = [userGroupIds[0]]; // Use first assigned store automatically
|
||||
console.log('🔍 Manager deliveries - using assigned store automatically:', {
|
||||
userId: user.id,
|
||||
role: user.role,
|
||||
assignedStore: userGroupIds[0],
|
||||
allUserGroups: userGroupIds
|
||||
});
|
||||
} else {
|
||||
console.log('🚫 Manager has no assigned stores:', {
|
||||
userId: user.id,
|
||||
role: user.role
|
||||
});
|
||||
return res.json([]);
|
||||
}
|
||||
} else {
|
||||
// For employee role, require explicit store selection
|
||||
console.log('🔍 Employee deliveries - no store selection, returning empty:', {
|
||||
|
||||
Reference in new issue
Block a user