diff --git a/public/css/product.css b/public/css/product.css index 56ac661..a2b5a47 100644 --- a/public/css/product.css +++ b/public/css/product.css @@ -41,6 +41,18 @@ 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 { color: white; background-color: darkred; diff --git a/public/css/register-error.css b/public/css/register-error.css new file mode 100644 index 0000000..bd3d028 --- /dev/null +++ b/public/css/register-error.css @@ -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; + } +} \ No newline at end of file diff --git a/routes/api.js b/routes/api.js index bd69d0b..aaa31de 100644 --- a/routes/api.js +++ b/routes/api.js @@ -1,12 +1,9 @@ const express = require("express"); const bcrypt = require("bcrypt"); const randtoken = require("rand-token"); - const router = express.Router(); - const db = require("../modules/db"); const mail = require("../modules/mail"); -const auth = require("../auth/auth"); const saltRounds = 10; @@ -241,61 +238,53 @@ router.post("/login", async (req, res) => { } }); -router.post("/verify-mail", async (req, res) => { - if (!req.body.token) { - res.status(400); - res.json({ - message: "Bad Request", - }); - } else { - const conn = db.connect(); - conn.query( - 'SELECT * FROM users WHERE token ="' + req.body.token + '"', - function (err, result) { - if (err) { - res.status(400); - res.json({ - message: "Bad Request", - }); - } - if (result.length > 0) { - if (result[0].verify == 0) { - var data = { - verify: 1, - token: randtoken.generate(64), - }; - conn.query( - 'UPDATE users SET ? WHERE email ="' + result[0].email + '"', - data, - function (err, result) { - if (err) { - res.status(400); - res.json({ - message: "Bad Request", - }); - } else { - res.status(200); - res.json({ - message: "Verified ~", - }); - } - } - ); - } else { - res.status(403); - res.json({ - message: "Forbidden", - }); - } - } else { - res.status(400); - res.json({ - message: "Bad Request", - }); - } +router.get("/verify-mail", async (req, res) => { + const conn = db.connect(); + conn.query( + 'SELECT * FROM users WHERE token ="' + req.query.token + '"', + function (err, result) { + if (err) { + res.status(400); + res.json({ + message: "Bad Request", + }); + } + if (result.length > 0) { + if (result[0].verify == 0) { + var data = { + verify: 1, + }; + db_connect.query( + 'UPDATE users SET ? WHERE email ="' + result[0].email + '"', + data, + function (err, result) { + if (err) { + res.status(400); + res.json({ + message: "Bad Request", + }); + } else { + res.status(200); + res.json({ + message: "Verified ~", + }); + } + } + ); + } else { + res.status(403); + res.json({ + message: "Forbidden", + }); + } + } else { + res.status(400); + res.json({ + message: "Bad Request", + }); } - ); } + ); }); router.post("/request-reset-password", async (req, res) => { @@ -411,193 +400,71 @@ router.post("/reset-password", 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 ( - !req.body.firstName || - !req.body.lastName || - !req.body.phoneNumber || - !req.body.streetAddress1 || - !req.body.streetAddress2 || - !req.body.region || - !req.body.province || - !req.body.city || - !req.body.district || - !req.body.subDistrict || - !req.body.postalCode || - !req.body.logistic || - !req.body.data - ) { - res.status(400); - res.json({ - message: "Bad Request", - }); - } else { - 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 = { - firstName: req.body.firstName, - lastName: req.body.lastName, - phoneNumber: req.body.phoneNumber, - streetAddress1: req.body.streetAddress1, - streetAddress2: req.body.streetAddress2, - region: req.body.region, - province: req.body.province, - city: req.body.city, - district: req.body.district, - subDistrict: req.body.subDistrict, - postalCode: req.body.postalCode, - logistic: req.body.logistic, - paymentMethod: '-', - data: req.body.data, - userId: resp[0].id, - paid: '0', - status: 'pending' - }; - conn.query( - "INSERT INTO transactions SET ?", - data, - function (error, response, fields) { - if (error) { - res.status(400); - res.json({ - message: "Bad Request", - }); - } else { - conn.query( - 'SELECT * FROM transactions WHERE id ="' + response.insertId + '"', - function (err, result) { - if (err) { - res.status(400); - res.json({ - message: "Bad Request", - }); - } else { - res.status(201); - res.json({ - 'order_id': result[0].id, - 'data': result[0].data - }); - } - }); - } - } - ); - } - } - ); - } - } 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) { + if ( + !req.body.firstName || + !req.body.lastName || + !req.body.phoneNumber || + !req.body.streetAddress1 || + !req.body.streetAddress2 || + !req.body.region || + !req.body.province || + !req.body.city || + !req.body.district || + !req.body.subDistrict || + !req.body.postalCode || + !req.body.logistic || + !req.body.data + ) { 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); + var data = { + firstName: req.body.firstName, + lastName: req.body.lastName, + phoneNumber: req.body.phoneNumber, + streetAddress1: req.body.streetAddress1, + streetAddress2: req.body.streetAddress2, + region: req.body.region, + province: req.body.province, + city: req.body.city, + district: req.body.district, + subDistrict: req.body.subDistrict, + postalCode: req.body.postalCode, + logistic: req.body.logistic, + paymentMethod: '-', + data: req.body.data, + userId: 14, + paid: '0', + status: 'pending' + }; + conn.query( + "INSERT INTO transactions SET ?", + data, + function (error, response, fields) { + if (error) { + res.status(400); res.json({ - message: "Success", + message: "Bad Request", + }); + } else { + conn.query( + 'SELECT * FROM transactions WHERE id ="' + response.insertId + '"', + function (err, result) { + if (err) { + res.status(400); + res.json({ + message: "Bad Request", + }); + } else { + res.status(201); + res.json({ + 'order_id': result[0].id, + 'data': result[0].data + }); + } }); } } diff --git a/routes/index.js b/routes/index.js index e298e14..24b1db5 100644 --- a/routes/index.js +++ b/routes/index.js @@ -39,7 +39,7 @@ router.route("/register") if (data == 200) { res.render("pages/register-verification-sent"); } else { - res.redirect("/register"); + res.render("pages/register-error") } }); }); diff --git a/views/layouts/header.ejs b/views/layouts/header.ejs index 01254f0..7bd7ec7 100644 --- a/views/layouts/header.ejs +++ b/views/layouts/header.ejs @@ -48,4 +48,4 @@ <% } else if(state == "faq") { %> <% } %> - \ No newline at end of file + diff --git a/views/pages/index.ejs b/views/pages/index.ejs index a6386a7..be5dbce 100644 --- a/views/pages/index.ejs +++ b/views/pages/index.ejs @@ -566,8 +566,25 @@ +
diff --git a/views/pages/product.ejs b/views/pages/product.ejs index 795429f..f918f72 100644 --- a/views/pages/product.ejs +++ b/views/pages/product.ejs @@ -44,10 +44,10 @@