chore: update space admin
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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() {
|
||||
)}
|
||||
</View>
|
||||
)}
|
||||
<Text style={styles.info}>Stock: {item.stock}g</Text>
|
||||
<Text style={styles.info}>Stock: {item.stock} {item.unit || "u"}</Text>
|
||||
{item.prices && item.prices.length > 0 && (
|
||||
<Text style={styles.info}>
|
||||
{item.prices
|
||||
.map((p) => `${p.quantity}g = ${p.price}€`)
|
||||
.map((p) => `${p.quantity}${item.unit || "u"} = ${p.price}€`)
|
||||
.join(" | ")}
|
||||
</Text>
|
||||
)}
|
||||
@@ -925,7 +940,7 @@ export default function ProductsScreen() {
|
||||
/>
|
||||
|
||||
{/* Stock */}
|
||||
<Text style={styles.label}>Stock (grammes) *</Text>
|
||||
<Text style={styles.label}>Stock *</Text>
|
||||
<RNTextInput
|
||||
style={styles.input}
|
||||
value={form.stock}
|
||||
@@ -937,6 +952,37 @@ export default function ProductsScreen() {
|
||||
keyboardType="numeric"
|
||||
/>
|
||||
|
||||
{/* Unité de mesure */}
|
||||
<Text style={styles.label}>Unité de mesure *</Text>
|
||||
<View style={styles.catRow}>
|
||||
{UNITS.map((u) => (
|
||||
<TouchableOpacity
|
||||
key={u.value}
|
||||
style={[
|
||||
styles.catBtn,
|
||||
form.unit === u.value &&
|
||||
styles.catBtnActive,
|
||||
]}
|
||||
onPress={() =>
|
||||
setForm((f) => ({
|
||||
...f,
|
||||
unit: u.value,
|
||||
}))
|
||||
}
|
||||
>
|
||||
<Text
|
||||
style={[
|
||||
styles.catBtnText,
|
||||
form.unit === u.value &&
|
||||
styles.catBtnTextActive,
|
||||
]}
|
||||
>
|
||||
{u.label}
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
))}
|
||||
</View>
|
||||
|
||||
{/* Prix */}
|
||||
<View style={styles.sectionHeader}>
|
||||
<Text style={styles.label}>Tarifs *</Text>
|
||||
|
||||
Reference in New Issue
Block a user