diff --git a/README.md b/README.md
index cf249873..665d77d7 100644
--- a/README.md
+++ b/README.md
@@ -259,20 +259,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made
Arindam
-
-
-
-
- Aryan Ramesh Jain
-
- |
-
-
-
-
- Haseeb Zaki
-
- |
@@ -280,8 +266,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made
alolika bhowmik
|
-
-
@@ -296,6 +280,8 @@ We extend our heartfelt gratitude to all the amazing contributors who have made
Mahera Nayan
|
+
+
@@ -310,13 +296,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made
Tyarla Shirisha
|
-
-
-
-
- Vinay Anand Lodhi
-
- |
@@ -324,8 +303,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made
Aman Yadav
|
-
-
@@ -334,17 +311,10 @@ We extend our heartfelt gratitude to all the amazing contributors who have made
|
-
-
-
- Suhas Koheda
-
- |
-
-
-
+
+
- Suman Bhadra
+ Haseeb Zaki
|
@@ -354,22 +324,22 @@ We extend our heartfelt gratitude to all the amazing contributors who have made
Sawan kushwah
|
+
+
-
-
+
+
- PavanTeja2005
+ Suhas Koheda
|
-
-
+
+
- Sajal Batra
+ Jay shah
|
-
-
@@ -378,10 +348,17 @@ We extend our heartfelt gratitude to all the amazing contributors who have made
|
-
-
+
+
- Jay shah
+ Sajal Batra
+
+ |
+
+
+
+
+ PavanTeja2005
|
@@ -391,6 +368,8 @@ We extend our heartfelt gratitude to all the amazing contributors who have made
Abhijit Motekar
|
+
+
@@ -398,6 +377,13 @@ We extend our heartfelt gratitude to all the amazing contributors who have made
Navneet Dadhich
|
+
+
+
+
+ Vinay Anand Lodhi
+
+ |
@@ -412,8 +398,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made
MD REHAN
|
-
-
@@ -428,13 +412,8 @@ We extend our heartfelt gratitude to all the amazing contributors who have made
Aditya Bakshi
|
-
-
-
-
- vaishnavipal1869
-
- |
+
+
@@ -456,8 +435,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made
Sourabh Singh Rawat
|
-
-
@@ -465,13 +442,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made
Shiva Bajpai
|
-
-
-
-
- Pushpa Vishwakarma
-
- |
@@ -486,6 +456,8 @@ We extend our heartfelt gratitude to all the amazing contributors who have made
Ayush Yadav
|
+
+
@@ -500,8 +472,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made
Vaibhav._Y
|
-
-
@@ -530,13 +500,8 @@ We extend our heartfelt gratitude to all the amazing contributors who have made
Sapna Kul
|
-
-
-
-
- Nikhil More
-
- |
+
+
@@ -544,8 +509,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made
Bashua Mutiat
|
-
-
@@ -560,13 +523,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made
Jai Dhingra
|
-
-
-
-
- Harjas Singh
-
- |
diff --git a/backend/.env.example b/backend/.env.example
index 8ccf528c..8c71fad6 100644
--- a/backend/.env.example
+++ b/backend/.env.example
@@ -1,4 +1,4 @@
-MONGO_URI=enter_your_mongo_uri
+MONGO_URI=
EMAIL_USER=your_gmail
PORT=3000
EMAIL_PASS=your_16_digit_pass
diff --git a/backend/controller/order.controller.js b/backend/controller/order.controller.js
new file mode 100644
index 00000000..24132926
--- /dev/null
+++ b/backend/controller/order.controller.js
@@ -0,0 +1,76 @@
+const Customer = require("../models/customer.model");
+const Order = require("../models/order.model");
+
+// Create a new order
+exports.createOrder = async (req, res) => {
+ try {
+ const { items } = req.body;
+ const customerId = req.params.id.trim();
+
+ if (!customerId) {
+ return res
+ .status(400)
+ .json({ success: false, message: "Customer ID is required." });
+ }
+
+ const totalAmount = items.reduce(
+ (sum, item) => sum + item.price * item.quantity,
+ 0
+ );
+
+ const order = new Order({
+ customer: customerId,
+ items,
+ totalAmount,
+ });
+
+ const savedOrder = await order.save();
+
+ await Customer.findByIdAndUpdate(customerId, {
+ $push: { orders: savedOrder._id },
+ });
+
+ res.status(201).json({ success: true, order: savedOrder });
+ } catch (error) {
+ res.status(500).json({ success: false, message: error.message });
+ }
+};
+
+// Get all orders for a customer
+exports.getOrders = async (req, res) => {
+ try {
+ const customerId = req.params.id.trim();
+
+ const orders = await Order.find({ customer: customerId });
+ res.status(200).json({ success: true, orders });
+ } catch (error) {
+ res.status(500).json({ success: false, message: error.message });
+ }
+};
+
+// Delete an order
+exports.deleteOrder = async (req, res) => {
+ try {
+ const { orderId } = req.body;
+ const customerId = req.params.id.trim();
+
+ const order = await Order.findOne({ _id: orderId, customer: customerId });
+
+ if (!order) {
+ return res
+ .status(404)
+ .json({ success: false, message: "Order not found" });
+ }
+
+ await Order.deleteOne({ _id: orderId });
+ await Customer.findByIdAndUpdate(customerId, {
+ $pull: { orders: orderId },
+ });
+
+ res
+ .status(200)
+ .json({ success: true, message: "Order deleted successfully" });
+ } catch (error) {
+ res.status(500).json({ success: false, message: error.message });
+ }
+};
diff --git a/backend/models/customer.model.js b/backend/models/customer.model.js
index cd446f41..122eb524 100644
--- a/backend/models/customer.model.js
+++ b/backend/models/customer.model.js
@@ -1,4 +1,4 @@
-/* eslint-disable no-useless-escape */
+
const mongoose = require("mongoose");
const Schema = mongoose.Schema;
@@ -19,7 +19,7 @@ const customerSchema = new Schema(
},
verificationCode: {
type: String,
- default: ""
+ default: "",
},
role: {
type: String,
@@ -27,8 +27,22 @@ const customerSchema = new Schema(
},
bio: String,
profilePicture: String,
+
+ bookedEvents: [
+ {
+ type: Schema.Types.ObjectId,
+ ref: "Event",
+ },
+ ],
+ orders: [
+ {
+ type: Schema.Types.ObjectId,
+ ref: "Order",
+ },
+ ],
+
},
- { timestamps: true },
+ { timestamps: true }
);
const Customer = mongoose.model("Customer", customerSchema);
diff --git a/backend/models/order.model.js b/backend/models/order.model.js
new file mode 100644
index 00000000..76c4cfd5
--- /dev/null
+++ b/backend/models/order.model.js
@@ -0,0 +1,36 @@
+// models/Order.js
+
+const mongoose = require("mongoose");
+const Schema = mongoose.Schema;
+
+const orderSchema = new Schema(
+ {
+ customer: {
+ type: Schema.Types.ObjectId,
+ ref: "Customer",
+ required: true,
+ },
+ items: [
+ {
+ name: { type: String, required: true },
+ description: String,
+ quantity: { type: Number, required: true, min: 1 },
+ price: { type: Number, required: true },
+ },
+ ],
+ totalAmount: {
+ type: Number,
+ required: true,
+ },
+ status: {
+ type: String,
+ enum: ["pending", "completed", "cancelled"],
+ default: "pending",
+ },
+ },
+ { timestamps: true }
+);
+
+const Order = mongoose.model("Order", orderSchema);
+
+module.exports = Order;
diff --git a/backend/routes/index.js b/backend/routes/index.js
index 27a2b8bd..bb18bae4 100644
--- a/backend/routes/index.js
+++ b/backend/routes/index.js
@@ -54,4 +54,6 @@ router.use("/user", require("./customerRouter"));
router.use("/reservation", require("./reservationRouter"));
router.use("/newsletter", require("./newsletterRoute"));
router.use("/forgot", require("./forgotRouter"));
+router.use("/order", require("./orderRouter"));
+
module.exports = router;
diff --git a/backend/routes/orderRouter.js b/backend/routes/orderRouter.js
new file mode 100644
index 00000000..591b2b8c
--- /dev/null
+++ b/backend/routes/orderRouter.js
@@ -0,0 +1,11 @@
+const express = require("express");
+const { createOrder, getOrders, deleteOrder } = require("../controller/order.controller.js");
+
+const router = express.Router();
+
+
+router.post("/create/:id", createOrder);
+router.get("/get/:id", getOrders);
+router.delete("/delete/:id", deleteOrder);
+
+module.exports = router;
|