diff --git a/frontend/public/20191227_012601_0000.png b/frontend/public/20191227_012601_0000.png deleted file mode 100644 index e4b0445..0000000 Binary files a/frontend/public/20191227_012601_0000.png and /dev/null differ diff --git a/frontend/public/Pictures/Acoustic-Guitar.jpg b/frontend/public/Uploads/Acoustic-Guitar.jpg similarity index 100% rename from frontend/public/Pictures/Acoustic-Guitar.jpg rename to frontend/public/Uploads/Acoustic-Guitar.jpg diff --git a/frontend/public/Pictures/Backpack.jpg b/frontend/public/Uploads/Backpack.jpg similarity index 100% rename from frontend/public/Pictures/Backpack.jpg rename to frontend/public/Uploads/Backpack.jpg diff --git a/frontend/public/Pictures/Basketball.jpg b/frontend/public/Uploads/Basketball.jpg similarity index 100% rename from frontend/public/Pictures/Basketball.jpg rename to frontend/public/Uploads/Basketball.jpg diff --git a/frontend/public/Pictures/Bluetooth-Speaker.jpg b/frontend/public/Uploads/Bluetooth-Speaker.jpg similarity index 100% rename from frontend/public/Pictures/Bluetooth-Speaker.jpg rename to frontend/public/Uploads/Bluetooth-Speaker.jpg diff --git a/frontend/public/Pictures/CS-Textbook.jpg b/frontend/public/Uploads/CS-Textbook.jpg similarity index 100% rename from frontend/public/Pictures/CS-Textbook.jpg rename to frontend/public/Uploads/CS-Textbook.jpg diff --git a/frontend/public/Pictures/Calculator.jpg b/frontend/public/Uploads/Calculator.jpg similarity index 100% rename from frontend/public/Pictures/Calculator.jpg rename to frontend/public/Uploads/Calculator.jpg diff --git a/frontend/public/Pictures/Calculus-Textbook.jpg b/frontend/public/Uploads/Calculus-Textbook.jpg similarity index 100% rename from frontend/public/Pictures/Calculus-Textbook.jpg rename to frontend/public/Uploads/Calculus-Textbook.jpg diff --git a/frontend/public/Pictures/Calculus-Textbook2.jpg b/frontend/public/Uploads/Calculus-Textbook2.jpg similarity index 100% rename from frontend/public/Pictures/Calculus-Textbook2.jpg rename to frontend/public/Uploads/Calculus-Textbook2.jpg diff --git a/frontend/public/Pictures/Calculus-Textbook3.jpg b/frontend/public/Uploads/Calculus-Textbook3.jpg similarity index 100% rename from frontend/public/Pictures/Calculus-Textbook3.jpg rename to frontend/public/Uploads/Calculus-Textbook3.jpg diff --git a/frontend/public/Pictures/Controller.jpg b/frontend/public/Uploads/Controller.jpg similarity index 100% rename from frontend/public/Pictures/Controller.jpg rename to frontend/public/Uploads/Controller.jpg diff --git a/frontend/public/Pictures/Dell1.jpg b/frontend/public/Uploads/Dell1.jpg similarity index 100% rename from frontend/public/Pictures/Dell1.jpg rename to frontend/public/Uploads/Dell1.jpg diff --git a/frontend/public/Pictures/Dell2.jpg b/frontend/public/Uploads/Dell2.jpg similarity index 100% rename from frontend/public/Pictures/Dell2.jpg rename to frontend/public/Uploads/Dell2.jpg diff --git a/frontend/public/Pictures/Dell3.jpg b/frontend/public/Uploads/Dell3.jpg similarity index 100% rename from frontend/public/Pictures/Dell3.jpg rename to frontend/public/Uploads/Dell3.jpg diff --git a/frontend/public/Pictures/Desk-Lamp.jpg b/frontend/public/Uploads/Desk-Lamp.jpg similarity index 100% rename from frontend/public/Pictures/Desk-Lamp.jpg rename to frontend/public/Uploads/Desk-Lamp.jpg diff --git a/frontend/public/Pictures/Dorm-Desk.jpg b/frontend/public/Uploads/Dorm-Desk.jpg similarity index 100% rename from frontend/public/Pictures/Dorm-Desk.jpg rename to frontend/public/Uploads/Dorm-Desk.jpg diff --git a/frontend/public/Pictures/HP-Calculator.jpg b/frontend/public/Uploads/HP-Calculator.jpg similarity index 100% rename from frontend/public/Pictures/HP-Calculator.jpg rename to frontend/public/Uploads/HP-Calculator.jpg diff --git a/frontend/public/Pictures/HP-Laptop1.jpg b/frontend/public/Uploads/HP-Laptop1.jpg similarity index 100% rename from frontend/public/Pictures/HP-Laptop1.jpg rename to frontend/public/Uploads/HP-Laptop1.jpg diff --git a/frontend/public/Pictures/HP-Laptop2.jpg b/frontend/public/Uploads/HP-Laptop2.jpg similarity index 100% rename from frontend/public/Pictures/HP-Laptop2.jpg rename to frontend/public/Uploads/HP-Laptop2.jpg diff --git a/frontend/public/Pictures/Lab-Coat.jpg b/frontend/public/Uploads/Lab-Coat.jpg similarity index 100% rename from frontend/public/Pictures/Lab-Coat.jpg rename to frontend/public/Uploads/Lab-Coat.jpg diff --git a/frontend/public/Pictures/Mini-Fridge.jpg b/frontend/public/Uploads/Mini-Fridge.jpg similarity index 100% rename from frontend/public/Pictures/Mini-Fridge.jpg rename to frontend/public/Uploads/Mini-Fridge.jpg diff --git a/frontend/public/Pictures/Mountain-Bike.jpg b/frontend/public/Uploads/Mountain-Bike.jpg similarity index 100% rename from frontend/public/Pictures/Mountain-Bike.jpg rename to frontend/public/Uploads/Mountain-Bike.jpg diff --git a/frontend/public/Pictures/Physics-Textbook.jpg b/frontend/public/Uploads/Physics-Textbook.jpg similarity index 100% rename from frontend/public/Pictures/Physics-Textbook.jpg rename to frontend/public/Uploads/Physics-Textbook.jpg diff --git a/frontend/public/Pictures/University-Hoodie.jpg b/frontend/public/Uploads/University-Hoodie.jpg similarity index 100% rename from frontend/public/Pictures/University-Hoodie.jpg rename to frontend/public/Uploads/University-Hoodie.jpg diff --git a/frontend/public/Pictures/Winter-Jacket.jpg b/frontend/public/Uploads/Winter-Jacket.jpg similarity index 100% rename from frontend/public/Pictures/Winter-Jacket.jpg rename to frontend/public/Uploads/Winter-Jacket.jpg diff --git a/frontend/public/Pictures/Wireless-Mouse.jpg b/frontend/public/Uploads/Wireless-Mouse.jpg similarity index 100% rename from frontend/public/Pictures/Wireless-Mouse.jpg rename to frontend/public/Uploads/Wireless-Mouse.jpg diff --git a/frontend/public/Pictures/Yoga-Mat.jpg b/frontend/public/Uploads/Yoga-Mat.jpg similarity index 100% rename from frontend/public/Pictures/Yoga-Mat.jpg rename to frontend/public/Uploads/Yoga-Mat.jpg diff --git a/frontend/public/market.png b/frontend/public/market.png deleted file mode 100644 index 9bfc35c..0000000 Binary files a/frontend/public/market.png and /dev/null differ diff --git a/frontend/public/university-of-calgary-logo.png b/frontend/public/university-of-calgary-logo.png deleted file mode 100644 index 875b098..0000000 Binary files a/frontend/public/university-of-calgary-logo.png and /dev/null differ diff --git a/frontend/src/pages/Selling.jsx b/frontend/src/pages/Selling.jsx index d5926fe..3ff07d2 100644 --- a/frontend/src/pages/Selling.jsx +++ b/frontend/src/pages/Selling.jsx @@ -9,6 +9,7 @@ const Selling = () => { const [categories, setCategories] = useState([]); const [categoryMapping, setCategoryMapping] = useState({}); const [selectedCategory, setSelectedCategory] = useState(""); + const [originalProduct, setOriginalProduct] = useState(null); const [editingProduct, setEditingProduct] = useState({ name: "", @@ -92,7 +93,6 @@ const Selling = () => { fetchProducts(); }, []); // Add userId to dependency array if it might change - // Handle creating or updating a product const handleSaveProduct = async () => { if (!(editingProduct.categories || []).length) { alert("Please select at least one category"); @@ -107,17 +107,24 @@ const Selling = () => { const simulatedPath = `/public/uploads/${file.name}`; imagePaths.push(simulatedPath); }); + } else if (originalProduct?.images?.length > 0) { + imagePaths.push(...originalProduct.images); } const categoryName = (editingProduct.categories || [])[0]; - const categoryID = categoryMapping[categoryName] || 1; + const categoryID = + categoryMapping[categoryName] || originalProduct?.category || 1; const payload = { - name: editingProduct.name || "", - price: parseFloat(editingProduct.price) || 0, + name: editingProduct.name || originalProduct?.name || "", + price: + parseFloat(editingProduct.price) || + parseFloat(originalProduct?.price) || + 0, qty: 1, userID: storedUser.ID, - description: editingProduct.description || "", + description: + editingProduct.description || originalProduct?.description || "", category: categoryID, images: imagePaths, }; @@ -160,7 +167,8 @@ const Selling = () => { images: [], }); - // Reload products + setOriginalProduct(null); // reset original as well + reloadPage(); } catch (error) { console.error("Error saving product:", error);