mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-11 17:27:31 +02:00
Corrected the logic in `DlcPage.tsx` to properly assign the `groupId` for DLC products, ensuring users are associated with their correct store group. 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/W2tfZav
1.9 KiB
1.9 KiB
Fix DLC GroupId - Production
Problème Identifié
Utilisateurs assignés au magasin #2 créent des DLC pour le magasin #1
Cause du Problème
Dans client/src/pages/DlcPage.tsx ligne 208, la logique était incorrecte :
// AVANT (Problématique)
groupId: selectedStoreId || stores[0]?.id || 2
Problème : Pour un utilisateur non-admin assigné au magasin #2 :
selectedStoreId= undefined (pas admin)stores[0]?.id= 1 (premier magasin de la liste)- Résultat : DLC créée pour magasin #1 au lieu de #2
Solution Appliquée
Nouvelle logique de sélection groupId :
// APRÈS (Corrigé)
let groupId;
if (user?.role === 'admin' && selectedStoreId) {
// Admin avec magasin sélectionné
groupId = selectedStoreId;
} else if (user?.userGroups?.[0]?.groupId) {
// Utilisateur non-admin : utiliser son groupe assigné ✅
groupId = user.userGroups[0].groupId;
} else if (user?.role === 'admin') {
// Admin sans sélection : premier magasin disponible
groupId = stores[0]?.id || 1;
} else {
// Fallback par défaut
groupId = 1;
}
Priorité de Sélection
- Admin avec magasin sélectionné →
selectedStoreId - Utilisateur avec groupe assigné →
user.userGroups[0].groupId✅ FIX PRINCIPAL - Admin sans sélection → Premier magasin disponible
- Fallback → Magasin #1
Log de Debug Ajouté
console.log("🏪 DLC GroupId Selection:", {
userRole: user?.role,
selectedStoreId,
userGroups: user?.userGroups?.map(ug => ({groupId: ug.groupId, groupName: ug.group?.name})),
finalGroupId: groupId
});
Test Production
Maintenant un employé assigné au magasin #2 devrait créer des DLC avec groupId: 2 au lieu de groupId: 1.
Déploiement
- ✅ Logique groupId corrigée dans
DlcPage.tsx - ✅ Debug logs ajoutés pour traçabilité
- 🔄 Redémarrer serveur production
- 🧪 Tester création DLC avec employé magasin #2