balls
This commit is contained in:
@@ -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;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user