Updates
This commit is contained in:
@@ -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, {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user