diff --git a/backend/src/routes/equipment.js b/backend/src/routes/equipment.js index c935f1b..ec8e6a9 100644 --- a/backend/src/routes/equipment.js +++ b/backend/src/routes/equipment.js @@ -193,11 +193,9 @@ router.get('/spreaders', async (req, res, next) => { FROM user_equipment ue LEFT JOIN equipment_categories ec ON ue.category_id = ec.id WHERE ue.user_id = $1 - AND ue.is_active = true - AND (ec.name ILIKE '%spreader%' - OR ue.spreader_type IS NOT NULL - OR ue.custom_name ILIKE '%spreader%' - OR ue.manufacturer ILIKE '%spreader%') + AND ue.is_active = true + -- Temporarily show all equipment so user can identify spreaders + -- TODO: Add proper spreader identification/categorization ORDER BY ue.custom_name, ue.manufacturer, ue.model`, [req.user.id] ); diff --git a/backend/src/utils/validation.js b/backend/src/utils/validation.js index 27e7c9f..cfd811a 100644 --- a/backend/src/utils/validation.js +++ b/backend/src/utils/validation.js @@ -109,10 +109,10 @@ const userProductSchema = Joi.object({ Joi.allow(null) ).optional() }).when('equipmentId', { - is: Joi.exist(), - then: Joi.object(), // When equipmentId exists, spreaderBrand is optional + is: Joi.number().positive(), + then: Joi.object(), // When equipmentId is a positive number, spreaderBrand is optional otherwise: Joi.object({ - spreaderBrand: Joi.string().max(100).required() // When no equipmentId, require spreaderBrand + spreaderBrand: Joi.string().max(100).required() // When no valid equipmentId, require spreaderBrand }) }) ).optional()