chore: build
Backend - Build & Lint / build (push) Successful in 31m25s
Frontend Admin - EAS Build / build (push) Successful in 1h24m40s

This commit is contained in:
Xor290
2026-11-15 22:05:14 +01:00
parent 3ce40dd2be
commit beb78bf062
14 changed files with 1204 additions and 35 deletions
+20 -1
View File
@@ -510,7 +510,7 @@ func UpdateProduct(c *gin.Context) {
return
}
_, err = database.GetProductByID(id)
current, err := database.GetProductByID(id)
if err != nil {
c.JSON(http.StatusNotFound, gin.H{"error": "Produit non trouvé"})
return
@@ -574,6 +574,25 @@ func UpdateProduct(c *gin.Context) {
}
}
// L'unité n'est qu'un libellé : la changer réinterpréterait les quantités des paniers et commandes en cours.
if current.Unit != "" && updateData.Unit != current.Unit {
baskets, commands, err := database.CountOpenProductUsage(id)
if err != nil {
utils.ServerErr(c, "Erreur vérification paniers et commandes", err)
return
}
if baskets > 0 || commands > 0 {
c.JSON(http.StatusConflict, gin.H{
"error": fmt.Sprintf("Impossible de changer l'unité (%s → %s) : produit présent dans %d panier(s) et %d commande(s) en cours", current.Unit, updateData.Unit, baskets, commands),
"open_baskets": baskets,
"open_commands": commands,
"current_unit": current.Unit,
"requested_unit": updateData.Unit,
})
return
}
}
log.Printf("🔄 [UpdateProduct] %s met à jour produit #%d", username, id)
comingSoon := false