Prioritize assigned user group for creating customer orders and DLCs

Update frontend logic in CustomerOrderForm and DlcPage to correctly assign the user's group as the primary identifier, fixing an issue where group ID 1 was used incorrectly.

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/JC3ViEJ
This commit is contained in:
michaelschal committed 2025-08-12 15:14:34 +00:00
1 parent 39bae75d82
commit c419733954
5 files changed
+298 -20

No files matched your search

+14 -8
View File
@@ -200,18 +200,24 @@ export default function DlcPage() {
// Déterminer le groupId correctement selon le rôle utilisateur
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é
// FORCE L'UTILISATION DU GROUPE ASSIGNÉ EN PREMIER
if (user?.userGroups?.[0]?.groupId) {
// Utilisateur avec groupe assigné : TOUJOURS utiliser ce groupe
groupId = user.userGroups[0].groupId;
} else if (user?.role === 'admin') {
console.log("🎯 DLC Frontend: Using user's assigned group (PRIORITY):", groupId);
} else if (user?.role === 'admin' && selectedStoreId) {
// Admin avec magasin sélectionné ET pas de groupe assigné
groupId = selectedStoreId;
console.log("🎯 DLC Frontend: Using admin selected store:", groupId);
} else if (user?.role === 'admin' && stores?.[0]?.id) {
// Admin sans sélection : premier magasin disponible
groupId = stores[0]?.id || 1;
groupId = stores[0].id;
console.log("🎯 DLC Frontend: Using first available store for admin:", groupId);
} else {
// Fallback par défaut
// Fallback d'urgence
groupId = 1;
console.log("🚨 DLC Frontend: Using emergency fallback groupId:", groupId);
}
console.log("🏪 DLC GroupId Selection DEBUG:", {