Skip to content

Commit

Permalink
Merge pull request #77 from fabcodingzest/bug-fixes
Browse files Browse the repository at this point in the history
Bug fixes
  • Loading branch information
fabcodingzest authored Sep 1, 2020
2 parents 5bfbcde + 901c49d commit c17a10d
Show file tree
Hide file tree
Showing 26 changed files with 528 additions and 528 deletions.
2 changes: 1 addition & 1 deletion helpers/getOverview.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module.exports = async function getOverview(symbol) {
}))
.catch((err) => {
console.log(err);
res.status(500).render("error/500");
res.status(500).render("error/500", { layout: "layouts/simple-page" });
});

return data;
Expand Down
2 changes: 1 addition & 1 deletion public/css/style.css

Large diffs are not rendered by default.

26 changes: 21 additions & 5 deletions public/css/tailwind.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

/* Custom CSS */

/* Main CSS */

html,
body {
margin: 0;
Expand All @@ -25,6 +23,7 @@ body {
width: 75vw;
}

/* Remove number input arrow buttons on transaction page */
input::-webkit-outer-spin-button.without-arrow,
input::-webkit-inner-spin-button.without-arrow {
-webkit-appearance: none;
Expand All @@ -44,7 +43,8 @@ input[type="number"].without-arrow {
-webkit-text-fill-color: transparent;
}

.notification .badge {
/* Edit icon */
.icon .badge {
position: absolute;
top: -5px;
right: -5px;
Expand All @@ -54,12 +54,12 @@ input[type="number"].without-arrow {
color: white;
}

/* search bar */
/* Search bar */
#searchbar:focus .search-list {
display: block;
}

/* Login Page */
/* Login Page animations */
animated {
-webkit-animation-duration: 1s;
animation-duration: 1s;
Expand Down Expand Up @@ -115,4 +115,20 @@ animated {
background-size: 16px 16px;
}

/* Done page */
.share > .container {
opacity: 0;
visibility: hidden;
transition: 0.4s all ease-in-out;
transform: translateY(50%);
}

/* Share button */
.share.showAddThisButtons > .container {
opacity: 1;
visibility: visible;
transform: translateY(40%);
margin-top: 0.5rem;
}

@tailwind utilities;
4 changes: 2 additions & 2 deletions routes/api/addBalance.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ router.post("/", ensureAuth, async (req, res) => {
},
(err) => {
if (err && err.type === "StripeCardError") {
return res.render("error/500");
return res.render("error/500", { layout: "layouts/simple-page" });
} else {
console.log("Payment Success");
}
Expand Down Expand Up @@ -79,7 +79,7 @@ router.post("/", ensureAuth, async (req, res) => {
res.redirect("/done");
} catch (err) {
console.error(err);
res.render("error/500");
res.render("error/500", { layout: "layouts/simple-page" });
}
});

Expand Down
2 changes: 1 addition & 1 deletion routes/api/cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ router.post("/buy", ensureAuth, async (req, res) => {
}
} catch (err) {
console.error(err);
res.render("error/500");
res.render("error/500", { layout: "layouts/simple-page" });
}
});

Expand Down
2 changes: 1 addition & 1 deletion routes/api/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ router.put("/", ensureAuth, async (req, res) => {
res.redirect("/portfolio");
} catch (err) {
console.error(err);
return res.render("error/500");
return res.render("error/500", { layout: "layouts/simple-page" });
}
});

Expand Down
8 changes: 4 additions & 4 deletions routes/api/transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ router.put("/confirm", ensureAuth, async (req, res) => {
res.redirect("/done");
} catch (err) {
console.error(err);
res.render("error/500");
res.render("error/500", { layout: "layouts/simple-page" });
}
});

Expand Down Expand Up @@ -159,7 +159,7 @@ router.get("/", ensureAuth, async (req, res) => {
}
} catch (err) {
console.error(err);
res.render("error/500");
res.render("error/500", { layout: "layouts/simple-page" });
}
});

Expand Down Expand Up @@ -208,10 +208,10 @@ router.post("/sell/:id", ensureAuth, async (req, res) => {
}
});

res.redirect("/done");
res.redirect("/done", { layout: "layouts/simple-page" });
} catch (err) {
console.error(err);
res.render("error/500");
res.render("error/500", { layout: "layouts/simple-page" });
}
});

Expand Down
30 changes: 25 additions & 5 deletions routes/api/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,31 @@ router.post("/signup", ensureGuest, (req, res) => {
// @route GET /user/signin
// @access Public
router.post("/signin", ensureGuest, (req, res, next) => {
passport.authenticate("local", {
successRedirect: "/portfolio",
failureRedirect: "/",
failureFlash: true,
})(req, res, next);
const { password, email } = req.body;
let errors = [];

if (!password || !email) {
errors.push({ msg: "Please enter all fields" });
}

if (password.length < 6) {
errors.push({ msg: "Password must be longer than 6 characters" });
}

if (errors.length > 0) {
res.render("login", {
layout: "layouts/login",
errors,
email,
password,
});
} else {
passport.authenticate("local", {
successRedirect: "/portfolio",
failureRedirect: "/",
failureFlash: true,
})(req, res, next);
}
});

module.exports = router;
2 changes: 1 addition & 1 deletion routes/api/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ router.get("/:symbol", ensureAuth, async (req, res) => {
})
.catch((err) => {
console.error(err);
res.render("error/404");
res.render("error/404", { layout: "layouts/simple-page" });
});
});

Expand Down
11 changes: 9 additions & 2 deletions views/addBalance.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Add Balance
</h2>
</div>

<hr class="border-2 border-gray-700" />

<div class="container py-16 mx-auto">
Expand All @@ -26,13 +26,14 @@
<input
id="amount"
min="50"
max="4999"
max="50000"
value="50"
type="number"
onchange="check(this.value)"
class="shadow appearance-none border rounded w-2/5 py-2 px-3 my-2 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
name="addAmount"
placeholder="$ Amount"
required
/>
<input type="hidden" name="_csrf" />
<!-- below key is a publishable test key by stripe -->
Expand Down Expand Up @@ -118,8 +119,14 @@
<script>
function check(value) {
if (value < 50) {
window.location.href = "/addBalance";
alert("Minimum $50 is valid only");
document.getElementById("amount").value = 50;
}
if (value > 50000) {
window.location.href = "/addBalance";
alert("You can add $50,000 at a time.");
document.getElementById("amount").value = 50;
}
}
</script>
3 changes: 2 additions & 1 deletion views/cart.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<form action="/cart/buy" method="POST">
<h1 class="text-xl lg:text-3xl font-bold mt-8 mb-4 flex">
Buy Stock :<input
class="bg-gray-300 max-w-sm w-24 ml-2"
class="bg-transparent max-w-sm w-24 ml-2"
type="text"
readonly
value="<%= symbol %>"
Expand Down Expand Up @@ -73,6 +73,7 @@
type="number"
value="1"
min="1"
max="30"
name="noOfStock"
id="noOfStock"
class="w-full font-semibold text-center text-gray-700 bg-gray-200 outline-none focus:outline-none hover:text-black focus:text-black"
Expand Down
Loading

0 comments on commit c17a10d

Please sign in to comment.