|
|
@ -883,3 +883,30 @@ exports.getPendingCustomers = async (req, reply) => {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exports.getconnectedCustomers = async (req, reply) => {
|
|
|
|
|
|
|
|
const limit = parseInt(req.query.limit) || 100;
|
|
|
|
|
|
|
|
const page = parseInt(req.query.page) || 1;
|
|
|
|
|
|
|
|
const startindex = (page - 1) * limit;
|
|
|
|
|
|
|
|
const supplierId = req.params.supplierId; // Assuming you have already authenticated the user and stored their ID in the request object
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
const friendRequests = await FriendRequest.find({ supplierId, status: ["accepted"] });
|
|
|
|
|
|
|
|
console.log(friendRequests,supplierId, "su....")
|
|
|
|
|
|
|
|
const supplierIdsToInclude = friendRequests.map((request) => request.customerId);
|
|
|
|
|
|
|
|
console.log(supplierIdsToInclude, "supplierIdsToInclude..")
|
|
|
|
|
|
|
|
await User.find({ customerId: { $in: supplierIdsToInclude } })
|
|
|
|
|
|
|
|
.limit(limit)
|
|
|
|
|
|
|
|
.skip(startindex)
|
|
|
|
|
|
|
|
.exec()
|
|
|
|
|
|
|
|
.then((docs) => {
|
|
|
|
|
|
|
|
reply.send({ status_code: 200, data: docs, count: docs.length });
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
.catch((err) => {
|
|
|
|
|
|
|
|
console.log(err);
|
|
|
|
|
|
|
|
reply.send({ error: err });
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
} catch (err) {
|
|
|
|
|
|
|
|
throw boom.boomify(err);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|