diff --git a/frontend/src/components/layout/Navbar.jsx b/frontend/src/components/layout/Navbar.jsx
index df17b48..4d7d791 100644
--- a/frontend/src/components/layout/Navbar.jsx
+++ b/frontend/src/components/layout/Navbar.jsx
@@ -40,27 +40,68 @@ export default function Navbar() {
{darkMode ? '☀️' : '🌙'}
- {isAuthenticated ? (
- <>
- {user?.role === 'admin' && (
- Admin
- )}
- Orders
- Wishlist
- Profile
-
- 🛒
- {itemCount > 0 && (
-
- {itemCount}
-
- )}
-
-
- >
- ) : (
+ {isAuthenticated ? (
+ user?.role === 'admin' ? (
+ <>
+
+ Admin
+
+
+
+ >
+ ) : (
+ <>
+
+ Orders
+
+
+
+ Wishlist
+
+
+
+ Profile
+
+
+
+ 🛒
+
+ {itemCount > 0 && (
+
+ {itemCount}
+
+ )}
+
+
+
+ >
+ )
+) : (
<>
Login
Sign Up
diff --git a/frontend/src/components/products/ProductCard.jsx b/frontend/src/components/products/ProductCard.jsx
index 85a5d44..ca2dbfd 100644
--- a/frontend/src/components/products/ProductCard.jsx
+++ b/frontend/src/components/products/ProductCard.jsx
@@ -40,7 +40,11 @@ export default function ProductCard({ product }) {
{product.primary_image ? (
-
GoCart Admin Dashboard
Shop Smarter. Shop Faster.
+
+
+
+
+ 📦 Manage Products
+
+
+
+ View, edit and delete products
+
+
+
+
+
+ ➕ Add Product
+
+
+
+ Create a new product
+
+
+
+
+
+ 📊 Inventory
+
+
+
+ Check stock levels and pricing
+
+
+
+
{statCards.map((s) => (
diff --git a/frontend/src/pages/admin/EditProduct.jsx b/frontend/src/pages/admin/EditProduct.jsx
index f2dd649..c1bf347 100644
--- a/frontend/src/pages/admin/EditProduct.jsx
+++ b/frontend/src/pages/admin/EditProduct.jsx
@@ -79,19 +79,33 @@ export default function EditProduct() {
...formData,
category: Number(formData.category),
})
- if (selectedImage) {
- const { data: product } = await productsAPI.get(slug)
+ if (selectedImage) {
+ const { data: product } = await productsAPI.get(slug)
- const imageData = new FormData()
+ console.log("EDIT PRODUCT:", product)
+ console.log("PRODUCT ID:", product.id)
+ console.log("PRODUCT IMAGES:", product.images)
- imageData.append('product', product.id)
- imageData.append('image', selectedImage)
- imageData.append('alt_text', formData.name)
- imageData.append('is_primary', true)
- imageData.append('order', 1)
+ const imageData = new FormData()
- await productImagesAPI.upload(imageData)
- }
+ imageData.append('image', selectedImage)
+ imageData.append('alt_text', formData.name)
+ imageData.append('is_primary', true)
+ imageData.append('order', 1)
+
+ if (product.images?.length > 0) {
+ console.log("Updating image:", product.images[0].id)
+
+ await productImagesAPI.update(
+ product.images[0].id,
+ imageData
+ )
+ } else {
+ imageData.append('product', product.id)
+
+ await productImagesAPI.upload(imageData)
+ }
+}
toast.success('Product updated successfully')
diff --git a/frontend/src/services/api.js b/frontend/src/services/api.js
index 0dbe528..e2ed13d 100644
--- a/frontend/src/services/api.js
+++ b/frontend/src/services/api.js
@@ -97,6 +97,13 @@ export const productImagesAPI = {
'Content-Type': 'multipart/form-data',
},
}),
+
+ update: (imageId, formData) =>
+ api.patch(`/products/images/${imageId}/`, formData, {
+ headers: {
+ 'Content-Type': 'multipart/form-data',
+ },
+ }),
remove: (imageId) =>
api.delete(`/products/images/${imageId}/`),