mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-21 14:08:15 +02:00
Fix product assignment for users in different stores to ensure correct placement
Implement backend logic to ensure correct product group assignment, resolving an issue where products were incorrectly placed in the wrong store due to missing group ID data from the frontend, and add detailed logging for better debugging. Replit-Commit-Author: Agent Replit-Commit-Session-Id: b163d4c0-de5e-4f4e-a9c0-aed4c7049718 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/b163d4c0-de5e-4f4e-a9c0-aed4c7049718/PoPN0Ru
This commit is contained in:
1 parent
9f53d7b296
commit
00e3c98550
6 files changed
+124
-5
No files matched your search
+17
-1
@@ -2319,15 +2319,31 @@ RÉSUMÉ DU SCAN
|
||||
userGroups: user.userGroups?.map(ug => ({groupId: ug.group.id, groupName: ug.group.name}))
|
||||
});
|
||||
|
||||
// Fix groupId if missing - use user's assigned group or fallback
|
||||
let finalGroupId = req.body.groupId;
|
||||
if (!finalGroupId) {
|
||||
if (user.userGroups?.[0]?.groupId) {
|
||||
finalGroupId = user.userGroups[0].groupId;
|
||||
console.log("🔧 Backend Fix: Using user's assigned group:", finalGroupId);
|
||||
} else {
|
||||
finalGroupId = 1; // Emergency fallback
|
||||
console.log("🚨 Backend Fix: Using emergency fallback groupId:", finalGroupId);
|
||||
}
|
||||
}
|
||||
|
||||
console.log("🔍 Pre-validation data:", {
|
||||
body: req.body,
|
||||
userId,
|
||||
combined: { ...req.body, createdBy: userId }
|
||||
userGroups: user.userGroups?.map(ug => ({groupId: ug.groupId, groupName: ug.group?.name})),
|
||||
originalGroupId: req.body.groupId,
|
||||
finalGroupId,
|
||||
combined: { ...req.body, createdBy: userId, groupId: finalGroupId }
|
||||
});
|
||||
|
||||
const validatedData = insertDlcProductFrontendSchema.parse({
|
||||
...req.body,
|
||||
createdBy: userId,
|
||||
groupId: finalGroupId,
|
||||
});
|
||||
|
||||
console.log("✅ Post-validation data:", validatedData);
|
||||
|
||||
Reference in new issue
Block a user