chore: update
This commit is contained in:
@@ -51,6 +51,11 @@ func AddProductsBasket(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if p, err := database.GetProductByID(req.ProductID); err == nil && p.ComingSoon {
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"error": "Ce produit n'est pas encore disponible"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
panier, err := database.AddToBasket(req.Username, req.ProductID, req.Quantity)
|
panier, err := database.AddToBasket(req.Username, req.ProductID, req.Quantity)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("❌ [ADD_PANIER] product_id=%d qty=%.3f: %v", req.ProductID, req.Quantity, err)
|
log.Printf("❌ [ADD_PANIER] product_id=%d qty=%.3f: %v", req.ProductID, req.Quantity, err)
|
||||||
|
|||||||
@@ -642,11 +642,11 @@ export default function ProductsScreen() {
|
|||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
},
|
},
|
||||||
comingSoonBtnActive: {
|
comingSoonBtnActive: {
|
||||||
borderColor: "#f59e0b",
|
borderColor: "#22c55e",
|
||||||
backgroundColor: "#f59e0b20",
|
backgroundColor: "#22c55e20",
|
||||||
},
|
},
|
||||||
comingSoonBtnText: { color: colors.textMuted, fontSize: fontSize.sm },
|
comingSoonBtnText: { color: colors.textMuted, fontSize: fontSize.sm },
|
||||||
comingSoonBtnTextActive: { color: "#f59e0b", fontWeight: "700" },
|
comingSoonBtnTextActive: { color: "#22c55e", fontWeight: "700" },
|
||||||
|
|
||||||
// Prices
|
// Prices
|
||||||
sectionHeader: {
|
sectionHeader: {
|
||||||
@@ -1027,7 +1027,14 @@ export default function ProductsScreen() {
|
|||||||
form.comingSoon && styles.comingSoonBtnActive,
|
form.comingSoon && styles.comingSoonBtnActive,
|
||||||
]}
|
]}
|
||||||
onPress={() =>
|
onPress={() =>
|
||||||
setForm((f) => ({ ...f, comingSoon: !f.comingSoon }))
|
setForm((f) => {
|
||||||
|
const next = !f.comingSoon;
|
||||||
|
return {
|
||||||
|
...f,
|
||||||
|
comingSoon: next,
|
||||||
|
prices: f.prices.map((p) => ({ ...p, active: !next })),
|
||||||
|
};
|
||||||
|
})
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Text style={[
|
<Text style={[
|
||||||
|
|||||||
@@ -183,17 +183,19 @@ function ProductCard({
|
|||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<button
|
<button
|
||||||
className={`quick-add-btn ${isOutOfStock ? "disabled" : ""}`}
|
className={`quick-add-btn ${isOutOfStock || isComingSoon ? "disabled" : ""}`}
|
||||||
onClick={handleQuickAddClick}
|
onClick={handleQuickAddClick}
|
||||||
disabled={isOutOfStock}
|
disabled={isOutOfStock || isComingSoon}
|
||||||
style={
|
style={
|
||||||
categoryColor && !isOutOfStock
|
categoryColor && !isOutOfStock && !isComingSoon
|
||||||
? { background: categoryColor, color: getTextColor(categoryColor) }
|
? { background: categoryColor, color: getTextColor(categoryColor) }
|
||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{isOutOfStock
|
{isOutOfStock
|
||||||
? "Rupture de stock"
|
? "Rupture de stock"
|
||||||
|
: isComingSoon
|
||||||
|
? "Bientôt disponible"
|
||||||
: "Ajouter rapidement"}
|
: "Ajouter rapidement"}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
|||||||
@@ -306,12 +306,14 @@ function ProductDetail() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
className={`add-to-cart-button ${isOutOfStock || selectedGrams === null ? "disabled" : ""}`}
|
className={`add-to-cart-button ${isOutOfStock || isComingSoon || selectedGrams === null ? "disabled" : ""}`}
|
||||||
onClick={handleAddToCart}
|
onClick={handleAddToCart}
|
||||||
disabled={isOutOfStock || selectedGrams === null}
|
disabled={isOutOfStock || isComingSoon || selectedGrams === null}
|
||||||
>
|
>
|
||||||
{isOutOfStock
|
{isOutOfStock
|
||||||
? "Rupture de stock"
|
? "Rupture de stock"
|
||||||
|
: isComingSoon
|
||||||
|
? "Bientôt disponible"
|
||||||
: "Ajouter au panier"}
|
: "Ajouter au panier"}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -218,13 +218,13 @@ export default function ProductCard({ product, onPress, categoryColor }: Product
|
|||||||
style={[
|
style={[
|
||||||
styles.quickAddBtn,
|
styles.quickAddBtn,
|
||||||
{ backgroundColor: catColor },
|
{ backgroundColor: catColor },
|
||||||
isSoldOut && {
|
(isSoldOut || isComingSoon) && {
|
||||||
backgroundColor: colors.textMuted,
|
backgroundColor: colors.textMuted,
|
||||||
opacity: 0.6,
|
opacity: 0.6,
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
onPress={handleQuickAdd}
|
onPress={handleQuickAdd}
|
||||||
disabled={isSoldOut}
|
disabled={isSoldOut || isComingSoon}
|
||||||
activeOpacity={0.7}
|
activeOpacity={0.7}
|
||||||
>
|
>
|
||||||
<Text
|
<Text
|
||||||
@@ -235,6 +235,8 @@ export default function ProductCard({ product, onPress, categoryColor }: Product
|
|||||||
>
|
>
|
||||||
{isSoldOut
|
{isSoldOut
|
||||||
? "Rupture de stock"
|
? "Rupture de stock"
|
||||||
|
: isComingSoon
|
||||||
|
? "Bientôt disponible"
|
||||||
: "Ajouter rapidement"}
|
: "Ajouter rapidement"}
|
||||||
</Text>
|
</Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
|
|||||||
@@ -615,24 +615,26 @@ export default function ProductDetailScreen() {
|
|||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
style={[
|
style={[
|
||||||
styles.addToCartBtn,
|
styles.addToCartBtn,
|
||||||
(isOutOfStock || selectedGrams === null) &&
|
(isOutOfStock || isComingSoon || selectedGrams === null) &&
|
||||||
styles.addToCartBtnDisabled,
|
styles.addToCartBtnDisabled,
|
||||||
]}
|
]}
|
||||||
onPress={handleAddToCart}
|
onPress={handleAddToCart}
|
||||||
disabled={
|
disabled={
|
||||||
isOutOfStock || selectedGrams === null || adding
|
isOutOfStock || isComingSoon || selectedGrams === null || adding
|
||||||
}
|
}
|
||||||
activeOpacity={0.7}
|
activeOpacity={0.7}
|
||||||
>
|
>
|
||||||
<Text
|
<Text
|
||||||
style={[
|
style={[
|
||||||
styles.addToCartText,
|
styles.addToCartText,
|
||||||
(isOutOfStock || selectedGrams === null) &&
|
(isOutOfStock || isComingSoon || selectedGrams === null) &&
|
||||||
styles.addToCartTextDisabled,
|
styles.addToCartTextDisabled,
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
{isOutOfStock
|
{isOutOfStock
|
||||||
? "Rupture de stock"
|
? "Rupture de stock"
|
||||||
|
: isComingSoon
|
||||||
|
? "Bientôt disponible"
|
||||||
: "Ajouter au panier"}
|
: "Ajouter au panier"}
|
||||||
</Text>
|
</Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
|
|||||||
Reference in New Issue
Block a user