@qite/tide-booking-component 1.4.98 → 1.4.100

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 (30) hide show
  1. package/build/build-cjs/index.js +1183 -669
  2. package/build/build-cjs/src/search-results/components/itinerary/index.d.ts +2 -0
  3. package/build/build-cjs/src/search-results/store/search-results-slice.d.ts +11 -10
  4. package/build/build-cjs/src/search-results/types.d.ts +23 -1
  5. package/build/build-cjs/src/search-results/utils/packaging-utils.d.ts +7 -0
  6. package/build/build-cjs/src/search-results/utils/query-utils.d.ts +11 -0
  7. package/build/build-cjs/src/shared/components/flyin/accommodation-flyin.d.ts +1 -2
  8. package/build/build-cjs/src/shared/components/flyin/flyin.d.ts +4 -0
  9. package/build/build-cjs/src/shared/utils/localization-util.d.ts +1 -0
  10. package/build/build-esm/index.js +1183 -669
  11. package/build/build-esm/src/search-results/components/itinerary/index.d.ts +2 -0
  12. package/build/build-esm/src/search-results/store/search-results-slice.d.ts +11 -10
  13. package/build/build-esm/src/search-results/types.d.ts +23 -1
  14. package/build/build-esm/src/search-results/utils/packaging-utils.d.ts +7 -0
  15. package/build/build-esm/src/search-results/utils/query-utils.d.ts +11 -0
  16. package/build/build-esm/src/shared/components/flyin/accommodation-flyin.d.ts +1 -2
  17. package/build/build-esm/src/shared/components/flyin/flyin.d.ts +4 -0
  18. package/build/build-esm/src/shared/utils/localization-util.d.ts +1 -0
  19. package/package.json +2 -2
  20. package/src/qsm/components/search-input-group/index.tsx +0 -1
  21. package/src/search-results/components/itinerary/index.tsx +150 -81
  22. package/src/search-results/components/search-results-container/search-results-container.tsx +463 -384
  23. package/src/search-results/store/search-results-slice.ts +28 -10
  24. package/src/search-results/types.ts +25 -1
  25. package/src/search-results/utils/packaging-utils.ts +75 -0
  26. package/src/search-results/utils/query-utils.ts +152 -0
  27. package/src/shared/components/flyin/accommodation-flyin.tsx +10 -11
  28. package/src/shared/components/flyin/flyin.tsx +52 -4
  29. package/styles/components/_flyin.scss +25 -0
  30. package/styles/components/_search.scss +26 -1
@@ -12823,7 +12823,7 @@ PERFORMANCE OF THIS SOFTWARE.
12823
12823
  return ENDPOINT$8 + '/details/' + transactionId + '/alternate-flights';
12824
12824
  };
12825
12825
  var ENDPOINT_BOOKABLE_DATES = ENDPOINT$8 + '/bookable-dates';
12826
- var ENDPOINT_PRICE_DETAILS = ENDPOINT$8 + '/price-details';
12826
+ var ENDPOINT_PRICE_DETAILS$1 = ENDPOINT$8 + '/price-details';
12827
12827
  var ENDPOINT_BOOK = ENDPOINT$8 + '/book';
12828
12828
  var ENDPOINT_UPDATE = ENDPOINT$8 + '/update';
12829
12829
  var ENDPOINT_AGENTS = ENDPOINT$8 + '/agents';
@@ -12923,7 +12923,7 @@ PERFORMANCE OF THIS SOFTWARE.
12923
12923
  return post(url, apiKey, body, config.token, signal, true);
12924
12924
  };
12925
12925
  var priceDetails = function (config, request, signal, languageCode) {
12926
- var url = '' + config.host + ENDPOINT_PRICE_DETAILS;
12926
+ var url = '' + config.host + ENDPOINT_PRICE_DETAILS$1;
12927
12927
  var apiKey = config.apiKey;
12928
12928
  var body = JSON.stringify(request);
12929
12929
  return post(url, apiKey, body, config.token, signal, true, languageCode);
@@ -13447,11 +13447,18 @@ PERFORMANCE OF THIS SOFTWARE.
13447
13447
  };
13448
13448
 
13449
13449
  var ENDPOINT = '/api/web/packaging';
13450
+ var ENDPOINT_START_TRANSACTION = ENDPOINT + '/start';
13450
13451
  var ENDPOINT_ACCOMMODATIONS = ENDPOINT + '/accommodations';
13452
+ var ENDPOINT_PRICE_DETAILS = ENDPOINT + '/price-details';
13451
13453
  var ENDPOINT_ENTRY = function (magicLinkCode) {
13452
13454
  return ENDPOINT + '/entry/' + magicLinkCode;
13453
13455
  };
13454
13456
  // MANUAL PACKAGING SEARCH
13457
+ var startTransaction = function (config, signal) {
13458
+ var apiKey = config.apiKey;
13459
+ var url = '' + config.host + ENDPOINT_START_TRANSACTION;
13460
+ return get(url, apiKey, config.token, signal, true);
13461
+ };
13455
13462
  var searchPackagingAccommodations = function (config, request, signal) {
13456
13463
  var url = '' + config.host + ENDPOINT_ACCOMMODATIONS;
13457
13464
  var apiKey = config.apiKey;
@@ -13463,6 +13470,12 @@ PERFORMANCE OF THIS SOFTWARE.
13463
13470
  var url = '' + config.host + ENDPOINT_ENTRY(magicLinkCode);
13464
13471
  return get(url, apiKey, config.token, signal, true);
13465
13472
  };
13473
+ var getPriceDetails = function (config, request, signal) {
13474
+ var url = '' + config.host + ENDPOINT_PRICE_DETAILS;
13475
+ var apiKey = config.apiKey;
13476
+ var body = JSON.stringify(request);
13477
+ return post(url, apiKey, body, config.token, signal, true);
13478
+ };
13466
13479
 
13467
13480
  exports.AllotmentType = AllotmentType;
13468
13481
  exports.ContactForm = ContactForm;
@@ -13518,6 +13531,7 @@ PERFORMANCE OF THIS SOFTWARE.
13518
13531
  exports.getLocations = getLocations;
13519
13532
  exports.getMolliePayment = getMolliePayment;
13520
13533
  exports.getPortal = getPortal;
13534
+ exports.getPriceDetails = getPriceDetails;
13521
13535
  exports.getPrintActions = getPrintActions;
13522
13536
  exports.getStyleSheet = getStyleSheet;
13523
13537
  exports.getTranslationDictionary = getTranslationDictionary;
@@ -13539,6 +13553,7 @@ PERFORMANCE OF THIS SOFTWARE.
13539
13553
  exports.searchWithErrorMapping = searchWithErrorMapping;
13540
13554
  exports.setCustomEntryStatus = setCustomEntryStatus;
13541
13555
  exports.setEntryStatus = setEntryStatus;
13556
+ exports.startTransaction = startTransaction;
13542
13557
  exports.tourCodes = tourCodes;
13543
13558
  exports.transportDates = transportDates;
13544
13559
  exports.update = update;
@@ -32702,7 +32717,6 @@ var SearchInputGroup = function (_a) {
32702
32717
  );
32703
32718
  useEffect(
32704
32719
  function () {
32705
- console.log('options updated, resetting loading state');
32706
32720
  setIsLoading(false);
32707
32721
  },
32708
32722
  [options]
@@ -33657,13 +33671,16 @@ var initialState$1 = {
33657
33671
  selectedFlight: null,
33658
33672
  selectedFlightDetails: null,
33659
33673
  bookingPackageDetails: null,
33660
- entry: null,
33661
33674
  isLoading: false,
33662
33675
  filters: [],
33663
33676
  selectedSortType: null,
33664
33677
  activeTab: 'compact',
33665
33678
  currentPage: 1,
33666
- flyInIsOpen: false
33679
+ flyInIsOpen: false,
33680
+ editablePackagingEntry: null,
33681
+ transactionId: null,
33682
+ accommodationFlyInStep: 'details',
33683
+ priceDetails: null
33667
33684
  };
33668
33685
  var searchResultsSlice = createSlice({
33669
33686
  name: 'searchResults',
@@ -33699,9 +33716,6 @@ var searchResultsSlice = createSlice({
33699
33716
  setBookingPackageDetails: function (state, action) {
33700
33717
  state.bookingPackageDetails = action.payload.details;
33701
33718
  },
33702
- setEntry: function (state, action) {
33703
- state.entry = action.payload.entry;
33704
- },
33705
33719
  selectFlight: function (state, action) {
33706
33720
  if (!state.bookingPackageDetails) return;
33707
33721
  var _a = action.payload,
@@ -33750,6 +33764,18 @@ var searchResultsSlice = createSlice({
33750
33764
  },
33751
33765
  setFlyInIsOpen: function (state, action) {
33752
33766
  state.flyInIsOpen = action.payload;
33767
+ },
33768
+ setEditablePackagingEntry: function (state, action) {
33769
+ state.editablePackagingEntry = action.payload;
33770
+ },
33771
+ setTransactionId: function (state, action) {
33772
+ state.transactionId = action.payload;
33773
+ },
33774
+ setAccommodationFlyInStep: function (state, action) {
33775
+ state.accommodationFlyInStep = action.payload;
33776
+ },
33777
+ setPriceDetails: function (state, action) {
33778
+ state.priceDetails = action.payload;
33753
33779
  }
33754
33780
  }
33755
33781
  });
@@ -33763,7 +33789,6 @@ var setResults = ((_a = searchResultsSlice.actions), _a.setResults),
33763
33789
  setSelectedFlight = _a.setSelectedFlight,
33764
33790
  setSelectedFlightDetails = _a.setSelectedFlightDetails,
33765
33791
  setBookingPackageDetails = _a.setBookingPackageDetails,
33766
- setEntry = _a.setEntry,
33767
33792
  selectFlight = _a.selectFlight,
33768
33793
  setIsLoading = _a.setIsLoading,
33769
33794
  setFilters = _a.setFilters,
@@ -33772,7 +33797,11 @@ var setResults = ((_a = searchResultsSlice.actions), _a.setResults),
33772
33797
  setActiveTab = _a.setActiveTab;
33773
33798
  _a.setCurrentPage;
33774
33799
  _a.resetSearchState;
33775
- var setFlyInIsOpen = _a.setFlyInIsOpen;
33800
+ var setFlyInIsOpen = _a.setFlyInIsOpen,
33801
+ setEditablePackagingEntry = _a.setEditablePackagingEntry,
33802
+ setTransactionId = _a.setTransactionId,
33803
+ setAccommodationFlyInStep = _a.setAccommodationFlyInStep,
33804
+ setPriceDetails = _a.setPriceDetails;
33776
33805
  var searchResultsReducer = searchResultsSlice.reducer;
33777
33806
 
33778
33807
  var ItemPicker = function (_a) {
@@ -34799,8 +34828,160 @@ var Icon$1 = function (_a) {
34799
34828
  }
34800
34829
  };
34801
34830
 
34802
- var FLIGHT_SERVICE_TYPE = 7;
34831
+ var GROUP_TOUR_SERVICE_TYPE = 1;
34803
34832
  var ACCOMMODATION_SERVICE_TYPE = 3;
34833
+ var FLIGHT_SERVICE_TYPE = 7;
34834
+ var toDateOnlyString = function (value) {
34835
+ var date = value instanceof Date ? value : new Date(value);
34836
+ return date.toISOString().split('T')[0];
34837
+ };
34838
+ var getAgeAtReferenceDate = function (dateOfBirth, referenceDate) {
34839
+ var dob = dateOfBirth instanceof Date ? dateOfBirth : new Date(dateOfBirth);
34840
+ var ref = referenceDate instanceof Date ? referenceDate : new Date(referenceDate);
34841
+ var age = ref.getFullYear() - dob.getFullYear();
34842
+ var monthDiff = ref.getMonth() - dob.getMonth();
34843
+ if (monthDiff < 0 || (monthDiff === 0 && ref.getDate() < dob.getDate())) {
34844
+ age--;
34845
+ }
34846
+ return age;
34847
+ };
34848
+ var getFlightLines$1 = function (lines) {
34849
+ return __spreadArray([], lines, true)
34850
+ .filter(function (line) {
34851
+ return line.serviceType === FLIGHT_SERVICE_TYPE;
34852
+ })
34853
+ .sort(function (a, b) {
34854
+ return new Date(a.from).getTime() - new Date(b.from).getTime();
34855
+ });
34856
+ };
34857
+ var getDepartureAirportFromEntry = function (lines) {
34858
+ var _a, _b, _c;
34859
+ var firstFlight = getFlightLines$1(lines)[0];
34860
+ var firstSegment =
34861
+ (_b =
34862
+ (_a = firstFlight === null || firstFlight === void 0 ? void 0 : firstFlight.flightInformation) === null || _a === void 0 ? void 0 : _a.flightLines) ===
34863
+ null || _b === void 0
34864
+ ? void 0
34865
+ : _b[0];
34866
+ return (_c = firstSegment === null || firstSegment === void 0 ? void 0 : firstSegment.departureAirportCode) !== null && _c !== void 0 ? _c : null;
34867
+ };
34868
+ var getDestinationAirportFromEntry = function (lines) {
34869
+ var _a, _b, _c;
34870
+ var outboundFlight = getFlightLines$1(lines)[0];
34871
+ var flightSegments =
34872
+ (_a = outboundFlight === null || outboundFlight === void 0 ? void 0 : outboundFlight.flightInformation) === null || _a === void 0 ? void 0 : _a.flightLines;
34873
+ if (!(flightSegments === null || flightSegments === void 0 ? void 0 : flightSegments.length)) return null;
34874
+ return (_c = (_b = flightSegments[flightSegments.length - 1]) === null || _b === void 0 ? void 0 : _b.arrivalAirportCode) !== null && _c !== void 0
34875
+ ? _c
34876
+ : null;
34877
+ };
34878
+ var mapPackagingPaxToBookingPax = function (pax, fallbackId, referenceDate) {
34879
+ var _a, _b, _c, _d, _e, _f;
34880
+ return {
34881
+ id: (_a = pax === null || pax === void 0 ? void 0 : pax.id) !== null && _a !== void 0 ? _a : fallbackId,
34882
+ guid:
34883
+ (_c = (_b = pax === null || pax === void 0 ? void 0 : pax.id) === null || _b === void 0 ? void 0 : _b.toString()) !== null && _c !== void 0
34884
+ ? _c
34885
+ : fallbackId.toString(),
34886
+ firstName: (_d = pax === null || pax === void 0 ? void 0 : pax.firstName) !== null && _d !== void 0 ? _d : '',
34887
+ lastName: (_e = pax === null || pax === void 0 ? void 0 : pax.lastName) !== null && _e !== void 0 ? _e : '',
34888
+ dateOfBirth: (_f = pax === null || pax === void 0 ? void 0 : pax.dateOfBirth) !== null && _f !== void 0 ? _f : undefined,
34889
+ age: (pax === null || pax === void 0 ? void 0 : pax.dateOfBirth) ? getAgeAtReferenceDate(pax.dateOfBirth, referenceDate) : undefined,
34890
+ isMainBooker: pax === null || pax === void 0 ? void 0 : pax.isMainBooker,
34891
+ email: ''
34892
+ };
34893
+ };
34894
+ var getRequestRoomsFromPackagingEntry = function (entry) {
34895
+ var _a, _b, _c, _d;
34896
+ var accommodationLines = ((_a = entry.lines) !== null && _a !== void 0 ? _a : []).filter(function (line) {
34897
+ var _a;
34898
+ return line.serviceType === ACCOMMODATION_SERVICE_TYPE && ((_a = line.pax) === null || _a === void 0 ? void 0 : _a.length) > 0;
34899
+ });
34900
+ var paxById = new Map(
34901
+ ((_b = entry.pax) !== null && _b !== void 0 ? _b : []).map(function (p) {
34902
+ return [p.id, p];
34903
+ })
34904
+ );
34905
+ if (!accommodationLines.length) {
34906
+ return [
34907
+ {
34908
+ index: 0,
34909
+ pax: ((_c = entry.pax) !== null && _c !== void 0 ? _c : []).map(function (p) {
34910
+ return mapPackagingPaxToBookingPax(p, p.id, new Date().toISOString());
34911
+ })
34912
+ }
34913
+ ];
34914
+ }
34915
+ var roomGroups = [];
34916
+ accommodationLines.forEach(function (line) {
34917
+ var groupedByRoom = new Map();
34918
+ line.pax.forEach(function (linePax) {
34919
+ var _a;
34920
+ var roomIndexWithinLine = Number((_a = linePax.room) !== null && _a !== void 0 ? _a : 0);
34921
+ var paxId = Number(linePax.paxId);
34922
+ var pax = mapPackagingPaxToBookingPax(paxById.get(paxId), paxId, line.from);
34923
+ if (!groupedByRoom.has(roomIndexWithinLine)) {
34924
+ groupedByRoom.set(roomIndexWithinLine, []);
34925
+ }
34926
+ groupedByRoom.get(roomIndexWithinLine).push(pax);
34927
+ });
34928
+ var sortedGroups = Array.from(groupedByRoom.entries())
34929
+ .sort(function (_a, _b) {
34930
+ var a = _a[0];
34931
+ var b = _b[0];
34932
+ return a - b;
34933
+ })
34934
+ .map(function (_a) {
34935
+ var pax = _a[1];
34936
+ return pax;
34937
+ });
34938
+ roomGroups.push.apply(roomGroups, sortedGroups);
34939
+ });
34940
+ if (!roomGroups.length) {
34941
+ return [
34942
+ {
34943
+ index: 0,
34944
+ pax: ((_d = entry.pax) !== null && _d !== void 0 ? _d : []).map(function (p) {
34945
+ return mapPackagingPaxToBookingPax(p, p.id, accommodationLines[0].from);
34946
+ })
34947
+ }
34948
+ ];
34949
+ }
34950
+ return roomGroups.map(function (pax, index) {
34951
+ return {
34952
+ index: index,
34953
+ pax: pax
34954
+ };
34955
+ });
34956
+ };
34957
+ var parseHotelId = function (line) {
34958
+ if (!(line === null || line === void 0 ? void 0 : line.productCode)) return null;
34959
+ var parsed = Number(line.productCode);
34960
+ return Number.isNaN(parsed) ? null : parsed;
34961
+ };
34962
+ var getPackagingRequestRoomsFromBookingRooms = function (rooms) {
34963
+ if (!(rooms === null || rooms === void 0 ? void 0 : rooms.length)) {
34964
+ var room_1 = { index: 0, travellers: [] };
34965
+ range(0, 2).forEach(function () {
34966
+ room_1.travellers.push({
34967
+ age: 30
34968
+ });
34969
+ });
34970
+ return [room_1];
34971
+ }
34972
+ return rooms.map(function (x, i) {
34973
+ var _a;
34974
+ var room = { index: (_a = x.index) !== null && _a !== void 0 ? _a : i, travellers: [] };
34975
+ x.pax.forEach(function (p) {
34976
+ var _a;
34977
+ room.travellers.push({
34978
+ age: (_a = p.age) !== null && _a !== void 0 ? _a : 30
34979
+ });
34980
+ });
34981
+ return room;
34982
+ });
34983
+ };
34984
+
34804
34985
  var getFlightLines = function (flight) {
34805
34986
  var _a, _b;
34806
34987
  return (_b = (_a = flight === null || flight === void 0 ? void 0 : flight.flightInformation) === null || _a === void 0 ? void 0 : _a.flightLines) !== null &&
@@ -34838,31 +35019,68 @@ var numberOfNights = function (segment) {
34838
35019
  var getSegmentIcon = function (segment) {
34839
35020
  switch (segment.serviceType) {
34840
35021
  case 3:
34841
- return React__default.createElement(Icon$1, { name: 'ui-bed', width: 15, height: 15 });
35022
+ return React__default.createElement(
35023
+ 'div',
35024
+ { className: 'search__filter__itinerary__segment-badge search__filter__itinerary__segment-badge--secondary' },
35025
+ React__default.createElement(Icon$1, { name: 'ui-bed', width: 15, height: 15 })
35026
+ );
34842
35027
  case 4:
34843
- return React__default.createElement(Icon$1, { name: 'ui-ticket', width: 15, height: 15 });
35028
+ return React__default.createElement(
35029
+ 'div',
35030
+ { className: 'search__filter__itinerary__segment-badge search__filter__itinerary__segment-badge--secondary' },
35031
+ React__default.createElement(Icon$1, { name: 'ui-ticket', width: 15, height: 15 })
35032
+ );
34844
35033
  case 11:
34845
- return React__default.createElement(Icon$1, { name: 'ui-ship', width: 15, height: 15 });
35034
+ return React__default.createElement(
35035
+ 'div',
35036
+ { className: 'search__filter__itinerary__segment-badge search__filter__itinerary__segment-badge--secondary' },
35037
+ React__default.createElement(Icon$1, { name: 'ui-ship', width: 15, height: 15 })
35038
+ );
34846
35039
  case 13:
34847
35040
  case 17:
34848
35041
  case 22:
34849
- return React__default.createElement(Icon$1, { name: 'ui-car', width: 15, height: 15 });
35042
+ return React__default.createElement(
35043
+ 'div',
35044
+ { className: 'search__filter__itinerary__transport-badge' },
35045
+ React__default.createElement(Icon$1, { name: 'ui-car', width: 15, height: 15 })
35046
+ );
34850
35047
  default:
34851
- return React__default.createElement(Icon$1, { name: 'ui-location', width: 15, height: 15 });
35048
+ return React__default.createElement(
35049
+ 'div',
35050
+ { className: 'search__filter__itinerary__segment-badge' },
35051
+ React__default.createElement(Icon$1, { name: 'ui-location', width: 15, height: 15 })
35052
+ );
35053
+ }
35054
+ };
35055
+ var canEdit = function (segment) {
35056
+ if (segment.serviceType === ACCOMMODATION_SERVICE_TYPE) {
35057
+ return true;
34852
35058
  }
35059
+ return false;
34853
35060
  };
34854
35061
  var getSegmentTitle = function (segment) {
34855
- if (segment.accommodationName) return segment.accommodationName;
34856
- return segment.productName;
35062
+ var _a;
35063
+ return (_a = segment.productName) !== null && _a !== void 0 ? _a : segment.accommodationName;
34857
35064
  };
34858
35065
  var Itinerary = function (_a) {
34859
35066
  var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
34860
35067
  var isOpen = _a.isOpen,
34861
- handleSetIsOpen = _a.handleSetIsOpen;
34862
- _a.isLoading;
35068
+ handleSetIsOpen = _a.handleSetIsOpen,
35069
+ isLoading = _a.isLoading,
35070
+ onEditAccommodation = _a.onEditAccommodation;
34863
35071
  var context = useContext(SearchResultsConfigurationContext);
34864
35072
  var translations = getTranslations((_b = context === null || context === void 0 ? void 0 : context.languageCode) !== null && _b !== void 0 ? _b : 'en-GB');
34865
- var packagingEntry = context === null || context === void 0 ? void 0 : context.packagingEntry;
35073
+ var _q = useSelector(function (state) {
35074
+ return state.searchResults;
35075
+ }),
35076
+ editablePackagingEntry = _q.editablePackagingEntry,
35077
+ priceDetails = _q.priceDetails;
35078
+ var packagingEntry =
35079
+ editablePackagingEntry !== null && editablePackagingEntry !== void 0
35080
+ ? editablePackagingEntry
35081
+ : context === null || context === void 0
35082
+ ? void 0
35083
+ : context.packagingEntry;
34866
35084
  var sortedLines = useMemo(
34867
35085
  function () {
34868
35086
  var _a;
@@ -34930,9 +35148,21 @@ var Itinerary = function (_a) {
34930
35148
  var otherSegments = sortedLines.filter(function (item) {
34931
35149
  return item.serviceType !== FLIGHT_SERVICE_TYPE;
34932
35150
  });
34933
- console.log('other segments', otherSegments);
35151
+ var grouped = groupBy(otherSegments, function (segment) {
35152
+ return ''.concat(segment.productCode, '-').concat(segment.from, '-').concat(segment.to);
35153
+ });
35154
+ var groupedOtherSegments = Object.entries(grouped).map(function (_a) {
35155
+ var key = _a[0],
35156
+ segments = _a[1];
35157
+ return {
35158
+ key: key,
35159
+ segments: segments
35160
+ };
35161
+ });
35162
+ console.log('otherSegments', otherSegments);
35163
+ console.log('groupedOtherSegments', groupedOtherSegments);
34934
35164
  var numberOfPax = ((_p = packagingEntry.pax) === null || _p === void 0 ? void 0 : _p.length) || 1;
34935
- var totalPrice = packagingEntry.price || 0;
35165
+ var totalPrice = (priceDetails === null || priceDetails === void 0 ? void 0 : priceDetails.total) || packagingEntry.price || 0;
34936
35166
  var pricePerPerson = totalPrice / numberOfPax;
34937
35167
  return React__default.createElement(
34938
35168
  'div',
@@ -34984,18 +35214,24 @@ var Itinerary = function (_a) {
34984
35214
  React__default.createElement(
34985
35215
  'div',
34986
35216
  { className: 'search__filter__prices' },
34987
- React__default.createElement(
34988
- 'div',
34989
- { className: 'search__filter__prices__wrapper' },
34990
- React__default.createElement('h3', { className: 'search__filter__prices--amount' }, formatPrice$2(pricePerPerson, 'EUR')),
34991
- React__default.createElement('p', null, translations.SRP.PACKAGE_PRICE_PER_PERSON),
34992
- React__default.createElement(
34993
- 'p',
34994
- null,
34995
- React__default.createElement('strong', null, '(', formatPrice$2(totalPrice, 'EUR'), ' ', translations.SRP.TOTAL, ')')
34996
- )
34997
- ),
34998
- React__default.createElement('button', { className: 'cta' }, translations.QSM.CONFIRM)
35217
+ isLoading
35218
+ ? React__default.createElement(Spinner, null)
35219
+ : React__default.createElement(
35220
+ React__default.Fragment,
35221
+ null,
35222
+ React__default.createElement(
35223
+ 'div',
35224
+ { className: 'search__filter__prices__wrapper' },
35225
+ React__default.createElement('h3', { className: 'search__filter__prices--amount' }, formatPrice$2(pricePerPerson, 'EUR')),
35226
+ React__default.createElement('p', null, translations.SRP.PACKAGE_PRICE_PER_PERSON),
35227
+ React__default.createElement(
35228
+ 'p',
35229
+ null,
35230
+ React__default.createElement('strong', null, '(', formatPrice$2(totalPrice, 'EUR'), ' ', translations.SRP.TOTAL, ')')
35231
+ )
35232
+ ),
35233
+ React__default.createElement('button', { className: 'cta' }, translations.QSM.CONFIRM)
35234
+ )
34999
35235
  ),
35000
35236
  React__default.createElement(
35001
35237
  'div',
@@ -35017,8 +35253,7 @@ var Itinerary = function (_a) {
35017
35253
  'p',
35018
35254
  null,
35019
35255
  format$1(new Date(firstEntryLine.from), 'EEE. d MMM yyyy'),
35020
- ' -',
35021
- ' ',
35256
+ ' - ',
35022
35257
  React__default.createElement('strong', null, translations.SRP.START)
35023
35258
  )
35024
35259
  )
@@ -35089,15 +35324,17 @@ var Itinerary = function (_a) {
35089
35324
  )
35090
35325
  )
35091
35326
  ),
35092
- !isEmpty(otherSegments) &&
35093
- React__default.createElement(
35094
- 'div',
35095
- { className: 'search__filter__itinerary__segments' },
35096
- otherSegments.map(function (segment, index) {
35097
- var _a, _b, _c, _d, _e, _f, _g, _h;
35098
- return React__default.createElement(
35327
+ !isEmpty(groupedOtherSegments) &&
35328
+ groupedOtherSegments.map(function (group) {
35329
+ var _a, _b, _c, _d, _e, _f, _g, _h;
35330
+ var firstSegment = first(group.segments);
35331
+ if (!firstSegment) return null;
35332
+ return React__default.createElement(
35333
+ 'div',
35334
+ { className: 'search__filter__itinerary__segments' },
35335
+ React__default.createElement(
35099
35336
  'div',
35100
- { className: 'search__filter__itinerary__segments__wrapper', key: 'segment-'.concat(index) },
35337
+ { className: 'search__filter__itinerary__segments__wrapper', key: group.key },
35101
35338
  React__default.createElement(
35102
35339
  'div',
35103
35340
  { className: 'search__filter__itinerary__segments-timeline' },
@@ -35115,9 +35352,9 @@ var Itinerary = function (_a) {
35115
35352
  React__default.createElement(
35116
35353
  'p',
35117
35354
  { className: 'search__filter__itinerary__transport-date-date' },
35118
- React__default.createElement('strong', null, format$1(new Date(segment.from), 'd'))
35355
+ React__default.createElement('strong', null, format$1(new Date(firstSegment.from), 'd'))
35119
35356
  ),
35120
- React__default.createElement('p', null, format$1(new Date(segment.from), 'MMM'))
35357
+ React__default.createElement('p', null, format$1(new Date(firstSegment.from), 'MMM'))
35121
35358
  ),
35122
35359
  React__default.createElement(
35123
35360
  'div',
@@ -35130,23 +35367,23 @@ var Itinerary = function (_a) {
35130
35367
  React__default.createElement(
35131
35368
  'h6',
35132
35369
  null,
35133
- ((_a = segment.location) === null || _a === void 0 ? void 0 : _a.name) ||
35134
- ((_b = segment.oord) === null || _b === void 0 ? void 0 : _b.name) ||
35135
- ((_c = segment.region) === null || _c === void 0 ? void 0 : _c.name),
35136
- (((_d = segment.location) === null || _d === void 0 ? void 0 : _d.name) ||
35137
- ((_e = segment.oord) === null || _e === void 0 ? void 0 : _e.name) ||
35138
- ((_f = segment.region) === null || _f === void 0 ? void 0 : _f.name)) &&
35139
- ((_g = segment.country) === null || _g === void 0 ? void 0 : _g.name)
35370
+ ((_a = firstSegment.location) === null || _a === void 0 ? void 0 : _a.name) ||
35371
+ ((_b = firstSegment.oord) === null || _b === void 0 ? void 0 : _b.name) ||
35372
+ ((_c = firstSegment.region) === null || _c === void 0 ? void 0 : _c.name),
35373
+ (((_d = firstSegment.location) === null || _d === void 0 ? void 0 : _d.name) ||
35374
+ ((_e = firstSegment.oord) === null || _e === void 0 ? void 0 : _e.name) ||
35375
+ ((_f = firstSegment.region) === null || _f === void 0 ? void 0 : _f.name)) &&
35376
+ ((_g = firstSegment.country) === null || _g === void 0 ? void 0 : _g.name)
35140
35377
  ? ', '
35141
35378
  : '',
35142
- (_h = segment.country) === null || _h === void 0 ? void 0 : _h.name
35379
+ (_h = firstSegment.country) === null || _h === void 0 ? void 0 : _h.name
35143
35380
  ),
35144
35381
  React__default.createElement(
35145
35382
  'p',
35146
35383
  { className: 'search__filter__itinerary__segment-details-text' },
35147
- format$1(new Date(segment.from), 'EEE. d MMM yyyy'),
35384
+ format$1(new Date(firstSegment.from), 'EEE. d MMM yyyy'),
35148
35385
  '> ',
35149
- format$1(new Date(segment.to), 'EEE. d MMM yyyy')
35386
+ format$1(new Date(firstSegment.to), 'EEE. d MMM yyyy')
35150
35387
  )
35151
35388
  )
35152
35389
  )
@@ -35156,38 +35393,65 @@ var Itinerary = function (_a) {
35156
35393
  { className: 'search__filter__itinerary__segment' },
35157
35394
  React__default.createElement(
35158
35395
  'div',
35159
- { className: 'search__filter__itinerary__segment-item' },
35396
+ {
35397
+ className: 'search__filter__itinerary__segment-item '.concat(
35398
+ canEdit(firstSegment) ? 'search__filter__itinerary__segment-item--editable' : ''
35399
+ ),
35400
+ onClick: function () {
35401
+ if (canEdit(firstSegment) && onEditAccommodation) {
35402
+ onEditAccommodation(group.segments);
35403
+ }
35404
+ }
35405
+ },
35160
35406
  React__default.createElement(
35161
35407
  'div',
35162
35408
  { className: 'search__filter__itinerary__segment-date search__filter__itinerary__segment-nights' },
35163
- segment.serviceType === ACCOMMODATION_SERVICE_TYPE &&
35409
+ firstSegment.serviceType === ACCOMMODATION_SERVICE_TYPE &&
35164
35410
  React__default.createElement(
35165
35411
  React__default.Fragment,
35166
35412
  null,
35167
35413
  React__default.createElement(
35168
35414
  'p',
35169
35415
  { className: 'search__filter__itinerary__segment-date-date' },
35170
- React__default.createElement('strong', null, numberOfNights(segment))
35416
+ React__default.createElement('strong', null, numberOfNights(firstSegment))
35171
35417
  ),
35172
35418
  React__default.createElement(Icon$1, { name: 'ui-moon', width: 16, height: 16 })
35173
35419
  )
35174
35420
  ),
35175
- React__default.createElement(
35176
- 'div',
35177
- { className: 'search__filter__itinerary__segment-badge search__filter__itinerary__segment-badge--secondary' },
35178
- getSegmentIcon(segment)
35179
- ),
35421
+ getSegmentIcon(firstSegment),
35180
35422
  React__default.createElement(
35181
35423
  'div',
35182
35424
  { className: 'search__filter__itinerary__segment-details' },
35183
- React__default.createElement('h6', null, getSegmentTitle(segment)),
35184
- segment.regimeName && React__default.createElement('p', null, segment.regimeName)
35425
+ React__default.createElement('h6', null, getSegmentTitle(firstSegment)),
35426
+ firstSegment.serviceType === ACCOMMODATION_SERVICE_TYPE &&
35427
+ group.segments.map(function (segment, index) {
35428
+ return React__default.createElement(
35429
+ React__default.Fragment,
35430
+ { key: segment.guid },
35431
+ React__default.createElement('strong', null, translations.SHARED.ROOM, '\u00A0', index + 1),
35432
+ segment.productName &&
35433
+ segment.accommodationName &&
35434
+ React__default.createElement(
35435
+ 'div',
35436
+ { className: 'search__filter__itinerary__segment-details__room' },
35437
+ React__default.createElement(Icon$1, { name: 'ui-bed', width: 12, height: 12 }),
35438
+ segment.accommodationName
35439
+ ),
35440
+ segment.regimeName &&
35441
+ React__default.createElement(
35442
+ 'div',
35443
+ { className: 'search__filter__itinerary__segment-details__room' },
35444
+ React__default.createElement(Icon$1, { name: 'ui-utensils', width: 12, height: 12 }),
35445
+ segment.regimeName
35446
+ )
35447
+ );
35448
+ })
35185
35449
  )
35186
35450
  )
35187
35451
  )
35188
- );
35189
- })
35190
- ),
35452
+ )
35453
+ );
35454
+ }),
35191
35455
  returnFlight &&
35192
35456
  returnFlight !== outboundFlight &&
35193
35457
  React__default.createElement(
@@ -35271,8 +35535,7 @@ var Itinerary = function (_a) {
35271
35535
  'p',
35272
35536
  null,
35273
35537
  format$1(new Date(lastEntryLine.to), 'EEE. d MMM yyyy'),
35274
- ' -',
35275
- ' ',
35538
+ ' - ',
35276
35539
  React__default.createElement('strong', null, translations.SRP.END)
35277
35540
  )
35278
35541
  )
@@ -38023,19 +38286,27 @@ var formatPrice$1 = function (price, currencyCode) {
38023
38286
  }).format(price);
38024
38287
  };
38025
38288
  var AccommodationFlyIn = function (_a) {
38026
- var _b;
38027
- _a.isLoading;
38028
- var isOpen = _a.isOpen,
38029
- setIsOpen = _a.setIsOpen;
38289
+ var _b, _c;
38290
+ var isLoading = _a.isLoading,
38291
+ handleConfirm = _a.handleConfirm;
38030
38292
  var dispatch = useDispatch();
38031
38293
  var context = useContext(SearchResultsConfigurationContext);
38032
- var language = (_b = context === null || context === void 0 ? void 0 : context.languageCode) !== null && _b !== void 0 ? _b : 'en-GB';
38294
+ if (isLoading) {
38295
+ return React__default.createElement(
38296
+ React__default.Fragment,
38297
+ null,
38298
+ (_b = context === null || context === void 0 ? void 0 : context.customSpinner) !== null && _b !== void 0
38299
+ ? _b
38300
+ : React__default.createElement(Spinner, null)
38301
+ );
38302
+ }
38303
+ var language = (_c = context === null || context === void 0 ? void 0 : context.languageCode) !== null && _c !== void 0 ? _c : 'en-GB';
38033
38304
  var translations = getTranslations(language);
38034
- var _c = useSelector(function (state) {
38305
+ var _d = useSelector(function (state) {
38035
38306
  return state.searchResults;
38036
38307
  }),
38037
- packagingAccoSearchDetails = _c.packagingAccoSearchDetails,
38038
- selectedPackagingAccoResultCode = _c.selectedPackagingAccoResultCode;
38308
+ packagingAccoSearchDetails = _d.packagingAccoSearchDetails,
38309
+ selectedPackagingAccoResultCode = _d.selectedPackagingAccoResultCode;
38039
38310
  var selectedPackagingAccoSearchDetails = useMemo(
38040
38311
  function () {
38041
38312
  return packagingAccoSearchDetails === null || packagingAccoSearchDetails === void 0
@@ -38126,11 +38397,6 @@ var AccommodationFlyIn = function (_a) {
38126
38397
  });
38127
38398
  dispatch(setPackagingAccoSearchDetails(updatedPackagingAccoSearchDetails));
38128
38399
  };
38129
- var handleConfirm = function () {
38130
- if (isOpen) {
38131
- setIsOpen(false);
38132
- }
38133
- };
38134
38400
  if (!selectedPackagingAccoSearchDetails) {
38135
38401
  return null;
38136
38402
  }
@@ -38290,7 +38556,13 @@ var AccommodationFlyIn = function (_a) {
38290
38556
  React__default.createElement(
38291
38557
  'div',
38292
38558
  { className: 'flyin__button-wrapper' },
38293
- React__default.createElement('button', { className: 'cta cta--select', onClick: handleConfirm }, translations.PRODUCT.BOOK_NOW)
38559
+ React__default.createElement(
38560
+ 'button',
38561
+ { className: 'cta cta--select', onClick: handleConfirm },
38562
+ (context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) == build.PortalQsmType.AccommodationAndFlight
38563
+ ? translations.QSM.CONFIRM
38564
+ : translations.PRODUCT.BOOK_NOW
38565
+ )
38294
38566
  )
38295
38567
  )
38296
38568
  );
@@ -38773,97 +39045,6 @@ var GroupTourFlyIn = function (_a) {
38773
39045
  );
38774
39046
  };
38775
39047
 
38776
- var FlyIn = function (_a) {
38777
- var title = _a.title,
38778
- srpType = _a.srpType,
38779
- isOpen = _a.isOpen,
38780
- setIsOpen = _a.setIsOpen,
38781
- _b = _a.className,
38782
- className = _b === void 0 ? '' : _b,
38783
- onPanelRef = _a.onPanelRef,
38784
- detailsLoading = _a.detailsLoading;
38785
- var dispatch = useDispatch();
38786
- var onCancelSearch = useFlightSearch().onCancelSearch;
38787
- var panelRef = useRef(null);
38788
- // expose DOM node if needed
38789
- useEffect(
38790
- function () {
38791
- onPanelRef === null || onPanelRef === void 0 ? void 0 : onPanelRef(panelRef.current);
38792
- return function () {
38793
- return onPanelRef === null || onPanelRef === void 0 ? void 0 : onPanelRef(null);
38794
- };
38795
- },
38796
- [onPanelRef]
38797
- );
38798
- useEffect(
38799
- function () {
38800
- // click outside detection
38801
- var handleClickOutside = function (event) {
38802
- if (isOpen && panelRef.current && !panelRef.current.contains(event.target)) {
38803
- handleClose();
38804
- }
38805
- };
38806
- document.addEventListener('mousedown', handleClickOutside);
38807
- return function () {
38808
- return document.removeEventListener('mousedown', handleClickOutside);
38809
- };
38810
- },
38811
- [isOpen, setIsOpen]
38812
- );
38813
- // body scroll lock
38814
- useEffect(
38815
- function () {
38816
- document.body.style.overflow = isOpen ? 'hidden' : '';
38817
- return function () {
38818
- document.body.style.overflow = '';
38819
- };
38820
- },
38821
- [isOpen]
38822
- );
38823
- var handleClose = function () {
38824
- if (isOpen && panelRef.current) {
38825
- if (srpType === build.PortalQsmType.Flight) {
38826
- dispatch(setSelectedFlight(null));
38827
- dispatch(setSelectedFlightDetails(null));
38828
- onCancelSearch();
38829
- }
38830
- setIsOpen(false);
38831
- }
38832
- };
38833
- return React__default.createElement(
38834
- 'div',
38835
- { className: 'flyin '.concat(isOpen ? 'flyin--active' : '', ' ').concat(className) },
38836
- React__default.createElement(
38837
- 'div',
38838
- { className: 'flyin__panel '.concat(isOpen ? 'flyin__panel--active' : ''), ref: panelRef },
38839
- React__default.createElement(
38840
- 'div',
38841
- { className: 'flyin__content' },
38842
- React__default.createElement(
38843
- 'div',
38844
- { className: 'flyin__content-title-row' },
38845
- React__default.createElement('h3', { className: 'flyin__content-title' }, title),
38846
- React__default.createElement(
38847
- 'span',
38848
- {
38849
- className: 'flyin__close',
38850
- onClick: function () {
38851
- return handleClose();
38852
- }
38853
- },
38854
- React__default.createElement(Icon, { name: 'ui-close', width: 30, height: 30, 'aria-hidden': 'true' })
38855
- )
38856
- )
38857
- ),
38858
- srpType === build.PortalQsmType.Flight && React__default.createElement(FlightsFlyIn, { isOpen: isOpen, setIsOpen: setIsOpen }),
38859
- srpType === build.PortalQsmType.Accommodation &&
38860
- React__default.createElement(AccommodationFlyIn, { isLoading: true, isOpen: isOpen, setIsOpen: setIsOpen }),
38861
- srpType === build.PortalQsmType.GroupTour &&
38862
- React__default.createElement(GroupTourFlyIn, { isLoading: detailsLoading, isOpen: isOpen, setIsOpen: setIsOpen })
38863
- )
38864
- );
38865
- };
38866
-
38867
39048
  var he$1 = { exports: {} };
38868
39049
 
38869
39050
  /*! https://mths.be/he v1.2.0 by @mathias | MIT license */
@@ -43336,6 +43517,132 @@ var HotelAccommodationResults = function (_a) {
43336
43517
  );
43337
43518
  };
43338
43519
 
43520
+ var FlyIn = function (_a) {
43521
+ var title = _a.title,
43522
+ srpType = _a.srpType,
43523
+ isOpen = _a.isOpen,
43524
+ setIsOpen = _a.setIsOpen,
43525
+ _b = _a.className,
43526
+ className = _b === void 0 ? '' : _b,
43527
+ onPanelRef = _a.onPanelRef,
43528
+ detailsLoading = _a.detailsLoading,
43529
+ accommodationStep = _a.accommodationStep,
43530
+ isPackageEditFlow = _a.isPackageEditFlow,
43531
+ handleConfirm = _a.handleConfirm;
43532
+ var dispatch = useDispatch();
43533
+ var onCancelSearch = useFlightSearch().onCancelSearch;
43534
+ var panelRef = useRef(null);
43535
+ // expose DOM node if needed
43536
+ useEffect(
43537
+ function () {
43538
+ onPanelRef === null || onPanelRef === void 0 ? void 0 : onPanelRef(panelRef.current);
43539
+ return function () {
43540
+ return onPanelRef === null || onPanelRef === void 0 ? void 0 : onPanelRef(null);
43541
+ };
43542
+ },
43543
+ [onPanelRef]
43544
+ );
43545
+ useEffect(
43546
+ function () {
43547
+ // click outside detection
43548
+ var handleClickOutside = function (event) {
43549
+ if (isOpen && panelRef.current && !panelRef.current.contains(event.target)) {
43550
+ handleClose();
43551
+ }
43552
+ };
43553
+ document.addEventListener('mousedown', handleClickOutside);
43554
+ return function () {
43555
+ return document.removeEventListener('mousedown', handleClickOutside);
43556
+ };
43557
+ },
43558
+ [isOpen, setIsOpen]
43559
+ );
43560
+ // body scroll lock
43561
+ useEffect(
43562
+ function () {
43563
+ document.body.style.overflow = isOpen ? 'hidden' : '';
43564
+ return function () {
43565
+ document.body.style.overflow = '';
43566
+ };
43567
+ },
43568
+ [isOpen]
43569
+ );
43570
+ var handleClose = function () {
43571
+ if (isOpen && panelRef.current) {
43572
+ if (srpType === build.PortalQsmType.Flight) {
43573
+ dispatch(setSelectedFlight(null));
43574
+ dispatch(setSelectedFlightDetails(null));
43575
+ onCancelSearch();
43576
+ } else {
43577
+ dispatch(setSelectedSearchResult(null));
43578
+ dispatch(setSelectedPackagingAccoResult(null));
43579
+ }
43580
+ dispatch(setAccommodationFlyInStep('details'));
43581
+ setIsOpen(false);
43582
+ }
43583
+ };
43584
+ var handleGoBack = function () {
43585
+ dispatch(setAccommodationFlyInStep('results'));
43586
+ };
43587
+ return React__default.createElement(
43588
+ 'div',
43589
+ {
43590
+ className: 'flyin '
43591
+ .concat(isOpen ? 'flyin--active' : '', ' ')
43592
+ .concat(className, ' ')
43593
+ .concat(isPackageEditFlow ? 'flyin--large' : '')
43594
+ },
43595
+ React__default.createElement(
43596
+ 'div',
43597
+ { className: 'flyin__panel '.concat(isOpen ? 'flyin__panel--active' : ''), ref: panelRef },
43598
+ React__default.createElement(
43599
+ 'div',
43600
+ { className: 'flyin__content' },
43601
+ React__default.createElement(
43602
+ 'div',
43603
+ { className: 'flyin__content-title-row' },
43604
+ React__default.createElement('h3', { className: 'flyin__content-title' }, title),
43605
+ React__default.createElement(
43606
+ 'span',
43607
+ {
43608
+ className: 'flyin__close',
43609
+ onClick: function () {
43610
+ return handleClose();
43611
+ }
43612
+ },
43613
+ React__default.createElement(Icon, { name: 'ui-close', width: 30, height: 30, 'aria-hidden': 'true' })
43614
+ )
43615
+ ),
43616
+ isPackageEditFlow &&
43617
+ accommodationStep === 'details' &&
43618
+ React__default.createElement(
43619
+ 'div',
43620
+ { className: 'flyin__content-title-row' },
43621
+ React__default.createElement(
43622
+ 'div',
43623
+ { onClick: handleGoBack, className: 'flyin__content-title__back' },
43624
+ React__default.createElement(Icon, { name: 'ui-chevron', width: 14, height: 14, 'aria-hidden': 'true' }),
43625
+ 'Go Back'
43626
+ )
43627
+ )
43628
+ ),
43629
+ srpType === build.PortalQsmType.Flight && React__default.createElement(FlightsFlyIn, { isOpen: isOpen, setIsOpen: setIsOpen }),
43630
+ (srpType === build.PortalQsmType.Accommodation || srpType === build.PortalQsmType.AccommodationAndFlight) &&
43631
+ accommodationStep === 'results' &&
43632
+ React__default.createElement(
43633
+ 'div',
43634
+ { className: 'flyin__content' },
43635
+ React__default.createElement(HotelAccommodationResults, { isLoading: detailsLoading })
43636
+ ),
43637
+ (srpType === build.PortalQsmType.Accommodation || srpType === build.PortalQsmType.AccommodationAndFlight) &&
43638
+ accommodationStep === 'details' &&
43639
+ React__default.createElement(AccommodationFlyIn, { isLoading: detailsLoading, handleConfirm: handleConfirm }),
43640
+ srpType === build.PortalQsmType.GroupTour &&
43641
+ React__default.createElement(GroupTourFlyIn, { isLoading: detailsLoading, isOpen: isOpen, setIsOpen: setIsOpen })
43642
+ )
43643
+ );
43644
+ };
43645
+
43339
43646
  var RoundTripResults = function () {
43340
43647
  var activeTab = useSelector(function (state) {
43341
43648
  return state.searchResults;
@@ -46686,42 +46993,135 @@ var applyFiltersToPackageAccoResults = function (results, filters, sortBy) {
46686
46993
  });
46687
46994
  };
46688
46995
 
46689
- var SearchResultsContainer = function () {
46996
+ var getSelectedOptionsPerRoom = function (details) {
46997
+ var _a;
46998
+ var firstResult = details[0];
46999
+ if (!((_a = firstResult === null || firstResult === void 0 ? void 0 : firstResult.rooms) === null || _a === void 0 ? void 0 : _a.length)) return [];
47000
+ return firstResult.rooms.map(function (room, roomIndex) {
47001
+ var _a;
47002
+ var selectedOption =
47003
+ (_a = room.options.find(function (option) {
47004
+ return option.isSelected;
47005
+ })) !== null && _a !== void 0
47006
+ ? _a
47007
+ : room.options[0];
47008
+ return {
47009
+ roomIndex: roomIndex,
47010
+ option: selectedOption !== null && selectedOption !== void 0 ? selectedOption : null
47011
+ };
47012
+ });
47013
+ };
47014
+ var getRequestRoomsFromPackagingSegments = function (entry, segments) {
46690
47015
  var _a;
47016
+ var accommodationLines = __spreadArray([], segments !== null && segments !== void 0 ? segments : [], true)
47017
+ .filter(function (line) {
47018
+ var _a;
47019
+ return line.serviceType === ACCOMMODATION_SERVICE_TYPE && ((_a = line.pax) === null || _a === void 0 ? void 0 : _a.length) > 0;
47020
+ })
47021
+ .sort(function (a, b) {
47022
+ return a.order - b.order;
47023
+ });
47024
+ var paxById = new Map(
47025
+ ((_a = entry.pax) !== null && _a !== void 0 ? _a : []).map(function (p) {
47026
+ return [p.id, p];
47027
+ })
47028
+ );
47029
+ if (!accommodationLines.length) {
47030
+ return [];
47031
+ }
47032
+ var roomGroups = [];
47033
+ accommodationLines.forEach(function (line) {
47034
+ var groupedByRoom = new Map();
47035
+ line.pax.forEach(function (linePax) {
47036
+ var _a, _b, _c, _d, _e, _f, _g;
47037
+ var roomIndexWithinLine = Number((_a = linePax.room) !== null && _a !== void 0 ? _a : 0);
47038
+ var paxId = Number(linePax.paxId);
47039
+ var paxSource = paxById.get(paxId);
47040
+ var pax = {
47041
+ id: (_b = paxSource === null || paxSource === void 0 ? void 0 : paxSource.id) !== null && _b !== void 0 ? _b : paxId,
47042
+ guid:
47043
+ (_d = (_c = paxSource === null || paxSource === void 0 ? void 0 : paxSource.id) === null || _c === void 0 ? void 0 : _c.toString()) !== null &&
47044
+ _d !== void 0
47045
+ ? _d
47046
+ : paxId.toString(),
47047
+ firstName: (_e = paxSource === null || paxSource === void 0 ? void 0 : paxSource.firstName) !== null && _e !== void 0 ? _e : '',
47048
+ lastName: (_f = paxSource === null || paxSource === void 0 ? void 0 : paxSource.lastName) !== null && _f !== void 0 ? _f : '',
47049
+ dateOfBirth: (_g = paxSource === null || paxSource === void 0 ? void 0 : paxSource.dateOfBirth) !== null && _g !== void 0 ? _g : undefined,
47050
+ age: (paxSource === null || paxSource === void 0 ? void 0 : paxSource.dateOfBirth) ? undefined : 30,
47051
+ isMainBooker: paxSource === null || paxSource === void 0 ? void 0 : paxSource.isMainBooker,
47052
+ email: ''
47053
+ };
47054
+ if (!groupedByRoom.has(roomIndexWithinLine)) {
47055
+ groupedByRoom.set(roomIndexWithinLine, []);
47056
+ }
47057
+ groupedByRoom.get(roomIndexWithinLine).push(pax);
47058
+ });
47059
+ var sortedGroups = Array.from(groupedByRoom.entries())
47060
+ .sort(function (_a, _b) {
47061
+ var a = _a[0];
47062
+ var b = _b[0];
47063
+ return a - b;
47064
+ })
47065
+ .map(function (_a) {
47066
+ var pax = _a[1];
47067
+ return pax;
47068
+ });
47069
+ roomGroups.push.apply(roomGroups, sortedGroups);
47070
+ });
47071
+ return roomGroups.map(function (pax, index) {
47072
+ return {
47073
+ index: index,
47074
+ pax: pax
47075
+ };
47076
+ });
47077
+ };
47078
+
47079
+ var SearchResultsContainer = function () {
47080
+ var _a, _b;
47081
+ var currentSearch = typeof window !== 'undefined' ? window.location.search : '';
46691
47082
  var dispatch = useDispatch();
46692
47083
  var context = useContext(SearchResultsConfigurationContext);
46693
47084
  var translations = getTranslations((_a = context === null || context === void 0 ? void 0 : context.languageCode) !== null && _a !== void 0 ? _a : 'en-GB');
46694
- var _b = useSelector(function (state) {
47085
+ var _c = useSelector(function (state) {
46695
47086
  return state.searchResults;
46696
47087
  }),
46697
- results = _b.results,
46698
- filteredResults = _b.filteredResults,
46699
- packagingAccoResults = _b.packagingAccoResults,
46700
- filteredPackagingAccoResults = _b.filteredPackagingAccoResults,
46701
- bookingPackageDetails = _b.bookingPackageDetails,
46702
- entry = _b.entry,
46703
- isLoading = _b.isLoading,
46704
- filters = _b.filters,
46705
- selectedSortType = _b.selectedSortType,
46706
- selectedSearchResult = _b.selectedSearchResult,
46707
- selectedPackagingAccoResultCode = _b.selectedPackagingAccoResultCode,
46708
- flyInIsOpen = _b.flyInIsOpen;
47088
+ results = _c.results,
47089
+ filteredResults = _c.filteredResults,
47090
+ packagingAccoResults = _c.packagingAccoResults,
47091
+ filteredPackagingAccoResults = _c.filteredPackagingAccoResults,
47092
+ bookingPackageDetails = _c.bookingPackageDetails,
47093
+ isLoading = _c.isLoading,
47094
+ filters = _c.filters,
47095
+ selectedSortType = _c.selectedSortType,
47096
+ selectedSearchResult = _c.selectedSearchResult,
47097
+ selectedPackagingAccoResultCode = _c.selectedPackagingAccoResultCode,
47098
+ flyInIsOpen = _c.flyInIsOpen,
47099
+ packagingAccoSearchDetails = _c.packagingAccoSearchDetails,
47100
+ editablePackagingEntry = _c.editablePackagingEntry,
47101
+ transactionId = _c.transactionId,
47102
+ accommodationFlyInStep = _c.accommodationFlyInStep;
46709
47103
  var isMobile = useMediaQuery('(max-width: 1200px)');
46710
- var _c = useState(false),
46711
- initialFiltersSet = _c[0],
46712
- setInitialFiltersSet = _c[1];
46713
- var _d = useState([]),
46714
- initialFilters = _d[0],
46715
- setInitialFilters = _d[1];
46716
- var _e = useState(false),
46717
- filtersOpen = _e[0],
46718
- setFiltersOpen = _e[1];
47104
+ var _d = useState(false),
47105
+ initialFiltersSet = _d[0],
47106
+ setInitialFiltersSet = _d[1];
47107
+ var _e = useState([]),
47108
+ initialFilters = _e[0],
47109
+ setInitialFilters = _e[1];
46719
47110
  var _f = useState(false),
46720
- detailsIsLoading = _f[0],
46721
- setDetailsIsLoading = _f[1];
47111
+ filtersOpen = _f[0],
47112
+ setFiltersOpen = _f[1];
46722
47113
  var _g = useState(false),
46723
- itineraryOpen = _g[0],
46724
- setItineraryOpen = _g[1];
47114
+ detailsIsLoading = _g[0],
47115
+ setDetailsIsLoading = _g[1];
47116
+ var _h = useState(false),
47117
+ pricesAreLoading = _h[0],
47118
+ setPricesAreLoading = _h[1];
47119
+ var _j = useState(false),
47120
+ itineraryOpen = _j[0],
47121
+ setItineraryOpen = _j[1];
47122
+ var _k = useState(null),
47123
+ selectedAccommodationSeed = _k[0],
47124
+ setSelectedAccommodationSeed = _k[1];
46725
47125
  var panelRef = useRef(null);
46726
47126
  var sortByTypes = [
46727
47127
  { direction: 'asc', label: 'default' },
@@ -46737,201 +47137,6 @@ var SearchResultsContainer = function () {
46737
47137
  dispatch(setSortType(newSortByType));
46738
47138
  }
46739
47139
  };
46740
- var buildSearchFromEntry = function (entry) {
46741
- var _a;
46742
- var from = new Date(
46743
- Math.min.apply(
46744
- Math,
46745
- entry.items.map(function (i) {
46746
- return i.startDate.getTime();
46747
- })
46748
- )
46749
- ).toISOString();
46750
- var to = new Date(
46751
- Math.max.apply(
46752
- Math,
46753
- entry.items.map(function (i) {
46754
- return i.endDate.getTime();
46755
- })
46756
- )
46757
- ).toISOString();
46758
- var rooms = entry.rooms;
46759
- var hotelItem = entry.items.find(function (i) {
46760
- return i.productType === 3;
46761
- });
46762
- var country = hotelItem ? hotelItem.countryId : null;
46763
- var region = hotelItem ? hotelItem.regionId : null;
46764
- var oord = hotelItem ? hotelItem.oordId : null;
46765
- var city = hotelItem ? hotelItem.locationId : null;
46766
- var hotel = hotelItem ? hotelItem.productCode : null;
46767
- if (typeof window !== 'undefined') {
46768
- window.scrollTo(0, 0);
46769
- }
46770
- var destinationId = null;
46771
- var destinationIsCountry = false;
46772
- var destinationIsRegion = false;
46773
- var destinationIsOord = false;
46774
- var destinationIsLocation = false;
46775
- if (country) {
46776
- destinationId = country;
46777
- destinationIsCountry = true;
46778
- } else if (region) {
46779
- destinationId = region;
46780
- destinationIsRegion = true;
46781
- } else if (oord) {
46782
- destinationId = oord;
46783
- destinationIsOord = true;
46784
- } else if (city) {
46785
- destinationId = city;
46786
- destinationIsLocation = true;
46787
- }
46788
- var searchRequest = {
46789
- officeId: 1,
46790
- agentId: context === null || context === void 0 ? void 0 : context.agentId,
46791
- payload: {
46792
- catalogueIds: (_a = context.tideConnection.catalogueIds) !== null && _a !== void 0 ? _a : [],
46793
- serviceType:
46794
- context.searchConfiguration.qsmType === build.PortalQsmType.Accommodation ||
46795
- context.searchConfiguration.qsmType === build.PortalQsmType.AccommodationAndFlight
46796
- ? 3
46797
- : context.searchConfiguration.qsmType === build.PortalQsmType.Flight
46798
- ? 7
46799
- : context.searchConfiguration.qsmType === build.PortalQsmType.RoundTrip
46800
- ? 1
46801
- : 0,
46802
- searchType: 0,
46803
- destination: {
46804
- id: Number(destinationId),
46805
- isCountry: destinationIsCountry,
46806
- isRegion: destinationIsRegion,
46807
- isOord: destinationIsOord,
46808
- isLocation: destinationIsLocation
46809
- },
46810
- rooms: getRequestRoomsFromEntry(rooms),
46811
- fromDate: from,
46812
- toDate: to,
46813
- earliestFromOffset: 0,
46814
- latestToOffset: 0,
46815
- includeFlights: true,
46816
- regimeCodes:
46817
- entry.items.map(function (i) {
46818
- return i.regimeCode;
46819
- }) || [],
46820
- useExactDates: true,
46821
- onlyCachedResults: false,
46822
- includeAllAllotments: true,
46823
- productCodes: hotel ? [hotel] : []
46824
- }
46825
- };
46826
- return searchRequest;
46827
- };
46828
- var buildSearchFromQueryParams = function (params) {
46829
- var _a;
46830
- var from = getDateFromParams(params, 'fromDate');
46831
- var to = getDateFromParams(params, 'toDate');
46832
- var rooms = getRoomsFromParams(params, 'rooms');
46833
- var country = getNumberFromParams(params, 'country');
46834
- var region = getNumberFromParams(params, 'region');
46835
- var oord = getNumberFromParams(params, 'oord');
46836
- var city = getNumberFromParams(params, 'location');
46837
- var hotel = getNumberFromParams(params, 'hotel');
46838
- var tagId = getNumberFromParams(params, 'tagId');
46839
- if (!from || !to) {
46840
- console.error('Missing fromDate or toDate in query params, using default values');
46841
- return null;
46842
- }
46843
- if (typeof window !== 'undefined') {
46844
- window.scrollTo(0, 0);
46845
- }
46846
- var destinationId = null;
46847
- var destinationIsCountry = false;
46848
- var destinationIsRegion = false;
46849
- var destinationIsOord = false;
46850
- var destinationIsLocation = false;
46851
- if (country) {
46852
- destinationId = country;
46853
- destinationIsCountry = true;
46854
- } else if (region) {
46855
- destinationId = region;
46856
- destinationIsRegion = true;
46857
- } else if (oord) {
46858
- destinationId = oord;
46859
- destinationIsOord = true;
46860
- } else if (city) {
46861
- destinationId = city;
46862
- destinationIsLocation = true;
46863
- }
46864
- var searchRequest = {
46865
- officeId: 1,
46866
- agentId: context === null || context === void 0 ? void 0 : context.agentId,
46867
- payload: {
46868
- catalogueIds: (_a = context.tideConnection.catalogueIds) !== null && _a !== void 0 ? _a : [],
46869
- serviceType:
46870
- context.searchConfiguration.qsmType === build.PortalQsmType.Accommodation ||
46871
- context.searchConfiguration.qsmType === build.PortalQsmType.AccommodationAndFlight
46872
- ? 3
46873
- : context.searchConfiguration.qsmType === build.PortalQsmType.Flight
46874
- ? 7
46875
- : context.searchConfiguration.qsmType === build.PortalQsmType.RoundTrip
46876
- ? 1
46877
- : undefined,
46878
- searchType: context.searchConfiguration.qsmType === build.PortalQsmType.GroupTour ? 1 : 0,
46879
- destination: {
46880
- id: Number(destinationId),
46881
- isCountry: destinationIsCountry,
46882
- isRegion: destinationIsRegion,
46883
- isOord: destinationIsOord,
46884
- isLocation: destinationIsLocation
46885
- },
46886
- rooms: getRequestRooms(rooms),
46887
- fromDate: from,
46888
- toDate: to,
46889
- earliestFromOffset: 0,
46890
- latestToOffset: 0,
46891
- includeFlights: context.searchConfiguration.qsmType === build.PortalQsmType.AccommodationAndFlight ? true : false,
46892
- // regimeCodes:
46893
- // filters
46894
- // .find((f) => f.property === 'regime')
46895
- // ?.options?.filter((o) => o.isChecked)
46896
- // .flatMap((o) => o.value.toString()) || [],
46897
- // minPrice: filters.find((f) => f.property === 'price')?.selectedMin,
46898
- // maxPrice: filters.find((f) => f.property === 'price')?.selectedMax,
46899
- useExactDates: (context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.GroupTour ? false : true,
46900
- onlyCachedResults: false,
46901
- includeAllAllotments: true,
46902
- productIds: hotel ? [hotel] : [],
46903
- productTagIds: tagId ? [tagId] : []
46904
- }
46905
- };
46906
- console.log('Built search request from query params', searchRequest);
46907
- return searchRequest;
46908
- };
46909
- var getRequestRoomsFromEntry = function (rooms) {
46910
- if (!rooms) {
46911
- // Fall back to 2 adults
46912
- var room = { index: 0, pax: [] };
46913
- range(0, 2).forEach(function () {
46914
- room.pax.push({
46915
- age: 30
46916
- });
46917
- });
46918
- return [room];
46919
- }
46920
- var requestRooms =
46921
- rooms === null || rooms === void 0
46922
- ? void 0
46923
- : rooms.map(function (x, i) {
46924
- var room = { index: i, pax: [] };
46925
- x.travellers.forEach(function (p) {
46926
- room.pax.push({
46927
- age: p.age,
46928
- dateOfBirth: p.dateOfBirth
46929
- });
46930
- });
46931
- return room;
46932
- });
46933
- return requestRooms;
46934
- };
46935
47140
  var getRequestRooms = function (rooms) {
46936
47141
  if (!rooms) {
46937
47142
  // Fall back to 2 adults
@@ -46962,23 +47167,14 @@ var SearchResultsContainer = function () {
46962
47167
  });
46963
47168
  return requestRooms;
46964
47169
  };
46965
- var buildPackagingAccommodationRequestFromQueryParams = function (params) {
46966
- var _a, _b;
46967
- var from = getDateFromParams(params, 'fromDate');
46968
- var to = getDateFromParams(params, 'toDate');
46969
- var rooms = getRoomsFromParams(params, 'rooms');
46970
- var country = getNumberFromParams(params, 'country');
46971
- var region = getNumberFromParams(params, 'region');
46972
- var oord = getNumberFromParams(params, 'oord');
46973
- var city = getNumberFromParams(params, 'location');
46974
- var hotel = getNumberFromParams(params, 'hotel');
46975
- var tagId = getNumberFromParams(params, 'tagId');
46976
- var agentId = getNumberFromParams(params, 'agentId');
46977
- var destinationAirport = getStringFromParams(params, 'destinationAirport');
46978
- if (!from || !to) {
46979
- console.error('Missing fromDate or toDate in query params, using default values');
46980
- return null;
46981
- }
47170
+ var buildSearchFromSeed = function (seed) {
47171
+ var _a;
47172
+ var country = seed.country;
47173
+ var region = seed.region;
47174
+ var oord = seed.oord;
47175
+ var city = seed.location;
47176
+ var hotel = seed.hotel;
47177
+ var tagId = seed.tagId;
46982
47178
  if (typeof window !== 'undefined') {
46983
47179
  window.scrollTo(0, 0);
46984
47180
  }
@@ -46987,8 +47183,6 @@ var SearchResultsContainer = function () {
46987
47183
  var destinationIsRegion = false;
46988
47184
  var destinationIsOord = false;
46989
47185
  var destinationIsLocation = false;
46990
- var destinationCode = null;
46991
- var destinationIsAirport = false;
46992
47186
  if (country) {
46993
47187
  destinationId = country;
46994
47188
  destinationIsCountry = true;
@@ -47001,19 +47195,88 @@ var SearchResultsContainer = function () {
47001
47195
  } else if (city) {
47002
47196
  destinationId = city;
47003
47197
  destinationIsLocation = true;
47198
+ }
47199
+ return {
47200
+ officeId: 1,
47201
+ agentId: context === null || context === void 0 ? void 0 : context.agentId,
47202
+ payload: {
47203
+ catalogueIds: (_a = context.tideConnection.catalogueIds) !== null && _a !== void 0 ? _a : [],
47204
+ serviceType:
47205
+ context.searchConfiguration.qsmType === build.PortalQsmType.Accommodation ||
47206
+ context.searchConfiguration.qsmType === build.PortalQsmType.AccommodationAndFlight
47207
+ ? ACCOMMODATION_SERVICE_TYPE
47208
+ : context.searchConfiguration.qsmType === build.PortalQsmType.Flight
47209
+ ? FLIGHT_SERVICE_TYPE
47210
+ : context.searchConfiguration.qsmType === build.PortalQsmType.RoundTrip
47211
+ ? GROUP_TOUR_SERVICE_TYPE
47212
+ : undefined,
47213
+ searchType: context.searchConfiguration.qsmType === build.PortalQsmType.GroupTour ? 1 : 0,
47214
+ destination: {
47215
+ id: Number(destinationId),
47216
+ isCountry: destinationIsCountry,
47217
+ isRegion: destinationIsRegion,
47218
+ isOord: destinationIsOord,
47219
+ isLocation: destinationIsLocation
47220
+ },
47221
+ rooms: seed.rooms,
47222
+ fromDate: seed.fromDate,
47223
+ toDate: seed.toDate,
47224
+ earliestFromOffset: 0,
47225
+ latestToOffset: 0,
47226
+ includeFlights: context.searchConfiguration.qsmType === build.PortalQsmType.AccommodationAndFlight,
47227
+ useExactDates: (context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.GroupTour ? false : true,
47228
+ onlyCachedResults: false,
47229
+ includeAllAllotments: true,
47230
+ productIds: hotel ? [hotel] : [],
47231
+ productTagIds: tagId ? [tagId] : []
47232
+ }
47233
+ };
47234
+ };
47235
+ var buildPackagingAccommodationRequestFromSeed = function (seed, currentTransactionId) {
47236
+ var _a, _b, _c, _d;
47237
+ var country = seed.country;
47238
+ var region = seed.region;
47239
+ var oord = seed.oord;
47240
+ var city = seed.location;
47241
+ (_a = seed.hotelCode) !== null && _a !== void 0 ? _a : seed.hotel ? seed.hotel.toString() : '';
47242
+ var tagId = seed.tagId;
47243
+ var destinationAirport = seed.destinationAirport;
47244
+ if (typeof window !== 'undefined') {
47245
+ window.scrollTo(0, 0);
47246
+ }
47247
+ var destinationId = null;
47248
+ var destinationIsCountry = false;
47249
+ var destinationIsRegion = false;
47250
+ var destinationIsOord = false;
47251
+ var destinationIsLocation = false;
47252
+ var destinationCode = null;
47253
+ var destinationIsAirport = false;
47254
+ if (city) {
47255
+ destinationId = city;
47256
+ destinationIsLocation = true;
47257
+ } else if (oord) {
47258
+ destinationId = oord;
47259
+ destinationIsOord = true;
47260
+ } else if (region) {
47261
+ destinationId = region;
47262
+ destinationIsRegion = true;
47263
+ } else if (country) {
47264
+ destinationId = country;
47265
+ destinationIsCountry = true;
47004
47266
  } else if (destinationAirport) {
47005
47267
  destinationCode = destinationAirport;
47006
47268
  destinationIsAirport = true;
47007
47269
  }
47008
- var searchRequest = {
47270
+ return {
47271
+ transactionId: currentTransactionId,
47009
47272
  officeId: 1,
47010
- agentId: agentId !== null && agentId !== void 0 ? agentId : null,
47011
- catalogueId: (_a = context.searchConfiguration.defaultCatalogueId) !== null && _a !== void 0 ? _a : 0,
47273
+ agentId: (_b = context === null || context === void 0 ? void 0 : context.agentId) !== null && _b !== void 0 ? _b : null,
47274
+ catalogueId: (_c = context.searchConfiguration.defaultCatalogueId) !== null && _c !== void 0 ? _c : 0,
47012
47275
  searchConfigurationId: context.searchConfiguration.id,
47013
- language: (_b = context.languageCode) !== null && _b !== void 0 ? _b : 'en-GB',
47014
- servicesType: 3, // accommodation
47015
- fromDate: from,
47016
- toDate: to,
47276
+ language: (_d = context.languageCode) !== null && _d !== void 0 ? _d : 'en-GB',
47277
+ serviceType: ACCOMMODATION_SERVICE_TYPE,
47278
+ fromDate: seed.fromDate,
47279
+ toDate: seed.toDate,
47017
47280
  destination: {
47018
47281
  id: Number(destinationId),
47019
47282
  isCountry: destinationIsCountry,
@@ -47023,43 +47286,136 @@ var SearchResultsContainer = function () {
47023
47286
  isAirport: destinationIsAirport,
47024
47287
  code: destinationCode
47025
47288
  },
47026
- productCode: hotel ? hotel.toString() : '',
47027
- rooms: getPackagingRequestRooms(rooms),
47289
+ productCode: '',
47290
+ rooms: getPackagingRequestRoomsFromBookingRooms(seed.rooms),
47028
47291
  tagIds: tagId ? [tagId] : []
47029
47292
  };
47030
- console.log('Search request for packaging accommodation from query params', searchRequest);
47031
- return searchRequest;
47032
47293
  };
47033
- var getPackagingRequestRooms = function (rooms) {
47034
- if (!rooms) {
47035
- // Fall back to 2 adults
47036
- var room = { index: 0, travellers: [] };
47037
- range(0, 2).forEach(function () {
47038
- room.travellers.push({
47039
- age: 30
47040
- });
47041
- });
47042
- return [room];
47294
+ var buildSearchSeedFromQueryParams = function (params) {
47295
+ var from = getDateFromParams(params, 'fromDate');
47296
+ var to = getDateFromParams(params, 'toDate');
47297
+ var rooms = getRoomsFromParams(params, 'rooms');
47298
+ var country = getNumberFromParams(params, 'country');
47299
+ var region = getNumberFromParams(params, 'region');
47300
+ var oord = getNumberFromParams(params, 'oord');
47301
+ var city = getNumberFromParams(params, 'location');
47302
+ var hotel = getNumberFromParams(params, 'hotel');
47303
+ var tagId = getNumberFromParams(params, 'tagId');
47304
+ var destinationAirport = getStringFromParams(params, 'destinationAirport');
47305
+ var departureAirport = getStringFromParams(params, 'departureAirport');
47306
+ if (!from || !to) {
47307
+ return null;
47043
47308
  }
47044
- var requestRooms =
47045
- rooms === null || rooms === void 0
47309
+ return {
47310
+ fromDate: from,
47311
+ toDate: to,
47312
+ country: country,
47313
+ region: region,
47314
+ oord: oord,
47315
+ location: city,
47316
+ hotel: hotel,
47317
+ hotelCode: hotel ? hotel.toString() : null,
47318
+ tagId: tagId,
47319
+ destinationAirport: destinationAirport,
47320
+ departureAirport: departureAirport,
47321
+ rooms: getRequestRooms(rooms)
47322
+ };
47323
+ };
47324
+ var handleConfirmHotelSwap = function () {
47325
+ var updatedEntry = swapHotelInPackagingEntry();
47326
+ console.log('Updated entry after hotel swap', updatedEntry);
47327
+ if (!updatedEntry) return;
47328
+ dispatch(setEditablePackagingEntry(updatedEntry));
47329
+ handleFlyInToggle(false);
47330
+ };
47331
+ var swapHotelInPackagingEntry = function () {
47332
+ var sourceEntry =
47333
+ editablePackagingEntry !== null && editablePackagingEntry !== void 0
47334
+ ? editablePackagingEntry
47335
+ : context === null || context === void 0
47046
47336
  ? void 0
47047
- : rooms.map(function (x, i) {
47048
- var room = { index: i, travellers: [] };
47049
- range(0, x.adults).forEach(function () {
47050
- room.travellers.push({
47051
- age: 30
47052
- });
47053
- });
47054
- x.childAges.forEach(function (x) {
47055
- room.travellers.push({
47056
- age: x
47057
- });
47058
- });
47059
- return room;
47060
- });
47061
- return requestRooms;
47337
+ : context.packagingEntry;
47338
+ var details = packagingAccoSearchDetails;
47339
+ if (!sourceEntry || !(details === null || details === void 0 ? void 0 : details.length)) return null;
47340
+ var selectedOptionsPerRoom = getSelectedOptionsPerRoom(details);
47341
+ console.log('Selected options per room', selectedOptionsPerRoom);
47342
+ if (!selectedOptionsPerRoom.length) return null;
47343
+ var selectedHotel = details[0];
47344
+ var roomIndex = 0;
47345
+ var updatedLines = sourceEntry.lines.map(function (line) {
47346
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
47347
+ if (line.serviceType !== ACCOMMODATION_SERVICE_TYPE) {
47348
+ return line;
47349
+ }
47350
+ var selectedRoom = selectedOptionsPerRoom.find(function (x) {
47351
+ return x.roomIndex === roomIndex;
47352
+ });
47353
+ var selectedOption = selectedRoom === null || selectedRoom === void 0 ? void 0 : selectedRoom.option;
47354
+ console.log('selectedRoom and selectedOption for line', line, selectedRoom, selectedOption);
47355
+ roomIndex++;
47356
+ if (!selectedOption) {
47357
+ return line;
47358
+ }
47359
+ return __assign(__assign({}, line), {
47360
+ guid: selectedOption.guid,
47361
+ productName: selectedHotel.name,
47362
+ productCode: selectedHotel.code,
47363
+ accommodationName: selectedOption.accommodationName,
47364
+ accommodationCode: selectedOption.accommodationCode,
47365
+ regimeName: selectedOption.regimeName,
47366
+ regimeCode: selectedOption.regimeCode,
47367
+ country: line.country
47368
+ ? __assign(__assign({}, line.country), {
47369
+ id: (_a = selectedHotel.countryId) !== null && _a !== void 0 ? _a : line.country.id,
47370
+ name: (_b = selectedHotel.countryName) !== null && _b !== void 0 ? _b : line.country.name
47371
+ })
47372
+ : selectedHotel.countryId
47373
+ ? { id: selectedHotel.countryId, name: selectedHotel.countryName, localizations: [] }
47374
+ : line.country,
47375
+ region: line.region
47376
+ ? __assign(__assign({}, line.region), {
47377
+ id: (_c = selectedHotel.regionId) !== null && _c !== void 0 ? _c : line.region.id,
47378
+ name: (_d = selectedHotel.regionName) !== null && _d !== void 0 ? _d : line.region.name
47379
+ })
47380
+ : selectedHotel.regionId
47381
+ ? { id: selectedHotel.regionId, name: selectedHotel.regionName, localizations: [] }
47382
+ : line.region,
47383
+ oord: line.oord
47384
+ ? __assign(__assign({}, line.oord), {
47385
+ id: (_e = selectedHotel.oordId) !== null && _e !== void 0 ? _e : line.oord.id,
47386
+ name: (_f = selectedHotel.oordName) !== null && _f !== void 0 ? _f : line.oord.name
47387
+ })
47388
+ : selectedHotel.oordId
47389
+ ? { id: selectedHotel.oordId, name: selectedHotel.oordName, localizations: [] }
47390
+ : line.oord,
47391
+ location: line.location
47392
+ ? __assign(__assign({}, line.location), {
47393
+ id: (_g = selectedHotel.locationId) !== null && _g !== void 0 ? _g : line.location.id,
47394
+ name: (_h = selectedHotel.locationName) !== null && _h !== void 0 ? _h : line.location.name
47395
+ })
47396
+ : selectedHotel.locationId
47397
+ ? { id: selectedHotel.locationId, name: selectedHotel.locationName, localizations: [] }
47398
+ : line.location,
47399
+ latitude: (_j = selectedHotel.latitude) !== null && _j !== void 0 ? _j : line.latitude,
47400
+ longitude: (_k = selectedHotel.longitude) !== null && _k !== void 0 ? _k : line.longitude,
47401
+ from: (_l = selectedHotel.fromDate) !== null && _l !== void 0 ? _l : line.from,
47402
+ to: (_m = selectedHotel.toDate) !== null && _m !== void 0 ? _m : line.to,
47403
+ isChanged: true
47404
+ });
47405
+ });
47406
+ return __assign(__assign({}, sourceEntry), { lines: updatedLines });
47062
47407
  };
47408
+ var activeSearchSeed = React__default.useMemo(
47409
+ function () {
47410
+ if (selectedAccommodationSeed) {
47411
+ return selectedAccommodationSeed;
47412
+ }
47413
+ if (typeof window === 'undefined') return null;
47414
+ var params = new URLSearchParams(window.location.search);
47415
+ return buildSearchSeedFromQueryParams(params);
47416
+ },
47417
+ [selectedAccommodationSeed, currentSearch]
47418
+ );
47063
47419
  useEffect(
47064
47420
  function () {
47065
47421
  if (typeof document !== 'undefined') {
@@ -47068,189 +47424,232 @@ var SearchResultsContainer = function () {
47068
47424
  },
47069
47425
  [filtersOpen]
47070
47426
  );
47071
- // seperate Search
47072
- useEffect(
47073
- function () {
47074
- var runSearch = function () {
47075
- return __awaiter(void 0, void 0, void 0, function () {
47076
- var config, params, entryId, entryLight, searchRequest, rq, packageSearchResults, enrichedFilters, initialFilteredResults, matching, err_1;
47077
- var _a;
47078
- return __generator(this, function (_b) {
47079
- switch (_b.label) {
47080
- case 0:
47081
- dispatch(setIsLoading(true));
47082
- _b.label = 1;
47083
- case 1:
47084
- _b.trys.push([1, 6, , 7]);
47085
- if (!context) {
47086
- return [2 /*return*/];
47087
- }
47088
- config = {
47089
- host: context.tideConnection.host,
47090
- apiKey: context.tideConnection.apiKey
47091
- };
47092
- params = new URLSearchParams(location.search);
47093
- entryId = getStringFromParams(params, 'entryId');
47094
- entryLight = null;
47095
- searchRequest = void 0;
47096
- if (!entryId) return [3 /*break*/, 3];
47097
- return [4 /*yield*/, build.getEntryLight(config, entryId)];
47098
- case 2:
47099
- entryLight = _b.sent();
47100
- // populate itinerary store
47101
- dispatch(setEntry({ entry: entryLight }));
47102
- searchRequest = buildSearchFromEntry(entryLight);
47103
- return [3 /*break*/, 4];
47104
- case 3:
47105
- rq = buildSearchFromQueryParams(params);
47106
- if (!rq) {
47107
- throw new Error('Invalid search parameters');
47108
- }
47109
- searchRequest = rq;
47110
- _b.label = 4;
47111
- case 4:
47112
- return [4 /*yield*/, build.search(config, searchRequest)];
47113
- case 5:
47114
- packageSearchResults = _b.sent();
47115
- console.log('Search results', packageSearchResults);
47116
- enrichedFilters = enrichFiltersWithResults(packageSearchResults, context.filters, (_a = context.tags) !== null && _a !== void 0 ? _a : []);
47117
- if (!initialFiltersSet) {
47118
- dispatch(resetFilters(enrichedFilters));
47119
- setInitialFilters(enrichedFilters);
47120
- setInitialFiltersSet(true);
47121
- }
47122
- dispatch(setResults(packageSearchResults));
47123
- initialFilteredResults = applyFilters(packageSearchResults, filters, null);
47124
- dispatch(setFilteredResults(initialFilteredResults));
47125
- if ((packageSearchResults === null || packageSearchResults === void 0 ? void 0 : packageSearchResults.length) > 0) {
47126
- if (entryId) {
47127
- matching = packageSearchResults.find(function (r) {
47128
- return r.productId === (entry === null || entry === void 0 ? void 0 : entry.id);
47129
- });
47130
- if (matching) {
47131
- dispatch(setSelectedSearchResult(matching));
47132
- }
47133
- } else {
47134
- if (context.searchConfiguration.qsmType === build.PortalQsmType.AccommodationAndFlight) {
47135
- dispatch(setSelectedSearchResult(packageSearchResults[0]));
47136
- }
47137
- }
47138
- }
47139
- dispatch(setIsLoading(false));
47140
- return [3 /*break*/, 7];
47141
- case 6:
47142
- err_1 = _b.sent();
47143
- console.error('Search failed', err_1);
47144
- dispatch(setIsLoading(false));
47145
- return [3 /*break*/, 7];
47146
- case 7:
47147
- return [2 /*return*/];
47427
+ var runSearch = function () {
47428
+ return __awaiter(void 0, void 0, void 0, function () {
47429
+ var config, seed, searchRequest, packageSearchResults, enrichedFilters, initialFilteredResults, err_1;
47430
+ var _a;
47431
+ return __generator(this, function (_b) {
47432
+ switch (_b.label) {
47433
+ case 0:
47434
+ _b.trys.push([0, 2, 3, 4]);
47435
+ if (!context) return [2 /*return*/];
47436
+ dispatch(setIsLoading(true));
47437
+ config = {
47438
+ host: context.tideConnection.host,
47439
+ apiKey: context.tideConnection.apiKey
47440
+ };
47441
+ seed = activeSearchSeed;
47442
+ if (!seed) {
47443
+ throw new Error('Invalid search parameters');
47148
47444
  }
47149
- });
47150
- });
47151
- };
47152
- var runHotelSearch = function () {
47153
- return __awaiter(void 0, void 0, void 0, function () {
47154
- var config, params, searchRequest, rq, packageAccoSearchResults, enrichedFilters, initialFilteredResults, err_2;
47155
- var _a;
47156
- return __generator(this, function (_b) {
47157
- switch (_b.label) {
47158
- case 0:
47159
- dispatch(setIsLoading(true));
47160
- _b.label = 1;
47161
- case 1:
47162
- _b.trys.push([1, 3, , 4]);
47163
- if (!context) {
47164
- return [2 /*return*/];
47165
- }
47166
- config = {
47167
- host: context.tideConnection.host,
47168
- apiKey: context.tideConnection.apiKey
47169
- };
47170
- params = new URLSearchParams(location.search);
47171
- searchRequest = void 0;
47172
- rq = buildPackagingAccommodationRequestFromQueryParams(params);
47173
- if (!rq) {
47174
- throw new Error('Invalid search parameters');
47175
- }
47176
- searchRequest = rq;
47177
- searchRequest.portalId = context.portalId;
47178
- searchRequest.agentId = context.agentId;
47179
- return [4 /*yield*/, build.searchPackagingAccommodations(config, searchRequest)];
47180
- case 2:
47181
- packageAccoSearchResults = _b.sent();
47182
- console.log('package Acco SearchResults', packageAccoSearchResults);
47183
- enrichedFilters = enrichFiltersWithPackageAccoResults(
47184
- packageAccoSearchResults,
47185
- context.filters,
47186
- (_a = context.tags) !== null && _a !== void 0 ? _a : []
47187
- );
47188
- if (!initialFiltersSet) {
47189
- dispatch(resetFilters(enrichedFilters));
47190
- setInitialFilters(enrichedFilters);
47191
- setInitialFiltersSet(true);
47192
- }
47193
- dispatch(setPackagingAccoResults(packageAccoSearchResults));
47194
- initialFilteredResults = applyFiltersToPackageAccoResults(packageAccoSearchResults, filters, null);
47195
- dispatch(setFilteredPackagingAccoResults(initialFilteredResults));
47196
- dispatch(setIsLoading(false));
47197
- return [3 /*break*/, 4];
47198
- case 3:
47199
- err_2 = _b.sent();
47200
- console.error('Search failed', err_2);
47201
- dispatch(setIsLoading(false));
47202
- return [3 /*break*/, 4];
47203
- case 4:
47204
- return [2 /*return*/];
47445
+ searchRequest = buildSearchFromSeed(seed);
47446
+ return [4 /*yield*/, build.search(config, searchRequest)];
47447
+ case 1:
47448
+ packageSearchResults = _b.sent();
47449
+ console.log('Search results', packageSearchResults);
47450
+ enrichedFilters = enrichFiltersWithResults(packageSearchResults, context.filters, (_a = context.tags) !== null && _a !== void 0 ? _a : []);
47451
+ if (!initialFiltersSet) {
47452
+ dispatch(resetFilters(enrichedFilters));
47453
+ setInitialFilters(enrichedFilters);
47454
+ setInitialFiltersSet(true);
47205
47455
  }
47206
- });
47207
- });
47208
- };
47209
- if (!(context === null || context === void 0 ? void 0 : context.showMockup)) {
47210
- if (
47211
- (context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.GroupTour ||
47212
- ((context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.AccommodationAndFlight &&
47213
- !context.searchConfiguration.enableManualPackaging)
47214
- ) {
47215
- runSearch();
47456
+ dispatch(setResults(packageSearchResults));
47457
+ initialFilteredResults = applyFilters(packageSearchResults, filters, null);
47458
+ dispatch(setFilteredResults(initialFilteredResults));
47459
+ if ((packageSearchResults === null || packageSearchResults === void 0 ? void 0 : packageSearchResults.length) > 0) {
47460
+ if (context.searchConfiguration.qsmType === build.PortalQsmType.AccommodationAndFlight) {
47461
+ dispatch(setSelectedSearchResult(packageSearchResults[0]));
47462
+ }
47463
+ }
47464
+ return [3 /*break*/, 4];
47465
+ case 2:
47466
+ err_1 = _b.sent();
47467
+ console.error('Search failed', err_1);
47468
+ return [3 /*break*/, 4];
47469
+ case 3:
47470
+ dispatch(setIsLoading(false));
47471
+ return [7 /*endfinally*/];
47472
+ case 4:
47473
+ return [2 /*return*/];
47216
47474
  }
47217
- if ((context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.Accommodation) {
47218
- runHotelSearch();
47475
+ });
47476
+ });
47477
+ };
47478
+ var runStartTransaction = function () {
47479
+ return __awaiter(void 0, void 0, void 0, function () {
47480
+ var config, transaction, err_2;
47481
+ return __generator(this, function (_a) {
47482
+ switch (_a.label) {
47483
+ case 0:
47484
+ _a.trys.push([0, 2, , 3]);
47485
+ if (!context) return [2 /*return*/, null];
47486
+ config = {
47487
+ host: context.tideConnection.host,
47488
+ apiKey: context.tideConnection.apiKey
47489
+ };
47490
+ return [4 /*yield*/, build.startTransaction(config)];
47491
+ case 1:
47492
+ transaction = _a.sent();
47493
+ console.log('Transaction started', transaction);
47494
+ dispatch(setTransactionId(transaction.transactionId));
47495
+ return [2 /*return*/, transaction.transactionId];
47496
+ case 2:
47497
+ err_2 = _a.sent();
47498
+ console.error('Transaction failed', err_2);
47499
+ return [2 /*return*/, null];
47500
+ case 3:
47501
+ return [2 /*return*/];
47219
47502
  }
47220
- if (
47221
- (context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.AccommodationAndFlight &&
47222
- context.searchConfiguration.enableManualPackaging
47223
- ) {
47224
- // Manual packaging flow.
47225
- if (context.searchConfiguration.allowAccommodations) {
47226
- runHotelSearch();
47227
- }
47503
+ });
47504
+ });
47505
+ };
47506
+ var runHotelSearch = function (currentTransactionId, seed) {
47507
+ return __awaiter(void 0, void 0, void 0, function () {
47508
+ var config, searchRequest, packageAccoSearchResults, enrichedFilters, initialFilteredResults, err_3;
47509
+ var _a;
47510
+ return __generator(this, function (_b) {
47511
+ switch (_b.label) {
47512
+ case 0:
47513
+ _b.trys.push([0, 2, , 3]);
47514
+ if (!context) return [2 /*return*/];
47515
+ dispatch(setIsLoading(true));
47516
+ config = {
47517
+ host: context.tideConnection.host,
47518
+ apiKey: context.tideConnection.apiKey
47519
+ };
47520
+ searchRequest = buildPackagingAccommodationRequestFromSeed(seed, currentTransactionId);
47521
+ searchRequest.portalId = context.portalId;
47522
+ searchRequest.agentId = context.agentId;
47523
+ console.log('Packaging accommodation search request', searchRequest);
47524
+ return [4 /*yield*/, build.searchPackagingAccommodations(config, searchRequest)];
47525
+ case 1:
47526
+ packageAccoSearchResults = _b.sent();
47527
+ enrichedFilters = enrichFiltersWithPackageAccoResults(
47528
+ packageAccoSearchResults,
47529
+ context.filters,
47530
+ (_a = context.tags) !== null && _a !== void 0 ? _a : []
47531
+ );
47532
+ if (!initialFiltersSet) {
47533
+ dispatch(resetFilters(enrichedFilters));
47534
+ setInitialFilters(enrichedFilters);
47535
+ setInitialFiltersSet(true);
47536
+ }
47537
+ dispatch(setPackagingAccoResults(packageAccoSearchResults));
47538
+ initialFilteredResults = applyFiltersToPackageAccoResults(packageAccoSearchResults, filters, null);
47539
+ dispatch(setFilteredPackagingAccoResults(initialFilteredResults));
47540
+ dispatch(setIsLoading(false));
47541
+ return [3 /*break*/, 3];
47542
+ case 2:
47543
+ err_3 = _b.sent();
47544
+ console.error('Search failed', err_3);
47545
+ dispatch(setIsLoading(false));
47546
+ return [3 /*break*/, 3];
47547
+ case 3:
47548
+ return [2 /*return*/];
47549
+ }
47550
+ });
47551
+ });
47552
+ };
47553
+ var runAccommodationFlow = function (seed) {
47554
+ return __awaiter(void 0, void 0, void 0, function () {
47555
+ var currentTransactionId;
47556
+ var _a;
47557
+ return __generator(this, function (_b) {
47558
+ switch (_b.label) {
47559
+ case 0:
47560
+ if (!context || context.showMockup) return [2 /*return*/];
47561
+ currentTransactionId =
47562
+ ((_a = context === null || context === void 0 ? void 0 : context.packagingEntry) === null || _a === void 0 ? void 0 : _a.transactionId) ||
47563
+ transactionId;
47564
+ console.log('Current transaction ID', currentTransactionId);
47565
+ if (!!currentTransactionId) return [3 /*break*/, 2];
47566
+ dispatch(setIsLoading(true));
47567
+ return [4 /*yield*/, runStartTransaction()];
47568
+ case 1:
47569
+ currentTransactionId = _b.sent();
47570
+ _b.label = 2;
47571
+ case 2:
47572
+ if (!currentTransactionId) {
47573
+ dispatch(setIsLoading(false));
47574
+ return [2 /*return*/];
47575
+ }
47576
+ return [4 /*yield*/, runHotelSearch(currentTransactionId, seed)];
47577
+ case 3:
47578
+ _b.sent();
47579
+ return [2 /*return*/];
47580
+ }
47581
+ });
47582
+ });
47583
+ };
47584
+ // separate Search
47585
+ useEffect(
47586
+ function () {
47587
+ if (
47588
+ (context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.GroupTour ||
47589
+ ((context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.AccommodationAndFlight &&
47590
+ !context.searchConfiguration.enableManualPackaging)
47591
+ ) {
47592
+ runSearch();
47593
+ }
47594
+ if ((context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.Accommodation) {
47595
+ var seed = activeSearchSeed;
47596
+ if (seed) {
47597
+ runAccommodationFlow(seed);
47598
+ }
47599
+ }
47600
+ if (
47601
+ (context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.AccommodationAndFlight &&
47602
+ context.searchConfiguration.enableManualPackaging &&
47603
+ context.searchConfiguration.allowAccommodations &&
47604
+ !(context === null || context === void 0 ? void 0 : context.packagingEntry)
47605
+ ) {
47606
+ var seed = activeSearchSeed;
47607
+ if (seed) {
47608
+ runAccommodationFlow(seed);
47228
47609
  }
47229
47610
  }
47230
47611
  },
47231
- [location.search]
47612
+ [
47613
+ location.search,
47614
+ context === null || context === void 0 ? void 0 : context.showMockup,
47615
+ context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType,
47616
+ context === null || context === void 0 ? void 0 : context.searchConfiguration.enableManualPackaging,
47617
+ context === null || context === void 0 ? void 0 : context.searchConfiguration.allowAccommodations,
47618
+ (_b = context === null || context === void 0 ? void 0 : context.packagingEntry) === null || _b === void 0 ? void 0 : _b.transactionId,
47619
+ activeSearchSeed
47620
+ ]
47232
47621
  );
47233
- // Seperate detailsCall
47622
+ useEffect(
47623
+ function () {
47624
+ if (context === null || context === void 0 ? void 0 : context.packagingEntry) {
47625
+ console.log('original packaging entry from context', context.packagingEntry);
47626
+ dispatch(setEditablePackagingEntry(structuredClone(context.packagingEntry)));
47627
+ dispatch(setTransactionId(context.packagingEntry.transactionId));
47628
+ }
47629
+ },
47630
+ [context === null || context === void 0 ? void 0 : context.packagingEntry]
47631
+ );
47632
+ // separate detailsCall
47234
47633
  useEffect(
47235
47634
  function () {
47236
47635
  var fetchDetails = function () {
47237
47636
  return __awaiter(void 0, void 0, void 0, function () {
47238
- var config, selectedItem, params, entryId, requestRooms, rooms, detailsRequest, detailsResponse, detailsResponse, err_3;
47239
- return __generator(this, function (_a) {
47240
- switch (_a.label) {
47637
+ var config, selectedItem, requestRooms, seed, detailsRequest, detailsResponse, err_4;
47638
+ var _a;
47639
+ return __generator(this, function (_b) {
47640
+ switch (_b.label) {
47241
47641
  case 0:
47242
- setDetailsIsLoading(true);
47243
- console.log('Fetching details for selected search result', selectedSearchResult);
47244
47642
  if (!selectedSearchResult || !context) return [2 /*return*/];
47643
+ setDetailsIsLoading(true);
47245
47644
  if (
47246
47645
  (context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.Accommodation ||
47247
47646
  (context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.GroupTour
47248
47647
  ) {
47249
47648
  handleFlyInToggle(true);
47250
47649
  }
47251
- _a.label = 1;
47650
+ _b.label = 1;
47252
47651
  case 1:
47253
- _a.trys.push([1, 6, , 7]);
47652
+ _b.trys.push([1, 3, , 4]);
47254
47653
  config = {
47255
47654
  host: context.tideConnection.host,
47256
47655
  apiKey: context.tideConnection.apiKey
@@ -47262,14 +47661,14 @@ var SearchResultsContainer = function () {
47262
47661
  // TODO: handle this case better, show an error message to the user
47263
47662
  return [2 /*return*/];
47264
47663
  }
47265
- params = new URLSearchParams(location.search);
47266
- entryId = getStringFromParams(params, 'entryId');
47267
47664
  requestRooms = void 0;
47268
- if (entry && entryId) {
47269
- requestRooms = getRequestRoomsFromEntry(entry.rooms);
47665
+ if (context === null || context === void 0 ? void 0 : context.packagingEntry) {
47666
+ requestRooms = getRequestRoomsFromPackagingEntry(context.packagingEntry);
47270
47667
  } else {
47271
- rooms = getRoomsFromParams(params, 'rooms');
47272
- requestRooms = getRequestRooms(rooms);
47668
+ seed = activeSearchSeed;
47669
+ requestRooms = ((_a = seed === null || seed === void 0 ? void 0 : seed.rooms) === null || _a === void 0 ? void 0 : _a.length)
47670
+ ? seed.rooms
47671
+ : getRequestRooms(null);
47273
47672
  }
47274
47673
  detailsRequest = {
47275
47674
  officeId: 1,
@@ -47291,29 +47690,18 @@ var SearchResultsContainer = function () {
47291
47690
  },
47292
47691
  agentId: context.agentId
47293
47692
  };
47294
- if (!(entry && entryId)) return [3 /*break*/, 3];
47295
- requestRooms = getRequestRoomsFromEntry(entry.rooms);
47296
47693
  return [4 /*yield*/, build.details(config, detailsRequest)];
47297
47694
  case 2:
47298
- detailsResponse = _a.sent();
47299
- console.log('Details:', detailsResponse);
47300
- dispatch(setBookingPackageDetails({ details: detailsResponse === null || detailsResponse === void 0 ? void 0 : detailsResponse.payload }));
47301
- return [3 /*break*/, 5];
47302
- case 3:
47303
- return [4 /*yield*/, build.details(config, detailsRequest)];
47304
- case 4:
47305
- detailsResponse = _a.sent();
47695
+ detailsResponse = _b.sent();
47306
47696
  dispatch(setBookingPackageDetails({ details: detailsResponse === null || detailsResponse === void 0 ? void 0 : detailsResponse.payload }));
47307
47697
  setDetailsIsLoading(false);
47308
- _a.label = 5;
47309
- case 5:
47310
- return [3 /*break*/, 7];
47311
- case 6:
47312
- err_3 = _a.sent();
47313
- console.error('Failed to fetch package details', err_3);
47698
+ return [3 /*break*/, 4];
47699
+ case 3:
47700
+ err_4 = _b.sent();
47701
+ console.error('Failed to fetch package details', err_4);
47314
47702
  setDetailsIsLoading(false);
47315
- return [3 /*break*/, 7];
47316
- case 7:
47703
+ return [3 /*break*/, 4];
47704
+ case 4:
47317
47705
  return [2 /*return*/];
47318
47706
  }
47319
47707
  });
@@ -47323,8 +47711,7 @@ var SearchResultsContainer = function () {
47323
47711
  return __awaiter(void 0, void 0, void 0, function () {
47324
47712
  var config,
47325
47713
  selectedItem,
47326
- params,
47327
- rooms,
47714
+ seed,
47328
47715
  tagId,
47329
47716
  destinationAirport,
47330
47717
  destinationId,
@@ -47336,38 +47723,37 @@ var SearchResultsContainer = function () {
47336
47723
  destinationIsAirport,
47337
47724
  detailSearchRequest,
47338
47725
  packageAccoSearchDetails,
47339
- err_4;
47340
- var _a, _b;
47341
- return __generator(this, function (_c) {
47342
- switch (_c.label) {
47726
+ err_5;
47727
+ var _a, _b, _c, _d, _e;
47728
+ return __generator(this, function (_f) {
47729
+ switch (_f.label) {
47343
47730
  case 0:
47344
47731
  if (!selectedPackagingAccoResultCode || !context) return [2 /*return*/];
47732
+ setDetailsIsLoading(true);
47345
47733
  if (
47346
47734
  (context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.Accommodation ||
47735
+ (context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.AccommodationAndFlight ||
47347
47736
  (context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.GroupTour
47348
47737
  ) {
47349
47738
  handleFlyInToggle(true);
47350
47739
  }
47351
- _c.label = 1;
47740
+ _f.label = 1;
47352
47741
  case 1:
47353
- _c.trys.push([1, 3, , 4]);
47742
+ _f.trys.push([1, 3, , 4]);
47354
47743
  config = {
47355
47744
  host: context.tideConnection.host,
47356
47745
  apiKey: context.tideConnection.apiKey
47357
47746
  };
47358
- console.log('selectedPackagingAccoResultCode', selectedPackagingAccoResultCode);
47359
47747
  selectedItem = packagingAccoResults.find(function (r) {
47360
47748
  return r.code === selectedPackagingAccoResultCode;
47361
47749
  });
47362
- console.log('Selected packaging acco item', selectedItem);
47363
47750
  if (!selectedItem) {
47364
47751
  // TODO: handle this case better, show an error message to the user
47365
47752
  return [2 /*return*/];
47366
47753
  }
47367
- params = new URLSearchParams(location.search);
47368
- rooms = getRoomsFromParams(params, 'rooms');
47369
- tagId = getNumberFromParams(params, 'tagId');
47370
- destinationAirport = getStringFromParams(params, 'destinationAirport');
47754
+ seed = activeSearchSeed;
47755
+ tagId = (_a = seed === null || seed === void 0 ? void 0 : seed.tagId) !== null && _a !== void 0 ? _a : null;
47756
+ destinationAirport = (_b = seed === null || seed === void 0 ? void 0 : seed.destinationAirport) !== null && _b !== void 0 ? _b : null;
47371
47757
  destinationId = null;
47372
47758
  destinationIsCountry = false;
47373
47759
  destinationIsRegion = false;
@@ -47392,14 +47778,15 @@ var SearchResultsContainer = function () {
47392
47778
  destinationIsAirport = true;
47393
47779
  }
47394
47780
  detailSearchRequest = {
47781
+ transactionId: transactionId !== null && transactionId !== void 0 ? transactionId : '',
47395
47782
  officeId: 1,
47396
47783
  portalId: context.portalId,
47397
47784
  agentId: context.agentId,
47398
- catalogueId: (_a = context.searchConfiguration.defaultCatalogueId) !== null && _a !== void 0 ? _a : 0,
47785
+ catalogueId: (_c = context.searchConfiguration.defaultCatalogueId) !== null && _c !== void 0 ? _c : 0,
47399
47786
  searchConfigurationId: context.searchConfiguration.id,
47400
47787
  vendorConfigurationId: selectedItem.vendorId,
47401
- language: (_b = context.languageCode) !== null && _b !== void 0 ? _b : 'en-GB',
47402
- serviceType: 3,
47788
+ language: (_d = context.languageCode) !== null && _d !== void 0 ? _d : 'en-GB',
47789
+ serviceType: ACCOMMODATION_SERVICE_TYPE,
47403
47790
  fromDate: selectedItem.fromDate,
47404
47791
  toDate: selectedItem.toDate,
47405
47792
  destination: {
@@ -47412,18 +47799,22 @@ var SearchResultsContainer = function () {
47412
47799
  code: destinationCode
47413
47800
  },
47414
47801
  productCode: selectedItem.code ? selectedItem.code : '',
47415
- rooms: getPackagingRequestRooms(rooms),
47802
+ rooms: getPackagingRequestRoomsFromBookingRooms(
47803
+ (_e = seed === null || seed === void 0 ? void 0 : seed.rooms) !== null && _e !== void 0 ? _e : null
47804
+ ),
47416
47805
  tagIds: tagId ? [tagId] : []
47417
47806
  };
47418
47807
  return [4 /*yield*/, build.searchPackagingAccommodations(config, detailSearchRequest)];
47419
47808
  case 2:
47420
- packageAccoSearchDetails = _c.sent();
47809
+ packageAccoSearchDetails = _f.sent();
47421
47810
  console.log('Packaging Acco Search details', packageAccoSearchDetails);
47422
47811
  dispatch(setPackagingAccoSearchDetails(packageAccoSearchDetails));
47812
+ setDetailsIsLoading(false);
47423
47813
  return [3 /*break*/, 4];
47424
47814
  case 3:
47425
- err_4 = _c.sent();
47426
- console.error('Failed to fetch package details', err_4);
47815
+ err_5 = _f.sent();
47816
+ console.error('Failed to fetch package details', err_5);
47817
+ setDetailsIsLoading(false);
47427
47818
  return [3 /*break*/, 4];
47428
47819
  case 4:
47429
47820
  return [2 /*return*/];
@@ -47437,6 +47828,7 @@ var SearchResultsContainer = function () {
47437
47828
  if (selectedPackagingAccoResultCode) {
47438
47829
  fetchPackagingAccoSearchDetails();
47439
47830
  }
47831
+ dispatch(setAccommodationFlyInStep('details'));
47440
47832
  },
47441
47833
  [selectedSearchResult, selectedPackagingAccoResultCode]
47442
47834
  );
@@ -47452,6 +47844,110 @@ var SearchResultsContainer = function () {
47452
47844
  },
47453
47845
  [filters, results, packagingAccoResults, selectedSortType]
47454
47846
  );
47847
+ useEffect(
47848
+ function () {
47849
+ setInitialFiltersSet(false);
47850
+ },
47851
+ [activeSearchSeed]
47852
+ );
47853
+ var handleEditAccommodation = function (segments) {
47854
+ return __awaiter(void 0, void 0, void 0, function () {
47855
+ var sourceEntry, seed;
47856
+ return __generator(this, function (_a) {
47857
+ switch (_a.label) {
47858
+ case 0:
47859
+ sourceEntry =
47860
+ editablePackagingEntry !== null && editablePackagingEntry !== void 0
47861
+ ? editablePackagingEntry
47862
+ : context === null || context === void 0
47863
+ ? void 0
47864
+ : context.packagingEntry;
47865
+ if (!sourceEntry) return [2 /*return*/];
47866
+ seed = buildSearchSeedFromAccommodationSegments(sourceEntry, segments);
47867
+ if (!seed) return [2 /*return*/];
47868
+ setDetailsIsLoading(true);
47869
+ setSelectedAccommodationSeed(seed);
47870
+ dispatch(setAccommodationFlyInStep('results'));
47871
+ handleFlyInToggle(true);
47872
+ return [4 /*yield*/, runAccommodationFlow(seed)];
47873
+ case 1:
47874
+ _a.sent();
47875
+ setDetailsIsLoading(false);
47876
+ return [2 /*return*/];
47877
+ }
47878
+ });
47879
+ });
47880
+ };
47881
+ var buildSearchSeedFromAccommodationSegments = function (entry, segments) {
47882
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
47883
+ if (!(segments === null || segments === void 0 ? void 0 : segments.length)) return null;
47884
+ var sortedSegments = __spreadArray([], segments, true).sort(function (a, b) {
47885
+ return new Date(a.from).getTime() - new Date(b.from).getTime();
47886
+ });
47887
+ var firstSegment = first(sortedSegments);
47888
+ var lastSegment = last(sortedSegments);
47889
+ if (!firstSegment || !lastSegment) return null;
47890
+ return {
47891
+ fromDate: toDateOnlyString(firstSegment.from),
47892
+ toDate: toDateOnlyString(lastSegment.to),
47893
+ country: (_b = (_a = firstSegment.country) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : null,
47894
+ region: (_d = (_c = firstSegment.region) === null || _c === void 0 ? void 0 : _c.id) !== null && _d !== void 0 ? _d : null,
47895
+ oord: (_f = (_e = firstSegment.oord) === null || _e === void 0 ? void 0 : _e.id) !== null && _f !== void 0 ? _f : null,
47896
+ location: (_h = (_g = firstSegment.location) === null || _g === void 0 ? void 0 : _g.id) !== null && _h !== void 0 ? _h : null,
47897
+ hotel: parseHotelId(firstSegment),
47898
+ hotelCode: (_j = firstSegment.productCode) !== null && _j !== void 0 ? _j : null,
47899
+ tagId: null,
47900
+ destinationAirport: getDestinationAirportFromEntry((_k = entry.lines) !== null && _k !== void 0 ? _k : []),
47901
+ departureAirport: getDepartureAirportFromEntry((_l = entry.lines) !== null && _l !== void 0 ? _l : []),
47902
+ rooms: getRequestRoomsFromPackagingSegments(entry, sortedSegments)
47903
+ };
47904
+ };
47905
+ useEffect(
47906
+ function () {
47907
+ var fetchPriceDetails = function () {
47908
+ return __awaiter(void 0, void 0, void 0, function () {
47909
+ var config, priceDetails, err_6;
47910
+ return __generator(this, function (_a) {
47911
+ switch (_a.label) {
47912
+ case 0:
47913
+ console.log(
47914
+ 'Fetching price details for entry',
47915
+ editablePackagingEntry !== null && editablePackagingEntry !== void 0
47916
+ ? editablePackagingEntry
47917
+ : context === null || context === void 0
47918
+ ? void 0
47919
+ : context.packagingEntry
47920
+ );
47921
+ if (!context || !editablePackagingEntry) return [2 /*return*/];
47922
+ setPricesAreLoading(true);
47923
+ _a.label = 1;
47924
+ case 1:
47925
+ _a.trys.push([1, 3, , 4]);
47926
+ config = {
47927
+ host: context.tideConnection.host,
47928
+ apiKey: context.tideConnection.apiKey
47929
+ };
47930
+ return [4 /*yield*/, build.getPriceDetails(config, editablePackagingEntry)];
47931
+ case 2:
47932
+ priceDetails = _a.sent();
47933
+ dispatch(setPriceDetails(priceDetails));
47934
+ setPricesAreLoading(false);
47935
+ return [3 /*break*/, 4];
47936
+ case 3:
47937
+ err_6 = _a.sent();
47938
+ console.error('Error fetching price details', err_6);
47939
+ setPricesAreLoading(false);
47940
+ return [3 /*break*/, 4];
47941
+ case 4:
47942
+ return [2 /*return*/];
47943
+ }
47944
+ });
47945
+ });
47946
+ };
47947
+ fetchPriceDetails();
47948
+ },
47949
+ [editablePackagingEntry]
47950
+ );
47455
47951
  return React__default.createElement(
47456
47952
  'div',
47457
47953
  { id: 'tide-booking', className: 'search__bg' },
@@ -47503,7 +47999,8 @@ var SearchResultsContainer = function () {
47503
47999
  handleSetIsOpen: function () {
47504
48000
  return setItineraryOpen(!itineraryOpen);
47505
48001
  },
47506
- isLoading: isLoading
48002
+ isLoading: pricesAreLoading,
48003
+ onEditAccommodation: handleEditAccommodation
47507
48004
  }),
47508
48005
  React__default.createElement(
47509
48006
  'div',
@@ -47568,6 +48065,7 @@ var SearchResultsContainer = function () {
47568
48065
  'span',
47569
48066
  { className: 'search__result-row-text' },
47570
48067
  !isLoading &&
48068
+ !context.packagingEntry &&
47571
48069
  React__default.createElement(
47572
48070
  React__default.Fragment,
47573
48071
  null,
@@ -47583,7 +48081,8 @@ var SearchResultsContainer = function () {
47583
48081
  translations.SRP.TOTAL_RESULTS_LABEL
47584
48082
  )
47585
48083
  ),
47586
- !isMobile &&
48084
+ !context.packagingEntry &&
48085
+ !isMobile &&
47587
48086
  sortByTypes &&
47588
48087
  sortByTypes.length > 0 &&
47589
48088
  React__default.createElement(
@@ -47611,25 +48110,35 @@ var SearchResultsContainer = function () {
47611
48110
  React__default.createElement(
47612
48111
  'div',
47613
48112
  { className: 'search__results__wrapper' },
47614
- context.showTabViews && React__default.createElement(TabViews, null),
48113
+ context.showTabViews &&
48114
+ (context.searchConfiguration.qsmType === build.PortalQsmType.GroupTour ||
48115
+ context.searchConfiguration.qsmType === build.PortalQsmType.Accommodation) &&
48116
+ React__default.createElement(TabViews, null),
47615
48117
  context.showRoundTripResults && context.showMockup && React__default.createElement(RoundTripResults, null),
47616
48118
  context.searchConfiguration.qsmType === build.PortalQsmType.GroupTour &&
47617
48119
  React__default.createElement(GroupTourResults, { isLoading: isLoading }),
47618
48120
  context.searchConfiguration.qsmType === build.PortalQsmType.AccommodationAndFlight &&
48121
+ !context.packagingEntry &&
47619
48122
  context.showFlightResults &&
47620
48123
  (bookingPackageDetails === null || bookingPackageDetails === void 0 ? void 0 : bookingPackageDetails.outwardFlights) &&
47621
48124
  React__default.createElement(FlightResults, {
47622
48125
  flights: bookingPackageDetails === null || bookingPackageDetails === void 0 ? void 0 : bookingPackageDetails.outwardFlights,
47623
48126
  isDeparture: true
47624
48127
  }),
47625
- context.showHotelAccommodationResults && React__default.createElement(HotelAccommodationResults, { isLoading: isLoading }),
48128
+ context.showHotelAccommodationResults &&
48129
+ !context.packagingEntry &&
48130
+ React__default.createElement(HotelAccommodationResults, { isLoading: isLoading }),
47626
48131
  context.searchConfiguration.qsmType === build.PortalQsmType.AccommodationAndFlight &&
48132
+ !context.packagingEntry &&
47627
48133
  context.showFlightResults &&
47628
48134
  (bookingPackageDetails === null || bookingPackageDetails === void 0 ? void 0 : bookingPackageDetails.returnFlights) &&
47629
48135
  React__default.createElement(FlightResults, {
47630
48136
  flights: bookingPackageDetails === null || bookingPackageDetails === void 0 ? void 0 : bookingPackageDetails.returnFlights,
47631
48137
  isDeparture: false
47632
- })
48138
+ }),
48139
+ context.searchConfiguration.qsmType === build.PortalQsmType.AccommodationAndFlight &&
48140
+ context.packagingEntry &&
48141
+ React__default.createElement('span', null, 'TODO: Show Full Itinerary here')
47633
48142
  )
47634
48143
  ),
47635
48144
  React__default.createElement(FlyIn, {
@@ -47637,10 +48146,15 @@ var SearchResultsContainer = function () {
47637
48146
  srpType: context.searchConfiguration.qsmType,
47638
48147
  isOpen: flyInIsOpen,
47639
48148
  setIsOpen: handleFlyInToggle,
48149
+ handleConfirm: function () {
48150
+ return handleConfirmHotelSwap();
48151
+ },
47640
48152
  onPanelRef: function (el) {
47641
48153
  return (panelRef.current = el);
47642
48154
  },
47643
- detailsLoading: detailsIsLoading
48155
+ detailsLoading: detailsIsLoading,
48156
+ accommodationStep: accommodationFlyInStep,
48157
+ isPackageEditFlow: !!context.packagingEntry
47644
48158
  })
47645
48159
  )
47646
48160
  )