updated the pdOrderControllers

This commit is contained in:
ROSHAN GARG 2024-09-09 13:13:43 +05:30
parent fe1648f856
commit 3056fbd2b3
2 changed files with 8 additions and 1 deletions

View File

@ -702,7 +702,14 @@ const formatDate = (date) => {
export const getOrderCounts = async (req, res) => {
try {
// console.log(req.user._id,"");
const userId = req.user._id;
const statusCounts = await PdOrder.aggregate([
{
$match: {
addedBy: userId, // Only match orders added by the current user
},
},
{
$group: {
_id: "$status", // Group by status

View File

@ -50,6 +50,6 @@ router
router
.route("/change/status/:id")
.patch(isAuthenticatedUser, authorizeRoles("admin"), updateOrderStatusById);
router.route("/get-counts-pdOrders").get(getOrderCounts);
router.route("/get-counts-pdOrders").get(isAuthenticatedUser, getOrderCounts);
export default router;