@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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytebrand/fe-ui-core",
3
- "version": "4.8.19",
3
+ "version": "4.8.20",
4
4
  "description": "UI components for the auto.de project",
5
5
  "main": "index.ts",
6
6
  "module": "dist/common.js",
@@ -20,6 +20,8 @@ export const FOURTEEN = 14;
20
20
  export const HUNDRED = 100;
21
21
  export const THOUSAND = 1000;
22
22
 
23
+ export const PREDICTABLE_PRICE_INDEX = 1.07814;
24
+
23
25
  export const CONTAINER_STYLES = {
24
26
  display: 'flex',
25
27
  flexDirection: 'row',
@@ -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
- if (!isCorrectCurrentSalesPrice || !isCorrectPredictablePrice) return 0;
360
+ const validatedPredictablePrice = getPredictablePrice(currentSalesPrice, predictablePrice);
350
361
 
351
- const ratingConfig = getPriceRatingConfig(currentSalesPrice, predictablePrice);
362
+ const ratingConfig = getPriceRatingConfig(currentSalesPrice, validatedPredictablePrice);
352
363
 
353
364
  for (const key of Object.keys(ratingConfig)) {
354
365
  const { min, max } = ratingConfig[key];