once the connect request is sent it will not show in connection request

master
varun 3 years ago
parent 062ddaed4a
commit e3490c5424

@ -1,5 +1,6 @@
//Get the data models
const { Supplier } = require('../models/supplier');
const { FriendRequest } = require('../models/supplier')
const { ProfilePicture } = require('../models/User')
const supplierController = require("../controllers/supplierController");
const customJwtAuth = require("../customAuthJwt");
@ -537,7 +538,7 @@ exports.getCurrentSupplier = async (req, reply) => {
}
};
// Get all users
exports.getSuppliers = async (req, reply) => {
exports.getSuppliers1 = async (req, reply) => {
const limit = parseInt(req.query.limit) || 100;
const page = parseInt(req.query.page) || 1;
const startindex = (page - 1) * limit;
@ -558,6 +559,31 @@ exports.getSuppliers = async (req, reply) => {
}
};
exports.getSuppliers = async (req, reply) => {
const limit = parseInt(req.query.limit) || 100;
const page = parseInt(req.query.page) || 1;
const startindex = (page - 1) * limit;
const customerId = req.params.customerId; // Assuming you have already authenticated the user and stored their ID in the request object
try {
const friendRequests = await FriendRequest.find({ customerId });
const supplierIdsToExclude = friendRequests.map((request) => request.supplierId);
await Supplier.find({ supplierId: { $nin: supplierIdsToExclude } })
.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);
}
};
// Get single user by ID
exports.getSingleSupplier = async (req, reply) => {
try {

@ -7,11 +7,21 @@ const validationHandler = require("../handlers/supplierHandler");
module.exports = function (fastify, opts, next) {
fastify.get("/api/suppliers", {
fastify.get("/api/suppliers/:customerId", {
schema: {
tags: ["Supplier-Data"],
description: "This is for Get All Suppliers",
summary: "This is for to Get All Suppliers",
params: {
type: "object",
properties: {
customerId: {
type: "string",
description: "customerId",
},
},
},
security: [
{
basicAuth: [],

Loading…
Cancel
Save