diff options
Diffstat (limited to 'interface/routes/transactions.js')
| -rw-r--r-- | interface/routes/transactions.js | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/interface/routes/transactions.js b/interface/routes/transactions.js new file mode 100644 index 0000000..751cc32 --- /dev/null +++ b/interface/routes/transactions.js @@ -0,0 +1,85 @@ +const express = require("express"); +const router = express.Router(); +const transactionsController = require("../controllers/transactions.controller"); + +router.get("/agriculture", (req, res) => { + const limit = parseInt(req.query.limit, 10) || 100; + const page = req.query.page ? (req.query.page - 1) * limit : 0; + Promise.all([ + transactionsController.getAgricultureTransactions(limit, page), + transactionsController.getAgricultureTransactionsCount(), + ]).then((results) => { + const [transactions, count] = results; + res.render("agriculture", { + title: "Agriculture Transactions", + transactions, + count: count[0].count, + }); + }); +}); + +router.get("/hospital", (req, res) => { + const limit = parseInt(req.query.limit, 10) || 100; + const page = req.query.page ? (req.query.page - 1) * limit : 0; + Promise.all([ + transactionsController.getHospitalTransactions(limit, page), + transactionsController.getHospitalTransactionsCount(), + ]).then((results) => { + const [transactions, count] = results; + res.render("hospital", { + title: "Hospital Transactions", + transactions, + count: count[0].count, + }); + }); +}); + +router.get("/lpg", (req, res) => { + const limit = parseInt(req.query.limit, 10) || 100; + const page = req.query.page ? (req.query.page - 1) * limit : 0; + Promise.all([ + transactionsController.getLPGTransactions(limit, page), + transactionsController.getLPGTransactionsCount(), + ]).then((results) => { + const [transactions, count] = results; + res.render("lpg", { + title: "LPG Transactions", + transactions, + count: count[0].count, + }); + }); +}); + +router.get("/nregs", (req, res) => { + const limit = parseInt(req.query.limit, 10) || 100; + const page = req.query.page ? (req.query.page - 1) * limit : 0; + Promise.all([ + transactionsController.getNREGSTransactions(limit, page), + transactionsController.getNREGSTransactionsCount(), + ]).then((results) => { + const [transactions, count] = results; + res.render("nregs", { + title: "NREGS Transactions", + transactions, + count: count[0].count, + }); + }); +}); + +router.get("/pension", (req, res) => { + const limit = parseInt(req.query.limit, 10) || 100; + const page = req.query.page ? (req.query.page - 1) * limit : 0; + Promise.all([ + transactionsController.getPensionTransactions(limit, page), + transactionsController.getPensionTransactionsCount(), + ]).then((results) => { + const [transactions, count] = results; + res.render("pension", { + title: "Pension Transactions", + transactions, + count: count[0].count, + }); + }); +}); + +module.exports = router; |
