Skip to content
This repository has been archived by the owner on Sep 15, 2024. It is now read-only.

Commit

Permalink
feat: edit deposit settings
Browse files Browse the repository at this point in the history
  • Loading branch information
kndonetm committed Nov 24, 2023
1 parent e105fe3 commit 19da3b4
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/routes/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ router.patch('/loans/:loanType', async (req, res, next) => {
const query = {}
query[req.params.loanType] = req.body

const ret = await LoanSettings.findOneAndUpdate({}, query).select('-_id -__v')

console.log(ret)
await LoanSettings.findOneAndUpdate({}, query).select('-_id -__v')

return res.status(200).json({ error: false, message: 'Updated loan settings' })
} catch (error) {
Expand Down Expand Up @@ -64,13 +62,16 @@ router.get('/deposits', async (req, res, next) => {
})(req, res, next)
})

router.patch('/deposits', async (req, res, next) => {
router.patch('/deposits/:depositType', async (req, res, next) => {
passport.authenticate('admin', { session: false }, async (err, admin, info) => {
if (err) return next(err)
if (!admin) return res.status(401).json({ message: info.message })

try {
await DepositSettings.findOneAndUpdate({}, req.body).select('-_id -__v')
const query = {}
query[req.params.depositType] = req.body

await DepositSettings.findOneAndUpdate({}, query).select('-_id -__v')

return res.status(200).json({ error: false, message: 'Updated deposit settings' })
} catch (error) {
Expand Down

0 comments on commit 19da3b4

Please sign in to comment.