diff --git a/attached_assets/{AC351FEE-BC19-401B-8F42-FBCC89BBAEDB}_1755013256979.png b/attached_assets/{AC351FEE-BC19-401B-8F42-FBCC89BBAEDB}_1755013256979.png new file mode 100644 index 0000000..121528f Binary files /dev/null and b/attached_assets/{AC351FEE-BC19-401B-8F42-FBCC89BBAEDB}_1755013256979.png differ diff --git a/client/src/components/CustomerOrderForm.tsx b/client/src/components/CustomerOrderForm.tsx index f34f652..548022c 100644 --- a/client/src/components/CustomerOrderForm.tsx +++ b/client/src/components/CustomerOrderForm.tsx @@ -135,30 +135,8 @@ export function CustomerOrderForm({ fullUserObject: user }); - // FORCE L'UTILISATION DU GROUPE ASSIGNÉ EN PREMIER - MÊME LOGIQUE QUE DLC - if (!groupId) { - if (user?.userGroups?.[0]?.groupId) { - // Utilisateur avec groupe assigné : TOUJOURS utiliser ce groupe (PRIORITÉ) - groupId = user.userGroups[0].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 sans sélection : premier groupe disponible - groupId = groups[0].id; - 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("⚠️ Customer Order Frontend: Emergency fallback to first group:", groupId); - } else { - // LAST RESORT: Hard-coded fallback - groupId = 1; - console.log("🚨 Customer Order Frontend: Using hard-coded groupId 1"); - } - } + // GroupId should already be correct from defaultValues - no override needed + console.log("✅ Customer Order: Using groupId from form (defaultValues already correct):", groupId); console.log("✅ CUSTOMER ORDER - Final groupId selected:", groupId, typeof groupId); diff --git a/replit.md b/replit.md index 2a51716..f386c9e 100644 --- a/replit.md +++ b/replit.md @@ -44,7 +44,7 @@ Preferred communication style: Simple, everyday language. - **Reconciliation Module**: For balancing and tracking financial discrepancies. **PRODUCTION-READY**: Rebuilt with robust UI components to eliminate React #310 errors in production. - **Automatic Reconciliation System**: Dual-mode BL/Invoice reconciliation with automatic validation for suppliers in automatic mode. Auto-validates deliveries when status = "delivered" AND BL number exists. - **Permission System**: Granular, hardcoded permissions (54 permissions across 12 categories, assigned to 4 roles) for improved performance and maintenance. **EMPLOYEE PERMISSIONS**: Employees can create customer orders and DLC products. -- **User Management**: Comprehensive features including user deletion with ownership transfer, consistent name and email field handling, and robust password hashing. **EMPLOYEE CUSTOMER ORDERS**: Fixed critical groupId assignment bug where employees assigned to store #2 were creating customer orders for store #1. Implemented dual-layer backend security with automatic groupId fallback from user assignments. +- **User Management**: Comprehensive features including user deletion with ownership transfer, consistent name and email field handling, and robust password hashing. **EMPLOYEE CUSTOMER ORDERS FINAL**: Fixed critical groupId assignment bug where employees assigned to store #2 were creating customer orders for store #1. Root cause was missing userGroups in /api/user response + form defaultValues override logic. Implemented proper group prioritization in both defaultValues and removed override logic in handleSubmit. - **Calendar Synchronization**: Proper display of delivery dates and automatic synchronization of order statuses. - **Database Schema Download**: Admin-only feature to download comprehensive database structure reports. - **DLC Product Management**: **PRODUCTION-READY**: Corrected MemStorage implementation for proper DLC persistence in development. Cache invalidation fixed with exact:false for production compatibility. **GROUPID-FIX-FINAL**: Resolved issue where users assigned to store #2 were creating DLC products for store #1 by implementing dual-layer groupId fallback logic (frontend + backend security).