@qite/tide-components 1.0.14-preview.4 → 1.0.14-preview.5

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.
@@ -30695,8 +30695,13 @@ const TrajectItinerary = ({ trajectEntry, packagingEntry, translations }) => {
30695
30695
  */
30696
30696
  const isBookedEntryTraject = (trajectEntry) => !!trajectEntry?.entry?.magicLink;
30697
30697
  const NODE_SERVICE_TYPES = new Set([ACCOMMODATION_SERVICE_TYPE, EXCURSION_SERVICE_TYPE, FLIGHT_SERVICE_TYPE]);
30698
+ const isBookedRoomLineOf = (line, root) => !!line.parentGuid &&
30699
+ (line.parentGuid === root.guid || line.parentGuid === root.parentGuid) &&
30700
+ line.serviceType === root.serviceType &&
30701
+ line.productCode === root.productCode &&
30702
+ dateFns.isSameDay(new Date(line.from), new Date(root.from));
30698
30703
  /**
30699
- * A room or option line joins its parent's node; a flight line never does — an outward and its
30704
+ * A room or option line joins its service's node; a flight line never does — an outward and its
30700
30705
  * return are separate legs of the trip even though the return points at the outward as parent.
30701
30706
  *
30702
30707
  * Lines that share a group key are one choice (a couple of hotels of which one is picked), so
@@ -30704,16 +30709,13 @@ const NODE_SERVICE_TYPES = new Set([ACCOMMODATION_SERVICE_TYPE, EXCURSION_SERVIC
30704
30709
  */
30705
30710
  const groupNodeLines = (lines) => {
30706
30711
  const groups = [];
30707
- const groupByGuid = new Map();
30708
30712
  lines.forEach((line) => {
30709
- const parentGroup = line.serviceType !== FLIGHT_SERVICE_TYPE && line.parentGuid ? groupByGuid.get(line.parentGuid) : undefined;
30710
- if (parentGroup) {
30711
- parentGroup.push(line);
30713
+ const service = line.serviceType !== FLIGHT_SERVICE_TYPE ? groups.find((group) => isBookedRoomLineOf(line, group[0])) : undefined;
30714
+ if (service) {
30715
+ service.push(line);
30712
30716
  return;
30713
30717
  }
30714
- const group = [line];
30715
- groups.push(group);
30716
- groupByGuid.set(line.guid, group);
30718
+ groups.push([line]);
30717
30719
  });
30718
30720
  const nodes = [];
30719
30721
  const nodeByGroupKey = new Map();
@@ -30770,11 +30772,13 @@ const buildBookedTrajectEntry = (entry) => {
30770
30772
  date: toDateOnlyString(dateFns.addDays(start, order))
30771
30773
  }));
30772
30774
  const dayOrderOf = (line) => Math.max(dateFns.differenceInCalendarDays(new Date(line.from), start), 0);
30773
- // Services starting the same day are laid out by where they end: the one that ends soonest opens
30774
- // the day (an outward flight on 2 Oct) and the one that spans further follows (the stay until 9 Oct).
30775
+ const flights = lodash.sortBy(lines.filter((line) => line.serviceType === FLIGHT_SERVICE_TYPE && isActiveEntryLine(line)), (line) => new Date(line.from).getTime(), (line) => line.order);
30776
+ const outward = lodash.first(flights);
30777
+ const homeward = flights.length > 1 ? lodash.last(flights) : undefined;
30778
+ const placeInDay = (line) => (line === outward ? -1 : line === homeward ? 1 : 0);
30775
30779
  const orderedGroups = groupNodeLines(lines).sort((a, b) => {
30776
30780
  const [lineA, lineB] = [a.lines[0], b.lines[0]];
30777
- return dayOrderOf(lineA) - dayOrderOf(lineB) || new Date(lineA.to).getTime() - new Date(lineB.to).getTime() || lineA.order - lineB.order;
30781
+ return dayOrderOf(lineA) - dayOrderOf(lineB) || placeInDay(lineA) - placeInDay(lineB) || lineA.order - lineB.order;
30778
30782
  });
30779
30783
  const nodes = orderedGroups.map(({ lines: groupLines, alternatives }, index) => {
30780
30784
  const line = groupLines[0];
@@ -30666,8 +30666,13 @@ const TrajectItinerary = ({ trajectEntry, packagingEntry, translations }) => {
30666
30666
  */
30667
30667
  const isBookedEntryTraject = (trajectEntry) => !!trajectEntry?.entry?.magicLink;
30668
30668
  const NODE_SERVICE_TYPES = new Set([ACCOMMODATION_SERVICE_TYPE, EXCURSION_SERVICE_TYPE, FLIGHT_SERVICE_TYPE]);
30669
+ const isBookedRoomLineOf = (line, root) => !!line.parentGuid &&
30670
+ (line.parentGuid === root.guid || line.parentGuid === root.parentGuid) &&
30671
+ line.serviceType === root.serviceType &&
30672
+ line.productCode === root.productCode &&
30673
+ isSameDay(new Date(line.from), new Date(root.from));
30669
30674
  /**
30670
- * A room or option line joins its parent's node; a flight line never does — an outward and its
30675
+ * A room or option line joins its service's node; a flight line never does — an outward and its
30671
30676
  * return are separate legs of the trip even though the return points at the outward as parent.
30672
30677
  *
30673
30678
  * Lines that share a group key are one choice (a couple of hotels of which one is picked), so
@@ -30675,16 +30680,13 @@ const NODE_SERVICE_TYPES = new Set([ACCOMMODATION_SERVICE_TYPE, EXCURSION_SERVIC
30675
30680
  */
30676
30681
  const groupNodeLines = (lines) => {
30677
30682
  const groups = [];
30678
- const groupByGuid = new Map();
30679
30683
  lines.forEach((line) => {
30680
- const parentGroup = line.serviceType !== FLIGHT_SERVICE_TYPE && line.parentGuid ? groupByGuid.get(line.parentGuid) : undefined;
30681
- if (parentGroup) {
30682
- parentGroup.push(line);
30684
+ const service = line.serviceType !== FLIGHT_SERVICE_TYPE ? groups.find((group) => isBookedRoomLineOf(line, group[0])) : undefined;
30685
+ if (service) {
30686
+ service.push(line);
30683
30687
  return;
30684
30688
  }
30685
- const group = [line];
30686
- groups.push(group);
30687
- groupByGuid.set(line.guid, group);
30689
+ groups.push([line]);
30688
30690
  });
30689
30691
  const nodes = [];
30690
30692
  const nodeByGroupKey = new Map();
@@ -30741,11 +30743,13 @@ const buildBookedTrajectEntry = (entry) => {
30741
30743
  date: toDateOnlyString(addDays(start, order))
30742
30744
  }));
30743
30745
  const dayOrderOf = (line) => Math.max(differenceInCalendarDays(new Date(line.from), start), 0);
30744
- // Services starting the same day are laid out by where they end: the one that ends soonest opens
30745
- // the day (an outward flight on 2 Oct) and the one that spans further follows (the stay until 9 Oct).
30746
+ const flights = sortBy(lines.filter((line) => line.serviceType === FLIGHT_SERVICE_TYPE && isActiveEntryLine(line)), (line) => new Date(line.from).getTime(), (line) => line.order);
30747
+ const outward = first(flights);
30748
+ const homeward = flights.length > 1 ? last(flights) : undefined;
30749
+ const placeInDay = (line) => (line === outward ? -1 : line === homeward ? 1 : 0);
30746
30750
  const orderedGroups = groupNodeLines(lines).sort((a, b) => {
30747
30751
  const [lineA, lineB] = [a.lines[0], b.lines[0]];
30748
- return dayOrderOf(lineA) - dayOrderOf(lineB) || new Date(lineA.to).getTime() - new Date(lineB.to).getTime() || lineA.order - lineB.order;
30752
+ return dayOrderOf(lineA) - dayOrderOf(lineB) || placeInDay(lineA) - placeInDay(lineB) || lineA.order - lineB.order;
30749
30753
  });
30750
30754
  const nodes = orderedGroups.map(({ lines: groupLines, alternatives }, index) => {
30751
30755
  const line = groupLines[0];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qite/tide-components",
3
- "version": "1.0.14-preview.4",
3
+ "version": "1.0.14-preview.5",
4
4
  "description": "React components for Tide (booking, product availability, form, ...)",
5
5
  "main": "build/build-cjs/index.js",
6
6
  "types": "build/build-cjs/src/index.d.ts",