diff --git a/frontend-admin/src/api/types.ts b/frontend-admin/src/api/types.ts
index 15181ce3..03cf1542 100644
--- a/frontend-admin/src/api/types.ts
+++ b/frontend-admin/src/api/types.ts
@@ -95,6 +95,7 @@ export interface Product {
description?: string;
category: string;
stock: number;
+ unit: string;
prices?: Array<{ quantity: number; price: number }>;
media?: Array<{ url: string; type: string; id?: number; created_at?: string }>;
created_at?: string;
diff --git a/frontend-admin/src/screens/admin/ProductsScreen.tsx b/frontend-admin/src/screens/admin/ProductsScreen.tsx
index 6dc622ee..dbeef734 100644
--- a/frontend-admin/src/screens/admin/ProductsScreen.tsx
+++ b/frontend-admin/src/screens/admin/ProductsScreen.tsx
@@ -60,11 +60,22 @@ const CATEGORIES = [
{ value: "gros&semi", label: "Gros & Semi" },
];
+const UNITS = [
+ { value: "u", label: "u" },
+ { value: "kg", label: "kg" },
+ { value: "g", label: "g" },
+ { value: "bag", label: "bag" },
+ { value: "l", label: "l" },
+ { value: "cl", label: "cl" },
+ { value: "pcs", label: "pcs" },
+];
+
interface FormState {
name: string;
category: string;
description: string;
stock: string;
+ unit: string;
prices: PriceRow[];
}
@@ -73,6 +84,7 @@ const emptyForm = (): FormState => ({
category: "weed&hash",
description: "",
stock: "",
+ unit: "u",
prices: [{ quantity: "1", price: "" }],
});
@@ -142,6 +154,7 @@ export default function ProductsScreen() {
category: product.category,
description: product.description || "",
stock: product.stock.toString(),
+ unit: product.unit || "u",
prices:
product.prices && product.prices.length > 0
? product.prices.map((p) => ({
@@ -299,6 +312,7 @@ export default function ProductsScreen() {
category: form.category,
description: form.description.trim(),
stock: parseFloat(form.stock),
+ unit: form.unit,
prices,
});
productId = editingProduct.id;
@@ -309,6 +323,7 @@ export default function ProductsScreen() {
fd.append("category", form.category);
fd.append("description", form.description.trim());
fd.append("stock", form.stock);
+ fd.append("unit", form.unit);
// ✅ FIX PRINCIPAL : Envoyer les prix au format que Go attend
// Backend attend : prices[0][quantity], prices[0][price], etc.
@@ -773,11 +788,11 @@ export default function ProductsScreen() {
)}
)}
- Stock: {item.stock}g
+ Stock: {item.stock} {item.unit || "u"}
{item.prices && item.prices.length > 0 && (
{item.prices
- .map((p) => `${p.quantity}g = ${p.price}€`)
+ .map((p) => `${p.quantity}${item.unit || "u"} = ${p.price}€`)
.join(" | ")}
)}
@@ -925,7 +940,7 @@ export default function ProductsScreen() {
/>
{/* Stock */}
- Stock (grammes) *
+ Stock *
+ {/* Unité de mesure */}
+ Unité de mesure *
+
+ {UNITS.map((u) => (
+
+ setForm((f) => ({
+ ...f,
+ unit: u.value,
+ }))
+ }
+ >
+
+ {u.label}
+
+
+ ))}
+
+
{/* Prix */}
Tarifs *