Add transaction page

This commit is contained in:
Moe Poi ~ 2021-11-21 09:57:26 +07:00
parent bef3abde74
commit c32e31edd4
2 changed files with 55 additions and 0 deletions

View file

@ -231,6 +231,25 @@ router.get("/payment", (_req, res) => {
res.redirect("/");
});
router.get("/transaction", (req, res) => {
auth.session_converter(req.cookies.session_token).then((key) => {
if (key != null) {
controller.transaction(key).then((data) => {
if (data[0] == 200) {
res.render("pages/transaction", {
data: data[1],
loggedIn: 'true'
});
} else {
res.redirect("/");
}
});
} else {
res.redirect("/login");
}
});
});
router.get("/about-us", (req, res) => {
auth.session_converter(req.cookies.session_token).then((key) => {
if (key != null) {

View file

@ -0,0 +1,36 @@
<html>
<%- include('../layouts/header.ejs', {title: 'Transaction List', state: 'transaction'}); %>
<body class="bg-color">
<%- include('../layouts/navbar.ejs', {types: 'v1', state: 'transaction'}); %>
<div class="container-fluid mt-3 comp-color">
<table class="table table-hover table-dark comp-color">
<thead>
<tr>
<th scope="col">Order ID</th>
<th scope="col">Name</th>
<th scope="col">Logistic</th>
<th scope="col">Status</th>
</tr>
</thead>
<tbody>
<% for(let i=0; i < data.length; i++) { %>
<tr>
<th scope="row"><%= data[i].id %></th>
<td><%= data[i].firstName + ' ' + data[i].lastName %></td>
<td><%= data[i].logistic %></td>
<td><%= data[i].status %></td>
</tr>
<% } %>
</tbody>
</table>
</div>
<%- include('../layouts/footer.ejs', {state: 'transaction'}); %>
</body>
</html>