aboutsummaryrefslogtreecommitdiff
path: root/server/controllers
diff options
context:
space:
mode:
authorMateja <mail@matejamaric.com>2021-07-29 20:50:02 +0200
committerMateja <mail@matejamaric.com>2021-07-29 20:50:02 +0200
commit104948f25ed38ef2ee354b271fb2368dca1b6c4d (patch)
tree249f79b65ecb778961f7f680caa284d9ec9c134d /server/controllers
parentaec70cba2579088d0f8a9cac2ba33030c5c17d22 (diff)
downloadmevn-ecommerce-104948f25ed38ef2ee354b271fb2368dca1b6c4d.tar.gz
mevn-ecommerce-104948f25ed38ef2ee354b271fb2368dca1b6c4d.zip
Add API endpoint for show paid orders to user.
Also, now all info in database is provided when authorized.
Diffstat (limited to 'server/controllers')
-rw-r--r--server/controllers/transaction.js15
1 files changed, 5 insertions, 10 deletions
diff --git a/server/controllers/transaction.js b/server/controllers/transaction.js
index 356672b..b8c2bf4 100644
--- a/server/controllers/transaction.js
+++ b/server/controllers/transaction.js
@@ -135,17 +135,12 @@ module.exports = {
async showPaid(req, res) {
const orders = await Order.find({status: 'paid'});
- let formattedResponse = [];
-
- orders.forEach(order => {
- formattedResponse.push({
- shipping: order.shipping,
- items: order.items,
- updatedAt: order.updatedAt
- });
- });
+ res.json(orders);
+ },
- res.json(formattedResponse);
+ async showPaidByUser(req, res) {
+ const orders = await Order.find({status: 'paid', userId: req.user._id});
+ res.json(orders);
}
};