diff --git a/src/controllers/cart.controller.ts b/src/controllers/cart.controller.ts index f7dc4d4..4c0d58c 100644 --- a/src/controllers/cart.controller.ts +++ b/src/controllers/cart.controller.ts @@ -71,6 +71,7 @@ export const getCart = async (req: Request, res: Response) => { as: "Product" } }); + return res.status(200).json({ cartitem }); } catch (error: any) { console.log(error); diff --git a/src/controllers/checkout.controller.ts b/src/controllers/checkout.controller.ts index c8bc07a..6edd612 100644 --- a/src/controllers/checkout.controller.ts +++ b/src/controllers/checkout.controller.ts @@ -29,6 +29,7 @@ export const createOrder = async (req: Request, res: Response) => { })); const totalAmount = orderItems.reduce((total, item) => total + (item.price * item.quantity), 0); + console.log(orderItems) const order = await Order.create({ orderId: uuidv4(), diff --git a/src/controllers/orderController.ts b/src/controllers/orderController.ts index 23139be..612f45a 100644 --- a/src/controllers/orderController.ts +++ b/src/controllers/orderController.ts @@ -105,6 +105,8 @@ export const getOrder = async (req: Request, res: Response) => { } }; + + export const getSellerOrder = async (req: Request, res: Response) => { try { const vendorId = req.params.vendorId; diff --git a/src/database/config/config.js b/src/database/config/config.js index 5037ce1..01ddaa7 100644 --- a/src/database/config/config.js +++ b/src/database/config/config.js @@ -34,9 +34,3 @@ const config = { }; module.exports = config; -<<<<<<< HEAD - - - -======= ->>>>>>> 0cff03db707fc42c5a1f30a76827dea013e4c413 diff --git a/src/database/migrations/20240520142627-create-order.js b/src/database/migrations/20240520142627-create-order.js index 76fbe3a..224a94b 100644 --- a/src/database/migrations/20240520142627-create-order.js +++ b/src/database/migrations/20240520142627-create-order.js @@ -22,7 +22,7 @@ module.exports = { }, client: { type: Sequelize.STRING, - allowNull: false, + allowNull: true, }, paymentMethod: { type: Sequelize.STRING, diff --git a/src/database/models/order.ts b/src/database/models/order.ts index 63d6181..cd6f3af 100644 --- a/src/database/models/order.ts +++ b/src/database/models/order.ts @@ -25,7 +25,6 @@ class Order extends Model { client: { type: DataTypes.STRING, allowNull: false }, paymentMethod: { type: DataTypes.INTEGER, allowNull: false }, status: { type: DataTypes.STRING, allowNull: false }, - client: { type: DataTypes.STRING, allowNull: false }, products: { type: DataTypes.JSONB, allowNull: false }, totalAmount: { type: DataTypes.INTEGER, allowNull: false }, expectedDeliveryDate: { type: DataTypes.DATE, allowNull: true }, diff --git a/src/database/seeders/20240522075149-seed-orders.js b/src/database/seeders/20240522075149-seed-orders.js index eb93788..babef13 100644 --- a/src/database/seeders/20240522075149-seed-orders.js +++ b/src/database/seeders/20240522075149-seed-orders.js @@ -12,8 +12,8 @@ module.exports = { `); const [products] = await queryInterface.sequelize.query(` - SELECT "productId", "name", "vendorId" - FROM "Products" + SELECT "productId","name","image","price" FROM "Products" + LIMIT 3; `); diff --git a/src/pusher.ts b/src/pusher.ts index 467844e..8ca1543 100644 --- a/src/pusher.ts +++ b/src/pusher.ts @@ -4,7 +4,7 @@ const pusher = new Pusher({ appId: process.env.PUSHER_APP_ID as string, key: process.env.PUSHER_KEY as string, secret: process.env.PUSHER_SECRET as string, - cluster: "ap2", + cluster: "mt1", }); export default pusher \ No newline at end of file