master
Bhaskara Kishore 3 years ago
parent e49f1260e4
commit 2a3c55810e

@ -1019,7 +1019,7 @@ exports.getPendingSuppliers = async (req, reply) => {
); );
console.log(supplierIdsToInclude, "SUPLIERINCLUDE"); console.log(supplierIdsToInclude, "SUPLIERINCLUDE");
const timestamps = friendRequests.map(request => const timestamps = friendRequests.map(request =>
moment(request.timestamp).format("DD-MM-YYYY hh:mm:ss") moment(request.timestamp, "DD-MM-YYYYTHH:mm:ss.SSSZ").format("DD-MM-YYYY hh:mm:ss")
); );
console.log(timestamps, "timestamps"); console.log(timestamps, "timestamps");
await Supplier.find({ supplierId: { $in: supplierIdsToInclude } }) await Supplier.find({ supplierId: { $in: supplierIdsToInclude } })
@ -1079,48 +1079,7 @@ exports.getRejectSuppliers = async (req, reply) => {
} }
}; };
// exports.getPendingCustomers = 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: ["pending"],
// });
// console.log(friendRequests, supplierId, "su....");
// const supplierIdsToInclude = friendRequests.map(
// (request) => request.customerId
// );
// console.log(supplierIdsToInclude, "supplierIdsToInclude..");
// const timestamps = friendRequests.map((request) => request.timestamp);
// console.log(timestamps, "timestamps");
// await User.find({ customerId: { $in: supplierIdsToInclude } })
// .limit(limit)
// .skip(startindex)
// .exec()
// .then((docs) => {
// // const customerDataWithTimestamp = docs.map((doc, index) => ({
// // data: doc,
// // //timestamp: timestamps[index],
// // }));
// reply.send({ status_code: 200, data: docs, count: docs.length });
// // reply.send({
// // status_code: 200,
// // data: customerDataWithTimestamp,
// // count: docs.length,
// // });
// })
// .catch((err) => {
// console.log(err);
// reply.send({ error: err });
// });
// } catch (err) {
// throw boom.boomify(err);
// }
// };
exports.getPendingCustomers = async (req, reply) => { exports.getPendingCustomers = async (req, reply) => {
const limit = parseInt(req.query.limit) || 100; const limit = parseInt(req.query.limit) || 100;
@ -1137,7 +1096,7 @@ exports.getPendingCustomers = async (req, reply) => {
(request) => request.customerId (request) => request.customerId
); );
const timestamps = friendRequests.map(request => const timestamps = friendRequests.map(request =>
moment(request.timestamp).format("DD-MM-YYYY hh:mm:ss") moment(request.timestamp, "DD-MM-YYYYTHH:mm:ss.SSSZ").format("DD-MM-YYYY hh:mm:ss")
); );
await User.find({ customerId: { $in: supplierIdsToInclude } }) await User.find({ customerId: { $in: supplierIdsToInclude } })
.limit(limit) .limit(limit)

Loading…
Cancel
Save