Claim voucher function

This commit is contained in:
ZacTohZY
2024-08-12 19:39:37 +08:00
parent 46b96542ee
commit 4429f48c40
4 changed files with 387 additions and 223 deletions

View File

@@ -50,5 +50,22 @@ router.get('/user/:userId', async (req, res) => {
}
});
router.delete('/:id', async (req, res) => {
const id = req.params.id;
try {
const userVoucher = await UserVoucher.findByPk(id);
if (!userVoucher) {
return res.status(404).json({ error: 'UserVoucher not found' });
}
await userVoucher.destroy();
res.status(204).send(); // No Content response
} catch (error) {
res.status(500).json({ error: 'Failed to delete UserVoucher' });
}
});
module.exports = router;