Add ML, fix product stock data

This commit is contained in:
NotII
2025-06-09 22:06:33 +01:00
parent bc8eda5eb8
commit b77f0d007d
2 changed files with 11 additions and 2 deletions

View File

@@ -115,6 +115,15 @@ export default function ProductsPage() {
throw new Error("Cannot update product without an ID");
}
// Prepare the product data with stock management fields
const productData = {
...data,
stockTracking: data.stockTracking ?? true,
currentStock: data.currentStock ?? 0,
lowStockThreshold: data.lowStockThreshold ?? 10,
stockStatus: data.stockStatus ?? 'out_of_stock'
};
// Save the product data
const endpoint = editing ? `/products/${data._id}` : "/products";
const method = editing ? "PUT" : "POST";
@@ -124,7 +133,7 @@ export default function ProductsPage() {
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(data),
body: JSON.stringify(productData),
});
// If there's a new image to upload

View File

@@ -42,7 +42,7 @@ export interface Product {
currentStock?: number
lowStockThreshold?: number
stockStatus?: 'in_stock' | 'low_stock' | 'out_of_stock'
unitType: string
unitType: 'pcs' | 'gr' | 'kg' | 'ml'
category: string
enabled?: boolean
pricing: PricingTier[]