@qite/tide-booking-component 1.4.98 → 1.4.100

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/build/build-cjs/index.js +1183 -669
  2. package/build/build-cjs/src/search-results/components/itinerary/index.d.ts +2 -0
  3. package/build/build-cjs/src/search-results/store/search-results-slice.d.ts +11 -10
  4. package/build/build-cjs/src/search-results/types.d.ts +23 -1
  5. package/build/build-cjs/src/search-results/utils/packaging-utils.d.ts +7 -0
  6. package/build/build-cjs/src/search-results/utils/query-utils.d.ts +11 -0
  7. package/build/build-cjs/src/shared/components/flyin/accommodation-flyin.d.ts +1 -2
  8. package/build/build-cjs/src/shared/components/flyin/flyin.d.ts +4 -0
  9. package/build/build-cjs/src/shared/utils/localization-util.d.ts +1 -0
  10. package/build/build-esm/index.js +1183 -669
  11. package/build/build-esm/src/search-results/components/itinerary/index.d.ts +2 -0
  12. package/build/build-esm/src/search-results/store/search-results-slice.d.ts +11 -10
  13. package/build/build-esm/src/search-results/types.d.ts +23 -1
  14. package/build/build-esm/src/search-results/utils/packaging-utils.d.ts +7 -0
  15. package/build/build-esm/src/search-results/utils/query-utils.d.ts +11 -0
  16. package/build/build-esm/src/shared/components/flyin/accommodation-flyin.d.ts +1 -2
  17. package/build/build-esm/src/shared/components/flyin/flyin.d.ts +4 -0
  18. package/build/build-esm/src/shared/utils/localization-util.d.ts +1 -0
  19. package/package.json +2 -2
  20. package/src/qsm/components/search-input-group/index.tsx +0 -1
  21. package/src/search-results/components/itinerary/index.tsx +150 -81
  22. package/src/search-results/components/search-results-container/search-results-container.tsx +463 -384
  23. package/src/search-results/store/search-results-slice.ts +28 -10
  24. package/src/search-results/types.ts +25 -1
  25. package/src/search-results/utils/packaging-utils.ts +75 -0
  26. package/src/search-results/utils/query-utils.ts +152 -0
  27. package/src/shared/components/flyin/accommodation-flyin.tsx +10 -11
  28. package/src/shared/components/flyin/flyin.tsx +52 -4
  29. package/styles/components/_flyin.scss +25 -0
  30. package/styles/components/_search.scss +26 -1
@@ -12791,7 +12791,7 @@ PERFORMANCE OF THIS SOFTWARE.
12791
12791
  return ENDPOINT$8 + '/details/' + transactionId + '/alternate-flights';
12792
12792
  };
12793
12793
  var ENDPOINT_BOOKABLE_DATES = ENDPOINT$8 + '/bookable-dates';
12794
- var ENDPOINT_PRICE_DETAILS = ENDPOINT$8 + '/price-details';
12794
+ var ENDPOINT_PRICE_DETAILS$1 = ENDPOINT$8 + '/price-details';
12795
12795
  var ENDPOINT_BOOK = ENDPOINT$8 + '/book';
12796
12796
  var ENDPOINT_UPDATE = ENDPOINT$8 + '/update';
12797
12797
  var ENDPOINT_AGENTS = ENDPOINT$8 + '/agents';
@@ -12891,7 +12891,7 @@ PERFORMANCE OF THIS SOFTWARE.
12891
12891
  return post(url, apiKey, body, config.token, signal, true);
12892
12892
  };
12893
12893
  var priceDetails = function (config, request, signal, languageCode) {
12894
- var url = '' + config.host + ENDPOINT_PRICE_DETAILS;
12894
+ var url = '' + config.host + ENDPOINT_PRICE_DETAILS$1;
12895
12895
  var apiKey = config.apiKey;
12896
12896
  var body = JSON.stringify(request);
12897
12897
  return post(url, apiKey, body, config.token, signal, true, languageCode);
@@ -13415,11 +13415,18 @@ 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';
13420
+ var ENDPOINT_PRICE_DETAILS = ENDPOINT + '/price-details';
13419
13421
  var ENDPOINT_ENTRY = function (magicLinkCode) {
13420
13422
  return ENDPOINT + '/entry/' + magicLinkCode;
13421
13423
  };
13422
13424
  // MANUAL PACKAGING SEARCH
13425
+ var startTransaction = function (config, signal) {
13426
+ var apiKey = config.apiKey;
13427
+ var url = '' + config.host + ENDPOINT_START_TRANSACTION;
13428
+ return get(url, apiKey, config.token, signal, true);
13429
+ };
13423
13430
  var searchPackagingAccommodations = function (config, request, signal) {
13424
13431
  var url = '' + config.host + ENDPOINT_ACCOMMODATIONS;
13425
13432
  var apiKey = config.apiKey;
@@ -13431,6 +13438,12 @@ PERFORMANCE OF THIS SOFTWARE.
13431
13438
  var url = '' + config.host + ENDPOINT_ENTRY(magicLinkCode);
13432
13439
  return get(url, apiKey, config.token, signal, true);
13433
13440
  };
13441
+ var getPriceDetails = function (config, request, signal) {
13442
+ var url = '' + config.host + ENDPOINT_PRICE_DETAILS;
13443
+ var apiKey = config.apiKey;
13444
+ var body = JSON.stringify(request);
13445
+ return post(url, apiKey, body, config.token, signal, true);
13446
+ };
13434
13447
 
13435
13448
  exports.AllotmentType = AllotmentType;
13436
13449
  exports.ContactForm = ContactForm;
@@ -13486,6 +13499,7 @@ PERFORMANCE OF THIS SOFTWARE.
13486
13499
  exports.getLocations = getLocations;
13487
13500
  exports.getMolliePayment = getMolliePayment;
13488
13501
  exports.getPortal = getPortal;
13502
+ exports.getPriceDetails = getPriceDetails;
13489
13503
  exports.getPrintActions = getPrintActions;
13490
13504
  exports.getStyleSheet = getStyleSheet;
13491
13505
  exports.getTranslationDictionary = getTranslationDictionary;
@@ -13507,6 +13521,7 @@ PERFORMANCE OF THIS SOFTWARE.
13507
13521
  exports.searchWithErrorMapping = searchWithErrorMapping;
13508
13522
  exports.setCustomEntryStatus = setCustomEntryStatus;
13509
13523
  exports.setEntryStatus = setEntryStatus;
13524
+ exports.startTransaction = startTransaction;
13510
13525
  exports.tourCodes = tourCodes;
13511
13526
  exports.transportDates = transportDates;
13512
13527
  exports.update = update;
@@ -32836,7 +32851,6 @@ var SearchInputGroup = function (_a) {
32836
32851
  );
32837
32852
  React.useEffect(
32838
32853
  function () {
32839
- console.log('options updated, resetting loading state');
32840
32854
  setIsLoading(false);
32841
32855
  },
32842
32856
  [options]
@@ -33798,13 +33812,16 @@ var initialState$1 = {
33798
33812
  selectedFlight: null,
33799
33813
  selectedFlightDetails: null,
33800
33814
  bookingPackageDetails: null,
33801
- entry: null,
33802
33815
  isLoading: false,
33803
33816
  filters: [],
33804
33817
  selectedSortType: null,
33805
33818
  activeTab: 'compact',
33806
33819
  currentPage: 1,
33807
- flyInIsOpen: false
33820
+ flyInIsOpen: false,
33821
+ editablePackagingEntry: null,
33822
+ transactionId: null,
33823
+ accommodationFlyInStep: 'details',
33824
+ priceDetails: null
33808
33825
  };
33809
33826
  var searchResultsSlice = toolkit.createSlice({
33810
33827
  name: 'searchResults',
@@ -33840,9 +33857,6 @@ var searchResultsSlice = toolkit.createSlice({
33840
33857
  setBookingPackageDetails: function (state, action) {
33841
33858
  state.bookingPackageDetails = action.payload.details;
33842
33859
  },
33843
- setEntry: function (state, action) {
33844
- state.entry = action.payload.entry;
33845
- },
33846
33860
  selectFlight: function (state, action) {
33847
33861
  if (!state.bookingPackageDetails) return;
33848
33862
  var _a = action.payload,
@@ -33891,6 +33905,18 @@ var searchResultsSlice = toolkit.createSlice({
33891
33905
  },
33892
33906
  setFlyInIsOpen: function (state, action) {
33893
33907
  state.flyInIsOpen = action.payload;
33908
+ },
33909
+ setEditablePackagingEntry: function (state, action) {
33910
+ state.editablePackagingEntry = action.payload;
33911
+ },
33912
+ setTransactionId: function (state, action) {
33913
+ state.transactionId = action.payload;
33914
+ },
33915
+ setAccommodationFlyInStep: function (state, action) {
33916
+ state.accommodationFlyInStep = action.payload;
33917
+ },
33918
+ setPriceDetails: function (state, action) {
33919
+ state.priceDetails = action.payload;
33894
33920
  }
33895
33921
  }
33896
33922
  });
@@ -33904,7 +33930,6 @@ var setResults = ((_a = searchResultsSlice.actions), _a.setResults),
33904
33930
  setSelectedFlight = _a.setSelectedFlight,
33905
33931
  setSelectedFlightDetails = _a.setSelectedFlightDetails,
33906
33932
  setBookingPackageDetails = _a.setBookingPackageDetails,
33907
- setEntry = _a.setEntry,
33908
33933
  selectFlight = _a.selectFlight,
33909
33934
  setIsLoading = _a.setIsLoading,
33910
33935
  setFilters = _a.setFilters,
@@ -33913,7 +33938,11 @@ var setResults = ((_a = searchResultsSlice.actions), _a.setResults),
33913
33938
  setActiveTab = _a.setActiveTab;
33914
33939
  _a.setCurrentPage;
33915
33940
  _a.resetSearchState;
33916
- var setFlyInIsOpen = _a.setFlyInIsOpen;
33941
+ var setFlyInIsOpen = _a.setFlyInIsOpen,
33942
+ setEditablePackagingEntry = _a.setEditablePackagingEntry,
33943
+ setTransactionId = _a.setTransactionId,
33944
+ setAccommodationFlyInStep = _a.setAccommodationFlyInStep,
33945
+ setPriceDetails = _a.setPriceDetails;
33917
33946
  var searchResultsReducer = searchResultsSlice.reducer;
33918
33947
 
33919
33948
  var ItemPicker = function (_a) {
@@ -34942,8 +34971,160 @@ var Icon$1 = function (_a) {
34942
34971
  }
34943
34972
  };
34944
34973
 
34945
- var FLIGHT_SERVICE_TYPE = 7;
34974
+ var GROUP_TOUR_SERVICE_TYPE = 1;
34946
34975
  var ACCOMMODATION_SERVICE_TYPE = 3;
34976
+ var FLIGHT_SERVICE_TYPE = 7;
34977
+ var toDateOnlyString = function (value) {
34978
+ var date = value instanceof Date ? value : new Date(value);
34979
+ return date.toISOString().split('T')[0];
34980
+ };
34981
+ var getAgeAtReferenceDate = function (dateOfBirth, referenceDate) {
34982
+ var dob = dateOfBirth instanceof Date ? dateOfBirth : new Date(dateOfBirth);
34983
+ var ref = referenceDate instanceof Date ? referenceDate : new Date(referenceDate);
34984
+ var age = ref.getFullYear() - dob.getFullYear();
34985
+ var monthDiff = ref.getMonth() - dob.getMonth();
34986
+ if (monthDiff < 0 || (monthDiff === 0 && ref.getDate() < dob.getDate())) {
34987
+ age--;
34988
+ }
34989
+ return age;
34990
+ };
34991
+ var getFlightLines$1 = function (lines) {
34992
+ return __spreadArray([], lines, true)
34993
+ .filter(function (line) {
34994
+ return line.serviceType === FLIGHT_SERVICE_TYPE;
34995
+ })
34996
+ .sort(function (a, b) {
34997
+ return new Date(a.from).getTime() - new Date(b.from).getTime();
34998
+ });
34999
+ };
35000
+ var getDepartureAirportFromEntry = function (lines) {
35001
+ var _a, _b, _c;
35002
+ var firstFlight = getFlightLines$1(lines)[0];
35003
+ var firstSegment =
35004
+ (_b =
35005
+ (_a = firstFlight === null || firstFlight === void 0 ? void 0 : firstFlight.flightInformation) === null || _a === void 0 ? void 0 : _a.flightLines) ===
35006
+ null || _b === void 0
35007
+ ? void 0
35008
+ : _b[0];
35009
+ return (_c = firstSegment === null || firstSegment === void 0 ? void 0 : firstSegment.departureAirportCode) !== null && _c !== void 0 ? _c : null;
35010
+ };
35011
+ var getDestinationAirportFromEntry = function (lines) {
35012
+ var _a, _b, _c;
35013
+ var outboundFlight = getFlightLines$1(lines)[0];
35014
+ var flightSegments =
35015
+ (_a = outboundFlight === null || outboundFlight === void 0 ? void 0 : outboundFlight.flightInformation) === null || _a === void 0 ? void 0 : _a.flightLines;
35016
+ if (!(flightSegments === null || flightSegments === void 0 ? void 0 : flightSegments.length)) return null;
35017
+ return (_c = (_b = flightSegments[flightSegments.length - 1]) === null || _b === void 0 ? void 0 : _b.arrivalAirportCode) !== null && _c !== void 0
35018
+ ? _c
35019
+ : null;
35020
+ };
35021
+ var mapPackagingPaxToBookingPax = function (pax, fallbackId, referenceDate) {
35022
+ var _a, _b, _c, _d, _e, _f;
35023
+ return {
35024
+ id: (_a = pax === null || pax === void 0 ? void 0 : pax.id) !== null && _a !== void 0 ? _a : fallbackId,
35025
+ guid:
35026
+ (_c = (_b = pax === null || pax === void 0 ? void 0 : pax.id) === null || _b === void 0 ? void 0 : _b.toString()) !== null && _c !== void 0
35027
+ ? _c
35028
+ : fallbackId.toString(),
35029
+ firstName: (_d = pax === null || pax === void 0 ? void 0 : pax.firstName) !== null && _d !== void 0 ? _d : '',
35030
+ lastName: (_e = pax === null || pax === void 0 ? void 0 : pax.lastName) !== null && _e !== void 0 ? _e : '',
35031
+ dateOfBirth: (_f = pax === null || pax === void 0 ? void 0 : pax.dateOfBirth) !== null && _f !== void 0 ? _f : undefined,
35032
+ age: (pax === null || pax === void 0 ? void 0 : pax.dateOfBirth) ? getAgeAtReferenceDate(pax.dateOfBirth, referenceDate) : undefined,
35033
+ isMainBooker: pax === null || pax === void 0 ? void 0 : pax.isMainBooker,
35034
+ email: ''
35035
+ };
35036
+ };
35037
+ var getRequestRoomsFromPackagingEntry = function (entry) {
35038
+ var _a, _b, _c, _d;
35039
+ var accommodationLines = ((_a = entry.lines) !== null && _a !== void 0 ? _a : []).filter(function (line) {
35040
+ var _a;
35041
+ return line.serviceType === ACCOMMODATION_SERVICE_TYPE && ((_a = line.pax) === null || _a === void 0 ? void 0 : _a.length) > 0;
35042
+ });
35043
+ var paxById = new Map(
35044
+ ((_b = entry.pax) !== null && _b !== void 0 ? _b : []).map(function (p) {
35045
+ return [p.id, p];
35046
+ })
35047
+ );
35048
+ if (!accommodationLines.length) {
35049
+ return [
35050
+ {
35051
+ index: 0,
35052
+ pax: ((_c = entry.pax) !== null && _c !== void 0 ? _c : []).map(function (p) {
35053
+ return mapPackagingPaxToBookingPax(p, p.id, new Date().toISOString());
35054
+ })
35055
+ }
35056
+ ];
35057
+ }
35058
+ var roomGroups = [];
35059
+ accommodationLines.forEach(function (line) {
35060
+ var groupedByRoom = new Map();
35061
+ line.pax.forEach(function (linePax) {
35062
+ var _a;
35063
+ var roomIndexWithinLine = Number((_a = linePax.room) !== null && _a !== void 0 ? _a : 0);
35064
+ var paxId = Number(linePax.paxId);
35065
+ var pax = mapPackagingPaxToBookingPax(paxById.get(paxId), paxId, line.from);
35066
+ if (!groupedByRoom.has(roomIndexWithinLine)) {
35067
+ groupedByRoom.set(roomIndexWithinLine, []);
35068
+ }
35069
+ groupedByRoom.get(roomIndexWithinLine).push(pax);
35070
+ });
35071
+ var sortedGroups = Array.from(groupedByRoom.entries())
35072
+ .sort(function (_a, _b) {
35073
+ var a = _a[0];
35074
+ var b = _b[0];
35075
+ return a - b;
35076
+ })
35077
+ .map(function (_a) {
35078
+ var pax = _a[1];
35079
+ return pax;
35080
+ });
35081
+ roomGroups.push.apply(roomGroups, sortedGroups);
35082
+ });
35083
+ if (!roomGroups.length) {
35084
+ return [
35085
+ {
35086
+ index: 0,
35087
+ pax: ((_d = entry.pax) !== null && _d !== void 0 ? _d : []).map(function (p) {
35088
+ return mapPackagingPaxToBookingPax(p, p.id, accommodationLines[0].from);
35089
+ })
35090
+ }
35091
+ ];
35092
+ }
35093
+ return roomGroups.map(function (pax, index) {
35094
+ return {
35095
+ index: index,
35096
+ pax: pax
35097
+ };
35098
+ });
35099
+ };
35100
+ var parseHotelId = function (line) {
35101
+ if (!(line === null || line === void 0 ? void 0 : line.productCode)) return null;
35102
+ var parsed = Number(line.productCode);
35103
+ return Number.isNaN(parsed) ? null : parsed;
35104
+ };
35105
+ var getPackagingRequestRoomsFromBookingRooms = function (rooms) {
35106
+ if (!(rooms === null || rooms === void 0 ? void 0 : rooms.length)) {
35107
+ var room_1 = { index: 0, travellers: [] };
35108
+ lodash.range(0, 2).forEach(function () {
35109
+ room_1.travellers.push({
35110
+ age: 30
35111
+ });
35112
+ });
35113
+ return [room_1];
35114
+ }
35115
+ return rooms.map(function (x, i) {
35116
+ var _a;
35117
+ var room = { index: (_a = x.index) !== null && _a !== void 0 ? _a : i, travellers: [] };
35118
+ x.pax.forEach(function (p) {
35119
+ var _a;
35120
+ room.travellers.push({
35121
+ age: (_a = p.age) !== null && _a !== void 0 ? _a : 30
35122
+ });
35123
+ });
35124
+ return room;
35125
+ });
35126
+ };
35127
+
34947
35128
  var getFlightLines = function (flight) {
34948
35129
  var _a, _b;
34949
35130
  return (_b = (_a = flight === null || flight === void 0 ? void 0 : flight.flightInformation) === null || _a === void 0 ? void 0 : _a.flightLines) !== null &&
@@ -34981,31 +35162,68 @@ var numberOfNights = function (segment) {
34981
35162
  var getSegmentIcon = function (segment) {
34982
35163
  switch (segment.serviceType) {
34983
35164
  case 3:
34984
- return React__default['default'].createElement(Icon$1, { name: 'ui-bed', width: 15, height: 15 });
35165
+ return React__default['default'].createElement(
35166
+ 'div',
35167
+ { className: 'search__filter__itinerary__segment-badge search__filter__itinerary__segment-badge--secondary' },
35168
+ React__default['default'].createElement(Icon$1, { name: 'ui-bed', width: 15, height: 15 })
35169
+ );
34985
35170
  case 4:
34986
- return React__default['default'].createElement(Icon$1, { name: 'ui-ticket', width: 15, height: 15 });
35171
+ return React__default['default'].createElement(
35172
+ 'div',
35173
+ { className: 'search__filter__itinerary__segment-badge search__filter__itinerary__segment-badge--secondary' },
35174
+ React__default['default'].createElement(Icon$1, { name: 'ui-ticket', width: 15, height: 15 })
35175
+ );
34987
35176
  case 11:
34988
- return React__default['default'].createElement(Icon$1, { name: 'ui-ship', width: 15, height: 15 });
35177
+ return React__default['default'].createElement(
35178
+ 'div',
35179
+ { className: 'search__filter__itinerary__segment-badge search__filter__itinerary__segment-badge--secondary' },
35180
+ React__default['default'].createElement(Icon$1, { name: 'ui-ship', width: 15, height: 15 })
35181
+ );
34989
35182
  case 13:
34990
35183
  case 17:
34991
35184
  case 22:
34992
- return React__default['default'].createElement(Icon$1, { name: 'ui-car', width: 15, height: 15 });
35185
+ return React__default['default'].createElement(
35186
+ 'div',
35187
+ { className: 'search__filter__itinerary__transport-badge' },
35188
+ React__default['default'].createElement(Icon$1, { name: 'ui-car', width: 15, height: 15 })
35189
+ );
34993
35190
  default:
34994
- return React__default['default'].createElement(Icon$1, { name: 'ui-location', width: 15, height: 15 });
35191
+ return React__default['default'].createElement(
35192
+ 'div',
35193
+ { className: 'search__filter__itinerary__segment-badge' },
35194
+ React__default['default'].createElement(Icon$1, { name: 'ui-location', width: 15, height: 15 })
35195
+ );
34995
35196
  }
34996
35197
  };
35198
+ var canEdit = function (segment) {
35199
+ if (segment.serviceType === ACCOMMODATION_SERVICE_TYPE) {
35200
+ return true;
35201
+ }
35202
+ return false;
35203
+ };
34997
35204
  var getSegmentTitle = function (segment) {
34998
- if (segment.accommodationName) return segment.accommodationName;
34999
- return segment.productName;
35205
+ var _a;
35206
+ return (_a = segment.productName) !== null && _a !== void 0 ? _a : segment.accommodationName;
35000
35207
  };
35001
35208
  var Itinerary = function (_a) {
35002
35209
  var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
35003
35210
  var isOpen = _a.isOpen,
35004
- handleSetIsOpen = _a.handleSetIsOpen;
35005
- _a.isLoading;
35211
+ handleSetIsOpen = _a.handleSetIsOpen,
35212
+ isLoading = _a.isLoading,
35213
+ onEditAccommodation = _a.onEditAccommodation;
35006
35214
  var context = React.useContext(SearchResultsConfigurationContext);
35007
35215
  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;
35216
+ var _q = reactRedux.useSelector(function (state) {
35217
+ return state.searchResults;
35218
+ }),
35219
+ editablePackagingEntry = _q.editablePackagingEntry,
35220
+ priceDetails = _q.priceDetails;
35221
+ var packagingEntry =
35222
+ editablePackagingEntry !== null && editablePackagingEntry !== void 0
35223
+ ? editablePackagingEntry
35224
+ : context === null || context === void 0
35225
+ ? void 0
35226
+ : context.packagingEntry;
35009
35227
  var sortedLines = React.useMemo(
35010
35228
  function () {
35011
35229
  var _a;
@@ -35073,9 +35291,21 @@ var Itinerary = function (_a) {
35073
35291
  var otherSegments = sortedLines.filter(function (item) {
35074
35292
  return item.serviceType !== FLIGHT_SERVICE_TYPE;
35075
35293
  });
35076
- console.log('other segments', otherSegments);
35294
+ var grouped = lodash.groupBy(otherSegments, function (segment) {
35295
+ return ''.concat(segment.productCode, '-').concat(segment.from, '-').concat(segment.to);
35296
+ });
35297
+ var groupedOtherSegments = Object.entries(grouped).map(function (_a) {
35298
+ var key = _a[0],
35299
+ segments = _a[1];
35300
+ return {
35301
+ key: key,
35302
+ segments: segments
35303
+ };
35304
+ });
35305
+ console.log('otherSegments', otherSegments);
35306
+ console.log('groupedOtherSegments', groupedOtherSegments);
35077
35307
  var numberOfPax = ((_p = packagingEntry.pax) === null || _p === void 0 ? void 0 : _p.length) || 1;
35078
- var totalPrice = packagingEntry.price || 0;
35308
+ var totalPrice = (priceDetails === null || priceDetails === void 0 ? void 0 : priceDetails.total) || packagingEntry.price || 0;
35079
35309
  var pricePerPerson = totalPrice / numberOfPax;
35080
35310
  return React__default['default'].createElement(
35081
35311
  'div',
@@ -35131,18 +35361,24 @@ var Itinerary = function (_a) {
35131
35361
  React__default['default'].createElement(
35132
35362
  'div',
35133
35363
  { className: 'search__filter__prices' },
35134
- React__default['default'].createElement(
35135
- 'div',
35136
- { className: 'search__filter__prices__wrapper' },
35137
- React__default['default'].createElement('h3', { className: 'search__filter__prices--amount' }, formatPrice$2(pricePerPerson, 'EUR')),
35138
- React__default['default'].createElement('p', null, translations.SRP.PACKAGE_PRICE_PER_PERSON),
35139
- React__default['default'].createElement(
35140
- 'p',
35141
- null,
35142
- React__default['default'].createElement('strong', null, '(', formatPrice$2(totalPrice, 'EUR'), ' ', translations.SRP.TOTAL, ')')
35143
- )
35144
- ),
35145
- React__default['default'].createElement('button', { className: 'cta' }, translations.QSM.CONFIRM)
35364
+ isLoading
35365
+ ? React__default['default'].createElement(Spinner, null)
35366
+ : React__default['default'].createElement(
35367
+ React__default['default'].Fragment,
35368
+ null,
35369
+ React__default['default'].createElement(
35370
+ 'div',
35371
+ { className: 'search__filter__prices__wrapper' },
35372
+ React__default['default'].createElement('h3', { className: 'search__filter__prices--amount' }, formatPrice$2(pricePerPerson, 'EUR')),
35373
+ React__default['default'].createElement('p', null, translations.SRP.PACKAGE_PRICE_PER_PERSON),
35374
+ React__default['default'].createElement(
35375
+ 'p',
35376
+ null,
35377
+ React__default['default'].createElement('strong', null, '(', formatPrice$2(totalPrice, 'EUR'), ' ', translations.SRP.TOTAL, ')')
35378
+ )
35379
+ ),
35380
+ React__default['default'].createElement('button', { className: 'cta' }, translations.QSM.CONFIRM)
35381
+ )
35146
35382
  ),
35147
35383
  React__default['default'].createElement(
35148
35384
  'div',
@@ -35164,8 +35400,7 @@ var Itinerary = function (_a) {
35164
35400
  'p',
35165
35401
  null,
35166
35402
  dateFns.format(new Date(firstEntryLine.from), 'EEE. d MMM yyyy'),
35167
- ' -',
35168
- ' ',
35403
+ ' - ',
35169
35404
  React__default['default'].createElement('strong', null, translations.SRP.START)
35170
35405
  )
35171
35406
  )
@@ -35236,15 +35471,17 @@ var Itinerary = function (_a) {
35236
35471
  )
35237
35472
  )
35238
35473
  ),
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(
35474
+ !lodash.isEmpty(groupedOtherSegments) &&
35475
+ groupedOtherSegments.map(function (group) {
35476
+ var _a, _b, _c, _d, _e, _f, _g, _h;
35477
+ var firstSegment = lodash.first(group.segments);
35478
+ if (!firstSegment) return null;
35479
+ return React__default['default'].createElement(
35480
+ 'div',
35481
+ { className: 'search__filter__itinerary__segments' },
35482
+ React__default['default'].createElement(
35246
35483
  'div',
35247
- { className: 'search__filter__itinerary__segments__wrapper', key: 'segment-'.concat(index) },
35484
+ { className: 'search__filter__itinerary__segments__wrapper', key: group.key },
35248
35485
  React__default['default'].createElement(
35249
35486
  'div',
35250
35487
  { className: 'search__filter__itinerary__segments-timeline' },
@@ -35262,9 +35499,9 @@ var Itinerary = function (_a) {
35262
35499
  React__default['default'].createElement(
35263
35500
  'p',
35264
35501
  { className: 'search__filter__itinerary__transport-date-date' },
35265
- React__default['default'].createElement('strong', null, dateFns.format(new Date(segment.from), 'd'))
35502
+ React__default['default'].createElement('strong', null, dateFns.format(new Date(firstSegment.from), 'd'))
35266
35503
  ),
35267
- React__default['default'].createElement('p', null, dateFns.format(new Date(segment.from), 'MMM'))
35504
+ React__default['default'].createElement('p', null, dateFns.format(new Date(firstSegment.from), 'MMM'))
35268
35505
  ),
35269
35506
  React__default['default'].createElement(
35270
35507
  'div',
@@ -35277,23 +35514,23 @@ var Itinerary = function (_a) {
35277
35514
  React__default['default'].createElement(
35278
35515
  'h6',
35279
35516
  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)
35517
+ ((_a = firstSegment.location) === null || _a === void 0 ? void 0 : _a.name) ||
35518
+ ((_b = firstSegment.oord) === null || _b === void 0 ? void 0 : _b.name) ||
35519
+ ((_c = firstSegment.region) === null || _c === void 0 ? void 0 : _c.name),
35520
+ (((_d = firstSegment.location) === null || _d === void 0 ? void 0 : _d.name) ||
35521
+ ((_e = firstSegment.oord) === null || _e === void 0 ? void 0 : _e.name) ||
35522
+ ((_f = firstSegment.region) === null || _f === void 0 ? void 0 : _f.name)) &&
35523
+ ((_g = firstSegment.country) === null || _g === void 0 ? void 0 : _g.name)
35287
35524
  ? ', '
35288
35525
  : '',
35289
- (_h = segment.country) === null || _h === void 0 ? void 0 : _h.name
35526
+ (_h = firstSegment.country) === null || _h === void 0 ? void 0 : _h.name
35290
35527
  ),
35291
35528
  React__default['default'].createElement(
35292
35529
  'p',
35293
35530
  { className: 'search__filter__itinerary__segment-details-text' },
35294
- dateFns.format(new Date(segment.from), 'EEE. d MMM yyyy'),
35531
+ dateFns.format(new Date(firstSegment.from), 'EEE. d MMM yyyy'),
35295
35532
  '> ',
35296
- dateFns.format(new Date(segment.to), 'EEE. d MMM yyyy')
35533
+ dateFns.format(new Date(firstSegment.to), 'EEE. d MMM yyyy')
35297
35534
  )
35298
35535
  )
35299
35536
  )
@@ -35303,38 +35540,65 @@ var Itinerary = function (_a) {
35303
35540
  { className: 'search__filter__itinerary__segment' },
35304
35541
  React__default['default'].createElement(
35305
35542
  'div',
35306
- { className: 'search__filter__itinerary__segment-item' },
35543
+ {
35544
+ className: 'search__filter__itinerary__segment-item '.concat(
35545
+ canEdit(firstSegment) ? 'search__filter__itinerary__segment-item--editable' : ''
35546
+ ),
35547
+ onClick: function () {
35548
+ if (canEdit(firstSegment) && onEditAccommodation) {
35549
+ onEditAccommodation(group.segments);
35550
+ }
35551
+ }
35552
+ },
35307
35553
  React__default['default'].createElement(
35308
35554
  'div',
35309
35555
  { className: 'search__filter__itinerary__segment-date search__filter__itinerary__segment-nights' },
35310
- segment.serviceType === ACCOMMODATION_SERVICE_TYPE &&
35556
+ firstSegment.serviceType === ACCOMMODATION_SERVICE_TYPE &&
35311
35557
  React__default['default'].createElement(
35312
35558
  React__default['default'].Fragment,
35313
35559
  null,
35314
35560
  React__default['default'].createElement(
35315
35561
  'p',
35316
35562
  { className: 'search__filter__itinerary__segment-date-date' },
35317
- React__default['default'].createElement('strong', null, numberOfNights(segment))
35563
+ React__default['default'].createElement('strong', null, numberOfNights(firstSegment))
35318
35564
  ),
35319
35565
  React__default['default'].createElement(Icon$1, { name: 'ui-moon', width: 16, height: 16 })
35320
35566
  )
35321
35567
  ),
35322
- React__default['default'].createElement(
35323
- 'div',
35324
- { className: 'search__filter__itinerary__segment-badge search__filter__itinerary__segment-badge--secondary' },
35325
- getSegmentIcon(segment)
35326
- ),
35568
+ getSegmentIcon(firstSegment),
35327
35569
  React__default['default'].createElement(
35328
35570
  'div',
35329
35571
  { 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)
35572
+ React__default['default'].createElement('h6', null, getSegmentTitle(firstSegment)),
35573
+ firstSegment.serviceType === ACCOMMODATION_SERVICE_TYPE &&
35574
+ group.segments.map(function (segment, index) {
35575
+ return React__default['default'].createElement(
35576
+ React__default['default'].Fragment,
35577
+ { key: segment.guid },
35578
+ React__default['default'].createElement('strong', null, translations.SHARED.ROOM, '\u00A0', index + 1),
35579
+ segment.productName &&
35580
+ segment.accommodationName &&
35581
+ React__default['default'].createElement(
35582
+ 'div',
35583
+ { className: 'search__filter__itinerary__segment-details__room' },
35584
+ React__default['default'].createElement(Icon$1, { name: 'ui-bed', width: 12, height: 12 }),
35585
+ segment.accommodationName
35586
+ ),
35587
+ segment.regimeName &&
35588
+ React__default['default'].createElement(
35589
+ 'div',
35590
+ { className: 'search__filter__itinerary__segment-details__room' },
35591
+ React__default['default'].createElement(Icon$1, { name: 'ui-utensils', width: 12, height: 12 }),
35592
+ segment.regimeName
35593
+ )
35594
+ );
35595
+ })
35332
35596
  )
35333
35597
  )
35334
35598
  )
35335
- );
35336
- })
35337
- ),
35599
+ )
35600
+ );
35601
+ }),
35338
35602
  returnFlight &&
35339
35603
  returnFlight !== outboundFlight &&
35340
35604
  React__default['default'].createElement(
@@ -35418,8 +35682,7 @@ var Itinerary = function (_a) {
35418
35682
  'p',
35419
35683
  null,
35420
35684
  dateFns.format(new Date(lastEntryLine.to), 'EEE. d MMM yyyy'),
35421
- ' -',
35422
- ' ',
35685
+ ' - ',
35423
35686
  React__default['default'].createElement('strong', null, translations.SRP.END)
35424
35687
  )
35425
35688
  )
@@ -38194,19 +38457,27 @@ var formatPrice$1 = function (price, currencyCode) {
38194
38457
  }).format(price);
38195
38458
  };
38196
38459
  var AccommodationFlyIn = function (_a) {
38197
- var _b;
38198
- _a.isLoading;
38199
- var isOpen = _a.isOpen,
38200
- setIsOpen = _a.setIsOpen;
38460
+ var _b, _c;
38461
+ var isLoading = _a.isLoading,
38462
+ handleConfirm = _a.handleConfirm;
38201
38463
  var dispatch = reactRedux.useDispatch();
38202
38464
  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';
38465
+ if (isLoading) {
38466
+ return React__default['default'].createElement(
38467
+ React__default['default'].Fragment,
38468
+ null,
38469
+ (_b = context === null || context === void 0 ? void 0 : context.customSpinner) !== null && _b !== void 0
38470
+ ? _b
38471
+ : React__default['default'].createElement(Spinner, null)
38472
+ );
38473
+ }
38474
+ var language = (_c = context === null || context === void 0 ? void 0 : context.languageCode) !== null && _c !== void 0 ? _c : 'en-GB';
38204
38475
  var translations = getTranslations(language);
38205
- var _c = reactRedux.useSelector(function (state) {
38476
+ var _d = reactRedux.useSelector(function (state) {
38206
38477
  return state.searchResults;
38207
38478
  }),
38208
- packagingAccoSearchDetails = _c.packagingAccoSearchDetails,
38209
- selectedPackagingAccoResultCode = _c.selectedPackagingAccoResultCode;
38479
+ packagingAccoSearchDetails = _d.packagingAccoSearchDetails,
38480
+ selectedPackagingAccoResultCode = _d.selectedPackagingAccoResultCode;
38210
38481
  var selectedPackagingAccoSearchDetails = React.useMemo(
38211
38482
  function () {
38212
38483
  return packagingAccoSearchDetails === null || packagingAccoSearchDetails === void 0
@@ -38297,11 +38568,6 @@ var AccommodationFlyIn = function (_a) {
38297
38568
  });
38298
38569
  dispatch(setPackagingAccoSearchDetails(updatedPackagingAccoSearchDetails));
38299
38570
  };
38300
- var handleConfirm = function () {
38301
- if (isOpen) {
38302
- setIsOpen(false);
38303
- }
38304
- };
38305
38571
  if (!selectedPackagingAccoSearchDetails) {
38306
38572
  return null;
38307
38573
  }
@@ -38461,7 +38727,13 @@ var AccommodationFlyIn = function (_a) {
38461
38727
  React__default['default'].createElement(
38462
38728
  'div',
38463
38729
  { className: 'flyin__button-wrapper' },
38464
- React__default['default'].createElement('button', { className: 'cta cta--select', onClick: handleConfirm }, translations.PRODUCT.BOOK_NOW)
38730
+ React__default['default'].createElement(
38731
+ 'button',
38732
+ { className: 'cta cta--select', onClick: handleConfirm },
38733
+ (context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) == build.PortalQsmType.AccommodationAndFlight
38734
+ ? translations.QSM.CONFIRM
38735
+ : translations.PRODUCT.BOOK_NOW
38736
+ )
38465
38737
  )
38466
38738
  )
38467
38739
  );
@@ -38948,97 +39220,6 @@ var GroupTourFlyIn = function (_a) {
38948
39220
  );
38949
39221
  };
38950
39222
 
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
39223
  var he$1 = { exports: {} };
39043
39224
 
39044
39225
  /*! https://mths.be/he v1.2.0 by @mathias | MIT license */
@@ -43517,6 +43698,132 @@ var HotelAccommodationResults = function (_a) {
43517
43698
  );
43518
43699
  };
43519
43700
 
43701
+ var FlyIn = function (_a) {
43702
+ var title = _a.title,
43703
+ srpType = _a.srpType,
43704
+ isOpen = _a.isOpen,
43705
+ setIsOpen = _a.setIsOpen,
43706
+ _b = _a.className,
43707
+ className = _b === void 0 ? '' : _b,
43708
+ onPanelRef = _a.onPanelRef,
43709
+ detailsLoading = _a.detailsLoading,
43710
+ accommodationStep = _a.accommodationStep,
43711
+ isPackageEditFlow = _a.isPackageEditFlow,
43712
+ handleConfirm = _a.handleConfirm;
43713
+ var dispatch = reactRedux.useDispatch();
43714
+ var onCancelSearch = useFlightSearch().onCancelSearch;
43715
+ var panelRef = React.useRef(null);
43716
+ // expose DOM node if needed
43717
+ React.useEffect(
43718
+ function () {
43719
+ onPanelRef === null || onPanelRef === void 0 ? void 0 : onPanelRef(panelRef.current);
43720
+ return function () {
43721
+ return onPanelRef === null || onPanelRef === void 0 ? void 0 : onPanelRef(null);
43722
+ };
43723
+ },
43724
+ [onPanelRef]
43725
+ );
43726
+ React.useEffect(
43727
+ function () {
43728
+ // click outside detection
43729
+ var handleClickOutside = function (event) {
43730
+ if (isOpen && panelRef.current && !panelRef.current.contains(event.target)) {
43731
+ handleClose();
43732
+ }
43733
+ };
43734
+ document.addEventListener('mousedown', handleClickOutside);
43735
+ return function () {
43736
+ return document.removeEventListener('mousedown', handleClickOutside);
43737
+ };
43738
+ },
43739
+ [isOpen, setIsOpen]
43740
+ );
43741
+ // body scroll lock
43742
+ React.useEffect(
43743
+ function () {
43744
+ document.body.style.overflow = isOpen ? 'hidden' : '';
43745
+ return function () {
43746
+ document.body.style.overflow = '';
43747
+ };
43748
+ },
43749
+ [isOpen]
43750
+ );
43751
+ var handleClose = function () {
43752
+ if (isOpen && panelRef.current) {
43753
+ if (srpType === build.PortalQsmType.Flight) {
43754
+ dispatch(setSelectedFlight(null));
43755
+ dispatch(setSelectedFlightDetails(null));
43756
+ onCancelSearch();
43757
+ } else {
43758
+ dispatch(setSelectedSearchResult(null));
43759
+ dispatch(setSelectedPackagingAccoResult(null));
43760
+ }
43761
+ dispatch(setAccommodationFlyInStep('details'));
43762
+ setIsOpen(false);
43763
+ }
43764
+ };
43765
+ var handleGoBack = function () {
43766
+ dispatch(setAccommodationFlyInStep('results'));
43767
+ };
43768
+ return React__default['default'].createElement(
43769
+ 'div',
43770
+ {
43771
+ className: 'flyin '
43772
+ .concat(isOpen ? 'flyin--active' : '', ' ')
43773
+ .concat(className, ' ')
43774
+ .concat(isPackageEditFlow ? 'flyin--large' : '')
43775
+ },
43776
+ React__default['default'].createElement(
43777
+ 'div',
43778
+ { className: 'flyin__panel '.concat(isOpen ? 'flyin__panel--active' : ''), ref: panelRef },
43779
+ React__default['default'].createElement(
43780
+ 'div',
43781
+ { className: 'flyin__content' },
43782
+ React__default['default'].createElement(
43783
+ 'div',
43784
+ { className: 'flyin__content-title-row' },
43785
+ React__default['default'].createElement('h3', { className: 'flyin__content-title' }, title),
43786
+ React__default['default'].createElement(
43787
+ 'span',
43788
+ {
43789
+ className: 'flyin__close',
43790
+ onClick: function () {
43791
+ return handleClose();
43792
+ }
43793
+ },
43794
+ React__default['default'].createElement(Icon, { name: 'ui-close', width: 30, height: 30, 'aria-hidden': 'true' })
43795
+ )
43796
+ ),
43797
+ isPackageEditFlow &&
43798
+ accommodationStep === 'details' &&
43799
+ React__default['default'].createElement(
43800
+ 'div',
43801
+ { className: 'flyin__content-title-row' },
43802
+ React__default['default'].createElement(
43803
+ 'div',
43804
+ { onClick: handleGoBack, className: 'flyin__content-title__back' },
43805
+ React__default['default'].createElement(Icon, { name: 'ui-chevron', width: 14, height: 14, 'aria-hidden': 'true' }),
43806
+ 'Go Back'
43807
+ )
43808
+ )
43809
+ ),
43810
+ srpType === build.PortalQsmType.Flight && React__default['default'].createElement(FlightsFlyIn, { isOpen: isOpen, setIsOpen: setIsOpen }),
43811
+ (srpType === build.PortalQsmType.Accommodation || srpType === build.PortalQsmType.AccommodationAndFlight) &&
43812
+ accommodationStep === 'results' &&
43813
+ React__default['default'].createElement(
43814
+ 'div',
43815
+ { className: 'flyin__content' },
43816
+ React__default['default'].createElement(HotelAccommodationResults, { isLoading: detailsLoading })
43817
+ ),
43818
+ (srpType === build.PortalQsmType.Accommodation || srpType === build.PortalQsmType.AccommodationAndFlight) &&
43819
+ accommodationStep === 'details' &&
43820
+ React__default['default'].createElement(AccommodationFlyIn, { isLoading: detailsLoading, handleConfirm: handleConfirm }),
43821
+ srpType === build.PortalQsmType.GroupTour &&
43822
+ React__default['default'].createElement(GroupTourFlyIn, { isLoading: detailsLoading, isOpen: isOpen, setIsOpen: setIsOpen })
43823
+ )
43824
+ );
43825
+ };
43826
+
43520
43827
  var RoundTripResults = function () {
43521
43828
  var activeTab = reactRedux.useSelector(function (state) {
43522
43829
  return state.searchResults;
@@ -46932,42 +47239,135 @@ var applyFiltersToPackageAccoResults = function (results, filters, sortBy) {
46932
47239
  });
46933
47240
  };
46934
47241
 
46935
- var SearchResultsContainer = function () {
47242
+ var getSelectedOptionsPerRoom = function (details) {
47243
+ var _a;
47244
+ var firstResult = details[0];
47245
+ if (!((_a = firstResult === null || firstResult === void 0 ? void 0 : firstResult.rooms) === null || _a === void 0 ? void 0 : _a.length)) return [];
47246
+ return firstResult.rooms.map(function (room, roomIndex) {
47247
+ var _a;
47248
+ var selectedOption =
47249
+ (_a = room.options.find(function (option) {
47250
+ return option.isSelected;
47251
+ })) !== null && _a !== void 0
47252
+ ? _a
47253
+ : room.options[0];
47254
+ return {
47255
+ roomIndex: roomIndex,
47256
+ option: selectedOption !== null && selectedOption !== void 0 ? selectedOption : null
47257
+ };
47258
+ });
47259
+ };
47260
+ var getRequestRoomsFromPackagingSegments = function (entry, segments) {
46936
47261
  var _a;
47262
+ var accommodationLines = __spreadArray([], segments !== null && segments !== void 0 ? segments : [], true)
47263
+ .filter(function (line) {
47264
+ var _a;
47265
+ return line.serviceType === ACCOMMODATION_SERVICE_TYPE && ((_a = line.pax) === null || _a === void 0 ? void 0 : _a.length) > 0;
47266
+ })
47267
+ .sort(function (a, b) {
47268
+ return a.order - b.order;
47269
+ });
47270
+ var paxById = new Map(
47271
+ ((_a = entry.pax) !== null && _a !== void 0 ? _a : []).map(function (p) {
47272
+ return [p.id, p];
47273
+ })
47274
+ );
47275
+ if (!accommodationLines.length) {
47276
+ return [];
47277
+ }
47278
+ var roomGroups = [];
47279
+ accommodationLines.forEach(function (line) {
47280
+ var groupedByRoom = new Map();
47281
+ line.pax.forEach(function (linePax) {
47282
+ var _a, _b, _c, _d, _e, _f, _g;
47283
+ var roomIndexWithinLine = Number((_a = linePax.room) !== null && _a !== void 0 ? _a : 0);
47284
+ var paxId = Number(linePax.paxId);
47285
+ var paxSource = paxById.get(paxId);
47286
+ var pax = {
47287
+ id: (_b = paxSource === null || paxSource === void 0 ? void 0 : paxSource.id) !== null && _b !== void 0 ? _b : paxId,
47288
+ guid:
47289
+ (_d = (_c = paxSource === null || paxSource === void 0 ? void 0 : paxSource.id) === null || _c === void 0 ? void 0 : _c.toString()) !== null &&
47290
+ _d !== void 0
47291
+ ? _d
47292
+ : paxId.toString(),
47293
+ firstName: (_e = paxSource === null || paxSource === void 0 ? void 0 : paxSource.firstName) !== null && _e !== void 0 ? _e : '',
47294
+ lastName: (_f = paxSource === null || paxSource === void 0 ? void 0 : paxSource.lastName) !== null && _f !== void 0 ? _f : '',
47295
+ dateOfBirth: (_g = paxSource === null || paxSource === void 0 ? void 0 : paxSource.dateOfBirth) !== null && _g !== void 0 ? _g : undefined,
47296
+ age: (paxSource === null || paxSource === void 0 ? void 0 : paxSource.dateOfBirth) ? undefined : 30,
47297
+ isMainBooker: paxSource === null || paxSource === void 0 ? void 0 : paxSource.isMainBooker,
47298
+ email: ''
47299
+ };
47300
+ if (!groupedByRoom.has(roomIndexWithinLine)) {
47301
+ groupedByRoom.set(roomIndexWithinLine, []);
47302
+ }
47303
+ groupedByRoom.get(roomIndexWithinLine).push(pax);
47304
+ });
47305
+ var sortedGroups = Array.from(groupedByRoom.entries())
47306
+ .sort(function (_a, _b) {
47307
+ var a = _a[0];
47308
+ var b = _b[0];
47309
+ return a - b;
47310
+ })
47311
+ .map(function (_a) {
47312
+ var pax = _a[1];
47313
+ return pax;
47314
+ });
47315
+ roomGroups.push.apply(roomGroups, sortedGroups);
47316
+ });
47317
+ return roomGroups.map(function (pax, index) {
47318
+ return {
47319
+ index: index,
47320
+ pax: pax
47321
+ };
47322
+ });
47323
+ };
47324
+
47325
+ var SearchResultsContainer = function () {
47326
+ var _a, _b;
47327
+ var currentSearch = typeof window !== 'undefined' ? window.location.search : '';
46937
47328
  var dispatch = reactRedux.useDispatch();
46938
47329
  var context = React.useContext(SearchResultsConfigurationContext);
46939
47330
  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) {
47331
+ var _c = reactRedux.useSelector(function (state) {
46941
47332
  return state.searchResults;
46942
47333
  }),
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;
47334
+ results = _c.results,
47335
+ filteredResults = _c.filteredResults,
47336
+ packagingAccoResults = _c.packagingAccoResults,
47337
+ filteredPackagingAccoResults = _c.filteredPackagingAccoResults,
47338
+ bookingPackageDetails = _c.bookingPackageDetails,
47339
+ isLoading = _c.isLoading,
47340
+ filters = _c.filters,
47341
+ selectedSortType = _c.selectedSortType,
47342
+ selectedSearchResult = _c.selectedSearchResult,
47343
+ selectedPackagingAccoResultCode = _c.selectedPackagingAccoResultCode,
47344
+ flyInIsOpen = _c.flyInIsOpen,
47345
+ packagingAccoSearchDetails = _c.packagingAccoSearchDetails,
47346
+ editablePackagingEntry = _c.editablePackagingEntry,
47347
+ transactionId = _c.transactionId,
47348
+ accommodationFlyInStep = _c.accommodationFlyInStep;
46955
47349
  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];
47350
+ var _d = React.useState(false),
47351
+ initialFiltersSet = _d[0],
47352
+ setInitialFiltersSet = _d[1];
47353
+ var _e = React.useState([]),
47354
+ initialFilters = _e[0],
47355
+ setInitialFilters = _e[1];
46965
47356
  var _f = React.useState(false),
46966
- detailsIsLoading = _f[0],
46967
- setDetailsIsLoading = _f[1];
47357
+ filtersOpen = _f[0],
47358
+ setFiltersOpen = _f[1];
46968
47359
  var _g = React.useState(false),
46969
- itineraryOpen = _g[0],
46970
- setItineraryOpen = _g[1];
47360
+ detailsIsLoading = _g[0],
47361
+ setDetailsIsLoading = _g[1];
47362
+ var _h = React.useState(false),
47363
+ pricesAreLoading = _h[0],
47364
+ setPricesAreLoading = _h[1];
47365
+ var _j = React.useState(false),
47366
+ itineraryOpen = _j[0],
47367
+ setItineraryOpen = _j[1];
47368
+ var _k = React.useState(null),
47369
+ selectedAccommodationSeed = _k[0],
47370
+ setSelectedAccommodationSeed = _k[1];
46971
47371
  var panelRef = React.useRef(null);
46972
47372
  var sortByTypes = [
46973
47373
  { direction: 'asc', label: 'default' },
@@ -46983,201 +47383,6 @@ var SearchResultsContainer = function () {
46983
47383
  dispatch(setSortType(newSortByType));
46984
47384
  }
46985
47385
  };
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;
47033
- }
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;
47073
- };
47074
- var buildSearchFromQueryParams = function (params) {
47075
- 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
- }
47089
- if (typeof window !== 'undefined') {
47090
- window.scrollTo(0, 0);
47091
- }
47092
- var destinationId = null;
47093
- var destinationIsCountry = false;
47094
- var destinationIsRegion = false;
47095
- var destinationIsOord = false;
47096
- var destinationIsLocation = false;
47097
- if (country) {
47098
- destinationId = country;
47099
- destinationIsCountry = true;
47100
- } else if (region) {
47101
- destinationId = region;
47102
- destinationIsRegion = true;
47103
- } else if (oord) {
47104
- destinationId = oord;
47105
- destinationIsOord = true;
47106
- } else if (city) {
47107
- destinationId = city;
47108
- destinationIsLocation = true;
47109
- }
47110
- var searchRequest = {
47111
- officeId: 1,
47112
- agentId: context === null || context === void 0 ? void 0 : context.agentId,
47113
- payload: {
47114
- catalogueIds: (_a = context.tideConnection.catalogueIds) !== null && _a !== void 0 ? _a : [],
47115
- serviceType:
47116
- context.searchConfiguration.qsmType === build.PortalQsmType.Accommodation ||
47117
- context.searchConfiguration.qsmType === build.PortalQsmType.AccommodationAndFlight
47118
- ? 3
47119
- : context.searchConfiguration.qsmType === build.PortalQsmType.Flight
47120
- ? 7
47121
- : context.searchConfiguration.qsmType === build.PortalQsmType.RoundTrip
47122
- ? 1
47123
- : undefined,
47124
- searchType: context.searchConfiguration.qsmType === build.PortalQsmType.GroupTour ? 1 : 0,
47125
- destination: {
47126
- id: Number(destinationId),
47127
- isCountry: destinationIsCountry,
47128
- isRegion: destinationIsRegion,
47129
- isOord: destinationIsOord,
47130
- isLocation: destinationIsLocation
47131
- },
47132
- rooms: getRequestRooms(rooms),
47133
- fromDate: from,
47134
- toDate: to,
47135
- earliestFromOffset: 0,
47136
- 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,
47145
- useExactDates: (context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.GroupTour ? false : true,
47146
- onlyCachedResults: false,
47147
- includeAllAllotments: true,
47148
- productIds: hotel ? [hotel] : [],
47149
- productTagIds: tagId ? [tagId] : []
47150
- }
47151
- };
47152
- console.log('Built search request from query params', searchRequest);
47153
- return searchRequest;
47154
- };
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
47386
  var getRequestRooms = function (rooms) {
47182
47387
  if (!rooms) {
47183
47388
  // Fall back to 2 adults
@@ -47208,23 +47413,14 @@ var SearchResultsContainer = function () {
47208
47413
  });
47209
47414
  return requestRooms;
47210
47415
  };
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
- }
47416
+ var buildSearchFromSeed = function (seed) {
47417
+ var _a;
47418
+ var country = seed.country;
47419
+ var region = seed.region;
47420
+ var oord = seed.oord;
47421
+ var city = seed.location;
47422
+ var hotel = seed.hotel;
47423
+ var tagId = seed.tagId;
47228
47424
  if (typeof window !== 'undefined') {
47229
47425
  window.scrollTo(0, 0);
47230
47426
  }
@@ -47233,8 +47429,6 @@ var SearchResultsContainer = function () {
47233
47429
  var destinationIsRegion = false;
47234
47430
  var destinationIsOord = false;
47235
47431
  var destinationIsLocation = false;
47236
- var destinationCode = null;
47237
- var destinationIsAirport = false;
47238
47432
  if (country) {
47239
47433
  destinationId = country;
47240
47434
  destinationIsCountry = true;
@@ -47247,19 +47441,88 @@ var SearchResultsContainer = function () {
47247
47441
  } else if (city) {
47248
47442
  destinationId = city;
47249
47443
  destinationIsLocation = true;
47444
+ }
47445
+ return {
47446
+ officeId: 1,
47447
+ agentId: context === null || context === void 0 ? void 0 : context.agentId,
47448
+ payload: {
47449
+ catalogueIds: (_a = context.tideConnection.catalogueIds) !== null && _a !== void 0 ? _a : [],
47450
+ serviceType:
47451
+ context.searchConfiguration.qsmType === build.PortalQsmType.Accommodation ||
47452
+ context.searchConfiguration.qsmType === build.PortalQsmType.AccommodationAndFlight
47453
+ ? ACCOMMODATION_SERVICE_TYPE
47454
+ : context.searchConfiguration.qsmType === build.PortalQsmType.Flight
47455
+ ? FLIGHT_SERVICE_TYPE
47456
+ : context.searchConfiguration.qsmType === build.PortalQsmType.RoundTrip
47457
+ ? GROUP_TOUR_SERVICE_TYPE
47458
+ : undefined,
47459
+ searchType: context.searchConfiguration.qsmType === build.PortalQsmType.GroupTour ? 1 : 0,
47460
+ destination: {
47461
+ id: Number(destinationId),
47462
+ isCountry: destinationIsCountry,
47463
+ isRegion: destinationIsRegion,
47464
+ isOord: destinationIsOord,
47465
+ isLocation: destinationIsLocation
47466
+ },
47467
+ rooms: seed.rooms,
47468
+ fromDate: seed.fromDate,
47469
+ toDate: seed.toDate,
47470
+ earliestFromOffset: 0,
47471
+ latestToOffset: 0,
47472
+ includeFlights: context.searchConfiguration.qsmType === build.PortalQsmType.AccommodationAndFlight,
47473
+ useExactDates: (context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.GroupTour ? false : true,
47474
+ onlyCachedResults: false,
47475
+ includeAllAllotments: true,
47476
+ productIds: hotel ? [hotel] : [],
47477
+ productTagIds: tagId ? [tagId] : []
47478
+ }
47479
+ };
47480
+ };
47481
+ var buildPackagingAccommodationRequestFromSeed = function (seed, currentTransactionId) {
47482
+ var _a, _b, _c, _d;
47483
+ var country = seed.country;
47484
+ var region = seed.region;
47485
+ var oord = seed.oord;
47486
+ var city = seed.location;
47487
+ (_a = seed.hotelCode) !== null && _a !== void 0 ? _a : seed.hotel ? seed.hotel.toString() : '';
47488
+ var tagId = seed.tagId;
47489
+ var destinationAirport = seed.destinationAirport;
47490
+ if (typeof window !== 'undefined') {
47491
+ window.scrollTo(0, 0);
47492
+ }
47493
+ var destinationId = null;
47494
+ var destinationIsCountry = false;
47495
+ var destinationIsRegion = false;
47496
+ var destinationIsOord = false;
47497
+ var destinationIsLocation = false;
47498
+ var destinationCode = null;
47499
+ var destinationIsAirport = false;
47500
+ if (city) {
47501
+ destinationId = city;
47502
+ destinationIsLocation = true;
47503
+ } else if (oord) {
47504
+ destinationId = oord;
47505
+ destinationIsOord = true;
47506
+ } else if (region) {
47507
+ destinationId = region;
47508
+ destinationIsRegion = true;
47509
+ } else if (country) {
47510
+ destinationId = country;
47511
+ destinationIsCountry = true;
47250
47512
  } else if (destinationAirport) {
47251
47513
  destinationCode = destinationAirport;
47252
47514
  destinationIsAirport = true;
47253
47515
  }
47254
- var searchRequest = {
47516
+ return {
47517
+ transactionId: currentTransactionId,
47255
47518
  officeId: 1,
47256
- agentId: agentId !== null && agentId !== void 0 ? agentId : null,
47257
- catalogueId: (_a = context.searchConfiguration.defaultCatalogueId) !== null && _a !== void 0 ? _a : 0,
47519
+ agentId: (_b = context === null || context === void 0 ? void 0 : context.agentId) !== null && _b !== void 0 ? _b : null,
47520
+ catalogueId: (_c = context.searchConfiguration.defaultCatalogueId) !== null && _c !== void 0 ? _c : 0,
47258
47521
  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,
47522
+ language: (_d = context.languageCode) !== null && _d !== void 0 ? _d : 'en-GB',
47523
+ serviceType: ACCOMMODATION_SERVICE_TYPE,
47524
+ fromDate: seed.fromDate,
47525
+ toDate: seed.toDate,
47263
47526
  destination: {
47264
47527
  id: Number(destinationId),
47265
47528
  isCountry: destinationIsCountry,
@@ -47269,43 +47532,136 @@ var SearchResultsContainer = function () {
47269
47532
  isAirport: destinationIsAirport,
47270
47533
  code: destinationCode
47271
47534
  },
47272
- productCode: hotel ? hotel.toString() : '',
47273
- rooms: getPackagingRequestRooms(rooms),
47535
+ productCode: '',
47536
+ rooms: getPackagingRequestRoomsFromBookingRooms(seed.rooms),
47274
47537
  tagIds: tagId ? [tagId] : []
47275
47538
  };
47276
- console.log('Search request for packaging accommodation from query params', searchRequest);
47277
- return searchRequest;
47278
47539
  };
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];
47540
+ var buildSearchSeedFromQueryParams = function (params) {
47541
+ var from = getDateFromParams(params, 'fromDate');
47542
+ var to = getDateFromParams(params, 'toDate');
47543
+ var rooms = getRoomsFromParams(params, 'rooms');
47544
+ var country = getNumberFromParams(params, 'country');
47545
+ var region = getNumberFromParams(params, 'region');
47546
+ var oord = getNumberFromParams(params, 'oord');
47547
+ var city = getNumberFromParams(params, 'location');
47548
+ var hotel = getNumberFromParams(params, 'hotel');
47549
+ var tagId = getNumberFromParams(params, 'tagId');
47550
+ var destinationAirport = getStringFromParams(params, 'destinationAirport');
47551
+ var departureAirport = getStringFromParams(params, 'departureAirport');
47552
+ if (!from || !to) {
47553
+ return null;
47289
47554
  }
47290
- var requestRooms =
47291
- rooms === null || rooms === void 0
47555
+ return {
47556
+ fromDate: from,
47557
+ toDate: to,
47558
+ country: country,
47559
+ region: region,
47560
+ oord: oord,
47561
+ location: city,
47562
+ hotel: hotel,
47563
+ hotelCode: hotel ? hotel.toString() : null,
47564
+ tagId: tagId,
47565
+ destinationAirport: destinationAirport,
47566
+ departureAirport: departureAirport,
47567
+ rooms: getRequestRooms(rooms)
47568
+ };
47569
+ };
47570
+ var handleConfirmHotelSwap = function () {
47571
+ var updatedEntry = swapHotelInPackagingEntry();
47572
+ console.log('Updated entry after hotel swap', updatedEntry);
47573
+ if (!updatedEntry) return;
47574
+ dispatch(setEditablePackagingEntry(updatedEntry));
47575
+ handleFlyInToggle(false);
47576
+ };
47577
+ var swapHotelInPackagingEntry = function () {
47578
+ var sourceEntry =
47579
+ editablePackagingEntry !== null && editablePackagingEntry !== void 0
47580
+ ? editablePackagingEntry
47581
+ : context === null || context === void 0
47292
47582
  ? 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;
47583
+ : context.packagingEntry;
47584
+ var details = packagingAccoSearchDetails;
47585
+ if (!sourceEntry || !(details === null || details === void 0 ? void 0 : details.length)) return null;
47586
+ var selectedOptionsPerRoom = getSelectedOptionsPerRoom(details);
47587
+ console.log('Selected options per room', selectedOptionsPerRoom);
47588
+ if (!selectedOptionsPerRoom.length) return null;
47589
+ var selectedHotel = details[0];
47590
+ var roomIndex = 0;
47591
+ var updatedLines = sourceEntry.lines.map(function (line) {
47592
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
47593
+ if (line.serviceType !== ACCOMMODATION_SERVICE_TYPE) {
47594
+ return line;
47595
+ }
47596
+ var selectedRoom = selectedOptionsPerRoom.find(function (x) {
47597
+ return x.roomIndex === roomIndex;
47598
+ });
47599
+ var selectedOption = selectedRoom === null || selectedRoom === void 0 ? void 0 : selectedRoom.option;
47600
+ console.log('selectedRoom and selectedOption for line', line, selectedRoom, selectedOption);
47601
+ roomIndex++;
47602
+ if (!selectedOption) {
47603
+ return line;
47604
+ }
47605
+ return __assign(__assign({}, line), {
47606
+ guid: selectedOption.guid,
47607
+ productName: selectedHotel.name,
47608
+ productCode: selectedHotel.code,
47609
+ accommodationName: selectedOption.accommodationName,
47610
+ accommodationCode: selectedOption.accommodationCode,
47611
+ regimeName: selectedOption.regimeName,
47612
+ regimeCode: selectedOption.regimeCode,
47613
+ country: line.country
47614
+ ? __assign(__assign({}, line.country), {
47615
+ id: (_a = selectedHotel.countryId) !== null && _a !== void 0 ? _a : line.country.id,
47616
+ name: (_b = selectedHotel.countryName) !== null && _b !== void 0 ? _b : line.country.name
47617
+ })
47618
+ : selectedHotel.countryId
47619
+ ? { id: selectedHotel.countryId, name: selectedHotel.countryName, localizations: [] }
47620
+ : line.country,
47621
+ region: line.region
47622
+ ? __assign(__assign({}, line.region), {
47623
+ id: (_c = selectedHotel.regionId) !== null && _c !== void 0 ? _c : line.region.id,
47624
+ name: (_d = selectedHotel.regionName) !== null && _d !== void 0 ? _d : line.region.name
47625
+ })
47626
+ : selectedHotel.regionId
47627
+ ? { id: selectedHotel.regionId, name: selectedHotel.regionName, localizations: [] }
47628
+ : line.region,
47629
+ oord: line.oord
47630
+ ? __assign(__assign({}, line.oord), {
47631
+ id: (_e = selectedHotel.oordId) !== null && _e !== void 0 ? _e : line.oord.id,
47632
+ name: (_f = selectedHotel.oordName) !== null && _f !== void 0 ? _f : line.oord.name
47633
+ })
47634
+ : selectedHotel.oordId
47635
+ ? { id: selectedHotel.oordId, name: selectedHotel.oordName, localizations: [] }
47636
+ : line.oord,
47637
+ location: line.location
47638
+ ? __assign(__assign({}, line.location), {
47639
+ id: (_g = selectedHotel.locationId) !== null && _g !== void 0 ? _g : line.location.id,
47640
+ name: (_h = selectedHotel.locationName) !== null && _h !== void 0 ? _h : line.location.name
47641
+ })
47642
+ : selectedHotel.locationId
47643
+ ? { id: selectedHotel.locationId, name: selectedHotel.locationName, localizations: [] }
47644
+ : line.location,
47645
+ latitude: (_j = selectedHotel.latitude) !== null && _j !== void 0 ? _j : line.latitude,
47646
+ longitude: (_k = selectedHotel.longitude) !== null && _k !== void 0 ? _k : line.longitude,
47647
+ from: (_l = selectedHotel.fromDate) !== null && _l !== void 0 ? _l : line.from,
47648
+ to: (_m = selectedHotel.toDate) !== null && _m !== void 0 ? _m : line.to,
47649
+ isChanged: true
47650
+ });
47651
+ });
47652
+ return __assign(__assign({}, sourceEntry), { lines: updatedLines });
47308
47653
  };
47654
+ var activeSearchSeed = React__default['default'].useMemo(
47655
+ function () {
47656
+ if (selectedAccommodationSeed) {
47657
+ return selectedAccommodationSeed;
47658
+ }
47659
+ if (typeof window === 'undefined') return null;
47660
+ var params = new URLSearchParams(window.location.search);
47661
+ return buildSearchSeedFromQueryParams(params);
47662
+ },
47663
+ [selectedAccommodationSeed, currentSearch]
47664
+ );
47309
47665
  React.useEffect(
47310
47666
  function () {
47311
47667
  if (typeof document !== 'undefined') {
@@ -47314,189 +47670,232 @@ var SearchResultsContainer = function () {
47314
47670
  },
47315
47671
  [filtersOpen]
47316
47672
  );
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*/];
47673
+ var runSearch = function () {
47674
+ return __awaiter(void 0, void 0, void 0, function () {
47675
+ var config, seed, searchRequest, packageSearchResults, enrichedFilters, initialFilteredResults, err_1;
47676
+ var _a;
47677
+ return __generator(this, function (_b) {
47678
+ switch (_b.label) {
47679
+ case 0:
47680
+ _b.trys.push([0, 2, 3, 4]);
47681
+ if (!context) return [2 /*return*/];
47682
+ dispatch(setIsLoading(true));
47683
+ config = {
47684
+ host: context.tideConnection.host,
47685
+ apiKey: context.tideConnection.apiKey
47686
+ };
47687
+ seed = activeSearchSeed;
47688
+ if (!seed) {
47689
+ throw new Error('Invalid search parameters');
47394
47690
  }
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*/];
47691
+ searchRequest = buildSearchFromSeed(seed);
47692
+ return [4 /*yield*/, build.search(config, searchRequest)];
47693
+ case 1:
47694
+ packageSearchResults = _b.sent();
47695
+ console.log('Search results', packageSearchResults);
47696
+ enrichedFilters = enrichFiltersWithResults(packageSearchResults, context.filters, (_a = context.tags) !== null && _a !== void 0 ? _a : []);
47697
+ if (!initialFiltersSet) {
47698
+ dispatch(resetFilters(enrichedFilters));
47699
+ setInitialFilters(enrichedFilters);
47700
+ setInitialFiltersSet(true);
47451
47701
  }
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();
47702
+ dispatch(setResults(packageSearchResults));
47703
+ initialFilteredResults = applyFilters(packageSearchResults, filters, null);
47704
+ dispatch(setFilteredResults(initialFilteredResults));
47705
+ if ((packageSearchResults === null || packageSearchResults === void 0 ? void 0 : packageSearchResults.length) > 0) {
47706
+ if (context.searchConfiguration.qsmType === build.PortalQsmType.AccommodationAndFlight) {
47707
+ dispatch(setSelectedSearchResult(packageSearchResults[0]));
47708
+ }
47709
+ }
47710
+ return [3 /*break*/, 4];
47711
+ case 2:
47712
+ err_1 = _b.sent();
47713
+ console.error('Search failed', err_1);
47714
+ return [3 /*break*/, 4];
47715
+ case 3:
47716
+ dispatch(setIsLoading(false));
47717
+ return [7 /*endfinally*/];
47718
+ case 4:
47719
+ return [2 /*return*/];
47462
47720
  }
47463
- if ((context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.Accommodation) {
47464
- runHotelSearch();
47721
+ });
47722
+ });
47723
+ };
47724
+ var runStartTransaction = function () {
47725
+ return __awaiter(void 0, void 0, void 0, function () {
47726
+ var config, transaction, err_2;
47727
+ return __generator(this, function (_a) {
47728
+ switch (_a.label) {
47729
+ case 0:
47730
+ _a.trys.push([0, 2, , 3]);
47731
+ if (!context) return [2 /*return*/, null];
47732
+ config = {
47733
+ host: context.tideConnection.host,
47734
+ apiKey: context.tideConnection.apiKey
47735
+ };
47736
+ return [4 /*yield*/, build.startTransaction(config)];
47737
+ case 1:
47738
+ transaction = _a.sent();
47739
+ console.log('Transaction started', transaction);
47740
+ dispatch(setTransactionId(transaction.transactionId));
47741
+ return [2 /*return*/, transaction.transactionId];
47742
+ case 2:
47743
+ err_2 = _a.sent();
47744
+ console.error('Transaction failed', err_2);
47745
+ return [2 /*return*/, null];
47746
+ case 3:
47747
+ return [2 /*return*/];
47465
47748
  }
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
- }
47749
+ });
47750
+ });
47751
+ };
47752
+ var runHotelSearch = function (currentTransactionId, seed) {
47753
+ return __awaiter(void 0, void 0, void 0, function () {
47754
+ var config, searchRequest, packageAccoSearchResults, enrichedFilters, initialFilteredResults, err_3;
47755
+ var _a;
47756
+ return __generator(this, function (_b) {
47757
+ switch (_b.label) {
47758
+ case 0:
47759
+ _b.trys.push([0, 2, , 3]);
47760
+ if (!context) return [2 /*return*/];
47761
+ dispatch(setIsLoading(true));
47762
+ config = {
47763
+ host: context.tideConnection.host,
47764
+ apiKey: context.tideConnection.apiKey
47765
+ };
47766
+ searchRequest = buildPackagingAccommodationRequestFromSeed(seed, currentTransactionId);
47767
+ searchRequest.portalId = context.portalId;
47768
+ searchRequest.agentId = context.agentId;
47769
+ console.log('Packaging accommodation search request', searchRequest);
47770
+ return [4 /*yield*/, build.searchPackagingAccommodations(config, searchRequest)];
47771
+ case 1:
47772
+ packageAccoSearchResults = _b.sent();
47773
+ enrichedFilters = enrichFiltersWithPackageAccoResults(
47774
+ packageAccoSearchResults,
47775
+ context.filters,
47776
+ (_a = context.tags) !== null && _a !== void 0 ? _a : []
47777
+ );
47778
+ if (!initialFiltersSet) {
47779
+ dispatch(resetFilters(enrichedFilters));
47780
+ setInitialFilters(enrichedFilters);
47781
+ setInitialFiltersSet(true);
47782
+ }
47783
+ dispatch(setPackagingAccoResults(packageAccoSearchResults));
47784
+ initialFilteredResults = applyFiltersToPackageAccoResults(packageAccoSearchResults, filters, null);
47785
+ dispatch(setFilteredPackagingAccoResults(initialFilteredResults));
47786
+ dispatch(setIsLoading(false));
47787
+ return [3 /*break*/, 3];
47788
+ case 2:
47789
+ err_3 = _b.sent();
47790
+ console.error('Search failed', err_3);
47791
+ dispatch(setIsLoading(false));
47792
+ return [3 /*break*/, 3];
47793
+ case 3:
47794
+ return [2 /*return*/];
47795
+ }
47796
+ });
47797
+ });
47798
+ };
47799
+ var runAccommodationFlow = function (seed) {
47800
+ return __awaiter(void 0, void 0, void 0, function () {
47801
+ var currentTransactionId;
47802
+ var _a;
47803
+ return __generator(this, function (_b) {
47804
+ switch (_b.label) {
47805
+ case 0:
47806
+ if (!context || context.showMockup) return [2 /*return*/];
47807
+ currentTransactionId =
47808
+ ((_a = context === null || context === void 0 ? void 0 : context.packagingEntry) === null || _a === void 0 ? void 0 : _a.transactionId) ||
47809
+ transactionId;
47810
+ console.log('Current transaction ID', currentTransactionId);
47811
+ if (!!currentTransactionId) return [3 /*break*/, 2];
47812
+ dispatch(setIsLoading(true));
47813
+ return [4 /*yield*/, runStartTransaction()];
47814
+ case 1:
47815
+ currentTransactionId = _b.sent();
47816
+ _b.label = 2;
47817
+ case 2:
47818
+ if (!currentTransactionId) {
47819
+ dispatch(setIsLoading(false));
47820
+ return [2 /*return*/];
47821
+ }
47822
+ return [4 /*yield*/, runHotelSearch(currentTransactionId, seed)];
47823
+ case 3:
47824
+ _b.sent();
47825
+ return [2 /*return*/];
47826
+ }
47827
+ });
47828
+ });
47829
+ };
47830
+ // separate Search
47831
+ React.useEffect(
47832
+ function () {
47833
+ if (
47834
+ (context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.GroupTour ||
47835
+ ((context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.AccommodationAndFlight &&
47836
+ !context.searchConfiguration.enableManualPackaging)
47837
+ ) {
47838
+ runSearch();
47839
+ }
47840
+ if ((context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.Accommodation) {
47841
+ var seed = activeSearchSeed;
47842
+ if (seed) {
47843
+ runAccommodationFlow(seed);
47844
+ }
47845
+ }
47846
+ if (
47847
+ (context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.AccommodationAndFlight &&
47848
+ context.searchConfiguration.enableManualPackaging &&
47849
+ context.searchConfiguration.allowAccommodations &&
47850
+ !(context === null || context === void 0 ? void 0 : context.packagingEntry)
47851
+ ) {
47852
+ var seed = activeSearchSeed;
47853
+ if (seed) {
47854
+ runAccommodationFlow(seed);
47474
47855
  }
47475
47856
  }
47476
47857
  },
47477
- [location.search]
47858
+ [
47859
+ location.search,
47860
+ context === null || context === void 0 ? void 0 : context.showMockup,
47861
+ context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType,
47862
+ context === null || context === void 0 ? void 0 : context.searchConfiguration.enableManualPackaging,
47863
+ context === null || context === void 0 ? void 0 : context.searchConfiguration.allowAccommodations,
47864
+ (_b = context === null || context === void 0 ? void 0 : context.packagingEntry) === null || _b === void 0 ? void 0 : _b.transactionId,
47865
+ activeSearchSeed
47866
+ ]
47478
47867
  );
47479
- // Seperate detailsCall
47868
+ React.useEffect(
47869
+ function () {
47870
+ if (context === null || context === void 0 ? void 0 : context.packagingEntry) {
47871
+ console.log('original packaging entry from context', context.packagingEntry);
47872
+ dispatch(setEditablePackagingEntry(structuredClone(context.packagingEntry)));
47873
+ dispatch(setTransactionId(context.packagingEntry.transactionId));
47874
+ }
47875
+ },
47876
+ [context === null || context === void 0 ? void 0 : context.packagingEntry]
47877
+ );
47878
+ // separate detailsCall
47480
47879
  React.useEffect(
47481
47880
  function () {
47482
47881
  var fetchDetails = function () {
47483
47882
  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) {
47883
+ var config, selectedItem, requestRooms, seed, detailsRequest, detailsResponse, err_4;
47884
+ var _a;
47885
+ return __generator(this, function (_b) {
47886
+ switch (_b.label) {
47487
47887
  case 0:
47488
- setDetailsIsLoading(true);
47489
- console.log('Fetching details for selected search result', selectedSearchResult);
47490
47888
  if (!selectedSearchResult || !context) return [2 /*return*/];
47889
+ setDetailsIsLoading(true);
47491
47890
  if (
47492
47891
  (context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.Accommodation ||
47493
47892
  (context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.GroupTour
47494
47893
  ) {
47495
47894
  handleFlyInToggle(true);
47496
47895
  }
47497
- _a.label = 1;
47896
+ _b.label = 1;
47498
47897
  case 1:
47499
- _a.trys.push([1, 6, , 7]);
47898
+ _b.trys.push([1, 3, , 4]);
47500
47899
  config = {
47501
47900
  host: context.tideConnection.host,
47502
47901
  apiKey: context.tideConnection.apiKey
@@ -47508,14 +47907,14 @@ var SearchResultsContainer = function () {
47508
47907
  // TODO: handle this case better, show an error message to the user
47509
47908
  return [2 /*return*/];
47510
47909
  }
47511
- params = new URLSearchParams(location.search);
47512
- entryId = getStringFromParams(params, 'entryId');
47513
47910
  requestRooms = void 0;
47514
- if (entry && entryId) {
47515
- requestRooms = getRequestRoomsFromEntry(entry.rooms);
47911
+ if (context === null || context === void 0 ? void 0 : context.packagingEntry) {
47912
+ requestRooms = getRequestRoomsFromPackagingEntry(context.packagingEntry);
47516
47913
  } else {
47517
- rooms = getRoomsFromParams(params, 'rooms');
47518
- requestRooms = getRequestRooms(rooms);
47914
+ seed = activeSearchSeed;
47915
+ requestRooms = ((_a = seed === null || seed === void 0 ? void 0 : seed.rooms) === null || _a === void 0 ? void 0 : _a.length)
47916
+ ? seed.rooms
47917
+ : getRequestRooms(null);
47519
47918
  }
47520
47919
  detailsRequest = {
47521
47920
  officeId: 1,
@@ -47537,29 +47936,18 @@ var SearchResultsContainer = function () {
47537
47936
  },
47538
47937
  agentId: context.agentId
47539
47938
  };
47540
- if (!(entry && entryId)) return [3 /*break*/, 3];
47541
- requestRooms = getRequestRoomsFromEntry(entry.rooms);
47542
47939
  return [4 /*yield*/, build.details(config, detailsRequest)];
47543
47940
  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();
47941
+ detailsResponse = _b.sent();
47552
47942
  dispatch(setBookingPackageDetails({ details: detailsResponse === null || detailsResponse === void 0 ? void 0 : detailsResponse.payload }));
47553
47943
  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);
47944
+ return [3 /*break*/, 4];
47945
+ case 3:
47946
+ err_4 = _b.sent();
47947
+ console.error('Failed to fetch package details', err_4);
47560
47948
  setDetailsIsLoading(false);
47561
- return [3 /*break*/, 7];
47562
- case 7:
47949
+ return [3 /*break*/, 4];
47950
+ case 4:
47563
47951
  return [2 /*return*/];
47564
47952
  }
47565
47953
  });
@@ -47569,8 +47957,7 @@ var SearchResultsContainer = function () {
47569
47957
  return __awaiter(void 0, void 0, void 0, function () {
47570
47958
  var config,
47571
47959
  selectedItem,
47572
- params,
47573
- rooms,
47960
+ seed,
47574
47961
  tagId,
47575
47962
  destinationAirport,
47576
47963
  destinationId,
@@ -47582,38 +47969,37 @@ var SearchResultsContainer = function () {
47582
47969
  destinationIsAirport,
47583
47970
  detailSearchRequest,
47584
47971
  packageAccoSearchDetails,
47585
- err_4;
47586
- var _a, _b;
47587
- return __generator(this, function (_c) {
47588
- switch (_c.label) {
47972
+ err_5;
47973
+ var _a, _b, _c, _d, _e;
47974
+ return __generator(this, function (_f) {
47975
+ switch (_f.label) {
47589
47976
  case 0:
47590
47977
  if (!selectedPackagingAccoResultCode || !context) return [2 /*return*/];
47978
+ setDetailsIsLoading(true);
47591
47979
  if (
47592
47980
  (context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.Accommodation ||
47981
+ (context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.AccommodationAndFlight ||
47593
47982
  (context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.GroupTour
47594
47983
  ) {
47595
47984
  handleFlyInToggle(true);
47596
47985
  }
47597
- _c.label = 1;
47986
+ _f.label = 1;
47598
47987
  case 1:
47599
- _c.trys.push([1, 3, , 4]);
47988
+ _f.trys.push([1, 3, , 4]);
47600
47989
  config = {
47601
47990
  host: context.tideConnection.host,
47602
47991
  apiKey: context.tideConnection.apiKey
47603
47992
  };
47604
- console.log('selectedPackagingAccoResultCode', selectedPackagingAccoResultCode);
47605
47993
  selectedItem = packagingAccoResults.find(function (r) {
47606
47994
  return r.code === selectedPackagingAccoResultCode;
47607
47995
  });
47608
- console.log('Selected packaging acco item', selectedItem);
47609
47996
  if (!selectedItem) {
47610
47997
  // TODO: handle this case better, show an error message to the user
47611
47998
  return [2 /*return*/];
47612
47999
  }
47613
- params = new URLSearchParams(location.search);
47614
- rooms = getRoomsFromParams(params, 'rooms');
47615
- tagId = getNumberFromParams(params, 'tagId');
47616
- destinationAirport = getStringFromParams(params, 'destinationAirport');
48000
+ seed = activeSearchSeed;
48001
+ tagId = (_a = seed === null || seed === void 0 ? void 0 : seed.tagId) !== null && _a !== void 0 ? _a : null;
48002
+ destinationAirport = (_b = seed === null || seed === void 0 ? void 0 : seed.destinationAirport) !== null && _b !== void 0 ? _b : null;
47617
48003
  destinationId = null;
47618
48004
  destinationIsCountry = false;
47619
48005
  destinationIsRegion = false;
@@ -47638,14 +48024,15 @@ var SearchResultsContainer = function () {
47638
48024
  destinationIsAirport = true;
47639
48025
  }
47640
48026
  detailSearchRequest = {
48027
+ transactionId: transactionId !== null && transactionId !== void 0 ? transactionId : '',
47641
48028
  officeId: 1,
47642
48029
  portalId: context.portalId,
47643
48030
  agentId: context.agentId,
47644
- catalogueId: (_a = context.searchConfiguration.defaultCatalogueId) !== null && _a !== void 0 ? _a : 0,
48031
+ catalogueId: (_c = context.searchConfiguration.defaultCatalogueId) !== null && _c !== void 0 ? _c : 0,
47645
48032
  searchConfigurationId: context.searchConfiguration.id,
47646
48033
  vendorConfigurationId: selectedItem.vendorId,
47647
- language: (_b = context.languageCode) !== null && _b !== void 0 ? _b : 'en-GB',
47648
- serviceType: 3,
48034
+ language: (_d = context.languageCode) !== null && _d !== void 0 ? _d : 'en-GB',
48035
+ serviceType: ACCOMMODATION_SERVICE_TYPE,
47649
48036
  fromDate: selectedItem.fromDate,
47650
48037
  toDate: selectedItem.toDate,
47651
48038
  destination: {
@@ -47658,18 +48045,22 @@ var SearchResultsContainer = function () {
47658
48045
  code: destinationCode
47659
48046
  },
47660
48047
  productCode: selectedItem.code ? selectedItem.code : '',
47661
- rooms: getPackagingRequestRooms(rooms),
48048
+ rooms: getPackagingRequestRoomsFromBookingRooms(
48049
+ (_e = seed === null || seed === void 0 ? void 0 : seed.rooms) !== null && _e !== void 0 ? _e : null
48050
+ ),
47662
48051
  tagIds: tagId ? [tagId] : []
47663
48052
  };
47664
48053
  return [4 /*yield*/, build.searchPackagingAccommodations(config, detailSearchRequest)];
47665
48054
  case 2:
47666
- packageAccoSearchDetails = _c.sent();
48055
+ packageAccoSearchDetails = _f.sent();
47667
48056
  console.log('Packaging Acco Search details', packageAccoSearchDetails);
47668
48057
  dispatch(setPackagingAccoSearchDetails(packageAccoSearchDetails));
48058
+ setDetailsIsLoading(false);
47669
48059
  return [3 /*break*/, 4];
47670
48060
  case 3:
47671
- err_4 = _c.sent();
47672
- console.error('Failed to fetch package details', err_4);
48061
+ err_5 = _f.sent();
48062
+ console.error('Failed to fetch package details', err_5);
48063
+ setDetailsIsLoading(false);
47673
48064
  return [3 /*break*/, 4];
47674
48065
  case 4:
47675
48066
  return [2 /*return*/];
@@ -47683,6 +48074,7 @@ var SearchResultsContainer = function () {
47683
48074
  if (selectedPackagingAccoResultCode) {
47684
48075
  fetchPackagingAccoSearchDetails();
47685
48076
  }
48077
+ dispatch(setAccommodationFlyInStep('details'));
47686
48078
  },
47687
48079
  [selectedSearchResult, selectedPackagingAccoResultCode]
47688
48080
  );
@@ -47698,6 +48090,110 @@ var SearchResultsContainer = function () {
47698
48090
  },
47699
48091
  [filters, results, packagingAccoResults, selectedSortType]
47700
48092
  );
48093
+ React.useEffect(
48094
+ function () {
48095
+ setInitialFiltersSet(false);
48096
+ },
48097
+ [activeSearchSeed]
48098
+ );
48099
+ var handleEditAccommodation = function (segments) {
48100
+ return __awaiter(void 0, void 0, void 0, function () {
48101
+ var sourceEntry, seed;
48102
+ return __generator(this, function (_a) {
48103
+ switch (_a.label) {
48104
+ case 0:
48105
+ sourceEntry =
48106
+ editablePackagingEntry !== null && editablePackagingEntry !== void 0
48107
+ ? editablePackagingEntry
48108
+ : context === null || context === void 0
48109
+ ? void 0
48110
+ : context.packagingEntry;
48111
+ if (!sourceEntry) return [2 /*return*/];
48112
+ seed = buildSearchSeedFromAccommodationSegments(sourceEntry, segments);
48113
+ if (!seed) return [2 /*return*/];
48114
+ setDetailsIsLoading(true);
48115
+ setSelectedAccommodationSeed(seed);
48116
+ dispatch(setAccommodationFlyInStep('results'));
48117
+ handleFlyInToggle(true);
48118
+ return [4 /*yield*/, runAccommodationFlow(seed)];
48119
+ case 1:
48120
+ _a.sent();
48121
+ setDetailsIsLoading(false);
48122
+ return [2 /*return*/];
48123
+ }
48124
+ });
48125
+ });
48126
+ };
48127
+ var buildSearchSeedFromAccommodationSegments = function (entry, segments) {
48128
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
48129
+ if (!(segments === null || segments === void 0 ? void 0 : segments.length)) return null;
48130
+ var sortedSegments = __spreadArray([], segments, true).sort(function (a, b) {
48131
+ return new Date(a.from).getTime() - new Date(b.from).getTime();
48132
+ });
48133
+ var firstSegment = lodash.first(sortedSegments);
48134
+ var lastSegment = lodash.last(sortedSegments);
48135
+ if (!firstSegment || !lastSegment) return null;
48136
+ return {
48137
+ fromDate: toDateOnlyString(firstSegment.from),
48138
+ toDate: toDateOnlyString(lastSegment.to),
48139
+ country: (_b = (_a = firstSegment.country) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : null,
48140
+ region: (_d = (_c = firstSegment.region) === null || _c === void 0 ? void 0 : _c.id) !== null && _d !== void 0 ? _d : null,
48141
+ oord: (_f = (_e = firstSegment.oord) === null || _e === void 0 ? void 0 : _e.id) !== null && _f !== void 0 ? _f : null,
48142
+ location: (_h = (_g = firstSegment.location) === null || _g === void 0 ? void 0 : _g.id) !== null && _h !== void 0 ? _h : null,
48143
+ hotel: parseHotelId(firstSegment),
48144
+ hotelCode: (_j = firstSegment.productCode) !== null && _j !== void 0 ? _j : null,
48145
+ tagId: null,
48146
+ destinationAirport: getDestinationAirportFromEntry((_k = entry.lines) !== null && _k !== void 0 ? _k : []),
48147
+ departureAirport: getDepartureAirportFromEntry((_l = entry.lines) !== null && _l !== void 0 ? _l : []),
48148
+ rooms: getRequestRoomsFromPackagingSegments(entry, sortedSegments)
48149
+ };
48150
+ };
48151
+ React.useEffect(
48152
+ function () {
48153
+ var fetchPriceDetails = function () {
48154
+ return __awaiter(void 0, void 0, void 0, function () {
48155
+ var config, priceDetails, err_6;
48156
+ return __generator(this, function (_a) {
48157
+ switch (_a.label) {
48158
+ case 0:
48159
+ console.log(
48160
+ 'Fetching price details for entry',
48161
+ editablePackagingEntry !== null && editablePackagingEntry !== void 0
48162
+ ? editablePackagingEntry
48163
+ : context === null || context === void 0
48164
+ ? void 0
48165
+ : context.packagingEntry
48166
+ );
48167
+ if (!context || !editablePackagingEntry) return [2 /*return*/];
48168
+ setPricesAreLoading(true);
48169
+ _a.label = 1;
48170
+ case 1:
48171
+ _a.trys.push([1, 3, , 4]);
48172
+ config = {
48173
+ host: context.tideConnection.host,
48174
+ apiKey: context.tideConnection.apiKey
48175
+ };
48176
+ return [4 /*yield*/, build.getPriceDetails(config, editablePackagingEntry)];
48177
+ case 2:
48178
+ priceDetails = _a.sent();
48179
+ dispatch(setPriceDetails(priceDetails));
48180
+ setPricesAreLoading(false);
48181
+ return [3 /*break*/, 4];
48182
+ case 3:
48183
+ err_6 = _a.sent();
48184
+ console.error('Error fetching price details', err_6);
48185
+ setPricesAreLoading(false);
48186
+ return [3 /*break*/, 4];
48187
+ case 4:
48188
+ return [2 /*return*/];
48189
+ }
48190
+ });
48191
+ });
48192
+ };
48193
+ fetchPriceDetails();
48194
+ },
48195
+ [editablePackagingEntry]
48196
+ );
47701
48197
  return React__default['default'].createElement(
47702
48198
  'div',
47703
48199
  { id: 'tide-booking', className: 'search__bg' },
@@ -47749,7 +48245,8 @@ var SearchResultsContainer = function () {
47749
48245
  handleSetIsOpen: function () {
47750
48246
  return setItineraryOpen(!itineraryOpen);
47751
48247
  },
47752
- isLoading: isLoading
48248
+ isLoading: pricesAreLoading,
48249
+ onEditAccommodation: handleEditAccommodation
47753
48250
  }),
47754
48251
  React__default['default'].createElement(
47755
48252
  'div',
@@ -47814,6 +48311,7 @@ var SearchResultsContainer = function () {
47814
48311
  'span',
47815
48312
  { className: 'search__result-row-text' },
47816
48313
  !isLoading &&
48314
+ !context.packagingEntry &&
47817
48315
  React__default['default'].createElement(
47818
48316
  React__default['default'].Fragment,
47819
48317
  null,
@@ -47829,7 +48327,8 @@ var SearchResultsContainer = function () {
47829
48327
  translations.SRP.TOTAL_RESULTS_LABEL
47830
48328
  )
47831
48329
  ),
47832
- !isMobile &&
48330
+ !context.packagingEntry &&
48331
+ !isMobile &&
47833
48332
  sortByTypes &&
47834
48333
  sortByTypes.length > 0 &&
47835
48334
  React__default['default'].createElement(
@@ -47857,25 +48356,35 @@ var SearchResultsContainer = function () {
47857
48356
  React__default['default'].createElement(
47858
48357
  'div',
47859
48358
  { className: 'search__results__wrapper' },
47860
- context.showTabViews && React__default['default'].createElement(TabViews, null),
48359
+ context.showTabViews &&
48360
+ (context.searchConfiguration.qsmType === build.PortalQsmType.GroupTour ||
48361
+ context.searchConfiguration.qsmType === build.PortalQsmType.Accommodation) &&
48362
+ React__default['default'].createElement(TabViews, null),
47861
48363
  context.showRoundTripResults && context.showMockup && React__default['default'].createElement(RoundTripResults, null),
47862
48364
  context.searchConfiguration.qsmType === build.PortalQsmType.GroupTour &&
47863
48365
  React__default['default'].createElement(GroupTourResults, { isLoading: isLoading }),
47864
48366
  context.searchConfiguration.qsmType === build.PortalQsmType.AccommodationAndFlight &&
48367
+ !context.packagingEntry &&
47865
48368
  context.showFlightResults &&
47866
48369
  (bookingPackageDetails === null || bookingPackageDetails === void 0 ? void 0 : bookingPackageDetails.outwardFlights) &&
47867
48370
  React__default['default'].createElement(FlightResults, {
47868
48371
  flights: bookingPackageDetails === null || bookingPackageDetails === void 0 ? void 0 : bookingPackageDetails.outwardFlights,
47869
48372
  isDeparture: true
47870
48373
  }),
47871
- context.showHotelAccommodationResults && React__default['default'].createElement(HotelAccommodationResults, { isLoading: isLoading }),
48374
+ context.showHotelAccommodationResults &&
48375
+ !context.packagingEntry &&
48376
+ React__default['default'].createElement(HotelAccommodationResults, { isLoading: isLoading }),
47872
48377
  context.searchConfiguration.qsmType === build.PortalQsmType.AccommodationAndFlight &&
48378
+ !context.packagingEntry &&
47873
48379
  context.showFlightResults &&
47874
48380
  (bookingPackageDetails === null || bookingPackageDetails === void 0 ? void 0 : bookingPackageDetails.returnFlights) &&
47875
48381
  React__default['default'].createElement(FlightResults, {
47876
48382
  flights: bookingPackageDetails === null || bookingPackageDetails === void 0 ? void 0 : bookingPackageDetails.returnFlights,
47877
48383
  isDeparture: false
47878
- })
48384
+ }),
48385
+ context.searchConfiguration.qsmType === build.PortalQsmType.AccommodationAndFlight &&
48386
+ context.packagingEntry &&
48387
+ React__default['default'].createElement('span', null, 'TODO: Show Full Itinerary here')
47879
48388
  )
47880
48389
  ),
47881
48390
  React__default['default'].createElement(FlyIn, {
@@ -47883,10 +48392,15 @@ var SearchResultsContainer = function () {
47883
48392
  srpType: context.searchConfiguration.qsmType,
47884
48393
  isOpen: flyInIsOpen,
47885
48394
  setIsOpen: handleFlyInToggle,
48395
+ handleConfirm: function () {
48396
+ return handleConfirmHotelSwap();
48397
+ },
47886
48398
  onPanelRef: function (el) {
47887
48399
  return (panelRef.current = el);
47888
48400
  },
47889
- detailsLoading: detailsIsLoading
48401
+ detailsLoading: detailsIsLoading,
48402
+ accommodationStep: accommodationFlyInStep,
48403
+ isPackageEditFlow: !!context.packagingEntry
47890
48404
  })
47891
48405
  )
47892
48406
  )