From 9b50dca96cef6afc8b1810652bb987950fefe55a Mon Sep 17 00:00:00 2001 From: Xor290 Date: Thu, 11 Jun 2026 12:16:02 +0200 Subject: [PATCH] chore: build --- backend/gestion/db/db_product.go | 11 ++++++++--- backend/gestion/handlers/product.go | 9 +++++++-- frontend-admin/src/screens/admin/ProductsScreen.tsx | 2 +- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/backend/gestion/db/db_product.go b/backend/gestion/db/db_product.go index 95e639b8..dc640f2d 100644 --- a/backend/gestion/db/db_product.go +++ b/backend/gestion/db/db_product.go @@ -52,10 +52,15 @@ func (d *Database) CreateProduct(product any) error { UpdatedAt time.Time `gorm:"column:updated_at"` } + comingSoonVal := false + if prodModel, ok2 := product.(*models.Product); ok2 { + comingSoonVal = prodModel.ComingSoon + } + err := d.GDB.Raw(` - INSERT INTO products (name, category, description, stock, unit, created_at, updated_at) - VALUES (?, ?, ?, ?, ?, ?, ?) RETURNING id, created_at, updated_at`, - p.GetName(), p.GetCategory(), p.GetDescription(), p.GetStock(), p.GetUnit(), now, now, + INSERT INTO products (name, category, description, stock, unit, coming_soon, created_at, updated_at) + VALUES (?, ?, ?, ?, ?, ?, ?, ?) RETURNING id, created_at, updated_at`, + p.GetName(), p.GetCategory(), p.GetDescription(), p.GetStock(), p.GetUnit(), comingSoonVal, now, now, ).Scan(&result).Error if err != nil { log.Printf("❌ [DB CreateProduct] Erreur INSERT: %v", err) diff --git a/backend/gestion/handlers/product.go b/backend/gestion/handlers/product.go index 6ebcc7ee..cd83cb40 100644 --- a/backend/gestion/handlers/product.go +++ b/backend/gestion/handlers/product.go @@ -238,6 +238,7 @@ func CreateProduct(c *gin.Context) { for priceIndex < 100 { // Limite anti-spam quantityKey := fmt.Sprintf("prices[%d][quantity]", priceIndex) priceKey := fmt.Sprintf("prices[%d][price]", priceIndex) + activePriceKey := fmt.Sprintf("prices[%d][active_price]", priceIndex) quantityStr := c.PostForm(quantityKey) priceStr := c.PostForm(priceKey) @@ -263,9 +264,13 @@ func CreateProduct(c *gin.Context) { return } + activePriceStr := c.PostForm(activePriceKey) + activePrice := activePriceStr != "false" + prices = append(prices, models.ProductPrice{ - Quantity: quantity, - Price: price, + Quantity: quantity, + Price: price, + ActivePrice: activePrice, }) priceIndex++ diff --git a/frontend-admin/src/screens/admin/ProductsScreen.tsx b/frontend-admin/src/screens/admin/ProductsScreen.tsx index 4020ec24..533bb8ec 100644 --- a/frontend-admin/src/screens/admin/ProductsScreen.tsx +++ b/frontend-admin/src/screens/admin/ProductsScreen.tsx @@ -1041,7 +1041,7 @@ export default function ProductsScreen() { styles.comingSoonBtnText, form.comingSoon && styles.comingSoonBtnTextActive, ]}> - {form.comingSoon ? "🔜 À venir (activé)" : "🔜 Marquer comme «À venir»"} + {form.comingSoon ? "À venir (activé)" : "Marquer comme «À venir»"}