Bhaskar 3 months ago
commit b5ca5672d5

@ -985,12 +985,17 @@ exports.getSuppliers = async (req, reply) => {
let tankers = await Tanker.find(tankerQuery); 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 => { tankers = tankers.filter(tanker => {
const tankerPrice = parsePrice(tanker.price); const tankerPrice = parsePrice(tanker.price);
return tankerPrice >= priceFrom && tankerPrice <= priceTo; return tankerPrice >= priceFrom && tankerPrice <= priceTo;
}); });
} }
tankers = tankers.filter(tanker => { tankers = tankers.filter(tanker => {
const key = `${tanker.supplierId}_${tanker.tankerName}`; const key = `${tanker.supplierId}_${tanker.tankerName}`;

Loading…
Cancel
Save