@bytebrand/fe-ui-core 4.8.19 → 4.8.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
} from '../constants/SearchWidget';
|
|
9
9
|
import { priceRatings, priceRatingConfig } from '../constants/price';
|
|
10
10
|
import { HUNDRED } from '../constants/common';
|
|
11
|
-
import { offers } from '../constants';
|
|
11
|
+
import { offers, PREDICTABLE_PRICE_INDEX } from '../constants';
|
|
12
12
|
import { FILTERS_IN_TITLE, MANUFACTURER_KEY, MAX_FILTERS_IN_TITLE, MODEL_KEY } from '../constants/Search';
|
|
13
13
|
import { SearchPage as SearchPageTranslate } from '../../locales/data';
|
|
14
14
|
import { isArray } from 'lodash';
|
|
@@ -342,13 +342,24 @@ export const getPriceRatingConfig = (currentPrice: number, pricePredicted: numbe
|
|
|
342
342
|
}, {}); // tslint:disable-line
|
|
343
343
|
};
|
|
344
344
|
|
|
345
|
+
export const getPredictablePrice = (currentSalesPrice: number, predictablePrice: number) => {
|
|
346
|
+
if (Number.isFinite(Number.parseFloat(`${predictablePrice}`))) {
|
|
347
|
+
return predictablePrice;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
return currentSalesPrice * PREDICTABLE_PRICE_INDEX;
|
|
351
|
+
}
|
|
352
|
+
|
|
345
353
|
export const getPriceRating = (currentSalesPrice: number, predictablePrice: number) => {
|
|
346
354
|
const isCorrectCurrentSalesPrice = Number.isFinite(Number.parseFloat(`${currentSalesPrice}`));
|
|
347
|
-
const isCorrectPredictablePrice = Number.isFinite(Number.parseFloat(`${predictablePrice}`));
|
|
355
|
+
// const isCorrectPredictablePrice = Number.isFinite(Number.parseFloat(`${predictablePrice}`));
|
|
356
|
+
|
|
357
|
+
if (!isCorrectCurrentSalesPrice) return 0;
|
|
358
|
+
|
|
348
359
|
|
|
349
|
-
|
|
360
|
+
const validatedPredictablePrice = getPredictablePrice(currentSalesPrice, predictablePrice);
|
|
350
361
|
|
|
351
|
-
const ratingConfig = getPriceRatingConfig(currentSalesPrice,
|
|
362
|
+
const ratingConfig = getPriceRatingConfig(currentSalesPrice, validatedPredictablePrice);
|
|
352
363
|
|
|
353
364
|
for (const key of Object.keys(ratingConfig)) {
|
|
354
365
|
const { min, max } = ratingConfig[key];
|