Add ML, fix product stock data
This commit is contained in:
@@ -115,6 +115,15 @@ export default function ProductsPage() {
|
|||||||
throw new Error("Cannot update product without an ID");
|
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
|
// Save the product data
|
||||||
const endpoint = editing ? `/products/${data._id}` : "/products";
|
const endpoint = editing ? `/products/${data._id}` : "/products";
|
||||||
const method = editing ? "PUT" : "POST";
|
const method = editing ? "PUT" : "POST";
|
||||||
@@ -124,7 +133,7 @@ export default function ProductsPage() {
|
|||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
body: JSON.stringify(data),
|
body: JSON.stringify(productData),
|
||||||
});
|
});
|
||||||
|
|
||||||
// If there's a new image to upload
|
// If there's a new image to upload
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ export interface Product {
|
|||||||
currentStock?: number
|
currentStock?: number
|
||||||
lowStockThreshold?: number
|
lowStockThreshold?: number
|
||||||
stockStatus?: 'in_stock' | 'low_stock' | 'out_of_stock'
|
stockStatus?: 'in_stock' | 'low_stock' | 'out_of_stock'
|
||||||
unitType: string
|
unitType: 'pcs' | 'gr' | 'kg' | 'ml'
|
||||||
category: string
|
category: string
|
||||||
enabled?: boolean
|
enabled?: boolean
|
||||||
pricing: PricingTier[]
|
pricing: PricingTier[]
|
||||||
|
|||||||
Reference in New Issue
Block a user