badge when owner gets pending rental request

This commit is contained in:
jackiettran
2025-10-31 12:18:40 -04:00
parent 71ce2c63fb
commit 99aa0b3bdc
5 changed files with 95 additions and 3 deletions

View File

@@ -109,6 +109,28 @@ router.get("/my-listings", authenticateToken, async (req, res) => {
}
});
// Get count of pending rental requests for owner
router.get("/pending-requests-count", authenticateToken, async (req, res) => {
try {
const count = await Rental.count({
where: {
ownerId: req.user.id,
status: "pending",
},
});
res.json({ count });
} catch (error) {
const reqLogger = logger.withRequestId(req.id);
reqLogger.error("Error getting pending rental count", {
error: error.message,
stack: error.stack,
userId: req.user.id,
});
res.status(500).json({ error: "Failed to get pending rental count" });
}
});
// Get rental by ID
router.get("/:id", authenticateToken, async (req, res) => {
try {