Bhaskar 3 months ago
commit b5ca5672d5

@ -985,7 +985,12 @@ exports.getSuppliers = async (req, reply) => {
let tankers = await Tanker.find(tankerQuery);
if (price_from && price_to) {
const isValidPrice = (val) => {
const num = parseInt(val);
return !isNaN(num) && isFinite(num);
};
if (isValidPrice(price_from) && isValidPrice(price_to)) {
tankers = tankers.filter(tanker => {
const tankerPrice = parsePrice(tanker.price);
return tankerPrice >= priceFrom && tankerPrice <= priceTo;

Loading…
Cancel
Save