|
|
@ -87,6 +87,25 @@ module.exports.getAllProducts = async (req, res) => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// getting product name by id
|
|
|
|
|
|
|
|
exports.getProductName = async (req, res) => {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
const { productId } = req.body;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Find the product by productId
|
|
|
|
|
|
|
|
const product = await Product.findOne({ _id: productId }).select('name');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!product) {
|
|
|
|
|
|
|
|
return res.status(404).json({ error: 'Product not found' });
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Send the product name in the response
|
|
|
|
|
|
|
|
res.json(product);
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
|
|
console.error('Error getting product name:', error);
|
|
|
|
|
|
|
|
res.status(500).json({ error: 'Internal Server Error' });
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// retrieve all active products controller
|
|
|
|
// retrieve all active products controller
|
|
|
|
exports.getAllActiveProducts = async (req, res) => {
|
|
|
|
exports.getAllActiveProducts = async (req, res) => {
|
|
|
|