Skip to content

Commit

Permalink
formatted the code in other files
Browse files Browse the repository at this point in the history
  • Loading branch information
fabcodingzest committed Aug 23, 2020
1 parent 4d10522 commit 1d74bd2
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 103 deletions.
2 changes: 0 additions & 2 deletions helpers/emailHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ const transporter = nodemailer.createTransport({
},
});



exports.sendEmail = mailOptions => new Promise((resolve, reject) => {
transporter.sendMail(mailOptions, (error) => {
if (error) {
Expand Down
55 changes: 29 additions & 26 deletions routes/api/addBalance.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
module.exports = router;
164 changes: 89 additions & 75 deletions views/portfolio.ejs
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
<main class="md:col-span-4 bg-gray-300 md:ml-56 lg:ml-64 md:pr-14 w-full">
<div class="container px-5 py-10 mx-auto md:px-auto">
<!-- <div class="absolute-center mx-auto"> -->
<div class="container px-5 py-10 mx-auto md:px-auto">
<!-- <div class="absolute-center mx-auto"> -->

<!-- header -->
<!-- header -->

<header class="mt-4 absolute-center">
<h2 class="text-gray-700 text-6xl font-semibold leading-none tracking-wider">
TradeByte
</h2>
</header>

<!-- search box -->

<div>
<div class="relative text-gray-600 mt-12 shadow-md rounded-b-lg">
<input type="search" name="serch" placeholder="Search Stocks" class="bg-transparent h-10 px-5 pr-10 rounded-full text-sm focus:outline-none" />
<button type="submit" class="absolute left-0 top-0 mt-3 ml-4">
<header class="mt-4 absolute-center">
<h2
class="text-gray-700 text-6xl font-semibold leading-none tracking-wider"
>
TradeByte
</h2>
</header>

<!-- search box -->

<div>
<div class="relative text-gray-600 mt-12 shadow-md rounded-b-lg">
<input
type="search"
name="serch"
placeholder="Search Stocks"
class="bg-transparent h-10 px-5 pr-10 rounded-full text-sm focus:outline-none"
/>
<button type="submit" class="absolute left-0 top-0 mt-3 ml-4">
<svg
class="h-4 w-4 fill-current"
xmlns="http://www.w3.org/2000/svg"
Expand All @@ -35,72 +42,79 @@
/>
</svg>
</button>
</div>

<div class="mt-8 grid lg:grid-cols-3 gap-10">
<!-- cards go here -->

<!-- card1 -->

<div class="card rounded-xl flex items-center h-20 sm:h-20 w-full object-cover px-5 shadow-2xl">
<div class="flex-shrink-0 w-10 h-10">
<img class="w-full h-full" src="images/graph.jpeg" alt=" " />
</div>
<div class="font-bold text-xl xl:text-2xl ml-3">
<p class="text-gray-900 whitespace-no-wrap">
$40,342.04
</p>
<span class="block text-gray-500 text-sm">Total Portfolio</span>
</div>
</div>

<!-- card 2 -->

<div class="card rounded-xl flex items-center h-20 sm:h-20 w-full object-cover px-5 shadow-2xl">
<div class="flex-shrink-0 w-10 h-10">
<img class="w-full h-full" src="images/graph.jpeg " alt=" " />
</div>
<div class="font-bold text-xl xl:text-2xl ml-3 justify-center">
<p class="text-gray-900 whitespace-no-wrap">
$ 40,342.04
</p>
<span class="block text-gray-500 text-sm">Profit / Loss</span>
</div>
</div>

<!-- card 3 -->

<div class="card rounded-xl flex items-center h-20 sm:h-20 w-full object-cover px-5 shadow-2xl">
<div class="flex-shrink-0 w-10 h-10">
<img class="w-full h-full" src="images/graph.jpeg " alt=" " />
</div>
<div class="font-bold text-xl xl:text-2xl ml-3">
<p class="text-gray-900 whitespace-no-wrap">
$40,342.04
</p>
<span class="block text-gray-500 text-sm">$ Balance</span>
</div>
</div>
</div>
</div>

<div class="mt-8 grid lg:grid-cols-3 gap-10">
<!-- cards go here -->

<!-- card1 -->

<div
class="card rounded-xl flex items-center h-20 sm:h-20 w-full object-cover px-5 shadow-2xl"
>
<div class="flex-shrink-0 w-10 h-10">
<img class="w-full h-full" src="images/graph.jpeg" alt=" " />
</div>
<div class="font-bold text-xl xl:text-2xl ml-3">
<p class="text-gray-900 whitespace-no-wrap">
$40,342.04
</p>
<span class="block text-gray-500 text-sm">Total Portfolio</span>
</div>
</div>

<!-- card 2 -->

<div
class="card rounded-xl flex items-center h-20 sm:h-20 w-full object-cover px-5 shadow-2xl"
>
<div class="flex-shrink-0 w-10 h-10">
<img class="w-full h-full" src="images/graph.jpeg " alt=" " />
</div>
<div class="font-bold text-xl xl:text-2xl ml-3 justify-center">
<p class="text-gray-900 whitespace-no-wrap">
$ 40,342.04
</p>
<span class="block text-gray-500 text-sm">Profit / Loss</span>
</div>
</div>

<!-- overview heading -->
<!-- card 3 -->

<div
class="card rounded-xl flex items-center h-20 sm:h-20 w-full object-cover px-5 shadow-2xl"
>
<div class="flex-shrink-0 w-10 h-10">
<img class="w-full h-full" src="images/graph.jpeg " alt=" " />
</div>
<div class="font-bold text-xl xl:text-2xl ml-3">
<p class="text-gray-900 whitespace-no-wrap">
$40,342.04
</p>
<span class="block text-gray-500 text-sm">$ Balance</span>
</div>
</div>
</div>
</div>

<h2 class="text-2xl font-bold leading-tight py-6 mt-6">Overview</h2>
<!-- graph card -->
<div class="card h-64 w-auto mb-10 shadow-2xl"></div>
<!-- overview heading -->

<!-- container for both tables -->
<h2 class="text-2xl font-bold leading-tight py-6 mt-6">Overview</h2>
<!-- graph card -->
<div class="card h-64 w-auto mb-10 shadow-2xl"></div>

<div class="lg:grid lg:grid-cols-2 -mx-8">
<!-- table component 1 -->
<!-- container for both tables -->

<div class="px-3 sm:px-6 py-4 overflow-hidden h-auto w-full">
<div class="flex justify-between">
<!-- heading of table -->
<div class="lg:grid lg:grid-cols-2 -mx-8">
<!-- table component 1 -->

<h2 class="text-2xl font-bold leading-tight py-6">Trade History</h2>
<a href="#" class="mt-6 mr-6 font-bold text-tempc-400">View All <span class="font-extrabold">></span></a
<div class="px-3 sm:px-6 py-4 overflow-hidden h-auto w-full">
<div class="flex justify-between">
<!-- heading of table -->

<h2 class="text-2xl font-bold leading-tight py-6">Trade History</h2>
<a href="#" class="mt-6 mr-6 font-bold text-tempc-400"
>View All <span class="font-extrabold">></span></a
>
</div>

Expand Down Expand Up @@ -729,4 +743,4 @@
</div>

<!-- </div> -->
</main>
</main>

0 comments on commit 1d74bd2

Please sign in to comment.