tripstorekrabi-shared 1.24.2 → 1.24.3

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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/product.js +13 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tripstorekrabi-shared",
3
- "version": "1.24.2",
3
+ "version": "1.24.3",
4
4
  "description": "Shared library for Trip Store Krabi",
5
5
  "author": "Stefan Sommer <tonprince@gmail.com>",
6
6
  "repository": {
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "dayjs": "^1.11.21",
21
- "libphonenumber-js": "^1.13.4",
21
+ "libphonenumber-js": "^1.13.5",
22
22
  "nanoid": "^5.1.11"
23
23
  },
24
24
  "scripts": {
package/product.js CHANGED
@@ -1,8 +1,18 @@
1
- import { calculateProductSellingPrice, countMinPeople } from "./price.js";
1
+ import dayjs from 'dayjs';
2
+ import { calculateProductSellingPrice, countMinPeople, getActiveRevision } from "./price.js";
2
3
 
3
4
  const MATCH_HTML_REGEXP = /(<([^>]+)>)/ig;
4
5
 
5
6
  export function buildIndex(id, product) {
7
+ const lightweightRevisions = (product.pricing?.revisions || []).map(rev => ({
8
+ id: rev.id,
9
+ startDate: rev.startDate.toDate(),
10
+ promotion: rev.promotion ? {
11
+ startDate: rev.promotion.startDate.toDate(),
12
+ endDate: rev.promotion.endDate.toDate()
13
+ } : null
14
+ }));
15
+
6
16
  let document = {
7
17
  id,
8
18
  title: product.title,
@@ -15,7 +25,8 @@ export function buildIndex(id, product) {
15
25
  price: calculateProductSellingPrice({ adults: countMinPeople(product.pricing), children: 0, infants: 0 }, product.pricing) / countMinPeople(product.pricing),
16
26
  priceType: product.pricing.type,
17
27
  availability: product.availability,
18
- live: product.live
28
+ live: product.live,
29
+ revisions: JSON.stringify(lightweightRevisions)
19
30
  };
20
31
 
21
32
  if (product.shortName) {