Skip to content

Commit 0b4a60c

Browse files
committed
transactions page added
1 parent 406ecb0 commit 0b4a60c

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

controllers/user.controller.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,13 @@ const resendOTP=(req,res)=>
165165
req.flash('alert','Your OTP has been resent successfully to your email.');
166166
res.redirect('/users/verify');
167167
}
168+
169+
const renderTransactions=async(req,res)=>
170+
{
171+
var transactions=await userService.getTransactions(req.body.user_id);
172+
res.render('users/transactions', {body: req.body,transactions:transactions});
173+
}
174+
168175
module.exports={
169176
renderLogin,
170177
renderRegister,
@@ -179,5 +186,6 @@ uploadImage,
179186
renderAddMoney,
180187
addMoney,
181188
apiOtp,
182-
resendOTP
189+
resendOTP,
190+
renderTransactions
183191
};

routes/user.route.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,7 @@ Router.route('/resendotp')
3939
Router.route('/logout')
4040
.delete(IsLoggedInMiddleware(), userController.logout);
4141

42+
Router.route('/transactions')
43+
.get(IsLoggedInMiddleware(),userController.renderTransactions);
44+
4245
module.exports=Router;

services/user.service.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,19 @@ const addMoney=async(user_id,added_money)=>
123123
await user.save();
124124
}
125125
}
126+
127+
const getTransactions=async(id)=>
128+
{
129+
var transactions=await Transactions.find({user_id:id});
130+
return transactions;
131+
}
132+
126133
module.exports={
127134
Register,
128135
Login,
129136
generateOtp,
130137
verified,
131138
updateImage,
132-
addMoney
139+
addMoney,
140+
getTransactions
133141
};

0 commit comments

Comments
 (0)