add date picker

This commit is contained in:
Nikola Petrov 2023-10-06 18:18:24 +02:00
parent dfb76ed5f0
commit 1a1318c048
2 changed files with 15 additions and 1 deletions

View File

@ -3,7 +3,20 @@ module.exports = {
list: async function (req, res) { list: async function (req, res) {
try { try {
const transactions = await cashTransactionModel.find({}, { _id: 0, __v: 0 }); var transactions;
const date = req.body.date;
if (date) {
const splitDate = date.split('-');
var year = splitDate[0];
var month = splitDate[1];
year = parseInt(year);
month = parseInt(month);
transactions = await cashTransactionModel.find({ year, month }, { _id: 0, __v: 0 });
} else {
transactions = await cashTransactionModel.find({}, { _id: 0, __v: 0 });
}
return res.json(transactions); return res.json(transactions);
} catch (err) { } catch (err) {
return res.status(500).json({ return res.status(500).json({

View File

@ -9,6 +9,7 @@
</button> </button>
<div class="collapse navbar-collapse" id="navbarSupportedContent"> <div class="collapse navbar-collapse" id="navbarSupportedContent">
<form class="d-flex" action="" id="myform"> <form class="d-flex" action="" id="myform">
<input class="form-control me-2" type="date" name="date" id="date" placeholder="date">
<input class="form-control me-2" type="password" name="password" id="pass" placeholder="password"> <input class="form-control me-2" type="password" name="password" id="pass" placeholder="password">
<input class="btn btn-outline-success" type="submit" value="Submit"> <input class="btn btn-outline-success" type="submit" value="Submit">
</form> </form>