mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-15 03:09:32 +02:00
Fix incorrect product assignment for store-assigned users
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
This commit is contained in:
1 parent
4abe7f8cd1
commit
03d18b91e0
4 files changed
+96
-3
No files matched your search
@@ -198,6 +198,29 @@ export default function DlcPage() {
|
||||
// Calculer la date d'expiration et le seuil d'alerte (15 jours avant)
|
||||
const dlcDate = new Date(data.dlcDate);
|
||||
|
||||
// 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é
|
||||
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;
|
||||
}
|
||||
|
||||
console.log("🏪 DLC GroupId Selection:", {
|
||||
userRole: user?.role,
|
||||
selectedStoreId,
|
||||
userGroups: user?.userGroups?.map(ug => ({groupId: ug.groupId, groupName: ug.group?.name})),
|
||||
finalGroupId: groupId
|
||||
});
|
||||
|
||||
const dlcData: InsertDlcProduct = {
|
||||
...data,
|
||||
dlcDate,
|
||||
@@ -205,7 +228,7 @@ export default function DlcPage() {
|
||||
unit: "unité", // Valeur par défaut
|
||||
location: "Magasin", // Valeur par défaut
|
||||
alertThreshold: 15, // Toujours 15 jours
|
||||
groupId: selectedStoreId || stores[0]?.id || 2, // Utilise le magasin sélectionné ou le premier disponible
|
||||
groupId,
|
||||
};
|
||||
|
||||
if (editingProduct) {
|
||||
|
||||
Reference in new issue
Block a user