This commit is contained in:
Moe Poi ~ 2021-11-21 13:51:57 +07:00
commit a5022d4447
8 changed files with 294 additions and 241 deletions

View file

@ -41,6 +41,18 @@
border-color: red; border-color: red;
} }
.button-close {
color: white;
background-color: darkred;
border-color: darkred;
border-radius: 100px;
}
.button-close:hover {
background-color: red;
border-color: red;
}
.button-checkout_1 { .button-checkout_1 {
color: white; color: white;
background-color: darkred; background-color: darkred;

View file

@ -0,0 +1,124 @@
body {
font-family: 'Poppins', sans-serif;
background-color: #1b1c1e;
}
.nav-color {
background-color: #212226;
}
.nav-radius {
border-bottom-left-radius: 20px;
border-bottom-right-radius: 20px;
}
.card {
position: center;
margin: auto;
text-align: center;
border-radius: 20px;
background-color: #212226;
}
.icon {
position: center;
margin: auto;
width: 70%;
height: 70%;
}
.btn {
background-color: darkred;
border-color: darkred;
border-radius: 100px;
width: 50%;
}
.btn:hover {
background-color: red;
border-color: red;
}
@media screen and (max-width: 766px) {
.card h2 {
font-size: 7vw;
}
.card h5 {
font-size: 5vw;
}
.card a {
font-size: 5vw;
}
.navbar-brand {
width: 11vw;
height: 11vw;
}
}
@media screen and (min-width: 767px) {
.card h2 {
font-size: 4vw;
}
.card h5 {
font-size: 2vw;
}
.card a {
font-size: 2.5vw;
}
.navbar-brand {
width: 8vw;
height: 8vw;
}
}
@media screen and (min-width: 993px) {
.card h2 {
font-size: 3vw;
}
.card h5 {
font-size: 1.3vw;
}
.card a {
font-size: 1.5vw;
}
.navbar-brand {
width: 6vw;
height: 6vw;
}
}
@media screen and (min-width: 1400px) {
.card h2 {
font-size: 3vw;
}
.card h5 {
font-size: 1.5vw;
}
.card a {
font-size: 2vw;
}
.navbar-brand {
width: 6vw;
height: 6vw;
}
:focus {
outline: 0 !important;
box-shadow: 0 0 0 0 rgba(0, 0, 0, 0) !important;
}
}

View file

@ -1,12 +1,9 @@
const express = require("express"); const express = require("express");
const bcrypt = require("bcrypt"); const bcrypt = require("bcrypt");
const randtoken = require("rand-token"); const randtoken = require("rand-token");
const router = express.Router(); const router = express.Router();
const db = require("../modules/db"); const db = require("../modules/db");
const mail = require("../modules/mail"); const mail = require("../modules/mail");
const auth = require("../auth/auth");
const saltRounds = 10; const saltRounds = 10;
@ -241,16 +238,10 @@ router.post("/login", async (req, res) => {
} }
}); });
router.post("/verify-mail", async (req, res) => { router.get("/verify-mail", async (req, res) => {
if (!req.body.token) {
res.status(400);
res.json({
message: "Bad Request",
});
} else {
const conn = db.connect(); const conn = db.connect();
conn.query( conn.query(
'SELECT * FROM users WHERE token ="' + req.body.token + '"', 'SELECT * FROM users WHERE token ="' + req.query.token + '"',
function (err, result) { function (err, result) {
if (err) { if (err) {
res.status(400); res.status(400);
@ -262,9 +253,8 @@ router.post("/verify-mail", async (req, res) => {
if (result[0].verify == 0) { if (result[0].verify == 0) {
var data = { var data = {
verify: 1, verify: 1,
token: randtoken.generate(64),
}; };
conn.query( db_connect.query(
'UPDATE users SET ? WHERE email ="' + result[0].email + '"', 'UPDATE users SET ? WHERE email ="' + result[0].email + '"',
data, data,
function (err, result) { function (err, result) {
@ -295,7 +285,6 @@ router.post("/verify-mail", async (req, res) => {
} }
} }
); );
}
}); });
router.post("/request-reset-password", async (req, res) => { router.post("/request-reset-password", async (req, res) => {
@ -411,14 +400,6 @@ router.post("/reset-password", async (req, res) => {
}); });
router.post("/checkout", async (req, res) => { router.post("/checkout", async (req, res) => {
if (!req.query.key) {
res.status(401);
res.json({
message: "Unauthorized",
});
} else {
auth.auth_checker(req.query.key).then((status) => {
if (status) {
if ( if (
!req.body.firstName || !req.body.firstName ||
!req.body.lastName || !req.body.lastName ||
@ -440,16 +421,6 @@ router.post("/checkout", async (req, res) => {
}); });
} else { } else {
const conn = db.connect(); const conn = db.connect();
conn.query(
"SELECT * FROM users WHERE token = ?",
[req.query.key],
async function (error, resp, fields) {
if (error) {
res.status(401);
res.json({
message: "Unauthorized",
});
} else {
var data = { var data = {
firstName: req.body.firstName, firstName: req.body.firstName,
lastName: req.body.lastName, lastName: req.body.lastName,
@ -465,7 +436,7 @@ router.post("/checkout", async (req, res) => {
logistic: req.body.logistic, logistic: req.body.logistic,
paymentMethod: '-', paymentMethod: '-',
data: req.body.data, data: req.body.data,
userId: resp[0].id, userId: 14,
paid: '0', paid: '0',
status: 'pending' status: 'pending'
}; };
@ -499,110 +470,6 @@ router.post("/checkout", async (req, res) => {
} }
); );
} }
}
);
}
} else {
res.status(401);
res.json({
message: "Unauthorized",
});
}
});
}
});
router.post("/transaction", async (req, res) => {
if (!req.query.key) {
res.status(401);
res.json({
message: "Unauthorized",
});
} else {
auth.auth_checker(req.query.key).then((status) => {
if (status) {
const conn = db.connect();
conn.query(
"SELECT * FROM users WHERE token = ?",
[req.query.key],
async function (error, response, fields) {
if (error) {
res.status(401);
res.json({
message: "Unauthorized",
});
} else {
conn.query(
"SELECT * FROM transactions WHERE userId = ?",
[response[0].id],
async function (error, resp, fields) {
if (error) {
res.status(400);
res.json({
message: "Bad Request",
});
} else {
res.status(200);
res.json(resp);
}
}
);
}
}
);
} else {
res.status(401);
res.json({
message: "Unauthorized",
});
}
});
}
});
router.get("/subscribe", (req, res) => {
if (!req.query.email) {
res.status(400);
res.json({
message: "Bad Request",
});
} else {
const conn = db.connect();
conn.execute(
"SELECT * FROM `subscribe` WHERE `email` = ?",
[req.query.email],
function (err, results) {
if (!results[0]) {
let data = {
email: req.query.email,
type: "email"
};
conn.query(
"INSERT INTO subscribe SET ?",
data,
function (err, resp) {
if (err) {
res.status(400);
res.json({
message: "Bad Request",
});
} else {
res.status(201);
res.json({
message: "Success",
});
}
}
);
} else {
res.status(200);
res.json({
message: "Success",
});
}
}
);
}
}); });
module.exports = router; module.exports = router;

View file

@ -39,7 +39,7 @@ router.route("/register")
if (data == 200) { if (data == 200) {
res.render("pages/register-verification-sent"); res.render("pages/register-verification-sent");
} else { } else {
res.redirect("/register"); res.render("pages/register-error")
} }
}); });
}); });

View file

@ -566,8 +566,25 @@
<input id="newsletter_email" type="email" placeholder="Input Your Email" required="required" <input id="newsletter_email" type="email" placeholder="Input Your Email" required="required"
data-error="valid email is required"> data-error="valid email is required">
<button id="newsletter_submit" class="newsletter_submit_btn trans_300" <button id="newsletter_submit" class="newsletter_submit_btn trans_300"
onclick="subscribe()" value="submit">Subscribe onclick="subscribe()" value="submit" data-toggle="modal" data-target="#exampleModal">Subscribe
</button> </button>
<div class="modal fade black" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content" style="background-color: #1b1c1e; color: white;">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body" style="text-align: center;">
You have successfully subscribed to the newsletter. Thank you for your subscription.
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>

View file

@ -44,10 +44,10 @@
</button> </button>
</div> </div>
<div class="modal-body" style="text-align: center;"> <div class="modal-body" style="text-align: center;">
Succefully added to Bag Successfully added to Bag
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> <button type="button" class="btn btn-secondary button-close" data-dismiss="modal">Close</button>
<a href="/bag"><button type="button" class="btn button-bag">Bag</button></a> <a href="/bag"><button type="button" class="btn button-bag">Bag</button></a>
</div> </div>
</div> </div>

View file

@ -0,0 +1,33 @@
<!doctype html>
<html lang="en">
<%- include('../layouts/header.ejs', {title: 'Register', state: 'register-error'}); %>
<body>
<%- include('../layouts/navbar.ejs', {types: 'v2', title: 'Register'}); %>
<br>
<div data-aos="fade-in" data-aos-delay="500" class="container">
<div class="row">
<div class="col">
<div class="card col-md-6 col-lg-6 col-xl-8">
<div class="card-header" style="color: cyan;">
<h2>ERROR</h2>
</div>
<lottie-player style="display: -webkit-box;-webkit-box-pack: center;" autoplay background="transparent" class="icon" loop speed="1"
src="https://assets5.lottiefiles.com/temp/lf20_QYm9j9.json"></lottie-player>
<div class="card-body">
<h5 class="card-text" style="color: cyan;">An error has occured... Make sure to check if you have empty fields, or if your email has been registered before. Click the button below to get back to the register page.</h5>
<br style="display: block;content: ' ';margin: 1vw 0;line-height: 1vw;">
<a class="btn btn-primary" href="register">Register</a>
</div>
</div>
</div>
</div>
</div>
<%- include('../layouts/footer.ejs', {state: 'register-error'}); %>
</body>
</html>