This commit is contained in:
NotII
2025-03-06 13:00:07 +00:00
parent bc9f8ebbf9
commit 308bcc13fa
3 changed files with 43 additions and 25 deletions

View File

@@ -43,7 +43,6 @@ export const saveProductImage = async(url: string, file:File, authToken: string)
method: "PUT",
headers: {
Authorization: `Bearer ${authToken}`,
//"Content-Type": "multipart/form-data",
},
body: formData,
});
@@ -70,9 +69,9 @@ export const deleteProductData = async (url: string, authToken: string) => {
};
// Stock management functions
export const fetchStockData = async (authToken: string) => {
export const fetchStockData = async (url: string, authToken: string) => {
try {
return await fetchData('/api/stock', {
return await fetchData(url, {
headers: { Authorization: `Bearer ${authToken}` },
credentials: "include",
});
@@ -92,7 +91,8 @@ export const updateProductStock = async (
authToken: string
) => {
try {
return await fetchData(`/api/stock/${productId}`, {
const url = `${process.env.NEXT_PUBLIC_API_URL}/stock/${productId}`;
return await fetchData(url, {
method: "PUT",
headers: {
Authorization: `Bearer ${authToken}`,