Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "create listings" for the admin page #9

Merged
Merged
Prev Previous commit
Next Next commit
Update changes to backend
jolynleow2301 committed Dec 26, 2024
commit 231591f214dcd130a12bc7ac3cd38e9c733cf289
2 changes: 1 addition & 1 deletion client/src/components/CreateListing.tsx
Original file line number Diff line number Diff line change
@@ -269,7 +269,7 @@ const CreateListing = () => {
*/
const handlePostListingClick = async () => {
try {
const response = await apiRequest("listings", "POST", "register", {
const response = await apiRequest("product", "POST", "create", {
title,
description,
images,
49 changes: 19 additions & 30 deletions server/src/models/products.js
Original file line number Diff line number Diff line change
@@ -9,38 +9,27 @@ const productSchema = new mongoose.Schema({
type: String,
required: true,
},
price: {
type: Number,
required: true,
},
discountPercentage: {
type: Number,
required: true,
},
rating: {
type: Number,
required: true,
},
stock: {
type: Number,
required: true,
},
brand: {
type: String,
required: true,
},
category: {
type: String,
required: true,
},
thumbnail: {
images: [{
type: String, // Assuming images are stored as URLs
required: true
}],
sizingChart: [{
type: String, // Assuming images are stored as URLs
required: true
}],
specifications: [{
colour: { type: String, required: true },
size: { type: String, required: true },
quantity: { type: String, required: true }
}],
deliveryMethods: {
shipping: { type: Boolean, required: true },
selfCollection: { type: Boolean, required: true }
},
collectionInfo: {
type: String,
required: true,
},
images: {
type: String,
required: true,
},
}
});

const Product = mongoose.model("Product", productSchema);