asdflkj
This commit is contained in:
@@ -34,20 +34,20 @@ router.get('/', async (req, res, next) => {
|
||||
const { category, type, search } = req.query;
|
||||
|
||||
let whereConditions = [];
|
||||
let queryParams = [req.user.id];
|
||||
let paramCount = 1;
|
||||
let sharedProductsParams = [];
|
||||
let paramCount = 0;
|
||||
|
||||
// Build WHERE clause for filtering
|
||||
// Build WHERE clause for filtering shared products
|
||||
if (category) {
|
||||
paramCount++;
|
||||
whereConditions.push(`pc.id = $${paramCount}`);
|
||||
queryParams.push(category);
|
||||
sharedProductsParams.push(category);
|
||||
}
|
||||
|
||||
if (type) {
|
||||
paramCount++;
|
||||
whereConditions.push(`p.product_type = $${paramCount}`);
|
||||
queryParams.push(type);
|
||||
sharedProductsParams.push(type);
|
||||
}
|
||||
|
||||
if (search) {
|
||||
@@ -58,7 +58,7 @@ router.get('/', async (req, res, next) => {
|
||||
paramCount++;
|
||||
const searchParam3 = paramCount;
|
||||
whereConditions.push(`(p.name ILIKE $${searchParam1} OR p.brand ILIKE $${searchParam2} OR p.active_ingredients ILIKE $${searchParam3})`);
|
||||
queryParams.push(`%${search}%`, `%${search}%`, `%${search}%`);
|
||||
sharedProductsParams.push(`%${search}%`, `%${search}%`, `%${search}%`);
|
||||
}
|
||||
|
||||
const whereClause = whereConditions.length > 0 ? `AND ${whereConditions.join(' AND ')}` : '';
|
||||
@@ -83,7 +83,7 @@ router.get('/', async (req, res, next) => {
|
||||
ORDER BY p.name
|
||||
`;
|
||||
|
||||
const sharedResult = await pool.query(sharedProductsQuery, queryParams.slice(1));
|
||||
const sharedResult = await pool.query(sharedProductsQuery, sharedProductsParams);
|
||||
|
||||
// Get user's custom products
|
||||
const userProductsQuery = `
|
||||
|
||||
Reference in New Issue
Block a user