Skip to content

Commit

Permalink
Merge pull request #78 from fabcodingzest/bug-fixes
Browse files Browse the repository at this point in the history
Removed Done and Error pages layout along with removing server side validation during sign in.
  • Loading branch information
iampavangandhi authored Sep 2, 2020
2 parents b3e7099 + c11e185 commit 9188d21
Show file tree
Hide file tree
Showing 12 changed files with 262 additions and 200 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", { layout: "layouts/simple-page" });
res.status(500).render("error/500");
});

return data;
Expand Down
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", { layout: "layouts/simple-page" });
return res.render("error/500");
} 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", { layout: "layouts/simple-page" });
res.render("error/500");
}
});

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", { layout: "layouts/simple-page" });
res.render("error/500");
}
});

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", { layout: "layouts/simple-page" });
return res.render("error/500");
}
});

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", { layout: "layouts/simple-page" });
res.render("error/500");
}
});

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

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

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

Expand Down
30 changes: 5 additions & 25 deletions routes/api/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,31 +96,11 @@ router.post("/signup", ensureGuest, (req, res) => {
// @route GET /user/signin
// @access Public
router.post("/signin", ensureGuest, (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);
}
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", { layout: "layouts/simple-page" });
res.render("error/404");
});
});

Expand Down
209 changes: 117 additions & 92 deletions views/done.ejs
Original file line number Diff line number Diff line change
@@ -1,109 +1,134 @@
<!---Card component-->
<div class="m-2">
<div
class="flex justify-center items-center done-container max-w-sm mx-auto flex p-5 bg-white rounded-lg shadow-2xl"
>
<div class="py-4">
<h1 class="heading font-bold mb-2 text-6xl text-center text-green-700">
Done
</h1>
<div class="flex justify-center items-center text-green-400 my-6">
<i id="check" class="far fa-check-circle fa-7x"></i>
</div>
<div>
<p class="text-black-700 text-center text-2xl font-semibold mt-4">
Thank you for using TradeByte
</p>
</div>
<div class="flex justify-center items-center mt-4">
<button
onClick="back()"
class="bg-gray-700 hover:bg-red-400 text-white font-bold py-2 px-3 md:px-5 mx-2 mt-4 mb-3 rounded-full"
>
<i class="far fa-times-circle"></i> Back
</button>
<!--Thankyou PAGE -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Tradebyte</title>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.0-2/css/all.min.css"
integrity="sha256-46r060N2LrChLLb5zowXQ72/iKKNiw/lAmygmHExk/o="
crossorigin="anonymous"
/>
<link
href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css"
rel="stylesheet"
/>
<link rel="stylesheet" href="css/style.css" />
</head>

<button
class="relative share bg-gray-700 hover:bg-blue-400 text-white font-bold py-2 px-3 md:px-5 mx-2 mt-4 mb-3 rounded-full cursor-pointer"
onclick="share(this)"
>
<i class="fas fa-share-alt"></i> Share
<div
class="container absolute top-0 left-0 w-48 bg-white shadow-lg rounded mt-10 mb-12 -ml-12 sm:ml-0"
<body class="flex justify-center items-center min-h-screen">
<!---Card component-->
<div class="m-2">
<div
class="flex justify-center items-center done-container max-w-sm mx-auto flex p-5 bg-white rounded-lg shadow-2xl"
>
<div class="py-4">
<h1
class="heading font-bold mb-2 text-6xl text-center text-green-700"
>
<div
class="addthis_inline_share_toolbox text-center"
data-url="<%= host %>/share/<%= userId %>"
></div>
<div class="addthis_sharing_toolbox text-center"></div>
Done
</h1>
<div class="flex justify-center items-center text-green-400 my-6">
<i id="check" class="far fa-check-circle fa-7x"></i>
</div>
<div>
<p class="text-black-700 text-center text-2xl font-semibold mt-4">
Thank you for using TradeByte
</p>
</div>
<div class="flex justify-center items-center mt-4">
<button
onClick="back()"
class="bg-gray-700 hover:bg-red-400 text-white font-bold py-2 px-3 md:px-5 mx-2 mt-4 mb-3 rounded-full"
>
<i class="far fa-times-circle"></i> Back
</button>

<button
class="relative share bg-gray-700 hover:bg-blue-400 text-white font-bold py-2 px-3 md:px-5 mx-2 mt-4 mb-3 rounded-full cursor-pointer"
onclick="share(this)"
>
<i class="fas fa-share-alt"></i> Share
<div
class="container absolute top-0 left-0 w-48 bg-white shadow-lg rounded mt-10 mb-12 -ml-12 sm:ml-0"
>
<div
class="addthis_inline_share_toolbox text-center"
data-url="<%= host %>/share/<%= userId %>"
></div>
<div class="addthis_sharing_toolbox text-center"></div>
</div>
</button>
</div>
</button>
</div>
</div>
</div>
</div>
</div>

<!---------------------JavaScript-------------------------->
<script>
let AddThisJSLoaded = false; // Addthis not loaded yet
let clickedOnShare = false; // share button is not clicked
<!---------------------JavaScript-------------------------->
<script>
let AddThisJSLoaded = false; // Addthis not loaded yet
let clickedOnShare = false; // share button is not clicked
function back() {
window.location.href = "/";
}
function back() {
window.location.href = "/";
}
//this is a publicer id
let AddthisPubID = "ra-5f3af90d32b2c7af";
let AddThisJS =
"//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-5f3af90d32b2c7af";
//this is a publicer id
let AddthisPubID = "ra-5f3af90d32b2c7af";
let AddThisJS =
"//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-5f3af90d32b2c7af";
function share(button) {
if (!AddThisJSLoaded && !clickedOnShare) {
//when AddThis not loaded
clickedOnShare = true; // share button is clicked
showLoading(button);
shareByAddThis(button);
} else {
toogleAddThisButtons(button);
}
}
function share(button) {
if (!AddThisJSLoaded && !clickedOnShare) {
//when AddThis not loaded
clickedOnShare = true; // share button is clicked
showLoading(button);
shareByAddThis(button);
} else {
toogleAddThisButtons(button);
}
}
function shareByAddThis(button) {
let script = document.createElement("script");
script.async = true;
script.src = AddThisJS;
function shareByAddThis(button) {
let script = document.createElement("script");
script.async = true;
script.src = AddThisJS;
script.onload = function () {
clickedOnShare = false; // AddThis js is loaded
addthis.user.ready(function (data) {
AddThisJSLoaded = true; //loaded and ready to use
hideLoading(button);
showAddThisButtons(button);
});
};
script.onload = function () {
clickedOnShare = false; // AddThis js is loaded
addthis.user.ready(function (data) {
AddThisJSLoaded = true; //loaded and ready to use
hideLoading(button);
showAddThisButtons(button);
});
};
script.onerror = function () {
clickedOnShare = false; // Addthis JS failed to laod
hideLoading(button);
};
script.onerror = function () {
clickedOnShare = false; // Addthis JS failed to laod
hideLoading(button);
};
document.body.appendChild(script);
}
document.body.appendChild(script);
}
function showLoading(button) {
button.classList.add("loading");
}
function showLoading(button) {
button.classList.add("loading");
}
function hideLoading(button) {
//hide the loading
button.classList.remove("loading");
}
function hideLoading(button) {
//hide the loading
button.classList.remove("loading");
}
function showAddThisButtons(button) {
button.classList.add("showAddThisButtons");
}
function showAddThisButtons(button) {
button.classList.add("showAddThisButtons");
}
function toogleAddThisButtons(button) {
button.classList.toogle("showAddThisButtons");
}
</script>
function toogleAddThisButtons(button) {
button.classList.toogle("showAddThisButtons");
}
</script>
</body>
</html>
Loading

0 comments on commit 9188d21

Please sign in to comment.