diff --git a/app/dashboard/products/page.tsx b/app/dashboard/products/page.tsx index c46432d..6fbec7c 100644 --- a/app/dashboard/products/page.tsx +++ b/app/dashboard/products/page.tsx @@ -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 diff --git a/lib/types/index.ts b/lib/types/index.ts index 33c9631..88896cc 100644 --- a/lib/types/index.ts +++ b/lib/types/index.ts @@ -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[]