chore: build
This commit is contained in:
@@ -52,10 +52,15 @@ func (d *Database) CreateProduct(product any) error {
|
|||||||
UpdatedAt time.Time `gorm:"column:updated_at"`
|
UpdatedAt time.Time `gorm:"column:updated_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
comingSoonVal := false
|
||||||
|
if prodModel, ok2 := product.(*models.Product); ok2 {
|
||||||
|
comingSoonVal = prodModel.ComingSoon
|
||||||
|
}
|
||||||
|
|
||||||
err := d.GDB.Raw(`
|
err := d.GDB.Raw(`
|
||||||
INSERT INTO products (name, category, description, stock, unit, created_at, updated_at)
|
INSERT INTO products (name, category, description, stock, unit, coming_soon, created_at, updated_at)
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?) RETURNING id, created_at, updated_at`,
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?) RETURNING id, created_at, updated_at`,
|
||||||
p.GetName(), p.GetCategory(), p.GetDescription(), p.GetStock(), p.GetUnit(), now, now,
|
p.GetName(), p.GetCategory(), p.GetDescription(), p.GetStock(), p.GetUnit(), comingSoonVal, now, now,
|
||||||
).Scan(&result).Error
|
).Scan(&result).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("❌ [DB CreateProduct] Erreur INSERT: %v", err)
|
log.Printf("❌ [DB CreateProduct] Erreur INSERT: %v", err)
|
||||||
|
|||||||
@@ -238,6 +238,7 @@ func CreateProduct(c *gin.Context) {
|
|||||||
for priceIndex < 100 { // Limite anti-spam
|
for priceIndex < 100 { // Limite anti-spam
|
||||||
quantityKey := fmt.Sprintf("prices[%d][quantity]", priceIndex)
|
quantityKey := fmt.Sprintf("prices[%d][quantity]", priceIndex)
|
||||||
priceKey := fmt.Sprintf("prices[%d][price]", priceIndex)
|
priceKey := fmt.Sprintf("prices[%d][price]", priceIndex)
|
||||||
|
activePriceKey := fmt.Sprintf("prices[%d][active_price]", priceIndex)
|
||||||
|
|
||||||
quantityStr := c.PostForm(quantityKey)
|
quantityStr := c.PostForm(quantityKey)
|
||||||
priceStr := c.PostForm(priceKey)
|
priceStr := c.PostForm(priceKey)
|
||||||
@@ -263,9 +264,13 @@ func CreateProduct(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
activePriceStr := c.PostForm(activePriceKey)
|
||||||
|
activePrice := activePriceStr != "false"
|
||||||
|
|
||||||
prices = append(prices, models.ProductPrice{
|
prices = append(prices, models.ProductPrice{
|
||||||
Quantity: quantity,
|
Quantity: quantity,
|
||||||
Price: price,
|
Price: price,
|
||||||
|
ActivePrice: activePrice,
|
||||||
})
|
})
|
||||||
|
|
||||||
priceIndex++
|
priceIndex++
|
||||||
|
|||||||
@@ -1041,7 +1041,7 @@ export default function ProductsScreen() {
|
|||||||
styles.comingSoonBtnText,
|
styles.comingSoonBtnText,
|
||||||
form.comingSoon && styles.comingSoonBtnTextActive,
|
form.comingSoon && styles.comingSoonBtnTextActive,
|
||||||
]}>
|
]}>
|
||||||
{form.comingSoon ? "🔜 À venir (activé)" : "🔜 Marquer comme «À venir»"}
|
{form.comingSoon ? "À venir (activé)" : "Marquer comme «À venir»"}
|
||||||
</Text>
|
</Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user