ashok 3 months ago
commit d85a26319b

@ -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) => {
tankers = tankers.filter(tanker => { const num = parseInt(val);
const tankerPrice = parsePrice(tanker.price); return !isNaN(num) && isFinite(num);
return tankerPrice >= priceFrom && tankerPrice <= priceTo; };
});
} if (isValidPrice(price_from) && isValidPrice(price_to)) {
tankers = tankers.filter(tanker => {
const tankerPrice = parsePrice(tanker.price);
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