mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-14 02:38:58 +02:00
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:
1 parent
39bae75d82
commit
c419733954
5 files changed
+298
-20
No files matched your search
@@ -81,7 +81,7 @@ export function CustomerOrderForm({
|
||||
deposit: order?.deposit || 0,
|
||||
isPromotionalPrice: order?.isPromotionalPrice || false,
|
||||
customerNotified: order?.customerNotified || false,
|
||||
groupId: order?.groupId || (user?.role === 'admin' && selectedStoreId ? selectedStoreId : user?.userGroups?.[0]?.groupId) || 1, // Force assignment with fallback
|
||||
groupId: order?.groupId || (user?.userGroups?.[0]?.groupId || (user?.role === 'admin' && selectedStoreId ? selectedStoreId : 1)), // PRIORITÉ: groupe utilisateur assigné
|
||||
},
|
||||
});
|
||||
|
||||
@@ -107,27 +107,28 @@ export function CustomerOrderForm({
|
||||
availableGroups: groups.map(g => ({id: g.id, name: g.name}))
|
||||
});
|
||||
|
||||
// FORCE L'UTILISATION DU GROUPE ASSIGNÉ EN PREMIER - MÊME LOGIQUE QUE DLC
|
||||
if (!groupId) {
|
||||
if (user?.role === 'admin' && selectedStoreId) {
|
||||
// Admin has selected a specific store - use it
|
||||
groupId = selectedStoreId;
|
||||
console.log("🏪 Using admin selected store:", selectedStoreId);
|
||||
} else if (user?.userGroups?.[0]?.groupId) {
|
||||
// User has assigned groups - use first one
|
||||
if (user?.userGroups?.[0]?.groupId) {
|
||||
// Utilisateur avec groupe assigné : TOUJOURS utiliser ce groupe (PRIORITÉ)
|
||||
groupId = user.userGroups[0].groupId;
|
||||
console.log("👤 Using user group:", groupId);
|
||||
console.log("🎯 Customer Order 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("🎯 Customer Order Frontend: Using admin selected store:", groupId);
|
||||
} else if (user?.role === 'admin' && groups.length > 0) {
|
||||
// Admin in "tous magasins" mode - use first group
|
||||
// Admin sans sélection : premier groupe disponible
|
||||
groupId = groups[0].id;
|
||||
console.log("🏢 Admin fallback to first group:", groupId);
|
||||
console.log("🎯 Customer Order Frontend: Using first group for admin:", groupId);
|
||||
} else if (groups.length > 0) {
|
||||
// EMERGENCY FALLBACK: Force assignment to first available group
|
||||
groupId = groups[0].id;
|
||||
console.log("⚠️ EMERGENCY: Force assigning to first group:", groupId);
|
||||
console.log("⚠️ Customer Order Frontend: Emergency fallback to first group:", groupId);
|
||||
} else {
|
||||
// LAST RESORT: Hard-coded fallback
|
||||
groupId = 1;
|
||||
console.log("🚨 LAST RESORT: Using hard-coded groupId 1");
|
||||
console.log("🚨 Customer Order Frontend: Using hard-coded groupId 1");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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:", {
|
||||
|
||||
Reference in new issue
Block a user