mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-11 17:27:31 +02:00
Improve order creation and retrieval for employees by adding logging
Add detailed logging to the order creation and retrieval processes to help diagnose potential issues with employee group assignments and access. 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/CBVNFjA
This commit is contained in:
1 parent
9f00702fae
commit
cf738cc49a
2 files changed
+77
-5
No files matched your search
@@ -0,0 +1,57 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* Instructions de debug pour le problème DLC employé en production
|
||||
*/
|
||||
|
||||
console.log('🔍 Debug DLC Employé - Instructions Production');
|
||||
console.log('='.repeat(50));
|
||||
|
||||
console.log(`
|
||||
ÉTAPES DE DIAGNOSTIC:
|
||||
|
||||
1. 🔍 TESTER CRÉATION DLC EMPLOYÉ:
|
||||
- Se connecter en tant qu'employé
|
||||
- Créer une DLC
|
||||
- Regarder les logs serveur pour:
|
||||
"🔍 Creating DLC product - no role restrictions:"
|
||||
- Noter le requestGroupId et userGroups dans les logs
|
||||
|
||||
2. 🔍 TESTER RÉCUPÉRATION DLC EMPLOYÉ:
|
||||
- Immédiatement après création, aller sur la page DLC
|
||||
- Regarder les logs serveur pour:
|
||||
"🔍 DLC Products API called with:"
|
||||
- Comparer groupIds utilisateur vs groupId de la DLC créée
|
||||
|
||||
3. 🔍 VÉRIFIER ASSIGNATION GROUPES:
|
||||
- Si userGroups est vide ou ne contient pas le bon groupId
|
||||
- L'employé n'est pas assigné au bon groupe dans user_groups
|
||||
|
||||
4. 🔍 TESTS À FAIRE:
|
||||
|
||||
Test A - Créer DLC:
|
||||
POST /api/dlc-products avec groupId=1
|
||||
-> Vérifier le log "🔍 Creating DLC product"
|
||||
-> Noter requestGroupId et userGroups
|
||||
|
||||
Test B - Lister DLC:
|
||||
GET /api/dlc-products
|
||||
-> Vérifier le log "🔍 DLC Products API called with"
|
||||
-> Comparer groupIds filtrés vs groupId de création
|
||||
|
||||
5. 🔍 SOLUTION PROBABLE:
|
||||
- Si userGroups ne contient pas le requestGroupId
|
||||
- Ajouter l'employé au bon groupe dans la table user_groups
|
||||
- Ou modifier le frontend pour utiliser le bon groupId
|
||||
|
||||
LOGS À RECHERCHER:
|
||||
- "🔍 Creating DLC product - no role restrictions:"
|
||||
- "🔍 DLC Products API called with:"
|
||||
- "📋 DLC Products returned:"
|
||||
- "📋 Sample DLC products groupIds:"
|
||||
`);
|
||||
|
||||
console.log('\n🔧 Tests de validation rapides en production:');
|
||||
console.log('1. Vérifier les groupes assignés à l\'employé');
|
||||
console.log('2. Vérifier que la DLC est créée avec le bon groupId');
|
||||
console.log('3. Vérifier que le filtre groupIds inclut ce groupId');
|
||||
+20
-5
@@ -2219,11 +2219,13 @@ RÉSUMÉ DU SCAN
|
||||
if (status) filters.status = status;
|
||||
if (supplierId) filters.supplierId = parseInt(supplierId);
|
||||
|
||||
console.log('DLC Products API called with:', {
|
||||
console.log('🔍 DLC Products API called with:', {
|
||||
userId,
|
||||
userRole: user.role,
|
||||
userGroups: user.userGroups?.map(ug => ({groupId: ug.group.id, groupName: ug.group.name})),
|
||||
groupIds: user.role === 'admin' && !req.query.storeId ? 'all' : groupIds,
|
||||
filters
|
||||
filters,
|
||||
queryStoreId: req.query.storeId
|
||||
});
|
||||
|
||||
const dlcProducts = await storage.getDlcProducts(
|
||||
@@ -2231,7 +2233,10 @@ RÉSUMÉ DU SCAN
|
||||
filters
|
||||
);
|
||||
|
||||
console.log('DLC Products returned:', dlcProducts.length, 'items');
|
||||
console.log('📋 DLC Products returned:', dlcProducts.length, 'items');
|
||||
if (dlcProducts.length > 0) {
|
||||
console.log('📋 Sample DLC products groupIds:', dlcProducts.slice(0, 3).map(p => ({id: p.id, name: p.productName, groupId: p.groupId})));
|
||||
}
|
||||
res.json(dlcProducts);
|
||||
} catch (error) {
|
||||
console.error("Error fetching DLC products:", error);
|
||||
@@ -2307,7 +2312,12 @@ RÉSUMÉ DU SCAN
|
||||
}
|
||||
|
||||
// REMOVED: All role restrictions - tous les rôles peuvent créer des DLC
|
||||
console.log("Creating DLC product - no role restrictions:", { userId, userRole: user.role, groupId: req.body.groupId });
|
||||
console.log("🔍 Creating DLC product - no role restrictions:", {
|
||||
userId,
|
||||
userRole: user.role,
|
||||
requestGroupId: req.body.groupId,
|
||||
userGroups: user.userGroups?.map(ug => ({groupId: ug.group.id, groupName: ug.group.name}))
|
||||
});
|
||||
|
||||
const validatedData = insertDlcProductFrontendSchema.parse({
|
||||
...req.body,
|
||||
@@ -2315,7 +2325,12 @@ RÉSUMÉ DU SCAN
|
||||
});
|
||||
|
||||
const dlcProduct = await storage.createDlcProduct(validatedData);
|
||||
console.log('✅ DLC Product created successfully:', dlcProduct.id);
|
||||
console.log('✅ DLC Product created successfully:', {
|
||||
id: dlcProduct.id,
|
||||
productName: dlcProduct.productName,
|
||||
groupId: dlcProduct.groupId,
|
||||
createdBy: dlcProduct.createdBy
|
||||
});
|
||||
|
||||
res.status(201).json(dlcProduct);
|
||||
} catch (error) {
|
||||
|
||||
Reference in new issue
Block a user