diff --git a/helpers/emailHelper.js b/helpers/emailHelper.js index 449317b..2ba786b 100644 --- a/helpers/emailHelper.js +++ b/helpers/emailHelper.js @@ -16,8 +16,6 @@ const transporter = nodemailer.createTransport({ }, }); - - exports.sendEmail = mailOptions => new Promise((resolve, reject) => { transporter.sendMail(mailOptions, (error) => { if (error) { diff --git a/routes/api/addBalance.js b/routes/api/addBalance.js index bd75df5..0c0cfb8 100644 --- a/routes/api/addBalance.js +++ b/routes/api/addBalance.js @@ -9,35 +9,38 @@ const User = require("../../models/User"); // @route GET / // @access Private router.get("/", ensureAuth, (req, res) => { - let user = req.user; - let avatar = req.user.image; - res - .status(200).render("addBalance", { - layout: "layouts/app", - avatar, - user, - href: "/addBalance" - }); + let user = req.user; + let avatar = req.user.image; + res.status(200).render("addBalance", { + layout: "layouts/app", + avatar, + user, + href: "/addBalance", + }); }); // TODO -router.post("/", ensureAuth, async(req, res) => { - // why ensureGuest here? - let amount = Number(req.body.addAmount); // type cast amount to number as body parser take it as string - let finalAmont = amount + req.user.balance; +router.post("/", ensureAuth, async (req, res) => { + // why ensureGuest here? + let amount = Number(req.body.addAmount); // type cast amount to number as body parser take it as string + let finalAmont = amount + req.user.balance; - try { - req.body.user = req.user.id; - const updateBalance = await User.findOneAndUpdate({ _id: req.user.id }, { balance: finalAmont }, { - new: true, // it will create a new one, if it doesn't exist - runValidators: true, // it check weather the fields are valid or not - }); - console.log(updateBalance); - res.redirect("/"); - } catch (err) { - console.error(err); - res.render("error/500"); - } + try { + req.body.user = req.user.id; + const updateBalance = await User.findOneAndUpdate( + { _id: req.user.id }, + { balance: finalAmont }, + { + new: true, // it will create a new one, if it doesn't exist + runValidators: true, // it check weather the fields are valid or not + } + ); + console.log(updateBalance); + res.redirect("/"); + } catch (err) { + console.error(err); + res.render("error/500"); + } }); -module.exports = router; \ No newline at end of file +module.exports = router; diff --git a/views/portfolio.ejs b/views/portfolio.ejs index d41ca90..bfe8c0e 100644 --- a/views/portfolio.ejs +++ b/views/portfolio.ejs @@ -1,21 +1,28 @@
-
- +
+ - + -
-

- TradeByte -

-
- - - -
-
- - -
- -
- - - - -
-
-  -
-
-

- $40,342.04 -

- Total Portfolio -
-
- - - -
-
-  -
-
-

- $ 40,342.04 -

- Profit / Loss -
-
- - - -
-
-  -
-
-

- $40,342.04 -

- $ Balance -
-
-
+
+ +
+ + + + +
+
+  +
+
+

+ $40,342.04 +

+ Total Portfolio +
+
+ + + +
+
+  +
+
+

+ $ 40,342.04 +

+ Profit / Loss +
- + + +
+
+  +
+
+

+ $40,342.04 +

+ $ Balance +
+
+
+
-

Overview

- -
+ - +

Overview

+ +
-
- + -
-
- +
+ -

Trade History

- View All > +
+ + +

Trade History

+ View All >
@@ -729,4 +743,4 @@
-
\ No newline at end of file +