@qite/tide-booking-component 1.4.98 → 1.4.99

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 +1088 -637
  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 +9 -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 +1088 -637
  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 +9 -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 +132 -70
  22. package/src/search-results/components/search-results-container/search-results-container.tsx +444 -383
  23. package/src/search-results/store/search-results-slice.ts +22 -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
@@ -13415,11 +13415,17 @@ PERFORMANCE OF THIS SOFTWARE.
13415
13415
  };
13416
13416
 
13417
13417
  var ENDPOINT = '/api/web/packaging';
13418
+ var ENDPOINT_START_TRANSACTION = ENDPOINT + '/start';
13418
13419
  var ENDPOINT_ACCOMMODATIONS = ENDPOINT + '/accommodations';
13419
13420
  var ENDPOINT_ENTRY = function (magicLinkCode) {
13420
13421
  return ENDPOINT + '/entry/' + magicLinkCode;
13421
13422
  };
13422
13423
  // MANUAL PACKAGING SEARCH
13424
+ var startTransaction = function (config, signal) {
13425
+ var apiKey = config.apiKey;
13426
+ var url = '' + config.host + ENDPOINT_START_TRANSACTION;
13427
+ return get(url, apiKey, config.token, signal, true);
13428
+ };
13423
13429
  var searchPackagingAccommodations = function (config, request, signal) {
13424
13430
  var url = '' + config.host + ENDPOINT_ACCOMMODATIONS;
13425
13431
  var apiKey = config.apiKey;
@@ -13507,6 +13513,7 @@ PERFORMANCE OF THIS SOFTWARE.
13507
13513
  exports.searchWithErrorMapping = searchWithErrorMapping;
13508
13514
  exports.setCustomEntryStatus = setCustomEntryStatus;
13509
13515
  exports.setEntryStatus = setEntryStatus;
13516
+ exports.startTransaction = startTransaction;
13510
13517
  exports.tourCodes = tourCodes;
13511
13518
  exports.transportDates = transportDates;
13512
13519
  exports.update = update;
@@ -32836,7 +32843,6 @@ var SearchInputGroup = function (_a) {
32836
32843
  );
32837
32844
  React.useEffect(
32838
32845
  function () {
32839
- console.log('options updated, resetting loading state');
32840
32846
  setIsLoading(false);
32841
32847
  },
32842
32848
  [options]
@@ -33798,13 +33804,15 @@ var initialState$1 = {
33798
33804
  selectedFlight: null,
33799
33805
  selectedFlightDetails: null,
33800
33806
  bookingPackageDetails: null,
33801
- entry: null,
33802
33807
  isLoading: false,
33803
33808
  filters: [],
33804
33809
  selectedSortType: null,
33805
33810
  activeTab: 'compact',
33806
33811
  currentPage: 1,
33807
- flyInIsOpen: false
33812
+ flyInIsOpen: false,
33813
+ editablePackagingEntry: null,
33814
+ transactionId: null,
33815
+ accommodationFlyInStep: 'details'
33808
33816
  };
33809
33817
  var searchResultsSlice = toolkit.createSlice({
33810
33818
  name: 'searchResults',
@@ -33840,9 +33848,6 @@ var searchResultsSlice = toolkit.createSlice({
33840
33848
  setBookingPackageDetails: function (state, action) {
33841
33849
  state.bookingPackageDetails = action.payload.details;
33842
33850
  },
33843
- setEntry: function (state, action) {
33844
- state.entry = action.payload.entry;
33845
- },
33846
33851
  selectFlight: function (state, action) {
33847
33852
  if (!state.bookingPackageDetails) return;
33848
33853
  var _a = action.payload,
@@ -33891,6 +33896,15 @@ var searchResultsSlice = toolkit.createSlice({
33891
33896
  },
33892
33897
  setFlyInIsOpen: function (state, action) {
33893
33898
  state.flyInIsOpen = action.payload;
33899
+ },
33900
+ setEditablePackagingEntry: function (state, action) {
33901
+ state.editablePackagingEntry = action.payload;
33902
+ },
33903
+ setTransactionId: function (state, action) {
33904
+ state.transactionId = action.payload;
33905
+ },
33906
+ setAccommodationFlyInStep: function (state, action) {
33907
+ state.accommodationFlyInStep = action.payload;
33894
33908
  }
33895
33909
  }
33896
33910
  });
@@ -33904,7 +33918,6 @@ var setResults = ((_a = searchResultsSlice.actions), _a.setResults),
33904
33918
  setSelectedFlight = _a.setSelectedFlight,
33905
33919
  setSelectedFlightDetails = _a.setSelectedFlightDetails,
33906
33920
  setBookingPackageDetails = _a.setBookingPackageDetails,
33907
- setEntry = _a.setEntry,
33908
33921
  selectFlight = _a.selectFlight,
33909
33922
  setIsLoading = _a.setIsLoading,
33910
33923
  setFilters = _a.setFilters,
@@ -33913,7 +33926,10 @@ var setResults = ((_a = searchResultsSlice.actions), _a.setResults),
33913
33926
  setActiveTab = _a.setActiveTab;
33914
33927
  _a.setCurrentPage;
33915
33928
  _a.resetSearchState;
33916
- var setFlyInIsOpen = _a.setFlyInIsOpen;
33929
+ var setFlyInIsOpen = _a.setFlyInIsOpen,
33930
+ setEditablePackagingEntry = _a.setEditablePackagingEntry,
33931
+ setTransactionId = _a.setTransactionId,
33932
+ setAccommodationFlyInStep = _a.setAccommodationFlyInStep;
33917
33933
  var searchResultsReducer = searchResultsSlice.reducer;
33918
33934
 
33919
33935
  var ItemPicker = function (_a) {
@@ -34942,8 +34958,160 @@ var Icon$1 = function (_a) {
34942
34958
  }
34943
34959
  };
34944
34960
 
34945
- var FLIGHT_SERVICE_TYPE = 7;
34961
+ var GROUP_TOUR_SERVICE_TYPE = 1;
34946
34962
  var ACCOMMODATION_SERVICE_TYPE = 3;
34963
+ var FLIGHT_SERVICE_TYPE = 7;
34964
+ var toDateOnlyString = function (value) {
34965
+ var date = value instanceof Date ? value : new Date(value);
34966
+ return date.toISOString().split('T')[0];
34967
+ };
34968
+ var getAgeAtReferenceDate = function (dateOfBirth, referenceDate) {
34969
+ var dob = dateOfBirth instanceof Date ? dateOfBirth : new Date(dateOfBirth);
34970
+ var ref = referenceDate instanceof Date ? referenceDate : new Date(referenceDate);
34971
+ var age = ref.getFullYear() - dob.getFullYear();
34972
+ var monthDiff = ref.getMonth() - dob.getMonth();
34973
+ if (monthDiff < 0 || (monthDiff === 0 && ref.getDate() < dob.getDate())) {
34974
+ age--;
34975
+ }
34976
+ return age;
34977
+ };
34978
+ var getFlightLines$1 = function (lines) {
34979
+ return __spreadArray([], lines, true)
34980
+ .filter(function (line) {
34981
+ return line.serviceType === FLIGHT_SERVICE_TYPE;
34982
+ })
34983
+ .sort(function (a, b) {
34984
+ return new Date(a.from).getTime() - new Date(b.from).getTime();
34985
+ });
34986
+ };
34987
+ var getDepartureAirportFromEntry = function (lines) {
34988
+ var _a, _b, _c;
34989
+ var firstFlight = getFlightLines$1(lines)[0];
34990
+ var firstSegment =
34991
+ (_b =
34992
+ (_a = firstFlight === null || firstFlight === void 0 ? void 0 : firstFlight.flightInformation) === null || _a === void 0 ? void 0 : _a.flightLines) ===
34993
+ null || _b === void 0
34994
+ ? void 0
34995
+ : _b[0];
34996
+ return (_c = firstSegment === null || firstSegment === void 0 ? void 0 : firstSegment.departureAirportCode) !== null && _c !== void 0 ? _c : null;
34997
+ };
34998
+ var getDestinationAirportFromEntry = function (lines) {
34999
+ var _a, _b, _c;
35000
+ var outboundFlight = getFlightLines$1(lines)[0];
35001
+ var flightSegments =
35002
+ (_a = outboundFlight === null || outboundFlight === void 0 ? void 0 : outboundFlight.flightInformation) === null || _a === void 0 ? void 0 : _a.flightLines;
35003
+ if (!(flightSegments === null || flightSegments === void 0 ? void 0 : flightSegments.length)) return null;
35004
+ return (_c = (_b = flightSegments[flightSegments.length - 1]) === null || _b === void 0 ? void 0 : _b.arrivalAirportCode) !== null && _c !== void 0
35005
+ ? _c
35006
+ : null;
35007
+ };
35008
+ var mapPackagingPaxToBookingPax = function (pax, fallbackId, referenceDate) {
35009
+ var _a, _b, _c, _d, _e, _f;
35010
+ return {
35011
+ id: (_a = pax === null || pax === void 0 ? void 0 : pax.id) !== null && _a !== void 0 ? _a : fallbackId,
35012
+ guid:
35013
+ (_c = (_b = pax === null || pax === void 0 ? void 0 : pax.id) === null || _b === void 0 ? void 0 : _b.toString()) !== null && _c !== void 0
35014
+ ? _c
35015
+ : fallbackId.toString(),
35016
+ firstName: (_d = pax === null || pax === void 0 ? void 0 : pax.firstName) !== null && _d !== void 0 ? _d : '',
35017
+ lastName: (_e = pax === null || pax === void 0 ? void 0 : pax.lastName) !== null && _e !== void 0 ? _e : '',
35018
+ dateOfBirth: (_f = pax === null || pax === void 0 ? void 0 : pax.dateOfBirth) !== null && _f !== void 0 ? _f : undefined,
35019
+ age: (pax === null || pax === void 0 ? void 0 : pax.dateOfBirth) ? getAgeAtReferenceDate(pax.dateOfBirth, referenceDate) : undefined,
35020
+ isMainBooker: pax === null || pax === void 0 ? void 0 : pax.isMainBooker,
35021
+ email: ''
35022
+ };
35023
+ };
35024
+ var getRequestRoomsFromPackagingEntry = function (entry) {
35025
+ var _a, _b, _c, _d;
35026
+ var accommodationLines = ((_a = entry.lines) !== null && _a !== void 0 ? _a : []).filter(function (line) {
35027
+ var _a;
35028
+ return line.serviceType === ACCOMMODATION_SERVICE_TYPE && ((_a = line.pax) === null || _a === void 0 ? void 0 : _a.length) > 0;
35029
+ });
35030
+ var paxById = new Map(
35031
+ ((_b = entry.pax) !== null && _b !== void 0 ? _b : []).map(function (p) {
35032
+ return [p.id, p];
35033
+ })
35034
+ );
35035
+ if (!accommodationLines.length) {
35036
+ return [
35037
+ {
35038
+ index: 0,
35039
+ pax: ((_c = entry.pax) !== null && _c !== void 0 ? _c : []).map(function (p) {
35040
+ return mapPackagingPaxToBookingPax(p, p.id, new Date().toISOString());
35041
+ })
35042
+ }
35043
+ ];
35044
+ }
35045
+ var roomGroups = [];
35046
+ accommodationLines.forEach(function (line) {
35047
+ var groupedByRoom = new Map();
35048
+ line.pax.forEach(function (linePax) {
35049
+ var _a;
35050
+ var roomIndexWithinLine = Number((_a = linePax.room) !== null && _a !== void 0 ? _a : 0);
35051
+ var paxId = Number(linePax.paxId);
35052
+ var pax = mapPackagingPaxToBookingPax(paxById.get(paxId), paxId, line.from);
35053
+ if (!groupedByRoom.has(roomIndexWithinLine)) {
35054
+ groupedByRoom.set(roomIndexWithinLine, []);
35055
+ }
35056
+ groupedByRoom.get(roomIndexWithinLine).push(pax);
35057
+ });
35058
+ var sortedGroups = Array.from(groupedByRoom.entries())
35059
+ .sort(function (_a, _b) {
35060
+ var a = _a[0];
35061
+ var b = _b[0];
35062
+ return a - b;
35063
+ })
35064
+ .map(function (_a) {
35065
+ var pax = _a[1];
35066
+ return pax;
35067
+ });
35068
+ roomGroups.push.apply(roomGroups, sortedGroups);
35069
+ });
35070
+ if (!roomGroups.length) {
35071
+ return [
35072
+ {
35073
+ index: 0,
35074
+ pax: ((_d = entry.pax) !== null && _d !== void 0 ? _d : []).map(function (p) {
35075
+ return mapPackagingPaxToBookingPax(p, p.id, accommodationLines[0].from);
35076
+ })
35077
+ }
35078
+ ];
35079
+ }
35080
+ return roomGroups.map(function (pax, index) {
35081
+ return {
35082
+ index: index,
35083
+ pax: pax
35084
+ };
35085
+ });
35086
+ };
35087
+ var parseHotelId = function (line) {
35088
+ if (!(line === null || line === void 0 ? void 0 : line.productCode)) return null;
35089
+ var parsed = Number(line.productCode);
35090
+ return Number.isNaN(parsed) ? null : parsed;
35091
+ };
35092
+ var getPackagingRequestRoomsFromBookingRooms = function (rooms) {
35093
+ if (!(rooms === null || rooms === void 0 ? void 0 : rooms.length)) {
35094
+ var room_1 = { index: 0, travellers: [] };
35095
+ lodash.range(0, 2).forEach(function () {
35096
+ room_1.travellers.push({
35097
+ age: 30
35098
+ });
35099
+ });
35100
+ return [room_1];
35101
+ }
35102
+ return rooms.map(function (x, i) {
35103
+ var _a;
35104
+ var room = { index: (_a = x.index) !== null && _a !== void 0 ? _a : i, travellers: [] };
35105
+ x.pax.forEach(function (p) {
35106
+ var _a;
35107
+ room.travellers.push({
35108
+ age: (_a = p.age) !== null && _a !== void 0 ? _a : 30
35109
+ });
35110
+ });
35111
+ return room;
35112
+ });
35113
+ };
35114
+
34947
35115
  var getFlightLines = function (flight) {
34948
35116
  var _a, _b;
34949
35117
  return (_b = (_a = flight === null || flight === void 0 ? void 0 : flight.flightInformation) === null || _a === void 0 ? void 0 : _a.flightLines) !== null &&
@@ -34981,31 +35149,66 @@ var numberOfNights = function (segment) {
34981
35149
  var getSegmentIcon = function (segment) {
34982
35150
  switch (segment.serviceType) {
34983
35151
  case 3:
34984
- return React__default['default'].createElement(Icon$1, { name: 'ui-bed', width: 15, height: 15 });
35152
+ return React__default['default'].createElement(
35153
+ 'div',
35154
+ { className: 'search__filter__itinerary__segment-badge search__filter__itinerary__segment-badge--secondary' },
35155
+ React__default['default'].createElement(Icon$1, { name: 'ui-bed', width: 15, height: 15 })
35156
+ );
34985
35157
  case 4:
34986
- return React__default['default'].createElement(Icon$1, { name: 'ui-ticket', width: 15, height: 15 });
35158
+ return React__default['default'].createElement(
35159
+ 'div',
35160
+ { className: 'search__filter__itinerary__segment-badge search__filter__itinerary__segment-badge--secondary' },
35161
+ React__default['default'].createElement(Icon$1, { name: 'ui-ticket', width: 15, height: 15 })
35162
+ );
34987
35163
  case 11:
34988
- return React__default['default'].createElement(Icon$1, { name: 'ui-ship', width: 15, height: 15 });
35164
+ return React__default['default'].createElement(
35165
+ 'div',
35166
+ { className: 'search__filter__itinerary__segment-badge search__filter__itinerary__segment-badge--secondary' },
35167
+ React__default['default'].createElement(Icon$1, { name: 'ui-ship', width: 15, height: 15 })
35168
+ );
34989
35169
  case 13:
34990
35170
  case 17:
34991
35171
  case 22:
34992
- return React__default['default'].createElement(Icon$1, { name: 'ui-car', width: 15, height: 15 });
35172
+ return React__default['default'].createElement(
35173
+ 'div',
35174
+ { className: 'search__filter__itinerary__transport-badge' },
35175
+ React__default['default'].createElement(Icon$1, { name: 'ui-car', width: 15, height: 15 })
35176
+ );
34993
35177
  default:
34994
- return React__default['default'].createElement(Icon$1, { name: 'ui-location', width: 15, height: 15 });
35178
+ return React__default['default'].createElement(
35179
+ 'div',
35180
+ { className: 'search__filter__itinerary__segment-badge' },
35181
+ React__default['default'].createElement(Icon$1, { name: 'ui-location', width: 15, height: 15 })
35182
+ );
34995
35183
  }
34996
35184
  };
35185
+ var canEdit = function (segment) {
35186
+ if (segment.serviceType === ACCOMMODATION_SERVICE_TYPE) {
35187
+ return true;
35188
+ }
35189
+ return false;
35190
+ };
34997
35191
  var getSegmentTitle = function (segment) {
34998
- if (segment.accommodationName) return segment.accommodationName;
34999
- return segment.productName;
35192
+ var _a;
35193
+ return (_a = segment.productName) !== null && _a !== void 0 ? _a : segment.accommodationName;
35000
35194
  };
35001
35195
  var Itinerary = function (_a) {
35002
35196
  var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
35003
35197
  var isOpen = _a.isOpen,
35004
35198
  handleSetIsOpen = _a.handleSetIsOpen;
35005
35199
  _a.isLoading;
35200
+ var onEditAccommodation = _a.onEditAccommodation;
35006
35201
  var context = React.useContext(SearchResultsConfigurationContext);
35007
35202
  var translations = getTranslations((_b = context === null || context === void 0 ? void 0 : context.languageCode) !== null && _b !== void 0 ? _b : 'en-GB');
35008
- var packagingEntry = context === null || context === void 0 ? void 0 : context.packagingEntry;
35203
+ var editablePackagingEntry = reactRedux.useSelector(function (state) {
35204
+ return state.searchResults;
35205
+ }).editablePackagingEntry;
35206
+ var packagingEntry =
35207
+ editablePackagingEntry !== null && editablePackagingEntry !== void 0
35208
+ ? editablePackagingEntry
35209
+ : context === null || context === void 0
35210
+ ? void 0
35211
+ : context.packagingEntry;
35009
35212
  var sortedLines = React.useMemo(
35010
35213
  function () {
35011
35214
  var _a;
@@ -35073,7 +35276,19 @@ var Itinerary = function (_a) {
35073
35276
  var otherSegments = sortedLines.filter(function (item) {
35074
35277
  return item.serviceType !== FLIGHT_SERVICE_TYPE;
35075
35278
  });
35076
- console.log('other segments', otherSegments);
35279
+ var grouped = lodash.groupBy(otherSegments, function (segment) {
35280
+ return ''.concat(segment.productCode, '-').concat(segment.from, '-').concat(segment.to);
35281
+ });
35282
+ var groupedOtherSegments = Object.entries(grouped).map(function (_a) {
35283
+ var key = _a[0],
35284
+ segments = _a[1];
35285
+ return {
35286
+ key: key,
35287
+ segments: segments
35288
+ };
35289
+ });
35290
+ console.log('otherSegments', otherSegments);
35291
+ console.log('groupedOtherSegments', groupedOtherSegments);
35077
35292
  var numberOfPax = ((_p = packagingEntry.pax) === null || _p === void 0 ? void 0 : _p.length) || 1;
35078
35293
  var totalPrice = packagingEntry.price || 0;
35079
35294
  var pricePerPerson = totalPrice / numberOfPax;
@@ -35164,8 +35379,7 @@ var Itinerary = function (_a) {
35164
35379
  'p',
35165
35380
  null,
35166
35381
  dateFns.format(new Date(firstEntryLine.from), 'EEE. d MMM yyyy'),
35167
- ' -',
35168
- ' ',
35382
+ ' - ',
35169
35383
  React__default['default'].createElement('strong', null, translations.SRP.START)
35170
35384
  )
35171
35385
  )
@@ -35236,15 +35450,17 @@ var Itinerary = function (_a) {
35236
35450
  )
35237
35451
  )
35238
35452
  ),
35239
- !lodash.isEmpty(otherSegments) &&
35240
- React__default['default'].createElement(
35241
- 'div',
35242
- { className: 'search__filter__itinerary__segments' },
35243
- otherSegments.map(function (segment, index) {
35244
- var _a, _b, _c, _d, _e, _f, _g, _h;
35245
- return React__default['default'].createElement(
35453
+ !lodash.isEmpty(groupedOtherSegments) &&
35454
+ groupedOtherSegments.map(function (group) {
35455
+ var _a, _b, _c, _d, _e, _f, _g, _h;
35456
+ var firstSegment = lodash.first(group.segments);
35457
+ if (!firstSegment) return null;
35458
+ return React__default['default'].createElement(
35459
+ 'div',
35460
+ { className: 'search__filter__itinerary__segments' },
35461
+ React__default['default'].createElement(
35246
35462
  'div',
35247
- { className: 'search__filter__itinerary__segments__wrapper', key: 'segment-'.concat(index) },
35463
+ { className: 'search__filter__itinerary__segments__wrapper', key: group.key },
35248
35464
  React__default['default'].createElement(
35249
35465
  'div',
35250
35466
  { className: 'search__filter__itinerary__segments-timeline' },
@@ -35262,9 +35478,9 @@ var Itinerary = function (_a) {
35262
35478
  React__default['default'].createElement(
35263
35479
  'p',
35264
35480
  { className: 'search__filter__itinerary__transport-date-date' },
35265
- React__default['default'].createElement('strong', null, dateFns.format(new Date(segment.from), 'd'))
35481
+ React__default['default'].createElement('strong', null, dateFns.format(new Date(firstSegment.from), 'd'))
35266
35482
  ),
35267
- React__default['default'].createElement('p', null, dateFns.format(new Date(segment.from), 'MMM'))
35483
+ React__default['default'].createElement('p', null, dateFns.format(new Date(firstSegment.from), 'MMM'))
35268
35484
  ),
35269
35485
  React__default['default'].createElement(
35270
35486
  'div',
@@ -35277,23 +35493,23 @@ var Itinerary = function (_a) {
35277
35493
  React__default['default'].createElement(
35278
35494
  'h6',
35279
35495
  null,
35280
- ((_a = segment.location) === null || _a === void 0 ? void 0 : _a.name) ||
35281
- ((_b = segment.oord) === null || _b === void 0 ? void 0 : _b.name) ||
35282
- ((_c = segment.region) === null || _c === void 0 ? void 0 : _c.name),
35283
- (((_d = segment.location) === null || _d === void 0 ? void 0 : _d.name) ||
35284
- ((_e = segment.oord) === null || _e === void 0 ? void 0 : _e.name) ||
35285
- ((_f = segment.region) === null || _f === void 0 ? void 0 : _f.name)) &&
35286
- ((_g = segment.country) === null || _g === void 0 ? void 0 : _g.name)
35496
+ ((_a = firstSegment.location) === null || _a === void 0 ? void 0 : _a.name) ||
35497
+ ((_b = firstSegment.oord) === null || _b === void 0 ? void 0 : _b.name) ||
35498
+ ((_c = firstSegment.region) === null || _c === void 0 ? void 0 : _c.name),
35499
+ (((_d = firstSegment.location) === null || _d === void 0 ? void 0 : _d.name) ||
35500
+ ((_e = firstSegment.oord) === null || _e === void 0 ? void 0 : _e.name) ||
35501
+ ((_f = firstSegment.region) === null || _f === void 0 ? void 0 : _f.name)) &&
35502
+ ((_g = firstSegment.country) === null || _g === void 0 ? void 0 : _g.name)
35287
35503
  ? ', '
35288
35504
  : '',
35289
- (_h = segment.country) === null || _h === void 0 ? void 0 : _h.name
35505
+ (_h = firstSegment.country) === null || _h === void 0 ? void 0 : _h.name
35290
35506
  ),
35291
35507
  React__default['default'].createElement(
35292
35508
  'p',
35293
35509
  { className: 'search__filter__itinerary__segment-details-text' },
35294
- dateFns.format(new Date(segment.from), 'EEE. d MMM yyyy'),
35510
+ dateFns.format(new Date(firstSegment.from), 'EEE. d MMM yyyy'),
35295
35511
  '> ',
35296
- dateFns.format(new Date(segment.to), 'EEE. d MMM yyyy')
35512
+ dateFns.format(new Date(firstSegment.to), 'EEE. d MMM yyyy')
35297
35513
  )
35298
35514
  )
35299
35515
  )
@@ -35303,38 +35519,65 @@ var Itinerary = function (_a) {
35303
35519
  { className: 'search__filter__itinerary__segment' },
35304
35520
  React__default['default'].createElement(
35305
35521
  'div',
35306
- { className: 'search__filter__itinerary__segment-item' },
35522
+ {
35523
+ className: 'search__filter__itinerary__segment-item '.concat(
35524
+ canEdit(firstSegment) ? 'search__filter__itinerary__segment-item--editable' : ''
35525
+ ),
35526
+ onClick: function () {
35527
+ if (canEdit(firstSegment) && onEditAccommodation) {
35528
+ onEditAccommodation(group.segments);
35529
+ }
35530
+ }
35531
+ },
35307
35532
  React__default['default'].createElement(
35308
35533
  'div',
35309
35534
  { className: 'search__filter__itinerary__segment-date search__filter__itinerary__segment-nights' },
35310
- segment.serviceType === ACCOMMODATION_SERVICE_TYPE &&
35535
+ firstSegment.serviceType === ACCOMMODATION_SERVICE_TYPE &&
35311
35536
  React__default['default'].createElement(
35312
35537
  React__default['default'].Fragment,
35313
35538
  null,
35314
35539
  React__default['default'].createElement(
35315
35540
  'p',
35316
35541
  { className: 'search__filter__itinerary__segment-date-date' },
35317
- React__default['default'].createElement('strong', null, numberOfNights(segment))
35542
+ React__default['default'].createElement('strong', null, numberOfNights(firstSegment))
35318
35543
  ),
35319
35544
  React__default['default'].createElement(Icon$1, { name: 'ui-moon', width: 16, height: 16 })
35320
35545
  )
35321
35546
  ),
35322
- React__default['default'].createElement(
35323
- 'div',
35324
- { className: 'search__filter__itinerary__segment-badge search__filter__itinerary__segment-badge--secondary' },
35325
- getSegmentIcon(segment)
35326
- ),
35547
+ getSegmentIcon(firstSegment),
35327
35548
  React__default['default'].createElement(
35328
35549
  'div',
35329
35550
  { className: 'search__filter__itinerary__segment-details' },
35330
- React__default['default'].createElement('h6', null, getSegmentTitle(segment)),
35331
- segment.regimeName && React__default['default'].createElement('p', null, segment.regimeName)
35551
+ React__default['default'].createElement('h6', null, getSegmentTitle(firstSegment)),
35552
+ firstSegment.serviceType === ACCOMMODATION_SERVICE_TYPE &&
35553
+ group.segments.map(function (segment, index) {
35554
+ return React__default['default'].createElement(
35555
+ React__default['default'].Fragment,
35556
+ { key: segment.guid },
35557
+ React__default['default'].createElement('strong', null, translations.SHARED.ROOM, '\u00A0', index + 1),
35558
+ segment.productName &&
35559
+ segment.accommodationName &&
35560
+ React__default['default'].createElement(
35561
+ 'div',
35562
+ { className: 'search__filter__itinerary__segment-details__room' },
35563
+ React__default['default'].createElement(Icon$1, { name: 'ui-bed', width: 12, height: 12 }),
35564
+ segment.accommodationName
35565
+ ),
35566
+ segment.regimeName &&
35567
+ React__default['default'].createElement(
35568
+ 'div',
35569
+ { className: 'search__filter__itinerary__segment-details__room' },
35570
+ React__default['default'].createElement(Icon$1, { name: 'ui-utensils', width: 12, height: 12 }),
35571
+ segment.regimeName
35572
+ )
35573
+ );
35574
+ })
35332
35575
  )
35333
35576
  )
35334
35577
  )
35335
- );
35336
- })
35337
- ),
35578
+ )
35579
+ );
35580
+ }),
35338
35581
  returnFlight &&
35339
35582
  returnFlight !== outboundFlight &&
35340
35583
  React__default['default'].createElement(
@@ -35418,8 +35661,7 @@ var Itinerary = function (_a) {
35418
35661
  'p',
35419
35662
  null,
35420
35663
  dateFns.format(new Date(lastEntryLine.to), 'EEE. d MMM yyyy'),
35421
- ' -',
35422
- ' ',
35664
+ ' - ',
35423
35665
  React__default['default'].createElement('strong', null, translations.SRP.END)
35424
35666
  )
35425
35667
  )
@@ -38194,19 +38436,27 @@ var formatPrice$1 = function (price, currencyCode) {
38194
38436
  }).format(price);
38195
38437
  };
38196
38438
  var AccommodationFlyIn = function (_a) {
38197
- var _b;
38198
- _a.isLoading;
38199
- var isOpen = _a.isOpen,
38200
- setIsOpen = _a.setIsOpen;
38439
+ var _b, _c;
38440
+ var isLoading = _a.isLoading,
38441
+ handleConfirm = _a.handleConfirm;
38201
38442
  var dispatch = reactRedux.useDispatch();
38202
38443
  var context = React.useContext(SearchResultsConfigurationContext);
38203
- var language = (_b = context === null || context === void 0 ? void 0 : context.languageCode) !== null && _b !== void 0 ? _b : 'en-GB';
38444
+ if (isLoading) {
38445
+ return React__default['default'].createElement(
38446
+ React__default['default'].Fragment,
38447
+ null,
38448
+ (_b = context === null || context === void 0 ? void 0 : context.customSpinner) !== null && _b !== void 0
38449
+ ? _b
38450
+ : React__default['default'].createElement(Spinner, null)
38451
+ );
38452
+ }
38453
+ var language = (_c = context === null || context === void 0 ? void 0 : context.languageCode) !== null && _c !== void 0 ? _c : 'en-GB';
38204
38454
  var translations = getTranslations(language);
38205
- var _c = reactRedux.useSelector(function (state) {
38455
+ var _d = reactRedux.useSelector(function (state) {
38206
38456
  return state.searchResults;
38207
38457
  }),
38208
- packagingAccoSearchDetails = _c.packagingAccoSearchDetails,
38209
- selectedPackagingAccoResultCode = _c.selectedPackagingAccoResultCode;
38458
+ packagingAccoSearchDetails = _d.packagingAccoSearchDetails,
38459
+ selectedPackagingAccoResultCode = _d.selectedPackagingAccoResultCode;
38210
38460
  var selectedPackagingAccoSearchDetails = React.useMemo(
38211
38461
  function () {
38212
38462
  return packagingAccoSearchDetails === null || packagingAccoSearchDetails === void 0
@@ -38297,11 +38547,6 @@ var AccommodationFlyIn = function (_a) {
38297
38547
  });
38298
38548
  dispatch(setPackagingAccoSearchDetails(updatedPackagingAccoSearchDetails));
38299
38549
  };
38300
- var handleConfirm = function () {
38301
- if (isOpen) {
38302
- setIsOpen(false);
38303
- }
38304
- };
38305
38550
  if (!selectedPackagingAccoSearchDetails) {
38306
38551
  return null;
38307
38552
  }
@@ -38461,7 +38706,13 @@ var AccommodationFlyIn = function (_a) {
38461
38706
  React__default['default'].createElement(
38462
38707
  'div',
38463
38708
  { className: 'flyin__button-wrapper' },
38464
- React__default['default'].createElement('button', { className: 'cta cta--select', onClick: handleConfirm }, translations.PRODUCT.BOOK_NOW)
38709
+ React__default['default'].createElement(
38710
+ 'button',
38711
+ { className: 'cta cta--select', onClick: handleConfirm },
38712
+ (context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) == build.PortalQsmType.AccommodationAndFlight
38713
+ ? translations.QSM.CONFIRM
38714
+ : translations.PRODUCT.BOOK_NOW
38715
+ )
38465
38716
  )
38466
38717
  )
38467
38718
  );
@@ -38948,97 +39199,6 @@ var GroupTourFlyIn = function (_a) {
38948
39199
  );
38949
39200
  };
38950
39201
 
38951
- var FlyIn = function (_a) {
38952
- var title = _a.title,
38953
- srpType = _a.srpType,
38954
- isOpen = _a.isOpen,
38955
- setIsOpen = _a.setIsOpen,
38956
- _b = _a.className,
38957
- className = _b === void 0 ? '' : _b,
38958
- onPanelRef = _a.onPanelRef,
38959
- detailsLoading = _a.detailsLoading;
38960
- var dispatch = reactRedux.useDispatch();
38961
- var onCancelSearch = useFlightSearch().onCancelSearch;
38962
- var panelRef = React.useRef(null);
38963
- // expose DOM node if needed
38964
- React.useEffect(
38965
- function () {
38966
- onPanelRef === null || onPanelRef === void 0 ? void 0 : onPanelRef(panelRef.current);
38967
- return function () {
38968
- return onPanelRef === null || onPanelRef === void 0 ? void 0 : onPanelRef(null);
38969
- };
38970
- },
38971
- [onPanelRef]
38972
- );
38973
- React.useEffect(
38974
- function () {
38975
- // click outside detection
38976
- var handleClickOutside = function (event) {
38977
- if (isOpen && panelRef.current && !panelRef.current.contains(event.target)) {
38978
- handleClose();
38979
- }
38980
- };
38981
- document.addEventListener('mousedown', handleClickOutside);
38982
- return function () {
38983
- return document.removeEventListener('mousedown', handleClickOutside);
38984
- };
38985
- },
38986
- [isOpen, setIsOpen]
38987
- );
38988
- // body scroll lock
38989
- React.useEffect(
38990
- function () {
38991
- document.body.style.overflow = isOpen ? 'hidden' : '';
38992
- return function () {
38993
- document.body.style.overflow = '';
38994
- };
38995
- },
38996
- [isOpen]
38997
- );
38998
- var handleClose = function () {
38999
- if (isOpen && panelRef.current) {
39000
- if (srpType === build.PortalQsmType.Flight) {
39001
- dispatch(setSelectedFlight(null));
39002
- dispatch(setSelectedFlightDetails(null));
39003
- onCancelSearch();
39004
- }
39005
- setIsOpen(false);
39006
- }
39007
- };
39008
- return React__default['default'].createElement(
39009
- 'div',
39010
- { className: 'flyin '.concat(isOpen ? 'flyin--active' : '', ' ').concat(className) },
39011
- React__default['default'].createElement(
39012
- 'div',
39013
- { className: 'flyin__panel '.concat(isOpen ? 'flyin__panel--active' : ''), ref: panelRef },
39014
- React__default['default'].createElement(
39015
- 'div',
39016
- { className: 'flyin__content' },
39017
- React__default['default'].createElement(
39018
- 'div',
39019
- { className: 'flyin__content-title-row' },
39020
- React__default['default'].createElement('h3', { className: 'flyin__content-title' }, title),
39021
- React__default['default'].createElement(
39022
- 'span',
39023
- {
39024
- className: 'flyin__close',
39025
- onClick: function () {
39026
- return handleClose();
39027
- }
39028
- },
39029
- React__default['default'].createElement(Icon, { name: 'ui-close', width: 30, height: 30, 'aria-hidden': 'true' })
39030
- )
39031
- )
39032
- ),
39033
- srpType === build.PortalQsmType.Flight && React__default['default'].createElement(FlightsFlyIn, { isOpen: isOpen, setIsOpen: setIsOpen }),
39034
- srpType === build.PortalQsmType.Accommodation &&
39035
- React__default['default'].createElement(AccommodationFlyIn, { isLoading: true, isOpen: isOpen, setIsOpen: setIsOpen }),
39036
- srpType === build.PortalQsmType.GroupTour &&
39037
- React__default['default'].createElement(GroupTourFlyIn, { isLoading: detailsLoading, isOpen: isOpen, setIsOpen: setIsOpen })
39038
- )
39039
- );
39040
- };
39041
-
39042
39202
  var he$1 = { exports: {} };
39043
39203
 
39044
39204
  /*! https://mths.be/he v1.2.0 by @mathias | MIT license */
@@ -43517,6 +43677,132 @@ var HotelAccommodationResults = function (_a) {
43517
43677
  );
43518
43678
  };
43519
43679
 
43680
+ var FlyIn = function (_a) {
43681
+ var title = _a.title,
43682
+ srpType = _a.srpType,
43683
+ isOpen = _a.isOpen,
43684
+ setIsOpen = _a.setIsOpen,
43685
+ _b = _a.className,
43686
+ className = _b === void 0 ? '' : _b,
43687
+ onPanelRef = _a.onPanelRef,
43688
+ detailsLoading = _a.detailsLoading,
43689
+ accommodationStep = _a.accommodationStep,
43690
+ isPackageEditFlow = _a.isPackageEditFlow,
43691
+ handleConfirm = _a.handleConfirm;
43692
+ var dispatch = reactRedux.useDispatch();
43693
+ var onCancelSearch = useFlightSearch().onCancelSearch;
43694
+ var panelRef = React.useRef(null);
43695
+ // expose DOM node if needed
43696
+ React.useEffect(
43697
+ function () {
43698
+ onPanelRef === null || onPanelRef === void 0 ? void 0 : onPanelRef(panelRef.current);
43699
+ return function () {
43700
+ return onPanelRef === null || onPanelRef === void 0 ? void 0 : onPanelRef(null);
43701
+ };
43702
+ },
43703
+ [onPanelRef]
43704
+ );
43705
+ React.useEffect(
43706
+ function () {
43707
+ // click outside detection
43708
+ var handleClickOutside = function (event) {
43709
+ if (isOpen && panelRef.current && !panelRef.current.contains(event.target)) {
43710
+ handleClose();
43711
+ }
43712
+ };
43713
+ document.addEventListener('mousedown', handleClickOutside);
43714
+ return function () {
43715
+ return document.removeEventListener('mousedown', handleClickOutside);
43716
+ };
43717
+ },
43718
+ [isOpen, setIsOpen]
43719
+ );
43720
+ // body scroll lock
43721
+ React.useEffect(
43722
+ function () {
43723
+ document.body.style.overflow = isOpen ? 'hidden' : '';
43724
+ return function () {
43725
+ document.body.style.overflow = '';
43726
+ };
43727
+ },
43728
+ [isOpen]
43729
+ );
43730
+ var handleClose = function () {
43731
+ if (isOpen && panelRef.current) {
43732
+ if (srpType === build.PortalQsmType.Flight) {
43733
+ dispatch(setSelectedFlight(null));
43734
+ dispatch(setSelectedFlightDetails(null));
43735
+ onCancelSearch();
43736
+ } else {
43737
+ dispatch(setSelectedSearchResult(null));
43738
+ dispatch(setSelectedPackagingAccoResult(null));
43739
+ }
43740
+ dispatch(setAccommodationFlyInStep('details'));
43741
+ setIsOpen(false);
43742
+ }
43743
+ };
43744
+ var handleGoBack = function () {
43745
+ dispatch(setAccommodationFlyInStep('results'));
43746
+ };
43747
+ return React__default['default'].createElement(
43748
+ 'div',
43749
+ {
43750
+ className: 'flyin '
43751
+ .concat(isOpen ? 'flyin--active' : '', ' ')
43752
+ .concat(className, ' ')
43753
+ .concat(isPackageEditFlow ? 'flyin--large' : '')
43754
+ },
43755
+ React__default['default'].createElement(
43756
+ 'div',
43757
+ { className: 'flyin__panel '.concat(isOpen ? 'flyin__panel--active' : ''), ref: panelRef },
43758
+ React__default['default'].createElement(
43759
+ 'div',
43760
+ { className: 'flyin__content' },
43761
+ React__default['default'].createElement(
43762
+ 'div',
43763
+ { className: 'flyin__content-title-row' },
43764
+ React__default['default'].createElement('h3', { className: 'flyin__content-title' }, title),
43765
+ React__default['default'].createElement(
43766
+ 'span',
43767
+ {
43768
+ className: 'flyin__close',
43769
+ onClick: function () {
43770
+ return handleClose();
43771
+ }
43772
+ },
43773
+ React__default['default'].createElement(Icon, { name: 'ui-close', width: 30, height: 30, 'aria-hidden': 'true' })
43774
+ )
43775
+ ),
43776
+ isPackageEditFlow &&
43777
+ accommodationStep === 'details' &&
43778
+ React__default['default'].createElement(
43779
+ 'div',
43780
+ { className: 'flyin__content-title-row' },
43781
+ React__default['default'].createElement(
43782
+ 'div',
43783
+ { onClick: handleGoBack, className: 'flyin__content-title__back' },
43784
+ React__default['default'].createElement(Icon, { name: 'ui-chevron', width: 14, height: 14, 'aria-hidden': 'true' }),
43785
+ 'Go Back'
43786
+ )
43787
+ )
43788
+ ),
43789
+ srpType === build.PortalQsmType.Flight && React__default['default'].createElement(FlightsFlyIn, { isOpen: isOpen, setIsOpen: setIsOpen }),
43790
+ (srpType === build.PortalQsmType.Accommodation || srpType === build.PortalQsmType.AccommodationAndFlight) &&
43791
+ accommodationStep === 'results' &&
43792
+ React__default['default'].createElement(
43793
+ 'div',
43794
+ { className: 'flyin__content' },
43795
+ React__default['default'].createElement(HotelAccommodationResults, { isLoading: detailsLoading })
43796
+ ),
43797
+ (srpType === build.PortalQsmType.Accommodation || srpType === build.PortalQsmType.AccommodationAndFlight) &&
43798
+ accommodationStep === 'details' &&
43799
+ React__default['default'].createElement(AccommodationFlyIn, { isLoading: detailsLoading, handleConfirm: handleConfirm }),
43800
+ srpType === build.PortalQsmType.GroupTour &&
43801
+ React__default['default'].createElement(GroupTourFlyIn, { isLoading: detailsLoading, isOpen: isOpen, setIsOpen: setIsOpen })
43802
+ )
43803
+ );
43804
+ };
43805
+
43520
43806
  var RoundTripResults = function () {
43521
43807
  var activeTab = reactRedux.useSelector(function (state) {
43522
43808
  return state.searchResults;
@@ -46932,42 +47218,140 @@ var applyFiltersToPackageAccoResults = function (results, filters, sortBy) {
46932
47218
  });
46933
47219
  };
46934
47220
 
46935
- var SearchResultsContainer = function () {
47221
+ var getSelectedOptionsPerRoom = function (details) {
46936
47222
  var _a;
47223
+ var firstResult = details[0];
47224
+ if (!((_a = firstResult === null || firstResult === void 0 ? void 0 : firstResult.rooms) === null || _a === void 0 ? void 0 : _a.length)) return [];
47225
+ return firstResult.rooms.map(function (room, roomIndex) {
47226
+ var _a;
47227
+ var selectedOption =
47228
+ (_a = room.options.find(function (option) {
47229
+ return option.isSelected;
47230
+ })) !== null && _a !== void 0
47231
+ ? _a
47232
+ : room.options[0];
47233
+ return {
47234
+ roomIndex: roomIndex,
47235
+ option: selectedOption !== null && selectedOption !== void 0 ? selectedOption : null
47236
+ };
47237
+ });
47238
+ };
47239
+ var getRoomIndexFromLine = function (line) {
47240
+ var _a, _b;
47241
+ if (!((_a = line.pax) === null || _a === void 0 ? void 0 : _a.length)) return 0;
47242
+ var firstPax = __spreadArray([], line.pax, true).sort(function (a, b) {
47243
+ return a.order - b.order;
47244
+ })[0];
47245
+ return (_b = firstPax === null || firstPax === void 0 ? void 0 : firstPax.room) !== null && _b !== void 0 ? _b : 0;
47246
+ };
47247
+ var getRequestRoomsFromPackagingSegments = function (entry, segments) {
47248
+ var _a;
47249
+ var accommodationLines = __spreadArray([], segments !== null && segments !== void 0 ? segments : [], true)
47250
+ .filter(function (line) {
47251
+ var _a;
47252
+ return line.serviceType === ACCOMMODATION_SERVICE_TYPE && ((_a = line.pax) === null || _a === void 0 ? void 0 : _a.length) > 0;
47253
+ })
47254
+ .sort(function (a, b) {
47255
+ return a.order - b.order;
47256
+ });
47257
+ var paxById = new Map(
47258
+ ((_a = entry.pax) !== null && _a !== void 0 ? _a : []).map(function (p) {
47259
+ return [p.id, p];
47260
+ })
47261
+ );
47262
+ if (!accommodationLines.length) {
47263
+ return [];
47264
+ }
47265
+ var roomGroups = [];
47266
+ accommodationLines.forEach(function (line) {
47267
+ var groupedByRoom = new Map();
47268
+ line.pax.forEach(function (linePax) {
47269
+ var _a, _b, _c, _d, _e, _f, _g;
47270
+ var roomIndexWithinLine = Number((_a = linePax.room) !== null && _a !== void 0 ? _a : 0);
47271
+ var paxId = Number(linePax.paxId);
47272
+ var paxSource = paxById.get(paxId);
47273
+ var pax = {
47274
+ id: (_b = paxSource === null || paxSource === void 0 ? void 0 : paxSource.id) !== null && _b !== void 0 ? _b : paxId,
47275
+ guid:
47276
+ (_d = (_c = paxSource === null || paxSource === void 0 ? void 0 : paxSource.id) === null || _c === void 0 ? void 0 : _c.toString()) !== null &&
47277
+ _d !== void 0
47278
+ ? _d
47279
+ : paxId.toString(),
47280
+ firstName: (_e = paxSource === null || paxSource === void 0 ? void 0 : paxSource.firstName) !== null && _e !== void 0 ? _e : '',
47281
+ lastName: (_f = paxSource === null || paxSource === void 0 ? void 0 : paxSource.lastName) !== null && _f !== void 0 ? _f : '',
47282
+ dateOfBirth: (_g = paxSource === null || paxSource === void 0 ? void 0 : paxSource.dateOfBirth) !== null && _g !== void 0 ? _g : undefined,
47283
+ age: (paxSource === null || paxSource === void 0 ? void 0 : paxSource.dateOfBirth) ? undefined : 30,
47284
+ isMainBooker: paxSource === null || paxSource === void 0 ? void 0 : paxSource.isMainBooker,
47285
+ email: ''
47286
+ };
47287
+ if (!groupedByRoom.has(roomIndexWithinLine)) {
47288
+ groupedByRoom.set(roomIndexWithinLine, []);
47289
+ }
47290
+ groupedByRoom.get(roomIndexWithinLine).push(pax);
47291
+ });
47292
+ var sortedGroups = Array.from(groupedByRoom.entries())
47293
+ .sort(function (_a, _b) {
47294
+ var a = _a[0];
47295
+ var b = _b[0];
47296
+ return a - b;
47297
+ })
47298
+ .map(function (_a) {
47299
+ var pax = _a[1];
47300
+ return pax;
47301
+ });
47302
+ roomGroups.push.apply(roomGroups, sortedGroups);
47303
+ });
47304
+ return roomGroups.map(function (pax, index) {
47305
+ return {
47306
+ index: index,
47307
+ pax: pax
47308
+ };
47309
+ });
47310
+ };
47311
+
47312
+ var SearchResultsContainer = function () {
47313
+ var _a, _b;
47314
+ var currentSearch = typeof window !== 'undefined' ? window.location.search : '';
46937
47315
  var dispatch = reactRedux.useDispatch();
46938
47316
  var context = React.useContext(SearchResultsConfigurationContext);
46939
47317
  var translations = getTranslations((_a = context === null || context === void 0 ? void 0 : context.languageCode) !== null && _a !== void 0 ? _a : 'en-GB');
46940
- var _b = reactRedux.useSelector(function (state) {
47318
+ var _c = reactRedux.useSelector(function (state) {
46941
47319
  return state.searchResults;
46942
47320
  }),
46943
- results = _b.results,
46944
- filteredResults = _b.filteredResults,
46945
- packagingAccoResults = _b.packagingAccoResults,
46946
- filteredPackagingAccoResults = _b.filteredPackagingAccoResults,
46947
- bookingPackageDetails = _b.bookingPackageDetails,
46948
- entry = _b.entry,
46949
- isLoading = _b.isLoading,
46950
- filters = _b.filters,
46951
- selectedSortType = _b.selectedSortType,
46952
- selectedSearchResult = _b.selectedSearchResult,
46953
- selectedPackagingAccoResultCode = _b.selectedPackagingAccoResultCode,
46954
- flyInIsOpen = _b.flyInIsOpen;
47321
+ results = _c.results,
47322
+ filteredResults = _c.filteredResults,
47323
+ packagingAccoResults = _c.packagingAccoResults,
47324
+ filteredPackagingAccoResults = _c.filteredPackagingAccoResults,
47325
+ bookingPackageDetails = _c.bookingPackageDetails,
47326
+ isLoading = _c.isLoading,
47327
+ filters = _c.filters,
47328
+ selectedSortType = _c.selectedSortType,
47329
+ selectedSearchResult = _c.selectedSearchResult,
47330
+ selectedPackagingAccoResultCode = _c.selectedPackagingAccoResultCode,
47331
+ flyInIsOpen = _c.flyInIsOpen,
47332
+ packagingAccoSearchDetails = _c.packagingAccoSearchDetails,
47333
+ editablePackagingEntry = _c.editablePackagingEntry,
47334
+ transactionId = _c.transactionId,
47335
+ accommodationFlyInStep = _c.accommodationFlyInStep;
46955
47336
  var isMobile = useMediaQuery('(max-width: 1200px)');
46956
- var _c = React.useState(false),
46957
- initialFiltersSet = _c[0],
46958
- setInitialFiltersSet = _c[1];
46959
- var _d = React.useState([]),
46960
- initialFilters = _d[0],
46961
- setInitialFilters = _d[1];
46962
- var _e = React.useState(false),
46963
- filtersOpen = _e[0],
46964
- setFiltersOpen = _e[1];
47337
+ var _d = React.useState(false),
47338
+ initialFiltersSet = _d[0],
47339
+ setInitialFiltersSet = _d[1];
47340
+ var _e = React.useState([]),
47341
+ initialFilters = _e[0],
47342
+ setInitialFilters = _e[1];
46965
47343
  var _f = React.useState(false),
46966
- detailsIsLoading = _f[0],
46967
- setDetailsIsLoading = _f[1];
47344
+ filtersOpen = _f[0],
47345
+ setFiltersOpen = _f[1];
46968
47346
  var _g = React.useState(false),
46969
- itineraryOpen = _g[0],
46970
- setItineraryOpen = _g[1];
47347
+ detailsIsLoading = _g[0],
47348
+ setDetailsIsLoading = _g[1];
47349
+ var _h = React.useState(false),
47350
+ itineraryOpen = _h[0],
47351
+ setItineraryOpen = _h[1];
47352
+ var _j = React.useState(null),
47353
+ selectedAccommodationSeed = _j[0],
47354
+ setSelectedAccommodationSeed = _j[1];
46971
47355
  var panelRef = React.useRef(null);
46972
47356
  var sortByTypes = [
46973
47357
  { direction: 'asc', label: 'default' },
@@ -46983,109 +47367,44 @@ var SearchResultsContainer = function () {
46983
47367
  dispatch(setSortType(newSortByType));
46984
47368
  }
46985
47369
  };
46986
- var buildSearchFromEntry = function (entry) {
46987
- var _a;
46988
- var from = new Date(
46989
- Math.min.apply(
46990
- Math,
46991
- entry.items.map(function (i) {
46992
- return i.startDate.getTime();
46993
- })
46994
- )
46995
- ).toISOString();
46996
- var to = new Date(
46997
- Math.max.apply(
46998
- Math,
46999
- entry.items.map(function (i) {
47000
- return i.endDate.getTime();
47001
- })
47002
- )
47003
- ).toISOString();
47004
- var rooms = entry.rooms;
47005
- var hotelItem = entry.items.find(function (i) {
47006
- return i.productType === 3;
47007
- });
47008
- var country = hotelItem ? hotelItem.countryId : null;
47009
- var region = hotelItem ? hotelItem.regionId : null;
47010
- var oord = hotelItem ? hotelItem.oordId : null;
47011
- var city = hotelItem ? hotelItem.locationId : null;
47012
- var hotel = hotelItem ? hotelItem.productCode : null;
47013
- if (typeof window !== 'undefined') {
47014
- window.scrollTo(0, 0);
47015
- }
47016
- var destinationId = null;
47017
- var destinationIsCountry = false;
47018
- var destinationIsRegion = false;
47019
- var destinationIsOord = false;
47020
- var destinationIsLocation = false;
47021
- if (country) {
47022
- destinationId = country;
47023
- destinationIsCountry = true;
47024
- } else if (region) {
47025
- destinationId = region;
47026
- destinationIsRegion = true;
47027
- } else if (oord) {
47028
- destinationId = oord;
47029
- destinationIsOord = true;
47030
- } else if (city) {
47031
- destinationId = city;
47032
- destinationIsLocation = true;
47370
+ var getRequestRooms = function (rooms) {
47371
+ if (!rooms) {
47372
+ // Fall back to 2 adults
47373
+ var room = { index: 0, pax: [] };
47374
+ lodash.range(0, 2).forEach(function () {
47375
+ room.pax.push({
47376
+ age: 30
47377
+ });
47378
+ });
47379
+ return [room];
47033
47380
  }
47034
- var searchRequest = {
47035
- officeId: 1,
47036
- agentId: context === null || context === void 0 ? void 0 : context.agentId,
47037
- payload: {
47038
- catalogueIds: (_a = context.tideConnection.catalogueIds) !== null && _a !== void 0 ? _a : [],
47039
- serviceType:
47040
- context.searchConfiguration.qsmType === build.PortalQsmType.Accommodation ||
47041
- context.searchConfiguration.qsmType === build.PortalQsmType.AccommodationAndFlight
47042
- ? 3
47043
- : context.searchConfiguration.qsmType === build.PortalQsmType.Flight
47044
- ? 7
47045
- : context.searchConfiguration.qsmType === build.PortalQsmType.RoundTrip
47046
- ? 1
47047
- : 0,
47048
- searchType: 0,
47049
- destination: {
47050
- id: Number(destinationId),
47051
- isCountry: destinationIsCountry,
47052
- isRegion: destinationIsRegion,
47053
- isOord: destinationIsOord,
47054
- isLocation: destinationIsLocation
47055
- },
47056
- rooms: getRequestRoomsFromEntry(rooms),
47057
- fromDate: from,
47058
- toDate: to,
47059
- earliestFromOffset: 0,
47060
- latestToOffset: 0,
47061
- includeFlights: true,
47062
- regimeCodes:
47063
- entry.items.map(function (i) {
47064
- return i.regimeCode;
47065
- }) || [],
47066
- useExactDates: true,
47067
- onlyCachedResults: false,
47068
- includeAllAllotments: true,
47069
- productCodes: hotel ? [hotel] : []
47070
- }
47071
- };
47072
- return searchRequest;
47381
+ var requestRooms =
47382
+ rooms === null || rooms === void 0
47383
+ ? void 0
47384
+ : rooms.map(function (x, i) {
47385
+ var room = { index: i, pax: [] };
47386
+ lodash.range(0, x.adults).forEach(function () {
47387
+ room.pax.push({
47388
+ age: 30
47389
+ });
47390
+ });
47391
+ x.childAges.forEach(function (x) {
47392
+ room.pax.push({
47393
+ age: x
47394
+ });
47395
+ });
47396
+ return room;
47397
+ });
47398
+ return requestRooms;
47073
47399
  };
47074
- var buildSearchFromQueryParams = function (params) {
47400
+ var buildSearchFromSeed = function (seed) {
47075
47401
  var _a;
47076
- var from = getDateFromParams(params, 'fromDate');
47077
- var to = getDateFromParams(params, 'toDate');
47078
- var rooms = getRoomsFromParams(params, 'rooms');
47079
- var country = getNumberFromParams(params, 'country');
47080
- var region = getNumberFromParams(params, 'region');
47081
- var oord = getNumberFromParams(params, 'oord');
47082
- var city = getNumberFromParams(params, 'location');
47083
- var hotel = getNumberFromParams(params, 'hotel');
47084
- var tagId = getNumberFromParams(params, 'tagId');
47085
- if (!from || !to) {
47086
- console.error('Missing fromDate or toDate in query params, using default values');
47087
- return null;
47088
- }
47402
+ var country = seed.country;
47403
+ var region = seed.region;
47404
+ var oord = seed.oord;
47405
+ var city = seed.location;
47406
+ var hotel = seed.hotel;
47407
+ var tagId = seed.tagId;
47089
47408
  if (typeof window !== 'undefined') {
47090
47409
  window.scrollTo(0, 0);
47091
47410
  }
@@ -47107,7 +47426,7 @@ var SearchResultsContainer = function () {
47107
47426
  destinationId = city;
47108
47427
  destinationIsLocation = true;
47109
47428
  }
47110
- var searchRequest = {
47429
+ return {
47111
47430
  officeId: 1,
47112
47431
  agentId: context === null || context === void 0 ? void 0 : context.agentId,
47113
47432
  payload: {
@@ -47115,11 +47434,11 @@ var SearchResultsContainer = function () {
47115
47434
  serviceType:
47116
47435
  context.searchConfiguration.qsmType === build.PortalQsmType.Accommodation ||
47117
47436
  context.searchConfiguration.qsmType === build.PortalQsmType.AccommodationAndFlight
47118
- ? 3
47437
+ ? ACCOMMODATION_SERVICE_TYPE
47119
47438
  : context.searchConfiguration.qsmType === build.PortalQsmType.Flight
47120
- ? 7
47439
+ ? FLIGHT_SERVICE_TYPE
47121
47440
  : context.searchConfiguration.qsmType === build.PortalQsmType.RoundTrip
47122
- ? 1
47441
+ ? GROUP_TOUR_SERVICE_TYPE
47123
47442
  : undefined,
47124
47443
  searchType: context.searchConfiguration.qsmType === build.PortalQsmType.GroupTour ? 1 : 0,
47125
47444
  destination: {
@@ -47129,19 +47448,12 @@ var SearchResultsContainer = function () {
47129
47448
  isOord: destinationIsOord,
47130
47449
  isLocation: destinationIsLocation
47131
47450
  },
47132
- rooms: getRequestRooms(rooms),
47133
- fromDate: from,
47134
- toDate: to,
47451
+ rooms: seed.rooms,
47452
+ fromDate: seed.fromDate,
47453
+ toDate: seed.toDate,
47135
47454
  earliestFromOffset: 0,
47136
47455
  latestToOffset: 0,
47137
- includeFlights: context.searchConfiguration.qsmType === build.PortalQsmType.AccommodationAndFlight ? true : false,
47138
- // regimeCodes:
47139
- // filters
47140
- // .find((f) => f.property === 'regime')
47141
- // ?.options?.filter((o) => o.isChecked)
47142
- // .flatMap((o) => o.value.toString()) || [],
47143
- // minPrice: filters.find((f) => f.property === 'price')?.selectedMin,
47144
- // maxPrice: filters.find((f) => f.property === 'price')?.selectedMax,
47456
+ includeFlights: context.searchConfiguration.qsmType === build.PortalQsmType.AccommodationAndFlight,
47145
47457
  useExactDates: (context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.GroupTour ? false : true,
47146
47458
  onlyCachedResults: false,
47147
47459
  includeAllAllotments: true,
@@ -47149,82 +47461,16 @@ var SearchResultsContainer = function () {
47149
47461
  productTagIds: tagId ? [tagId] : []
47150
47462
  }
47151
47463
  };
47152
- console.log('Built search request from query params', searchRequest);
47153
- return searchRequest;
47154
47464
  };
47155
- var getRequestRoomsFromEntry = function (rooms) {
47156
- if (!rooms) {
47157
- // Fall back to 2 adults
47158
- var room = { index: 0, pax: [] };
47159
- lodash.range(0, 2).forEach(function () {
47160
- room.pax.push({
47161
- age: 30
47162
- });
47163
- });
47164
- return [room];
47165
- }
47166
- var requestRooms =
47167
- rooms === null || rooms === void 0
47168
- ? void 0
47169
- : rooms.map(function (x, i) {
47170
- var room = { index: i, pax: [] };
47171
- x.travellers.forEach(function (p) {
47172
- room.pax.push({
47173
- age: p.age,
47174
- dateOfBirth: p.dateOfBirth
47175
- });
47176
- });
47177
- return room;
47178
- });
47179
- return requestRooms;
47180
- };
47181
- var getRequestRooms = function (rooms) {
47182
- if (!rooms) {
47183
- // Fall back to 2 adults
47184
- var room = { index: 0, pax: [] };
47185
- lodash.range(0, 2).forEach(function () {
47186
- room.pax.push({
47187
- age: 30
47188
- });
47189
- });
47190
- return [room];
47191
- }
47192
- var requestRooms =
47193
- rooms === null || rooms === void 0
47194
- ? void 0
47195
- : rooms.map(function (x, i) {
47196
- var room = { index: i, pax: [] };
47197
- lodash.range(0, x.adults).forEach(function () {
47198
- room.pax.push({
47199
- age: 30
47200
- });
47201
- });
47202
- x.childAges.forEach(function (x) {
47203
- room.pax.push({
47204
- age: x
47205
- });
47206
- });
47207
- return room;
47208
- });
47209
- return requestRooms;
47210
- };
47211
- var buildPackagingAccommodationRequestFromQueryParams = function (params) {
47212
- var _a, _b;
47213
- var from = getDateFromParams(params, 'fromDate');
47214
- var to = getDateFromParams(params, 'toDate');
47215
- var rooms = getRoomsFromParams(params, 'rooms');
47216
- var country = getNumberFromParams(params, 'country');
47217
- var region = getNumberFromParams(params, 'region');
47218
- var oord = getNumberFromParams(params, 'oord');
47219
- var city = getNumberFromParams(params, 'location');
47220
- var hotel = getNumberFromParams(params, 'hotel');
47221
- var tagId = getNumberFromParams(params, 'tagId');
47222
- var agentId = getNumberFromParams(params, 'agentId');
47223
- var destinationAirport = getStringFromParams(params, 'destinationAirport');
47224
- if (!from || !to) {
47225
- console.error('Missing fromDate or toDate in query params, using default values');
47226
- return null;
47227
- }
47465
+ var buildPackagingAccommodationRequestFromSeed = function (seed, currentTransactionId) {
47466
+ var _a, _b, _c, _d;
47467
+ var country = seed.country;
47468
+ var region = seed.region;
47469
+ var oord = seed.oord;
47470
+ var city = seed.location;
47471
+ (_a = seed.hotelCode) !== null && _a !== void 0 ? _a : seed.hotel ? seed.hotel.toString() : '';
47472
+ var tagId = seed.tagId;
47473
+ var destinationAirport = seed.destinationAirport;
47228
47474
  if (typeof window !== 'undefined') {
47229
47475
  window.scrollTo(0, 0);
47230
47476
  }
@@ -47235,31 +47481,32 @@ var SearchResultsContainer = function () {
47235
47481
  var destinationIsLocation = false;
47236
47482
  var destinationCode = null;
47237
47483
  var destinationIsAirport = false;
47238
- if (country) {
47239
- destinationId = country;
47240
- destinationIsCountry = true;
47241
- } else if (region) {
47242
- destinationId = region;
47243
- destinationIsRegion = true;
47484
+ if (city) {
47485
+ destinationId = city;
47486
+ destinationIsLocation = true;
47244
47487
  } else if (oord) {
47245
47488
  destinationId = oord;
47246
47489
  destinationIsOord = true;
47247
- } else if (city) {
47248
- destinationId = city;
47249
- destinationIsLocation = true;
47490
+ } else if (region) {
47491
+ destinationId = region;
47492
+ destinationIsRegion = true;
47493
+ } else if (country) {
47494
+ destinationId = country;
47495
+ destinationIsCountry = true;
47250
47496
  } else if (destinationAirport) {
47251
47497
  destinationCode = destinationAirport;
47252
47498
  destinationIsAirport = true;
47253
47499
  }
47254
- var searchRequest = {
47500
+ return {
47501
+ transactionId: currentTransactionId,
47255
47502
  officeId: 1,
47256
- agentId: agentId !== null && agentId !== void 0 ? agentId : null,
47257
- catalogueId: (_a = context.searchConfiguration.defaultCatalogueId) !== null && _a !== void 0 ? _a : 0,
47503
+ agentId: (_b = context === null || context === void 0 ? void 0 : context.agentId) !== null && _b !== void 0 ? _b : null,
47504
+ catalogueId: (_c = context.searchConfiguration.defaultCatalogueId) !== null && _c !== void 0 ? _c : 0,
47258
47505
  searchConfigurationId: context.searchConfiguration.id,
47259
- language: (_b = context.languageCode) !== null && _b !== void 0 ? _b : 'en-GB',
47260
- servicesType: 3, // accommodation
47261
- fromDate: from,
47262
- toDate: to,
47506
+ language: (_d = context.languageCode) !== null && _d !== void 0 ? _d : 'en-GB',
47507
+ serviceType: ACCOMMODATION_SERVICE_TYPE,
47508
+ fromDate: seed.fromDate,
47509
+ toDate: seed.toDate,
47263
47510
  destination: {
47264
47511
  id: Number(destinationId),
47265
47512
  isCountry: destinationIsCountry,
@@ -47269,43 +47516,135 @@ var SearchResultsContainer = function () {
47269
47516
  isAirport: destinationIsAirport,
47270
47517
  code: destinationCode
47271
47518
  },
47272
- productCode: hotel ? hotel.toString() : '',
47273
- rooms: getPackagingRequestRooms(rooms),
47519
+ productCode: '',
47520
+ rooms: getPackagingRequestRoomsFromBookingRooms(seed.rooms),
47274
47521
  tagIds: tagId ? [tagId] : []
47275
47522
  };
47276
- console.log('Search request for packaging accommodation from query params', searchRequest);
47277
- return searchRequest;
47278
47523
  };
47279
- var getPackagingRequestRooms = function (rooms) {
47280
- if (!rooms) {
47281
- // Fall back to 2 adults
47282
- var room = { index: 0, travellers: [] };
47283
- lodash.range(0, 2).forEach(function () {
47284
- room.travellers.push({
47285
- age: 30
47286
- });
47287
- });
47288
- return [room];
47524
+ var buildSearchSeedFromQueryParams = function (params) {
47525
+ var from = getDateFromParams(params, 'fromDate');
47526
+ var to = getDateFromParams(params, 'toDate');
47527
+ var rooms = getRoomsFromParams(params, 'rooms');
47528
+ var country = getNumberFromParams(params, 'country');
47529
+ var region = getNumberFromParams(params, 'region');
47530
+ var oord = getNumberFromParams(params, 'oord');
47531
+ var city = getNumberFromParams(params, 'location');
47532
+ var hotel = getNumberFromParams(params, 'hotel');
47533
+ var tagId = getNumberFromParams(params, 'tagId');
47534
+ var destinationAirport = getStringFromParams(params, 'destinationAirport');
47535
+ var departureAirport = getStringFromParams(params, 'departureAirport');
47536
+ if (!from || !to) {
47537
+ return null;
47289
47538
  }
47290
- var requestRooms =
47291
- rooms === null || rooms === void 0
47539
+ return {
47540
+ fromDate: from,
47541
+ toDate: to,
47542
+ country: country,
47543
+ region: region,
47544
+ oord: oord,
47545
+ location: city,
47546
+ hotel: hotel,
47547
+ hotelCode: hotel ? hotel.toString() : null,
47548
+ tagId: tagId,
47549
+ destinationAirport: destinationAirport,
47550
+ departureAirport: departureAirport,
47551
+ rooms: getRequestRooms(rooms)
47552
+ };
47553
+ };
47554
+ var handleConfirmHotelSwap = function () {
47555
+ var updatedEntry = swapHotelInPackagingEntry();
47556
+ console.log('Updated entry after hotel swap', updatedEntry);
47557
+ if (!updatedEntry) return;
47558
+ dispatch(setEditablePackagingEntry(updatedEntry));
47559
+ handleFlyInToggle(false);
47560
+ };
47561
+ var swapHotelInPackagingEntry = function () {
47562
+ var sourceEntry =
47563
+ editablePackagingEntry !== null && editablePackagingEntry !== void 0
47564
+ ? editablePackagingEntry
47565
+ : context === null || context === void 0
47292
47566
  ? void 0
47293
- : rooms.map(function (x, i) {
47294
- var room = { index: i, travellers: [] };
47295
- lodash.range(0, x.adults).forEach(function () {
47296
- room.travellers.push({
47297
- age: 30
47298
- });
47299
- });
47300
- x.childAges.forEach(function (x) {
47301
- room.travellers.push({
47302
- age: x
47303
- });
47304
- });
47305
- return room;
47306
- });
47307
- return requestRooms;
47567
+ : context.packagingEntry;
47568
+ var details = packagingAccoSearchDetails;
47569
+ if (!sourceEntry || !(details === null || details === void 0 ? void 0 : details.length)) return null;
47570
+ var selectedOptionsPerRoom = getSelectedOptionsPerRoom(details);
47571
+ if (!selectedOptionsPerRoom.length) return null;
47572
+ var selectedHotel = details[0];
47573
+ var updatedLines = sourceEntry.lines.map(function (line) {
47574
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
47575
+ if (line.serviceType !== ACCOMMODATION_SERVICE_TYPE) {
47576
+ return line;
47577
+ }
47578
+ // TODO: fix roomIndex
47579
+ var roomIndex = getRoomIndexFromLine(line);
47580
+ console.log('Processing line', line, 'with room index', roomIndex);
47581
+ var selectedRoom = selectedOptionsPerRoom.find(function (x) {
47582
+ return x.roomIndex === roomIndex;
47583
+ });
47584
+ var selectedOption = selectedRoom === null || selectedRoom === void 0 ? void 0 : selectedRoom.option;
47585
+ if (!selectedOption) {
47586
+ return line;
47587
+ }
47588
+ return __assign(__assign({}, line), {
47589
+ guid: selectedOption.guid,
47590
+ productName: selectedHotel.name,
47591
+ productCode: selectedHotel.code,
47592
+ accommodationName: selectedOption.accommodationName,
47593
+ accommodationCode: selectedOption.accommodationCode,
47594
+ regimeName: selectedOption.regimeName,
47595
+ regimeCode: selectedOption.regimeCode,
47596
+ country: line.country
47597
+ ? __assign(__assign({}, line.country), {
47598
+ id: (_a = selectedHotel.countryId) !== null && _a !== void 0 ? _a : line.country.id,
47599
+ name: (_b = selectedHotel.countryName) !== null && _b !== void 0 ? _b : line.country.name
47600
+ })
47601
+ : selectedHotel.countryId
47602
+ ? { id: selectedHotel.countryId, name: selectedHotel.countryName, localizations: [] }
47603
+ : line.country,
47604
+ region: line.region
47605
+ ? __assign(__assign({}, line.region), {
47606
+ id: (_c = selectedHotel.regionId) !== null && _c !== void 0 ? _c : line.region.id,
47607
+ name: (_d = selectedHotel.regionName) !== null && _d !== void 0 ? _d : line.region.name
47608
+ })
47609
+ : selectedHotel.regionId
47610
+ ? { id: selectedHotel.regionId, name: selectedHotel.regionName, localizations: [] }
47611
+ : line.region,
47612
+ oord: line.oord
47613
+ ? __assign(__assign({}, line.oord), {
47614
+ id: (_e = selectedHotel.oordId) !== null && _e !== void 0 ? _e : line.oord.id,
47615
+ name: (_f = selectedHotel.oordName) !== null && _f !== void 0 ? _f : line.oord.name
47616
+ })
47617
+ : selectedHotel.oordId
47618
+ ? { id: selectedHotel.oordId, name: selectedHotel.oordName, localizations: [] }
47619
+ : line.oord,
47620
+ location: line.location
47621
+ ? __assign(__assign({}, line.location), {
47622
+ id: (_g = selectedHotel.locationId) !== null && _g !== void 0 ? _g : line.location.id,
47623
+ name: (_h = selectedHotel.locationName) !== null && _h !== void 0 ? _h : line.location.name
47624
+ })
47625
+ : selectedHotel.locationId
47626
+ ? { id: selectedHotel.locationId, name: selectedHotel.locationName, localizations: [] }
47627
+ : line.location,
47628
+ latitude: (_j = selectedHotel.latitude) !== null && _j !== void 0 ? _j : line.latitude,
47629
+ longitude: (_k = selectedHotel.longitude) !== null && _k !== void 0 ? _k : line.longitude,
47630
+ from: (_l = selectedHotel.fromDate) !== null && _l !== void 0 ? _l : line.from,
47631
+ to: (_m = selectedHotel.toDate) !== null && _m !== void 0 ? _m : line.to,
47632
+ isChanged: true
47633
+ });
47634
+ });
47635
+ return __assign(__assign({}, sourceEntry), { lines: updatedLines });
47308
47636
  };
47637
+ var activeSearchSeed = React__default['default'].useMemo(
47638
+ function () {
47639
+ if (selectedAccommodationSeed) {
47640
+ return selectedAccommodationSeed;
47641
+ }
47642
+ if (typeof window === 'undefined') return null;
47643
+ var params = new URLSearchParams(window.location.search);
47644
+ return buildSearchSeedFromQueryParams(params);
47645
+ },
47646
+ [selectedAccommodationSeed, currentSearch]
47647
+ );
47309
47648
  React.useEffect(
47310
47649
  function () {
47311
47650
  if (typeof document !== 'undefined') {
@@ -47314,189 +47653,232 @@ var SearchResultsContainer = function () {
47314
47653
  },
47315
47654
  [filtersOpen]
47316
47655
  );
47317
- // seperate Search
47318
- React.useEffect(
47319
- function () {
47320
- var runSearch = function () {
47321
- return __awaiter(void 0, void 0, void 0, function () {
47322
- var config, params, entryId, entryLight, searchRequest, rq, packageSearchResults, enrichedFilters, initialFilteredResults, matching, err_1;
47323
- var _a;
47324
- return __generator(this, function (_b) {
47325
- switch (_b.label) {
47326
- case 0:
47327
- dispatch(setIsLoading(true));
47328
- _b.label = 1;
47329
- case 1:
47330
- _b.trys.push([1, 6, , 7]);
47331
- if (!context) {
47332
- return [2 /*return*/];
47333
- }
47334
- config = {
47335
- host: context.tideConnection.host,
47336
- apiKey: context.tideConnection.apiKey
47337
- };
47338
- params = new URLSearchParams(location.search);
47339
- entryId = getStringFromParams(params, 'entryId');
47340
- entryLight = null;
47341
- searchRequest = void 0;
47342
- if (!entryId) return [3 /*break*/, 3];
47343
- return [4 /*yield*/, build.getEntryLight(config, entryId)];
47344
- case 2:
47345
- entryLight = _b.sent();
47346
- // populate itinerary store
47347
- dispatch(setEntry({ entry: entryLight }));
47348
- searchRequest = buildSearchFromEntry(entryLight);
47349
- return [3 /*break*/, 4];
47350
- case 3:
47351
- rq = buildSearchFromQueryParams(params);
47352
- if (!rq) {
47353
- throw new Error('Invalid search parameters');
47354
- }
47355
- searchRequest = rq;
47356
- _b.label = 4;
47357
- case 4:
47358
- return [4 /*yield*/, build.search(config, searchRequest)];
47359
- case 5:
47360
- packageSearchResults = _b.sent();
47361
- console.log('Search results', packageSearchResults);
47362
- enrichedFilters = enrichFiltersWithResults(packageSearchResults, context.filters, (_a = context.tags) !== null && _a !== void 0 ? _a : []);
47363
- if (!initialFiltersSet) {
47364
- dispatch(resetFilters(enrichedFilters));
47365
- setInitialFilters(enrichedFilters);
47366
- setInitialFiltersSet(true);
47367
- }
47368
- dispatch(setResults(packageSearchResults));
47369
- initialFilteredResults = applyFilters(packageSearchResults, filters, null);
47370
- dispatch(setFilteredResults(initialFilteredResults));
47371
- if ((packageSearchResults === null || packageSearchResults === void 0 ? void 0 : packageSearchResults.length) > 0) {
47372
- if (entryId) {
47373
- matching = packageSearchResults.find(function (r) {
47374
- return r.productId === (entry === null || entry === void 0 ? void 0 : entry.id);
47375
- });
47376
- if (matching) {
47377
- dispatch(setSelectedSearchResult(matching));
47378
- }
47379
- } else {
47380
- if (context.searchConfiguration.qsmType === build.PortalQsmType.AccommodationAndFlight) {
47381
- dispatch(setSelectedSearchResult(packageSearchResults[0]));
47382
- }
47383
- }
47384
- }
47385
- dispatch(setIsLoading(false));
47386
- return [3 /*break*/, 7];
47387
- case 6:
47388
- err_1 = _b.sent();
47389
- console.error('Search failed', err_1);
47390
- dispatch(setIsLoading(false));
47391
- return [3 /*break*/, 7];
47392
- case 7:
47393
- return [2 /*return*/];
47656
+ var runSearch = function () {
47657
+ return __awaiter(void 0, void 0, void 0, function () {
47658
+ var config, seed, searchRequest, packageSearchResults, enrichedFilters, initialFilteredResults, err_1;
47659
+ var _a;
47660
+ return __generator(this, function (_b) {
47661
+ switch (_b.label) {
47662
+ case 0:
47663
+ _b.trys.push([0, 2, 3, 4]);
47664
+ if (!context) return [2 /*return*/];
47665
+ dispatch(setIsLoading(true));
47666
+ config = {
47667
+ host: context.tideConnection.host,
47668
+ apiKey: context.tideConnection.apiKey
47669
+ };
47670
+ seed = activeSearchSeed;
47671
+ if (!seed) {
47672
+ throw new Error('Invalid search parameters');
47394
47673
  }
47395
- });
47396
- });
47397
- };
47398
- var runHotelSearch = function () {
47399
- return __awaiter(void 0, void 0, void 0, function () {
47400
- var config, params, searchRequest, rq, packageAccoSearchResults, enrichedFilters, initialFilteredResults, err_2;
47401
- var _a;
47402
- return __generator(this, function (_b) {
47403
- switch (_b.label) {
47404
- case 0:
47405
- dispatch(setIsLoading(true));
47406
- _b.label = 1;
47407
- case 1:
47408
- _b.trys.push([1, 3, , 4]);
47409
- if (!context) {
47410
- return [2 /*return*/];
47411
- }
47412
- config = {
47413
- host: context.tideConnection.host,
47414
- apiKey: context.tideConnection.apiKey
47415
- };
47416
- params = new URLSearchParams(location.search);
47417
- searchRequest = void 0;
47418
- rq = buildPackagingAccommodationRequestFromQueryParams(params);
47419
- if (!rq) {
47420
- throw new Error('Invalid search parameters');
47421
- }
47422
- searchRequest = rq;
47423
- searchRequest.portalId = context.portalId;
47424
- searchRequest.agentId = context.agentId;
47425
- return [4 /*yield*/, build.searchPackagingAccommodations(config, searchRequest)];
47426
- case 2:
47427
- packageAccoSearchResults = _b.sent();
47428
- console.log('package Acco SearchResults', packageAccoSearchResults);
47429
- enrichedFilters = enrichFiltersWithPackageAccoResults(
47430
- packageAccoSearchResults,
47431
- context.filters,
47432
- (_a = context.tags) !== null && _a !== void 0 ? _a : []
47433
- );
47434
- if (!initialFiltersSet) {
47435
- dispatch(resetFilters(enrichedFilters));
47436
- setInitialFilters(enrichedFilters);
47437
- setInitialFiltersSet(true);
47438
- }
47439
- dispatch(setPackagingAccoResults(packageAccoSearchResults));
47440
- initialFilteredResults = applyFiltersToPackageAccoResults(packageAccoSearchResults, filters, null);
47441
- dispatch(setFilteredPackagingAccoResults(initialFilteredResults));
47442
- dispatch(setIsLoading(false));
47443
- return [3 /*break*/, 4];
47444
- case 3:
47445
- err_2 = _b.sent();
47446
- console.error('Search failed', err_2);
47447
- dispatch(setIsLoading(false));
47448
- return [3 /*break*/, 4];
47449
- case 4:
47450
- return [2 /*return*/];
47674
+ searchRequest = buildSearchFromSeed(seed);
47675
+ return [4 /*yield*/, build.search(config, searchRequest)];
47676
+ case 1:
47677
+ packageSearchResults = _b.sent();
47678
+ console.log('Search results', packageSearchResults);
47679
+ enrichedFilters = enrichFiltersWithResults(packageSearchResults, context.filters, (_a = context.tags) !== null && _a !== void 0 ? _a : []);
47680
+ if (!initialFiltersSet) {
47681
+ dispatch(resetFilters(enrichedFilters));
47682
+ setInitialFilters(enrichedFilters);
47683
+ setInitialFiltersSet(true);
47451
47684
  }
47452
- });
47453
- });
47454
- };
47455
- if (!(context === null || context === void 0 ? void 0 : context.showMockup)) {
47456
- if (
47457
- (context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.GroupTour ||
47458
- ((context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.AccommodationAndFlight &&
47459
- !context.searchConfiguration.enableManualPackaging)
47460
- ) {
47461
- runSearch();
47685
+ dispatch(setResults(packageSearchResults));
47686
+ initialFilteredResults = applyFilters(packageSearchResults, filters, null);
47687
+ dispatch(setFilteredResults(initialFilteredResults));
47688
+ if ((packageSearchResults === null || packageSearchResults === void 0 ? void 0 : packageSearchResults.length) > 0) {
47689
+ if (context.searchConfiguration.qsmType === build.PortalQsmType.AccommodationAndFlight) {
47690
+ dispatch(setSelectedSearchResult(packageSearchResults[0]));
47691
+ }
47692
+ }
47693
+ return [3 /*break*/, 4];
47694
+ case 2:
47695
+ err_1 = _b.sent();
47696
+ console.error('Search failed', err_1);
47697
+ return [3 /*break*/, 4];
47698
+ case 3:
47699
+ dispatch(setIsLoading(false));
47700
+ return [7 /*endfinally*/];
47701
+ case 4:
47702
+ return [2 /*return*/];
47462
47703
  }
47463
- if ((context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.Accommodation) {
47464
- runHotelSearch();
47704
+ });
47705
+ });
47706
+ };
47707
+ var runStartTransaction = function () {
47708
+ return __awaiter(void 0, void 0, void 0, function () {
47709
+ var config, transaction, err_2;
47710
+ return __generator(this, function (_a) {
47711
+ switch (_a.label) {
47712
+ case 0:
47713
+ _a.trys.push([0, 2, , 3]);
47714
+ if (!context) return [2 /*return*/, null];
47715
+ config = {
47716
+ host: context.tideConnection.host,
47717
+ apiKey: context.tideConnection.apiKey
47718
+ };
47719
+ return [4 /*yield*/, build.startTransaction(config)];
47720
+ case 1:
47721
+ transaction = _a.sent();
47722
+ console.log('Transaction started', transaction);
47723
+ dispatch(setTransactionId(transaction.transactionId));
47724
+ return [2 /*return*/, transaction.transactionId];
47725
+ case 2:
47726
+ err_2 = _a.sent();
47727
+ console.error('Transaction failed', err_2);
47728
+ return [2 /*return*/, null];
47729
+ case 3:
47730
+ return [2 /*return*/];
47465
47731
  }
47466
- if (
47467
- (context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.AccommodationAndFlight &&
47468
- context.searchConfiguration.enableManualPackaging
47469
- ) {
47470
- // Manual packaging flow.
47471
- if (context.searchConfiguration.allowAccommodations) {
47472
- runHotelSearch();
47473
- }
47732
+ });
47733
+ });
47734
+ };
47735
+ var runHotelSearch = function (currentTransactionId, seed) {
47736
+ return __awaiter(void 0, void 0, void 0, function () {
47737
+ var config, searchRequest, packageAccoSearchResults, enrichedFilters, initialFilteredResults, err_3;
47738
+ var _a;
47739
+ return __generator(this, function (_b) {
47740
+ switch (_b.label) {
47741
+ case 0:
47742
+ _b.trys.push([0, 2, , 3]);
47743
+ if (!context) return [2 /*return*/];
47744
+ dispatch(setIsLoading(true));
47745
+ config = {
47746
+ host: context.tideConnection.host,
47747
+ apiKey: context.tideConnection.apiKey
47748
+ };
47749
+ searchRequest = buildPackagingAccommodationRequestFromSeed(seed, currentTransactionId);
47750
+ searchRequest.portalId = context.portalId;
47751
+ searchRequest.agentId = context.agentId;
47752
+ console.log('Packaging accommodation search request', searchRequest);
47753
+ return [4 /*yield*/, build.searchPackagingAccommodations(config, searchRequest)];
47754
+ case 1:
47755
+ packageAccoSearchResults = _b.sent();
47756
+ enrichedFilters = enrichFiltersWithPackageAccoResults(
47757
+ packageAccoSearchResults,
47758
+ context.filters,
47759
+ (_a = context.tags) !== null && _a !== void 0 ? _a : []
47760
+ );
47761
+ if (!initialFiltersSet) {
47762
+ dispatch(resetFilters(enrichedFilters));
47763
+ setInitialFilters(enrichedFilters);
47764
+ setInitialFiltersSet(true);
47765
+ }
47766
+ dispatch(setPackagingAccoResults(packageAccoSearchResults));
47767
+ initialFilteredResults = applyFiltersToPackageAccoResults(packageAccoSearchResults, filters, null);
47768
+ dispatch(setFilteredPackagingAccoResults(initialFilteredResults));
47769
+ dispatch(setIsLoading(false));
47770
+ return [3 /*break*/, 3];
47771
+ case 2:
47772
+ err_3 = _b.sent();
47773
+ console.error('Search failed', err_3);
47774
+ dispatch(setIsLoading(false));
47775
+ return [3 /*break*/, 3];
47776
+ case 3:
47777
+ return [2 /*return*/];
47778
+ }
47779
+ });
47780
+ });
47781
+ };
47782
+ var runAccommodationFlow = function (seed) {
47783
+ return __awaiter(void 0, void 0, void 0, function () {
47784
+ var currentTransactionId;
47785
+ var _a;
47786
+ return __generator(this, function (_b) {
47787
+ switch (_b.label) {
47788
+ case 0:
47789
+ if (!context || context.showMockup) return [2 /*return*/];
47790
+ currentTransactionId =
47791
+ ((_a = context === null || context === void 0 ? void 0 : context.packagingEntry) === null || _a === void 0 ? void 0 : _a.transactionId) ||
47792
+ transactionId;
47793
+ console.log('Current transaction ID', currentTransactionId);
47794
+ if (!!currentTransactionId) return [3 /*break*/, 2];
47795
+ dispatch(setIsLoading(true));
47796
+ return [4 /*yield*/, runStartTransaction()];
47797
+ case 1:
47798
+ currentTransactionId = _b.sent();
47799
+ _b.label = 2;
47800
+ case 2:
47801
+ if (!currentTransactionId) {
47802
+ dispatch(setIsLoading(false));
47803
+ return [2 /*return*/];
47804
+ }
47805
+ return [4 /*yield*/, runHotelSearch(currentTransactionId, seed)];
47806
+ case 3:
47807
+ _b.sent();
47808
+ return [2 /*return*/];
47809
+ }
47810
+ });
47811
+ });
47812
+ };
47813
+ // separate Search
47814
+ React.useEffect(
47815
+ function () {
47816
+ if (
47817
+ (context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.GroupTour ||
47818
+ ((context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.AccommodationAndFlight &&
47819
+ !context.searchConfiguration.enableManualPackaging)
47820
+ ) {
47821
+ runSearch();
47822
+ }
47823
+ if ((context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.Accommodation) {
47824
+ var seed = activeSearchSeed;
47825
+ if (seed) {
47826
+ runAccommodationFlow(seed);
47827
+ }
47828
+ }
47829
+ if (
47830
+ (context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.AccommodationAndFlight &&
47831
+ context.searchConfiguration.enableManualPackaging &&
47832
+ context.searchConfiguration.allowAccommodations &&
47833
+ !(context === null || context === void 0 ? void 0 : context.packagingEntry)
47834
+ ) {
47835
+ var seed = activeSearchSeed;
47836
+ if (seed) {
47837
+ runAccommodationFlow(seed);
47474
47838
  }
47475
47839
  }
47476
47840
  },
47477
- [location.search]
47841
+ [
47842
+ location.search,
47843
+ context === null || context === void 0 ? void 0 : context.showMockup,
47844
+ context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType,
47845
+ context === null || context === void 0 ? void 0 : context.searchConfiguration.enableManualPackaging,
47846
+ context === null || context === void 0 ? void 0 : context.searchConfiguration.allowAccommodations,
47847
+ (_b = context === null || context === void 0 ? void 0 : context.packagingEntry) === null || _b === void 0 ? void 0 : _b.transactionId,
47848
+ activeSearchSeed
47849
+ ]
47478
47850
  );
47479
- // Seperate detailsCall
47851
+ React.useEffect(
47852
+ function () {
47853
+ if (context === null || context === void 0 ? void 0 : context.packagingEntry) {
47854
+ console.log('original packaging entry from context', context.packagingEntry);
47855
+ dispatch(setEditablePackagingEntry(structuredClone(context.packagingEntry)));
47856
+ dispatch(setTransactionId(context.packagingEntry.transactionId));
47857
+ }
47858
+ },
47859
+ [context === null || context === void 0 ? void 0 : context.packagingEntry]
47860
+ );
47861
+ // separate detailsCall
47480
47862
  React.useEffect(
47481
47863
  function () {
47482
47864
  var fetchDetails = function () {
47483
47865
  return __awaiter(void 0, void 0, void 0, function () {
47484
- var config, selectedItem, params, entryId, requestRooms, rooms, detailsRequest, detailsResponse, detailsResponse, err_3;
47485
- return __generator(this, function (_a) {
47486
- switch (_a.label) {
47866
+ var config, selectedItem, requestRooms, seed, detailsRequest, detailsResponse, err_4;
47867
+ var _a;
47868
+ return __generator(this, function (_b) {
47869
+ switch (_b.label) {
47487
47870
  case 0:
47488
- setDetailsIsLoading(true);
47489
- console.log('Fetching details for selected search result', selectedSearchResult);
47490
47871
  if (!selectedSearchResult || !context) return [2 /*return*/];
47872
+ setDetailsIsLoading(true);
47491
47873
  if (
47492
47874
  (context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.Accommodation ||
47493
47875
  (context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.GroupTour
47494
47876
  ) {
47495
47877
  handleFlyInToggle(true);
47496
47878
  }
47497
- _a.label = 1;
47879
+ _b.label = 1;
47498
47880
  case 1:
47499
- _a.trys.push([1, 6, , 7]);
47881
+ _b.trys.push([1, 3, , 4]);
47500
47882
  config = {
47501
47883
  host: context.tideConnection.host,
47502
47884
  apiKey: context.tideConnection.apiKey
@@ -47508,14 +47890,14 @@ var SearchResultsContainer = function () {
47508
47890
  // TODO: handle this case better, show an error message to the user
47509
47891
  return [2 /*return*/];
47510
47892
  }
47511
- params = new URLSearchParams(location.search);
47512
- entryId = getStringFromParams(params, 'entryId');
47513
47893
  requestRooms = void 0;
47514
- if (entry && entryId) {
47515
- requestRooms = getRequestRoomsFromEntry(entry.rooms);
47894
+ if (context === null || context === void 0 ? void 0 : context.packagingEntry) {
47895
+ requestRooms = getRequestRoomsFromPackagingEntry(context.packagingEntry);
47516
47896
  } else {
47517
- rooms = getRoomsFromParams(params, 'rooms');
47518
- requestRooms = getRequestRooms(rooms);
47897
+ seed = activeSearchSeed;
47898
+ requestRooms = ((_a = seed === null || seed === void 0 ? void 0 : seed.rooms) === null || _a === void 0 ? void 0 : _a.length)
47899
+ ? seed.rooms
47900
+ : getRequestRooms(null);
47519
47901
  }
47520
47902
  detailsRequest = {
47521
47903
  officeId: 1,
@@ -47537,29 +47919,18 @@ var SearchResultsContainer = function () {
47537
47919
  },
47538
47920
  agentId: context.agentId
47539
47921
  };
47540
- if (!(entry && entryId)) return [3 /*break*/, 3];
47541
- requestRooms = getRequestRoomsFromEntry(entry.rooms);
47542
47922
  return [4 /*yield*/, build.details(config, detailsRequest)];
47543
47923
  case 2:
47544
- detailsResponse = _a.sent();
47545
- console.log('Details:', detailsResponse);
47546
- dispatch(setBookingPackageDetails({ details: detailsResponse === null || detailsResponse === void 0 ? void 0 : detailsResponse.payload }));
47547
- return [3 /*break*/, 5];
47548
- case 3:
47549
- return [4 /*yield*/, build.details(config, detailsRequest)];
47550
- case 4:
47551
- detailsResponse = _a.sent();
47924
+ detailsResponse = _b.sent();
47552
47925
  dispatch(setBookingPackageDetails({ details: detailsResponse === null || detailsResponse === void 0 ? void 0 : detailsResponse.payload }));
47553
47926
  setDetailsIsLoading(false);
47554
- _a.label = 5;
47555
- case 5:
47556
- return [3 /*break*/, 7];
47557
- case 6:
47558
- err_3 = _a.sent();
47559
- console.error('Failed to fetch package details', err_3);
47927
+ return [3 /*break*/, 4];
47928
+ case 3:
47929
+ err_4 = _b.sent();
47930
+ console.error('Failed to fetch package details', err_4);
47560
47931
  setDetailsIsLoading(false);
47561
- return [3 /*break*/, 7];
47562
- case 7:
47932
+ return [3 /*break*/, 4];
47933
+ case 4:
47563
47934
  return [2 /*return*/];
47564
47935
  }
47565
47936
  });
@@ -47569,8 +47940,7 @@ var SearchResultsContainer = function () {
47569
47940
  return __awaiter(void 0, void 0, void 0, function () {
47570
47941
  var config,
47571
47942
  selectedItem,
47572
- params,
47573
- rooms,
47943
+ seed,
47574
47944
  tagId,
47575
47945
  destinationAirport,
47576
47946
  destinationId,
@@ -47582,38 +47952,37 @@ var SearchResultsContainer = function () {
47582
47952
  destinationIsAirport,
47583
47953
  detailSearchRequest,
47584
47954
  packageAccoSearchDetails,
47585
- err_4;
47586
- var _a, _b;
47587
- return __generator(this, function (_c) {
47588
- switch (_c.label) {
47955
+ err_5;
47956
+ var _a, _b, _c, _d, _e;
47957
+ return __generator(this, function (_f) {
47958
+ switch (_f.label) {
47589
47959
  case 0:
47590
47960
  if (!selectedPackagingAccoResultCode || !context) return [2 /*return*/];
47961
+ setDetailsIsLoading(true);
47591
47962
  if (
47592
47963
  (context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.Accommodation ||
47964
+ (context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.AccommodationAndFlight ||
47593
47965
  (context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.GroupTour
47594
47966
  ) {
47595
47967
  handleFlyInToggle(true);
47596
47968
  }
47597
- _c.label = 1;
47969
+ _f.label = 1;
47598
47970
  case 1:
47599
- _c.trys.push([1, 3, , 4]);
47971
+ _f.trys.push([1, 3, , 4]);
47600
47972
  config = {
47601
47973
  host: context.tideConnection.host,
47602
47974
  apiKey: context.tideConnection.apiKey
47603
47975
  };
47604
- console.log('selectedPackagingAccoResultCode', selectedPackagingAccoResultCode);
47605
47976
  selectedItem = packagingAccoResults.find(function (r) {
47606
47977
  return r.code === selectedPackagingAccoResultCode;
47607
47978
  });
47608
- console.log('Selected packaging acco item', selectedItem);
47609
47979
  if (!selectedItem) {
47610
47980
  // TODO: handle this case better, show an error message to the user
47611
47981
  return [2 /*return*/];
47612
47982
  }
47613
- params = new URLSearchParams(location.search);
47614
- rooms = getRoomsFromParams(params, 'rooms');
47615
- tagId = getNumberFromParams(params, 'tagId');
47616
- destinationAirport = getStringFromParams(params, 'destinationAirport');
47983
+ seed = activeSearchSeed;
47984
+ tagId = (_a = seed === null || seed === void 0 ? void 0 : seed.tagId) !== null && _a !== void 0 ? _a : null;
47985
+ destinationAirport = (_b = seed === null || seed === void 0 ? void 0 : seed.destinationAirport) !== null && _b !== void 0 ? _b : null;
47617
47986
  destinationId = null;
47618
47987
  destinationIsCountry = false;
47619
47988
  destinationIsRegion = false;
@@ -47638,14 +48007,15 @@ var SearchResultsContainer = function () {
47638
48007
  destinationIsAirport = true;
47639
48008
  }
47640
48009
  detailSearchRequest = {
48010
+ transactionId: transactionId !== null && transactionId !== void 0 ? transactionId : '',
47641
48011
  officeId: 1,
47642
48012
  portalId: context.portalId,
47643
48013
  agentId: context.agentId,
47644
- catalogueId: (_a = context.searchConfiguration.defaultCatalogueId) !== null && _a !== void 0 ? _a : 0,
48014
+ catalogueId: (_c = context.searchConfiguration.defaultCatalogueId) !== null && _c !== void 0 ? _c : 0,
47645
48015
  searchConfigurationId: context.searchConfiguration.id,
47646
48016
  vendorConfigurationId: selectedItem.vendorId,
47647
- language: (_b = context.languageCode) !== null && _b !== void 0 ? _b : 'en-GB',
47648
- serviceType: 3,
48017
+ language: (_d = context.languageCode) !== null && _d !== void 0 ? _d : 'en-GB',
48018
+ serviceType: ACCOMMODATION_SERVICE_TYPE,
47649
48019
  fromDate: selectedItem.fromDate,
47650
48020
  toDate: selectedItem.toDate,
47651
48021
  destination: {
@@ -47658,18 +48028,22 @@ var SearchResultsContainer = function () {
47658
48028
  code: destinationCode
47659
48029
  },
47660
48030
  productCode: selectedItem.code ? selectedItem.code : '',
47661
- rooms: getPackagingRequestRooms(rooms),
48031
+ rooms: getPackagingRequestRoomsFromBookingRooms(
48032
+ (_e = seed === null || seed === void 0 ? void 0 : seed.rooms) !== null && _e !== void 0 ? _e : null
48033
+ ),
47662
48034
  tagIds: tagId ? [tagId] : []
47663
48035
  };
47664
48036
  return [4 /*yield*/, build.searchPackagingAccommodations(config, detailSearchRequest)];
47665
48037
  case 2:
47666
- packageAccoSearchDetails = _c.sent();
48038
+ packageAccoSearchDetails = _f.sent();
47667
48039
  console.log('Packaging Acco Search details', packageAccoSearchDetails);
47668
48040
  dispatch(setPackagingAccoSearchDetails(packageAccoSearchDetails));
48041
+ setDetailsIsLoading(false);
47669
48042
  return [3 /*break*/, 4];
47670
48043
  case 3:
47671
- err_4 = _c.sent();
47672
- console.error('Failed to fetch package details', err_4);
48044
+ err_5 = _f.sent();
48045
+ console.error('Failed to fetch package details', err_5);
48046
+ setDetailsIsLoading(false);
47673
48047
  return [3 /*break*/, 4];
47674
48048
  case 4:
47675
48049
  return [2 /*return*/];
@@ -47683,6 +48057,7 @@ var SearchResultsContainer = function () {
47683
48057
  if (selectedPackagingAccoResultCode) {
47684
48058
  fetchPackagingAccoSearchDetails();
47685
48059
  }
48060
+ dispatch(setAccommodationFlyInStep('details'));
47686
48061
  },
47687
48062
  [selectedSearchResult, selectedPackagingAccoResultCode]
47688
48063
  );
@@ -47698,6 +48073,64 @@ var SearchResultsContainer = function () {
47698
48073
  },
47699
48074
  [filters, results, packagingAccoResults, selectedSortType]
47700
48075
  );
48076
+ React.useEffect(
48077
+ function () {
48078
+ setInitialFiltersSet(false);
48079
+ },
48080
+ [activeSearchSeed]
48081
+ );
48082
+ var handleEditAccommodation = function (segments) {
48083
+ return __awaiter(void 0, void 0, void 0, function () {
48084
+ var sourceEntry, seed;
48085
+ return __generator(this, function (_a) {
48086
+ switch (_a.label) {
48087
+ case 0:
48088
+ sourceEntry =
48089
+ editablePackagingEntry !== null && editablePackagingEntry !== void 0
48090
+ ? editablePackagingEntry
48091
+ : context === null || context === void 0
48092
+ ? void 0
48093
+ : context.packagingEntry;
48094
+ if (!sourceEntry) return [2 /*return*/];
48095
+ seed = buildSearchSeedFromAccommodationSegments(sourceEntry, segments);
48096
+ if (!seed) return [2 /*return*/];
48097
+ setDetailsIsLoading(true);
48098
+ setSelectedAccommodationSeed(seed);
48099
+ dispatch(setAccommodationFlyInStep('results'));
48100
+ handleFlyInToggle(true);
48101
+ return [4 /*yield*/, runAccommodationFlow(seed)];
48102
+ case 1:
48103
+ _a.sent();
48104
+ setDetailsIsLoading(false);
48105
+ return [2 /*return*/];
48106
+ }
48107
+ });
48108
+ });
48109
+ };
48110
+ var buildSearchSeedFromAccommodationSegments = function (entry, segments) {
48111
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
48112
+ if (!(segments === null || segments === void 0 ? void 0 : segments.length)) return null;
48113
+ var sortedSegments = __spreadArray([], segments, true).sort(function (a, b) {
48114
+ return new Date(a.from).getTime() - new Date(b.from).getTime();
48115
+ });
48116
+ var firstSegment = lodash.first(sortedSegments);
48117
+ var lastSegment = lodash.last(sortedSegments);
48118
+ if (!firstSegment || !lastSegment) return null;
48119
+ return {
48120
+ fromDate: toDateOnlyString(firstSegment.from),
48121
+ toDate: toDateOnlyString(lastSegment.to),
48122
+ country: (_b = (_a = firstSegment.country) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : null,
48123
+ region: (_d = (_c = firstSegment.region) === null || _c === void 0 ? void 0 : _c.id) !== null && _d !== void 0 ? _d : null,
48124
+ oord: (_f = (_e = firstSegment.oord) === null || _e === void 0 ? void 0 : _e.id) !== null && _f !== void 0 ? _f : null,
48125
+ location: (_h = (_g = firstSegment.location) === null || _g === void 0 ? void 0 : _g.id) !== null && _h !== void 0 ? _h : null,
48126
+ hotel: parseHotelId(firstSegment),
48127
+ hotelCode: (_j = firstSegment.productCode) !== null && _j !== void 0 ? _j : null,
48128
+ tagId: null,
48129
+ destinationAirport: getDestinationAirportFromEntry((_k = entry.lines) !== null && _k !== void 0 ? _k : []),
48130
+ departureAirport: getDepartureAirportFromEntry((_l = entry.lines) !== null && _l !== void 0 ? _l : []),
48131
+ rooms: getRequestRoomsFromPackagingSegments(entry, sortedSegments)
48132
+ };
48133
+ };
47701
48134
  return React__default['default'].createElement(
47702
48135
  'div',
47703
48136
  { id: 'tide-booking', className: 'search__bg' },
@@ -47749,7 +48182,8 @@ var SearchResultsContainer = function () {
47749
48182
  handleSetIsOpen: function () {
47750
48183
  return setItineraryOpen(!itineraryOpen);
47751
48184
  },
47752
- isLoading: isLoading
48185
+ isLoading: isLoading,
48186
+ onEditAccommodation: handleEditAccommodation
47753
48187
  }),
47754
48188
  React__default['default'].createElement(
47755
48189
  'div',
@@ -47814,6 +48248,7 @@ var SearchResultsContainer = function () {
47814
48248
  'span',
47815
48249
  { className: 'search__result-row-text' },
47816
48250
  !isLoading &&
48251
+ !context.packagingEntry &&
47817
48252
  React__default['default'].createElement(
47818
48253
  React__default['default'].Fragment,
47819
48254
  null,
@@ -47829,7 +48264,8 @@ var SearchResultsContainer = function () {
47829
48264
  translations.SRP.TOTAL_RESULTS_LABEL
47830
48265
  )
47831
48266
  ),
47832
- !isMobile &&
48267
+ !context.packagingEntry &&
48268
+ !isMobile &&
47833
48269
  sortByTypes &&
47834
48270
  sortByTypes.length > 0 &&
47835
48271
  React__default['default'].createElement(
@@ -47857,25 +48293,35 @@ var SearchResultsContainer = function () {
47857
48293
  React__default['default'].createElement(
47858
48294
  'div',
47859
48295
  { className: 'search__results__wrapper' },
47860
- context.showTabViews && React__default['default'].createElement(TabViews, null),
48296
+ context.showTabViews &&
48297
+ (context.searchConfiguration.qsmType === build.PortalQsmType.GroupTour ||
48298
+ context.searchConfiguration.qsmType === build.PortalQsmType.Accommodation) &&
48299
+ React__default['default'].createElement(TabViews, null),
47861
48300
  context.showRoundTripResults && context.showMockup && React__default['default'].createElement(RoundTripResults, null),
47862
48301
  context.searchConfiguration.qsmType === build.PortalQsmType.GroupTour &&
47863
48302
  React__default['default'].createElement(GroupTourResults, { isLoading: isLoading }),
47864
48303
  context.searchConfiguration.qsmType === build.PortalQsmType.AccommodationAndFlight &&
48304
+ !context.packagingEntry &&
47865
48305
  context.showFlightResults &&
47866
48306
  (bookingPackageDetails === null || bookingPackageDetails === void 0 ? void 0 : bookingPackageDetails.outwardFlights) &&
47867
48307
  React__default['default'].createElement(FlightResults, {
47868
48308
  flights: bookingPackageDetails === null || bookingPackageDetails === void 0 ? void 0 : bookingPackageDetails.outwardFlights,
47869
48309
  isDeparture: true
47870
48310
  }),
47871
- context.showHotelAccommodationResults && React__default['default'].createElement(HotelAccommodationResults, { isLoading: isLoading }),
48311
+ context.showHotelAccommodationResults &&
48312
+ !context.packagingEntry &&
48313
+ React__default['default'].createElement(HotelAccommodationResults, { isLoading: isLoading }),
47872
48314
  context.searchConfiguration.qsmType === build.PortalQsmType.AccommodationAndFlight &&
48315
+ !context.packagingEntry &&
47873
48316
  context.showFlightResults &&
47874
48317
  (bookingPackageDetails === null || bookingPackageDetails === void 0 ? void 0 : bookingPackageDetails.returnFlights) &&
47875
48318
  React__default['default'].createElement(FlightResults, {
47876
48319
  flights: bookingPackageDetails === null || bookingPackageDetails === void 0 ? void 0 : bookingPackageDetails.returnFlights,
47877
48320
  isDeparture: false
47878
- })
48321
+ }),
48322
+ context.searchConfiguration.qsmType === build.PortalQsmType.AccommodationAndFlight &&
48323
+ context.packagingEntry &&
48324
+ React__default['default'].createElement('span', null, 'TODO: Show Full Itinerary here')
47879
48325
  )
47880
48326
  ),
47881
48327
  React__default['default'].createElement(FlyIn, {
@@ -47883,10 +48329,15 @@ var SearchResultsContainer = function () {
47883
48329
  srpType: context.searchConfiguration.qsmType,
47884
48330
  isOpen: flyInIsOpen,
47885
48331
  setIsOpen: handleFlyInToggle,
48332
+ handleConfirm: function () {
48333
+ return handleConfirmHotelSwap();
48334
+ },
47886
48335
  onPanelRef: function (el) {
47887
48336
  return (panelRef.current = el);
47888
48337
  },
47889
- detailsLoading: detailsIsLoading
48338
+ detailsLoading: detailsIsLoading,
48339
+ accommodationStep: accommodationFlyInStep,
48340
+ isPackageEditFlow: !!context.packagingEntry
47890
48341
  })
47891
48342
  )
47892
48343
  )