This commit is contained in:
g
2025-02-08 16:06:39 +00:00
parent 7374e56253
commit bce4b26ffa
7 changed files with 280 additions and 115 deletions

View File

@@ -34,6 +34,25 @@ export const saveProductData = async (
}
};
export const saveProductImage = async(url: string, file:File, authToken: string) => {
try{
const formData = new FormData();
formData.append("file", file);
return await fetchData(url, {
method: "POST",
headers: {
Authorization: `Bearer ${authToken}`,
//"Content-Type": "multipart/form-data",
},
body: formData,
});
} catch (error) {
console.error("Error uploading image:", error);
throw error;
}
}
export const deleteProductData = async (url: string, authToken: string) => {
try {
return await fetchData(url, {

View File

@@ -4,7 +4,7 @@ import type React from "react"
export interface ProductModalProps {
open: boolean
onClose: () => void
onSave: (productData: ProductData) => void
onSave: (productData: ProductData, imageFile?: File | null) => void;
productData: ProductData
categories: Category[]
editing: boolean