This commit is contained in:
NotII
2025-03-06 12:49:01 +00:00
parent e26069abfa
commit bc9f8ebbf9
8 changed files with 573 additions and 85 deletions

View File

@@ -67,4 +67,42 @@ export const deleteProductData = async (url: string, authToken: string) => {
console.error("Error deleting product data:", error);
throw error;
}
};
// Stock management functions
export const fetchStockData = async (authToken: string) => {
try {
return await fetchData('/api/stock', {
headers: { Authorization: `Bearer ${authToken}` },
credentials: "include",
});
} catch (error) {
console.error("Error fetching stock data:", error);
throw error;
}
};
export const updateProductStock = async (
productId: string,
stockData: {
currentStock: number;
stockTracking?: boolean;
lowStockThreshold?: number;
},
authToken: string
) => {
try {
return await fetchData(`/api/stock/${productId}`, {
method: "PUT",
headers: {
Authorization: `Bearer ${authToken}`,
"Content-Type": "application/json",
},
credentials: "include",
body: JSON.stringify(stockData),
});
} catch (error) {
console.error("Error updating product stock:", error);
throw error;
}
};

View File

@@ -38,6 +38,10 @@ export interface Product {
name: string
description: string
stock?: number
stockTracking?: boolean
currentStock?: number
lowStockThreshold?: number
stockStatus?: 'in_stock' | 'low_stock' | 'out_of_stock'
unitType: string
category: string
pricing: PricingTier[]