@qite/tide-booking-component 1.4.97 → 1.4.99

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/build/build-cjs/index.js +1423 -975
  2. package/build/build-cjs/src/search-results/components/itinerary/index.d.ts +2 -0
  3. package/build/build-cjs/src/search-results/store/search-results-slice.d.ts +9 -10
  4. package/build/build-cjs/src/search-results/types.d.ts +24 -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 +1419 -965
  11. package/build/build-esm/src/search-results/components/itinerary/index.d.ts +2 -0
  12. package/build/build-esm/src/search-results/store/search-results-slice.d.ts +9 -10
  13. package/build/build-esm/src/search-results/types.d.ts +24 -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 +331 -234
  22. package/src/search-results/components/search-results-container/search-results-container.tsx +444 -383
  23. package/src/search-results/store/search-results-slice.ts +22 -10
  24. package/src/search-results/types.ts +26 -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 +28 -1
@@ -13447,11 +13447,17 @@ PERFORMANCE OF THIS SOFTWARE.
13447
13447
  };
13448
13448
 
13449
13449
  var ENDPOINT = '/api/web/packaging';
13450
+ var ENDPOINT_START_TRANSACTION = ENDPOINT + '/start';
13450
13451
  var ENDPOINT_ACCOMMODATIONS = ENDPOINT + '/accommodations';
13451
13452
  var ENDPOINT_ENTRY = function (magicLinkCode) {
13452
13453
  return ENDPOINT + '/entry/' + magicLinkCode;
13453
13454
  };
13454
13455
  // MANUAL PACKAGING SEARCH
13456
+ var startTransaction = function (config, signal) {
13457
+ var apiKey = config.apiKey;
13458
+ var url = '' + config.host + ENDPOINT_START_TRANSACTION;
13459
+ return get(url, apiKey, config.token, signal, true);
13460
+ };
13455
13461
  var searchPackagingAccommodations = function (config, request, signal) {
13456
13462
  var url = '' + config.host + ENDPOINT_ACCOMMODATIONS;
13457
13463
  var apiKey = config.apiKey;
@@ -13539,6 +13545,7 @@ PERFORMANCE OF THIS SOFTWARE.
13539
13545
  exports.searchWithErrorMapping = searchWithErrorMapping;
13540
13546
  exports.setCustomEntryStatus = setCustomEntryStatus;
13541
13547
  exports.setEntryStatus = setEntryStatus;
13548
+ exports.startTransaction = startTransaction;
13542
13549
  exports.tourCodes = tourCodes;
13543
13550
  exports.transportDates = transportDates;
13544
13551
  exports.update = update;
@@ -32702,7 +32709,6 @@ var SearchInputGroup = function (_a) {
32702
32709
  );
32703
32710
  useEffect(
32704
32711
  function () {
32705
- console.log('options updated, resetting loading state');
32706
32712
  setIsLoading(false);
32707
32713
  },
32708
32714
  [options]
@@ -33657,13 +33663,15 @@ var initialState$1 = {
33657
33663
  selectedFlight: null,
33658
33664
  selectedFlightDetails: null,
33659
33665
  bookingPackageDetails: null,
33660
- entry: null,
33661
33666
  isLoading: false,
33662
33667
  filters: [],
33663
33668
  selectedSortType: null,
33664
33669
  activeTab: 'compact',
33665
33670
  currentPage: 1,
33666
- flyInIsOpen: false
33671
+ flyInIsOpen: false,
33672
+ editablePackagingEntry: null,
33673
+ transactionId: null,
33674
+ accommodationFlyInStep: 'details'
33667
33675
  };
33668
33676
  var searchResultsSlice = createSlice({
33669
33677
  name: 'searchResults',
@@ -33699,9 +33707,6 @@ var searchResultsSlice = createSlice({
33699
33707
  setBookingPackageDetails: function (state, action) {
33700
33708
  state.bookingPackageDetails = action.payload.details;
33701
33709
  },
33702
- setEntry: function (state, action) {
33703
- state.entry = action.payload.entry;
33704
- },
33705
33710
  selectFlight: function (state, action) {
33706
33711
  if (!state.bookingPackageDetails) return;
33707
33712
  var _a = action.payload,
@@ -33750,6 +33755,15 @@ var searchResultsSlice = createSlice({
33750
33755
  },
33751
33756
  setFlyInIsOpen: function (state, action) {
33752
33757
  state.flyInIsOpen = action.payload;
33758
+ },
33759
+ setEditablePackagingEntry: function (state, action) {
33760
+ state.editablePackagingEntry = action.payload;
33761
+ },
33762
+ setTransactionId: function (state, action) {
33763
+ state.transactionId = action.payload;
33764
+ },
33765
+ setAccommodationFlyInStep: function (state, action) {
33766
+ state.accommodationFlyInStep = action.payload;
33753
33767
  }
33754
33768
  }
33755
33769
  });
@@ -33763,7 +33777,6 @@ var setResults = ((_a = searchResultsSlice.actions), _a.setResults),
33763
33777
  setSelectedFlight = _a.setSelectedFlight,
33764
33778
  setSelectedFlightDetails = _a.setSelectedFlightDetails,
33765
33779
  setBookingPackageDetails = _a.setBookingPackageDetails,
33766
- setEntry = _a.setEntry,
33767
33780
  selectFlight = _a.selectFlight,
33768
33781
  setIsLoading = _a.setIsLoading,
33769
33782
  setFilters = _a.setFilters,
@@ -33772,7 +33785,10 @@ var setResults = ((_a = searchResultsSlice.actions), _a.setResults),
33772
33785
  setActiveTab = _a.setActiveTab;
33773
33786
  _a.setCurrentPage;
33774
33787
  _a.resetSearchState;
33775
- var setFlyInIsOpen = _a.setFlyInIsOpen;
33788
+ var setFlyInIsOpen = _a.setFlyInIsOpen,
33789
+ setEditablePackagingEntry = _a.setEditablePackagingEntry,
33790
+ setTransactionId = _a.setTransactionId,
33791
+ setAccommodationFlyInStep = _a.setAccommodationFlyInStep;
33776
33792
  var searchResultsReducer = searchResultsSlice.reducer;
33777
33793
 
33778
33794
  var ItemPicker = function (_a) {
@@ -34799,482 +34815,711 @@ var Icon$1 = function (_a) {
34799
34815
  }
34800
34816
  };
34801
34817
 
34802
- var getDepartureTime = function (flight) {
34803
- var _a, _b;
34804
- if (isEmpty(flight === null || flight === void 0 ? void 0 : flight.metaDatas)) return '';
34805
- try {
34806
- var config = (_a = first(flight === null || flight === void 0 ? void 0 : flight.metaDatas)) === null || _a === void 0 ? void 0 : _a.configuration;
34807
- if (!config) return '';
34808
- var parsed = JSON.parse(config);
34809
- var line = first(parsed === null || parsed === void 0 ? void 0 : parsed.FlightLines);
34810
- return (_b = line === null || line === void 0 ? void 0 : line.DepartureTime) !== null && _b !== void 0 ? _b : '';
34811
- } catch (_c) {
34812
- return '';
34818
+ var GROUP_TOUR_SERVICE_TYPE = 1;
34819
+ var ACCOMMODATION_SERVICE_TYPE = 3;
34820
+ var FLIGHT_SERVICE_TYPE = 7;
34821
+ var toDateOnlyString = function (value) {
34822
+ var date = value instanceof Date ? value : new Date(value);
34823
+ return date.toISOString().split('T')[0];
34824
+ };
34825
+ var getAgeAtReferenceDate = function (dateOfBirth, referenceDate) {
34826
+ var dob = dateOfBirth instanceof Date ? dateOfBirth : new Date(dateOfBirth);
34827
+ var ref = referenceDate instanceof Date ? referenceDate : new Date(referenceDate);
34828
+ var age = ref.getFullYear() - dob.getFullYear();
34829
+ var monthDiff = ref.getMonth() - dob.getMonth();
34830
+ if (monthDiff < 0 || (monthDiff === 0 && ref.getDate() < dob.getDate())) {
34831
+ age--;
34813
34832
  }
34833
+ return age;
34814
34834
  };
34815
- var getArrivalTime = function (flight) {
34816
- var _a, _b;
34817
- if (isEmpty(flight === null || flight === void 0 ? void 0 : flight.metaDatas)) return '';
34818
- try {
34819
- var config = (_a = first(flight === null || flight === void 0 ? void 0 : flight.metaDatas)) === null || _a === void 0 ? void 0 : _a.configuration;
34820
- if (!config) return '';
34821
- var parsed = JSON.parse(config);
34822
- var line = last(parsed === null || parsed === void 0 ? void 0 : parsed.FlightLines);
34823
- return (_b = line === null || line === void 0 ? void 0 : line.ArrivalTime) !== null && _b !== void 0 ? _b : '';
34824
- } catch (_c) {
34825
- return '';
34835
+ var getFlightLines$1 = function (lines) {
34836
+ return __spreadArray([], lines, true)
34837
+ .filter(function (line) {
34838
+ return line.serviceType === FLIGHT_SERVICE_TYPE;
34839
+ })
34840
+ .sort(function (a, b) {
34841
+ return new Date(a.from).getTime() - new Date(b.from).getTime();
34842
+ });
34843
+ };
34844
+ var getDepartureAirportFromEntry = function (lines) {
34845
+ var _a, _b, _c;
34846
+ var firstFlight = getFlightLines$1(lines)[0];
34847
+ var firstSegment =
34848
+ (_b =
34849
+ (_a = firstFlight === null || firstFlight === void 0 ? void 0 : firstFlight.flightInformation) === null || _a === void 0 ? void 0 : _a.flightLines) ===
34850
+ null || _b === void 0
34851
+ ? void 0
34852
+ : _b[0];
34853
+ return (_c = firstSegment === null || firstSegment === void 0 ? void 0 : firstSegment.departureAirportCode) !== null && _c !== void 0 ? _c : null;
34854
+ };
34855
+ var getDestinationAirportFromEntry = function (lines) {
34856
+ var _a, _b, _c;
34857
+ var outboundFlight = getFlightLines$1(lines)[0];
34858
+ var flightSegments =
34859
+ (_a = outboundFlight === null || outboundFlight === void 0 ? void 0 : outboundFlight.flightInformation) === null || _a === void 0 ? void 0 : _a.flightLines;
34860
+ if (!(flightSegments === null || flightSegments === void 0 ? void 0 : flightSegments.length)) return null;
34861
+ return (_c = (_b = flightSegments[flightSegments.length - 1]) === null || _b === void 0 ? void 0 : _b.arrivalAirportCode) !== null && _c !== void 0
34862
+ ? _c
34863
+ : null;
34864
+ };
34865
+ var mapPackagingPaxToBookingPax = function (pax, fallbackId, referenceDate) {
34866
+ var _a, _b, _c, _d, _e, _f;
34867
+ return {
34868
+ id: (_a = pax === null || pax === void 0 ? void 0 : pax.id) !== null && _a !== void 0 ? _a : fallbackId,
34869
+ guid:
34870
+ (_c = (_b = pax === null || pax === void 0 ? void 0 : pax.id) === null || _b === void 0 ? void 0 : _b.toString()) !== null && _c !== void 0
34871
+ ? _c
34872
+ : fallbackId.toString(),
34873
+ firstName: (_d = pax === null || pax === void 0 ? void 0 : pax.firstName) !== null && _d !== void 0 ? _d : '',
34874
+ lastName: (_e = pax === null || pax === void 0 ? void 0 : pax.lastName) !== null && _e !== void 0 ? _e : '',
34875
+ dateOfBirth: (_f = pax === null || pax === void 0 ? void 0 : pax.dateOfBirth) !== null && _f !== void 0 ? _f : undefined,
34876
+ age: (pax === null || pax === void 0 ? void 0 : pax.dateOfBirth) ? getAgeAtReferenceDate(pax.dateOfBirth, referenceDate) : undefined,
34877
+ isMainBooker: pax === null || pax === void 0 ? void 0 : pax.isMainBooker,
34878
+ email: ''
34879
+ };
34880
+ };
34881
+ var getRequestRoomsFromPackagingEntry = function (entry) {
34882
+ var _a, _b, _c, _d;
34883
+ var accommodationLines = ((_a = entry.lines) !== null && _a !== void 0 ? _a : []).filter(function (line) {
34884
+ var _a;
34885
+ return line.serviceType === ACCOMMODATION_SERVICE_TYPE && ((_a = line.pax) === null || _a === void 0 ? void 0 : _a.length) > 0;
34886
+ });
34887
+ var paxById = new Map(
34888
+ ((_b = entry.pax) !== null && _b !== void 0 ? _b : []).map(function (p) {
34889
+ return [p.id, p];
34890
+ })
34891
+ );
34892
+ if (!accommodationLines.length) {
34893
+ return [
34894
+ {
34895
+ index: 0,
34896
+ pax: ((_c = entry.pax) !== null && _c !== void 0 ? _c : []).map(function (p) {
34897
+ return mapPackagingPaxToBookingPax(p, p.id, new Date().toISOString());
34898
+ })
34899
+ }
34900
+ ];
34826
34901
  }
34902
+ var roomGroups = [];
34903
+ accommodationLines.forEach(function (line) {
34904
+ var groupedByRoom = new Map();
34905
+ line.pax.forEach(function (linePax) {
34906
+ var _a;
34907
+ var roomIndexWithinLine = Number((_a = linePax.room) !== null && _a !== void 0 ? _a : 0);
34908
+ var paxId = Number(linePax.paxId);
34909
+ var pax = mapPackagingPaxToBookingPax(paxById.get(paxId), paxId, line.from);
34910
+ if (!groupedByRoom.has(roomIndexWithinLine)) {
34911
+ groupedByRoom.set(roomIndexWithinLine, []);
34912
+ }
34913
+ groupedByRoom.get(roomIndexWithinLine).push(pax);
34914
+ });
34915
+ var sortedGroups = Array.from(groupedByRoom.entries())
34916
+ .sort(function (_a, _b) {
34917
+ var a = _a[0];
34918
+ var b = _b[0];
34919
+ return a - b;
34920
+ })
34921
+ .map(function (_a) {
34922
+ var pax = _a[1];
34923
+ return pax;
34924
+ });
34925
+ roomGroups.push.apply(roomGroups, sortedGroups);
34926
+ });
34927
+ if (!roomGroups.length) {
34928
+ return [
34929
+ {
34930
+ index: 0,
34931
+ pax: ((_d = entry.pax) !== null && _d !== void 0 ? _d : []).map(function (p) {
34932
+ return mapPackagingPaxToBookingPax(p, p.id, accommodationLines[0].from);
34933
+ })
34934
+ }
34935
+ ];
34936
+ }
34937
+ return roomGroups.map(function (pax, index) {
34938
+ return {
34939
+ index: index,
34940
+ pax: pax
34941
+ };
34942
+ });
34827
34943
  };
34828
- var getDuration = function (flight) {
34829
- var _a;
34830
- if (isEmpty(flight === null || flight === void 0 ? void 0 : flight.metaDatas)) return '';
34831
- try {
34832
- var config = (_a = first(flight === null || flight === void 0 ? void 0 : flight.metaDatas)) === null || _a === void 0 ? void 0 : _a.configuration;
34833
- if (!config) return '';
34834
- var parsed = JSON.parse(config);
34835
- var ticks = parsed === null || parsed === void 0 ? void 0 : parsed.DurationInTicks;
34836
- if (!ticks) return '';
34837
- var seconds = ticks / 10000000;
34838
- var hours = Math.floor(seconds / 3600);
34839
- var minutes = Math.floor((seconds % 3600) / 60);
34840
- return ''.concat(hours, 'h ').concat(minutes.toString().padStart(2, '0'), 'm');
34841
- } catch (_b) {
34842
- return '';
34944
+ var parseHotelId = function (line) {
34945
+ if (!(line === null || line === void 0 ? void 0 : line.productCode)) return null;
34946
+ var parsed = Number(line.productCode);
34947
+ return Number.isNaN(parsed) ? null : parsed;
34948
+ };
34949
+ var getPackagingRequestRoomsFromBookingRooms = function (rooms) {
34950
+ if (!(rooms === null || rooms === void 0 ? void 0 : rooms.length)) {
34951
+ var room_1 = { index: 0, travellers: [] };
34952
+ range(0, 2).forEach(function () {
34953
+ room_1.travellers.push({
34954
+ age: 30
34955
+ });
34956
+ });
34957
+ return [room_1];
34843
34958
  }
34959
+ return rooms.map(function (x, i) {
34960
+ var _a;
34961
+ var room = { index: (_a = x.index) !== null && _a !== void 0 ? _a : i, travellers: [] };
34962
+ x.pax.forEach(function (p) {
34963
+ var _a;
34964
+ room.travellers.push({
34965
+ age: (_a = p.age) !== null && _a !== void 0 ? _a : 30
34966
+ });
34967
+ });
34968
+ return room;
34969
+ });
34970
+ };
34971
+
34972
+ var getFlightLines = function (flight) {
34973
+ var _a, _b;
34974
+ return (_b = (_a = flight === null || flight === void 0 ? void 0 : flight.flightInformation) === null || _a === void 0 ? void 0 : _a.flightLines) !== null &&
34975
+ _b !== void 0
34976
+ ? _b
34977
+ : [];
34978
+ };
34979
+ var getDepartureTime = function (flight) {
34980
+ var firstLine = first(getFlightLines(flight));
34981
+ if (!(firstLine === null || firstLine === void 0 ? void 0 : firstLine.departureTime)) return '';
34982
+ return firstLine.departureTime.slice(0, 5);
34983
+ };
34984
+ var getArrivalTime = function (flight) {
34985
+ var lastLine = last(getFlightLines(flight));
34986
+ if (!(lastLine === null || lastLine === void 0 ? void 0 : lastLine.arrivalTime)) return '';
34987
+ return lastLine.arrivalTime.slice(0, 5);
34988
+ };
34989
+ var getDuration = function (flight) {
34990
+ var lines = getFlightLines(flight);
34991
+ if (!lines.length) return '';
34992
+ var totalTicks =
34993
+ lines.reduce(function (sum, line) {
34994
+ var _a;
34995
+ return sum + ((_a = line.durationInTicks) !== null && _a !== void 0 ? _a : 0);
34996
+ }, 0) || 0;
34997
+ if (!totalTicks) return '';
34998
+ var seconds = totalTicks / 10000000;
34999
+ var hours = Math.floor(seconds / 3600);
35000
+ var minutes = Math.floor((seconds % 3600) / 60);
35001
+ return ''.concat(hours, 'h ').concat(minutes.toString().padStart(2, '0'), 'm');
34844
35002
  };
34845
35003
  var numberOfNights = function (segment) {
34846
- return differenceInCalendarDays(new Date(segment.endDate), new Date(segment.startDate));
35004
+ return differenceInCalendarDays(new Date(segment.to), new Date(segment.from));
35005
+ };
35006
+ var getSegmentIcon = function (segment) {
35007
+ switch (segment.serviceType) {
35008
+ case 3:
35009
+ return React__default.createElement(
35010
+ 'div',
35011
+ { className: 'search__filter__itinerary__segment-badge search__filter__itinerary__segment-badge--secondary' },
35012
+ React__default.createElement(Icon$1, { name: 'ui-bed', width: 15, height: 15 })
35013
+ );
35014
+ case 4:
35015
+ return React__default.createElement(
35016
+ 'div',
35017
+ { className: 'search__filter__itinerary__segment-badge search__filter__itinerary__segment-badge--secondary' },
35018
+ React__default.createElement(Icon$1, { name: 'ui-ticket', width: 15, height: 15 })
35019
+ );
35020
+ case 11:
35021
+ return React__default.createElement(
35022
+ 'div',
35023
+ { className: 'search__filter__itinerary__segment-badge search__filter__itinerary__segment-badge--secondary' },
35024
+ React__default.createElement(Icon$1, { name: 'ui-ship', width: 15, height: 15 })
35025
+ );
35026
+ case 13:
35027
+ case 17:
35028
+ case 22:
35029
+ return React__default.createElement(
35030
+ 'div',
35031
+ { className: 'search__filter__itinerary__transport-badge' },
35032
+ React__default.createElement(Icon$1, { name: 'ui-car', width: 15, height: 15 })
35033
+ );
35034
+ default:
35035
+ return React__default.createElement(
35036
+ 'div',
35037
+ { className: 'search__filter__itinerary__segment-badge' },
35038
+ React__default.createElement(Icon$1, { name: 'ui-location', width: 15, height: 15 })
35039
+ );
35040
+ }
35041
+ };
35042
+ var canEdit = function (segment) {
35043
+ if (segment.serviceType === ACCOMMODATION_SERVICE_TYPE) {
35044
+ return true;
35045
+ }
35046
+ return false;
35047
+ };
35048
+ var getSegmentTitle = function (segment) {
35049
+ var _a;
35050
+ return (_a = segment.productName) !== null && _a !== void 0 ? _a : segment.accommodationName;
34847
35051
  };
34848
35052
  var Itinerary = function (_a) {
34849
- var _b;
35053
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
34850
35054
  var isOpen = _a.isOpen,
34851
- handleSetIsOpen = _a.handleSetIsOpen,
34852
- isLoading = _a.isLoading;
35055
+ handleSetIsOpen = _a.handleSetIsOpen;
35056
+ _a.isLoading;
35057
+ var onEditAccommodation = _a.onEditAccommodation;
34853
35058
  var context = useContext(SearchResultsConfigurationContext);
34854
35059
  var translations = getTranslations((_b = context === null || context === void 0 ? void 0 : context.languageCode) !== null && _b !== void 0 ? _b : 'en-GB');
34855
- var entry = useSelector(function (state) {
35060
+ var editablePackagingEntry = useSelector(function (state) {
34856
35061
  return state.searchResults;
34857
- }).entry;
34858
- if (isLoading || !entry) {
35062
+ }).editablePackagingEntry;
35063
+ var packagingEntry =
35064
+ editablePackagingEntry !== null && editablePackagingEntry !== void 0
35065
+ ? editablePackagingEntry
35066
+ : context === null || context === void 0
35067
+ ? void 0
35068
+ : context.packagingEntry;
35069
+ var sortedLines = useMemo(
35070
+ function () {
35071
+ var _a;
35072
+ return __spreadArray(
35073
+ [],
35074
+ (_a = packagingEntry === null || packagingEntry === void 0 ? void 0 : packagingEntry.lines) !== null && _a !== void 0 ? _a : [],
35075
+ true
35076
+ ).sort(function (a, b) {
35077
+ var _a, _b;
35078
+ var orderA = (_a = a.order) !== null && _a !== void 0 ? _a : Infinity;
35079
+ var orderB = (_b = b.order) !== null && _b !== void 0 ? _b : Infinity;
35080
+ // First sort by order
35081
+ if (orderA !== orderB) {
35082
+ return orderA - orderB;
35083
+ }
35084
+ // Fallback to date
35085
+ return new Date(a.from).getTime() - new Date(b.from).getTime();
35086
+ });
35087
+ },
35088
+ [packagingEntry]
35089
+ );
35090
+ if (!packagingEntry) {
34859
35091
  return null;
34860
35092
  }
34861
- var firstEntryLine = first(entry === null || entry === void 0 ? void 0 : entry.items);
34862
- var lastEntryLine = last(entry === null || entry === void 0 ? void 0 : entry.items);
34863
- var country = firstEntryLine === null || firstEntryLine === void 0 ? void 0 : firstEntryLine.countryName;
34864
- var location = firstEntryLine === null || firstEntryLine === void 0 ? void 0 : firstEntryLine.locationName;
34865
- var outboundFlight =
34866
- entry === null || entry === void 0
34867
- ? void 0
34868
- : entry.items.find(function (item) {
34869
- return item.productType === 7 && !item.isReturnFlight;
34870
- });
34871
- var returnFlight =
34872
- entry === null || entry === void 0
35093
+ var firstEntryLine = first(sortedLines);
35094
+ var lastEntryLine = last(sortedLines);
35095
+ var accommodationLine =
35096
+ (_c = sortedLines.find(function (line) {
35097
+ return line.serviceType === ACCOMMODATION_SERVICE_TYPE;
35098
+ })) !== null && _c !== void 0
35099
+ ? _c
35100
+ : firstEntryLine;
35101
+ var country =
35102
+ (_e =
35103
+ (_d = accommodationLine === null || accommodationLine === void 0 ? void 0 : accommodationLine.country) === null || _d === void 0 ? void 0 : _d.name) !==
35104
+ null && _e !== void 0
35105
+ ? _e
35106
+ : (_f = firstEntryLine === null || firstEntryLine === void 0 ? void 0 : firstEntryLine.country) === null || _f === void 0
34873
35107
  ? void 0
34874
- : entry.items.find(function (item) {
34875
- return item.productType === 7 && item.isReturnFlight;
34876
- });
34877
- var otherSegments =
34878
- entry === null || entry === void 0
35108
+ : _f.name;
35109
+ var location =
35110
+ (_m =
35111
+ (_k =
35112
+ (_h =
35113
+ (_g = accommodationLine === null || accommodationLine === void 0 ? void 0 : accommodationLine.location) === null || _g === void 0
35114
+ ? void 0
35115
+ : _g.name) !== null && _h !== void 0
35116
+ ? _h
35117
+ : (_j = accommodationLine === null || accommodationLine === void 0 ? void 0 : accommodationLine.oord) === null || _j === void 0
35118
+ ? void 0
35119
+ : _j.name) !== null && _k !== void 0
35120
+ ? _k
35121
+ : (_l = accommodationLine === null || accommodationLine === void 0 ? void 0 : accommodationLine.region) === null || _l === void 0
35122
+ ? void 0
35123
+ : _l.name) !== null && _m !== void 0
35124
+ ? _m
35125
+ : (_o = firstEntryLine === null || firstEntryLine === void 0 ? void 0 : firstEntryLine.location) === null || _o === void 0
34879
35126
  ? void 0
34880
- : entry.items.filter(function (item) {
34881
- return item.productType !== 7;
34882
- });
35127
+ : _o.name;
35128
+ var flightSegments = sortedLines.filter(function (item) {
35129
+ return item.serviceType === FLIGHT_SERVICE_TYPE;
35130
+ });
35131
+ var outboundFlight = first(flightSegments);
35132
+ var returnFlight = flightSegments.length > 1 ? last(flightSegments) : undefined;
35133
+ var otherSegments = sortedLines.filter(function (item) {
35134
+ return item.serviceType !== FLIGHT_SERVICE_TYPE;
35135
+ });
35136
+ var grouped = groupBy(otherSegments, function (segment) {
35137
+ return ''.concat(segment.productCode, '-').concat(segment.from, '-').concat(segment.to);
35138
+ });
35139
+ var groupedOtherSegments = Object.entries(grouped).map(function (_a) {
35140
+ var key = _a[0],
35141
+ segments = _a[1];
35142
+ return {
35143
+ key: key,
35144
+ segments: segments
35145
+ };
35146
+ });
35147
+ console.log('otherSegments', otherSegments);
35148
+ console.log('groupedOtherSegments', groupedOtherSegments);
35149
+ var numberOfPax = ((_p = packagingEntry.pax) === null || _p === void 0 ? void 0 : _p.length) || 1;
35150
+ var totalPrice = packagingEntry.price || 0;
35151
+ var pricePerPerson = totalPrice / numberOfPax;
34883
35152
  return React__default.createElement(
34884
- React__default.Fragment,
34885
- null,
35153
+ 'div',
35154
+ { className: 'search__filters--modal '.concat(isOpen ? 'is-open' : '') },
35155
+ React__default.createElement('div', { className: 'search__filters--background', onClick: handleSetIsOpen }),
35156
+ React__default.createElement(
35157
+ 'button',
35158
+ { className: 'search__filters--close', onClick: handleSetIsOpen },
35159
+ React__default.createElement(Icon$1, { name: 'ui-close', height: 24 })
35160
+ ),
34886
35161
  React__default.createElement(
34887
35162
  'div',
34888
- { className: 'search__filters--modal '.concat(isOpen ? 'is-open' : '') },
34889
- React__default.createElement('div', {
34890
- className: 'search__filters--background',
34891
- onClick: function () {
34892
- return handleSetIsOpen();
34893
- }
34894
- }),
35163
+ { className: 'search__filters' },
34895
35164
  React__default.createElement(
34896
- 'button',
34897
- {
34898
- className: 'search__filters--close',
34899
- onClick: function () {
34900
- return handleSetIsOpen();
34901
- }
34902
- },
34903
- React__default.createElement(Icon$1, { name: 'ui-close', height: 24 })
35165
+ 'div',
35166
+ { className: 'search__filter-row search__filter__header' },
35167
+ React__default.createElement(
35168
+ 'div',
35169
+ { className: 'search__filter-row-flex-title' },
35170
+ React__default.createElement('p', { className: 'search__filter-small-title' }, translations.SRP.ITINERARY_TITLE)
35171
+ )
34904
35172
  ),
34905
35173
  React__default.createElement(
34906
- 'div',
34907
- { className: 'search__filters' },
35174
+ React__default.Fragment,
35175
+ null,
34908
35176
  React__default.createElement(
34909
35177
  'div',
34910
- { className: 'search__filter-row search__filter__header' },
35178
+ { className: 'search__filter-group' },
35179
+ (context === null || context === void 0 ? void 0 : context.destinationImage) &&
35180
+ React__default.createElement(
35181
+ 'div',
35182
+ { className: 'search__filter__image__wrapper' },
35183
+ React__default.createElement('img', { src: context.destinationImage.url, alt: context.destinationImage.alt, className: 'search__filter__image' }),
35184
+ (packagingEntry === null || packagingEntry === void 0 ? void 0 : packagingEntry.dossierNumber) &&
35185
+ React__default.createElement(
35186
+ 'span',
35187
+ { className: 'search__filter__image__text' },
35188
+ translations.SRP.DOSSIER_NUMBER,
35189
+ ': ',
35190
+ packagingEntry.dossierNumber
35191
+ ),
35192
+ React__default.createElement(
35193
+ 'h4',
35194
+ { className: 'search__filter__image__title' },
35195
+ (location || '') + (location && country ? ' - ' : '') + (country || '')
35196
+ )
35197
+ )
35198
+ ),
35199
+ React__default.createElement(
35200
+ 'div',
35201
+ { className: 'search__filter__prices' },
34911
35202
  React__default.createElement(
34912
35203
  'div',
34913
- { className: 'search__filter-row-flex-title' },
34914
- React__default.createElement('p', { className: 'search__filter-small-title' }, translations.SRP.ITINERARY_TITLE)
34915
- )
34916
- ),
34917
- isLoading
34918
- ? React__default.createElement(Spinner, null)
34919
- : React__default.createElement(
34920
- React__default.Fragment,
35204
+ { className: 'search__filter__prices__wrapper' },
35205
+ React__default.createElement('h3', { className: 'search__filter__prices--amount' }, formatPrice$2(pricePerPerson, 'EUR')),
35206
+ React__default.createElement('p', null, translations.SRP.PACKAGE_PRICE_PER_PERSON),
35207
+ React__default.createElement(
35208
+ 'p',
34921
35209
  null,
35210
+ React__default.createElement('strong', null, '(', formatPrice$2(totalPrice, 'EUR'), ' ', translations.SRP.TOTAL, ')')
35211
+ )
35212
+ ),
35213
+ React__default.createElement('button', { className: 'cta' }, translations.QSM.CONFIRM)
35214
+ ),
35215
+ React__default.createElement(
35216
+ 'div',
35217
+ { className: 'search__filter__itinerary' },
35218
+ React__default.createElement('p', null, translations.SRP.DAY_BY_DAY),
35219
+ firstEntryLine &&
35220
+ React__default.createElement(
35221
+ 'div',
35222
+ { className: 'search__filter__itinerary__country' },
34922
35223
  React__default.createElement(
34923
35224
  'div',
34924
- { className: 'search__filter-group' },
34925
- (context === null || context === void 0 ? void 0 : context.destinationImage) &&
34926
- React__default.createElement(
34927
- 'div',
34928
- { className: 'search__filter__image__wrapper' },
34929
- React__default.createElement('img', {
34930
- src: context.destinationImage.url,
34931
- alt: context.destinationImage.alt,
34932
- className: 'search__filter__image'
34933
- }),
34934
- (entry === null || entry === void 0 ? void 0 : entry.number) &&
34935
- React__default.createElement(
34936
- 'span',
34937
- { className: 'search__filter__image__text' },
34938
- translations.SRP.DOSSIER_NUMBER,
34939
- ': ',
34940
- entry === null || entry === void 0 ? void 0 : entry.number
34941
- ),
34942
- React__default.createElement(
34943
- 'h4',
34944
- { className: 'search__filter__image__title' },
34945
- (location || '') + (location && country ? ' - ' : '') + (country || '')
34946
- )
34947
- )
35225
+ { className: 'search__filter__itinerary__country-icon' },
35226
+ React__default.createElement(Icon$1, { name: 'ui-flag', width: 17.5, height: 20 })
34948
35227
  ),
34949
35228
  React__default.createElement(
34950
35229
  'div',
34951
- { className: 'search__filter__prices' },
35230
+ { className: 'search__filter__itinerary__country-content' },
35231
+ React__default.createElement(
35232
+ 'p',
35233
+ null,
35234
+ format$1(new Date(firstEntryLine.from), 'EEE. d MMM yyyy'),
35235
+ ' - ',
35236
+ React__default.createElement('strong', null, translations.SRP.START)
35237
+ )
35238
+ )
35239
+ ),
35240
+ outboundFlight &&
35241
+ React__default.createElement(
35242
+ 'div',
35243
+ { className: 'search__filter__itinerary__transport' },
35244
+ React__default.createElement(
35245
+ 'div',
35246
+ { className: 'search__filter__itinerary__transport-timeline' },
35247
+ React__default.createElement('div', { className: 'search__filter__itinerary__transport-timeline-line' })
35248
+ ),
35249
+ React__default.createElement(
35250
+ 'div',
35251
+ { className: 'search__filter__itinerary__transport-item' },
34952
35252
  React__default.createElement(
34953
35253
  'div',
34954
- { className: 'search__filter__prices__wrapper' },
35254
+ { className: 'search__filter__itinerary__transport-date' },
34955
35255
  React__default.createElement(
34956
- 'h3',
34957
- { className: 'search__filter__prices--amount' },
34958
- formatPrice$2(
34959
- ((entry === null || entry === void 0 ? void 0 : entry.sellingPrice) || 0) /
34960
- ((entry === null || entry === void 0 ? void 0 : entry.numberOfPax) || 1),
34961
- (entry === null || entry === void 0 ? void 0 : entry.currencyCode) || 'EUR'
35256
+ 'p',
35257
+ { className: 'search__filter__itinerary__transport-date-date' },
35258
+ React__default.createElement('strong', null, format$1(new Date(outboundFlight.from), 'd'))
35259
+ ),
35260
+ React__default.createElement('p', null, format$1(new Date(outboundFlight.from), 'MMM'))
35261
+ ),
35262
+ React__default.createElement(
35263
+ 'div',
35264
+ { className: 'search__filter__itinerary__transport-badge' },
35265
+ React__default.createElement(Icon$1, { name: 'ui-plane', height: 15 })
35266
+ ),
35267
+ React__default.createElement(
35268
+ 'div',
35269
+ { className: 'search__filter__itinerary__transport-details' },
35270
+ React__default.createElement('h6', null, outboundFlight.productName),
35271
+ React__default.createElement(
35272
+ 'p',
35273
+ { className: 'search__filter__itinerary__transport-details-plane' },
35274
+ React__default.createElement(
35275
+ 'span',
35276
+ null,
35277
+ React__default.createElement(Icon$1, { name: 'ui-plane-depart', height: 14 }),
35278
+ ' ',
35279
+ React__default.createElement('strong', null, getDepartureTime(outboundFlight))
35280
+ ),
35281
+ ' ',
35282
+ '-',
35283
+ ' ',
35284
+ React__default.createElement(
35285
+ 'span',
35286
+ null,
35287
+ React__default.createElement(Icon$1, { name: 'ui-plane-arrive', height: 14 }),
35288
+ ' ',
35289
+ React__default.createElement('strong', null, getArrivalTime(outboundFlight))
34962
35290
  )
34963
35291
  ),
34964
- React__default.createElement('p', null, translations.SRP.PACKAGE_PRICE_PER_PERSON),
34965
35292
  React__default.createElement(
34966
35293
  'p',
34967
- null,
35294
+ { className: 'search__filter__itinerary__transport-details-time' },
34968
35295
  React__default.createElement(
34969
- 'strong',
35296
+ 'span',
34970
35297
  null,
34971
- '(',
34972
- formatPrice$2(
34973
- (entry === null || entry === void 0 ? void 0 : entry.sellingPrice) || 0,
34974
- (entry === null || entry === void 0 ? void 0 : entry.currencyCode) || 'EUR'
34975
- ),
35298
+ React__default.createElement(Icon$1, { name: 'ui-clock', height: 20 }),
34976
35299
  ' ',
34977
- translations.SRP.TOTAL,
34978
- ')'
35300
+ getDuration(outboundFlight)
34979
35301
  )
34980
35302
  )
34981
- ),
34982
- React__default.createElement('button', { className: 'cta' }, translations.QSM.CONFIRM)
34983
- ),
34984
- React__default.createElement(
35303
+ )
35304
+ )
35305
+ ),
35306
+ !isEmpty(groupedOtherSegments) &&
35307
+ groupedOtherSegments.map(function (group) {
35308
+ var _a, _b, _c, _d, _e, _f, _g, _h;
35309
+ var firstSegment = first(group.segments);
35310
+ if (!firstSegment) return null;
35311
+ return React__default.createElement(
34985
35312
  'div',
34986
- { className: 'search__filter__itinerary' },
34987
- React__default.createElement('p', null, translations.SRP.DAY_BY_DAY),
35313
+ { className: 'search__filter__itinerary__segments' },
34988
35314
  React__default.createElement(
34989
35315
  'div',
34990
- { className: 'search__filter__itinerary__country' },
35316
+ { className: 'search__filter__itinerary__segments__wrapper', key: group.key },
34991
35317
  React__default.createElement(
34992
35318
  'div',
34993
- { className: 'search__filter__itinerary__country-icon' },
34994
- React__default.createElement(Icon$1, { name: 'ui-flag', width: 17.5, height: 20 })
35319
+ { className: 'search__filter__itinerary__segments-timeline' },
35320
+ React__default.createElement('div', { className: 'search__filter__itinerary__segments-timeline-line' })
34995
35321
  ),
34996
35322
  React__default.createElement(
34997
35323
  'div',
34998
- { className: 'search__filter__itinerary__country-content' },
34999
- React__default.createElement(
35000
- 'p',
35001
- null,
35002
- format$1(new Date((firstEntryLine === null || firstEntryLine === void 0 ? void 0 : firstEntryLine.startDate) || ''), 'EEE. d MMM yyyy'),
35003
- ' - ',
35004
- React__default.createElement('strong', null, translations.SRP.START)
35005
- )
35006
- )
35007
- ),
35008
- outboundFlight &&
35009
- React__default.createElement(
35010
- 'div',
35011
- { className: 'search__filter__itinerary__transport' },
35324
+ { className: 'search__filter__itinerary__segment' },
35012
35325
  React__default.createElement(
35013
35326
  'div',
35014
- { className: 'search__filter__itinerary__transport-timeline' },
35015
- React__default.createElement('div', { className: 'search__filter__itinerary__transport-timeline-line' })
35016
- ),
35017
- React__default.createElement(
35018
- 'div',
35019
- { className: 'search__filter__itinerary__transport-item' },
35327
+ { className: 'search__filter__itinerary__segment-item search__filter__itinerary__segment-item--start' },
35020
35328
  React__default.createElement(
35021
35329
  'div',
35022
35330
  { className: 'search__filter__itinerary__transport-date' },
35023
35331
  React__default.createElement(
35024
35332
  'p',
35025
35333
  { className: 'search__filter__itinerary__transport-date-date' },
35026
- React__default.createElement(
35027
- 'strong',
35028
- null,
35029
- format$1(new Date((outboundFlight === null || outboundFlight === void 0 ? void 0 : outboundFlight.startDate) || ''), 'd')
35030
- )
35334
+ React__default.createElement('strong', null, format$1(new Date(firstSegment.from), 'd'))
35031
35335
  ),
35032
- React__default.createElement(
35033
- 'p',
35034
- null,
35035
- format$1(new Date((outboundFlight === null || outboundFlight === void 0 ? void 0 : outboundFlight.startDate) || ''), 'MMM')
35036
- )
35336
+ React__default.createElement('p', null, format$1(new Date(firstSegment.from), 'MMM'))
35037
35337
  ),
35038
35338
  React__default.createElement(
35039
35339
  'div',
35040
- { className: 'search__filter__itinerary__transport-badge' },
35041
- React__default.createElement(Icon$1, { name: 'ui-plane', height: 15 })
35340
+ { className: 'search__filter__itinerary__segment-badge' },
35341
+ React__default.createElement(Icon$1, { name: 'ui-location', width: 15, height: 15 })
35042
35342
  ),
35043
35343
  React__default.createElement(
35044
35344
  'div',
35045
- { className: 'search__filter__itinerary__transport-details' },
35046
- React__default.createElement('h6', null, outboundFlight.productName),
35345
+ { className: 'search__filter__itinerary__segment-details' },
35047
35346
  React__default.createElement(
35048
- 'p',
35049
- { className: 'search__filter__itinerary__transport-details-plane' },
35050
- React__default.createElement(
35051
- 'span',
35052
- null,
35053
- React__default.createElement(Icon$1, { name: 'ui-plane-depart', height: 14 }),
35054
- ' ',
35055
- React__default.createElement('strong', null, getDepartureTime(outboundFlight))
35056
- ),
35057
- ' ',
35058
- '-',
35059
- ' ',
35060
- React__default.createElement(
35061
- 'span',
35062
- null,
35063
- React__default.createElement(Icon$1, { name: 'ui-plane-arrive', height: 14 }),
35064
- ' ',
35065
- React__default.createElement('strong', null, getArrivalTime(outboundFlight))
35066
- )
35347
+ 'h6',
35348
+ null,
35349
+ ((_a = firstSegment.location) === null || _a === void 0 ? void 0 : _a.name) ||
35350
+ ((_b = firstSegment.oord) === null || _b === void 0 ? void 0 : _b.name) ||
35351
+ ((_c = firstSegment.region) === null || _c === void 0 ? void 0 : _c.name),
35352
+ (((_d = firstSegment.location) === null || _d === void 0 ? void 0 : _d.name) ||
35353
+ ((_e = firstSegment.oord) === null || _e === void 0 ? void 0 : _e.name) ||
35354
+ ((_f = firstSegment.region) === null || _f === void 0 ? void 0 : _f.name)) &&
35355
+ ((_g = firstSegment.country) === null || _g === void 0 ? void 0 : _g.name)
35356
+ ? ', '
35357
+ : '',
35358
+ (_h = firstSegment.country) === null || _h === void 0 ? void 0 : _h.name
35067
35359
  ),
35068
35360
  React__default.createElement(
35069
35361
  'p',
35070
- { className: 'search__filter__itinerary__transport-details-time' },
35071
- React__default.createElement(
35072
- 'span',
35073
- null,
35074
- React__default.createElement(Icon$1, { name: 'ui-clock', height: 20 }),
35075
- ' ',
35076
- getDuration(outboundFlight)
35077
- )
35362
+ { className: 'search__filter__itinerary__segment-details-text' },
35363
+ format$1(new Date(firstSegment.from), 'EEE. d MMM yyyy'),
35364
+ '> ',
35365
+ format$1(new Date(firstSegment.to), 'EEE. d MMM yyyy')
35078
35366
  )
35079
35367
  )
35080
35368
  )
35081
35369
  ),
35082
- !isEmpty(otherSegments) &&
35083
35370
  React__default.createElement(
35084
35371
  'div',
35085
- { className: 'search__filter__itinerary__segments' },
35086
- otherSegments === null || otherSegments === void 0
35087
- ? void 0
35088
- : otherSegments.map(function (segment, index) {
35089
- return React__default.createElement(
35090
- 'div',
35091
- { className: 'search__filter__itinerary__segments__wrapper', key: 'segment-'.concat(index) },
35092
- React__default.createElement(
35093
- 'div',
35094
- { className: 'search__filter__itinerary__segments-timeline' },
35095
- React__default.createElement('div', { className: 'search__filter__itinerary__segments-timeline-line' })
35096
- ),
35097
- React__default.createElement(
35098
- 'div',
35099
- { className: 'search__filter__itinerary__segment' },
35100
- React__default.createElement(
35101
- 'div',
35102
- { className: 'search__filter__itinerary__segment-item search__filter__itinerary__segment-item--start' },
35103
- React__default.createElement(
35104
- 'div',
35105
- { className: 'search__filter__itinerary__transport-date' },
35106
- React__default.createElement(
35107
- 'p',
35108
- { className: 'search__filter__itinerary__transport-date-date' },
35109
- React__default.createElement(
35110
- 'strong',
35111
- null,
35112
- format$1(new Date((segment === null || segment === void 0 ? void 0 : segment.startDate) || ''), 'd')
35113
- )
35114
- ),
35115
- React__default.createElement(
35116
- 'p',
35117
- null,
35118
- format$1(new Date((segment === null || segment === void 0 ? void 0 : segment.startDate) || ''), 'MMM')
35119
- )
35120
- ),
35121
- React__default.createElement(
35122
- 'div',
35123
- { className: 'search__filter__itinerary__segment-badge' },
35124
- React__default.createElement(Icon$1, { name: 'ui-location', width: 15, height: 15 })
35125
- ),
35126
- React__default.createElement(
35127
- 'div',
35128
- { className: 'search__filter__itinerary__segment-details' },
35129
- React__default.createElement(
35130
- 'h6',
35131
- null,
35132
- segment === null || segment === void 0 ? void 0 : segment.locationName,
35133
- ', ',
35134
- segment === null || segment === void 0 ? void 0 : segment.countryName
35135
- ),
35136
- React__default.createElement(
35137
- 'p',
35138
- { className: 'search__filter__itinerary__segment-details-text' },
35139
- format$1(new Date((segment === null || segment === void 0 ? void 0 : segment.startDate) || ''), 'EEE. d MMM yyyy'),
35140
- '> ',
35141
- format$1(new Date((segment === null || segment === void 0 ? void 0 : segment.endDate) || ''), 'EEE. d MMM yyyy')
35142
- )
35143
- )
35144
- )
35145
- ),
35146
- React__default.createElement(
35147
- 'div',
35148
- { className: 'search__filter__itinerary__segment' },
35149
- React__default.createElement(
35150
- 'div',
35151
- { className: 'search__filter__itinerary__segment-item' },
35152
- segment.productType === 3 &&
35153
- React__default.createElement(
35154
- 'div',
35155
- { className: 'search__filter__itinerary__segment-date search__filter__itinerary__segment-nights' },
35156
- React__default.createElement(
35157
- 'p',
35158
- { className: 'search__filter__itinerary__segment-date-date' },
35159
- React__default.createElement('strong', null, numberOfNights(segment))
35160
- ),
35161
- React__default.createElement(Icon$1, { name: 'ui-moon', width: 16, height: 16 })
35162
- ),
35163
- React__default.createElement(
35164
- 'div',
35165
- { className: 'search__filter__itinerary__segment-badge search__filter__itinerary__segment-badge--secondary' },
35166
- segment.productType === 3 && React__default.createElement(Icon$1, { name: 'ui-bed', width: 15, height: 15 }),
35167
- segment.productType === 4 && React__default.createElement(Icon$1, { name: 'ui-ticket', width: 15, height: 15 }),
35168
- (segment.productType === 17 || segment.productType === 22) &&
35169
- React__default.createElement(Icon$1, { name: 'ui-car', width: 15, height: 15 }),
35170
- segment.productType === 11 && React__default.createElement(Icon$1, { name: 'ui-ship', width: 15, height: 15 })
35171
- ),
35172
- React__default.createElement(
35173
- 'div',
35174
- { className: 'search__filter__itinerary__segment-details' },
35175
- React__default.createElement('h6', null, segment === null || segment === void 0 ? void 0 : segment.productName)
35176
- )
35177
- )
35178
- )
35179
- );
35180
- })
35181
- ),
35182
- returnFlight &&
35183
- React__default.createElement(
35184
- 'div',
35185
- { className: 'search__filter__itinerary__transport' },
35372
+ { className: 'search__filter__itinerary__segment' },
35186
35373
  React__default.createElement(
35187
35374
  'div',
35188
- { className: 'search__filter__itinerary__transport-timeline' },
35189
- React__default.createElement('div', { className: 'search__filter__itinerary__transport-timeline-line' })
35190
- ),
35191
- React__default.createElement(
35192
- 'div',
35193
- { className: 'search__filter__itinerary__transport-item' },
35375
+ {
35376
+ className: 'search__filter__itinerary__segment-item '.concat(
35377
+ canEdit(firstSegment) ? 'search__filter__itinerary__segment-item--editable' : ''
35378
+ ),
35379
+ onClick: function () {
35380
+ if (canEdit(firstSegment) && onEditAccommodation) {
35381
+ onEditAccommodation(group.segments);
35382
+ }
35383
+ }
35384
+ },
35194
35385
  React__default.createElement(
35195
35386
  'div',
35196
- { className: 'search__filter__itinerary__transport-date' },
35197
- React__default.createElement(
35198
- 'p',
35199
- { className: 'search__filter__itinerary__transport-date-date' },
35387
+ { className: 'search__filter__itinerary__segment-date search__filter__itinerary__segment-nights' },
35388
+ firstSegment.serviceType === ACCOMMODATION_SERVICE_TYPE &&
35200
35389
  React__default.createElement(
35201
- 'strong',
35390
+ React__default.Fragment,
35202
35391
  null,
35203
- format$1(new Date((returnFlight === null || returnFlight === void 0 ? void 0 : returnFlight.startDate) || ''), 'd')
35392
+ React__default.createElement(
35393
+ 'p',
35394
+ { className: 'search__filter__itinerary__segment-date-date' },
35395
+ React__default.createElement('strong', null, numberOfNights(firstSegment))
35396
+ ),
35397
+ React__default.createElement(Icon$1, { name: 'ui-moon', width: 16, height: 16 })
35204
35398
  )
35205
- ),
35206
- React__default.createElement(
35207
- 'p',
35208
- null,
35209
- format$1(new Date((returnFlight === null || returnFlight === void 0 ? void 0 : returnFlight.startDate) || ''), 'MMM')
35210
- )
35211
- ),
35212
- React__default.createElement(
35213
- 'div',
35214
- { className: 'search__filter__itinerary__transport-badge' },
35215
- React__default.createElement(Icon$1, { name: 'ui-plane', height: 15 })
35216
35399
  ),
35400
+ getSegmentIcon(firstSegment),
35217
35401
  React__default.createElement(
35218
35402
  'div',
35219
- { className: 'search__filter__itinerary__transport-details' },
35220
- React__default.createElement('h6', null, returnFlight === null || returnFlight === void 0 ? void 0 : returnFlight.productName),
35221
- React__default.createElement(
35222
- 'p',
35223
- { className: 'search__filter__itinerary__transport-details-plane' },
35224
- React__default.createElement(
35225
- 'span',
35226
- null,
35227
- React__default.createElement(Icon$1, { name: 'ui-plane-depart', height: 14 }),
35228
- ' ',
35229
- React__default.createElement('strong', null, getDepartureTime(returnFlight))
35230
- ),
35231
- ' ',
35232
- '-',
35233
- ' ',
35234
- React__default.createElement(
35235
- 'span',
35236
- null,
35237
- React__default.createElement(Icon$1, { name: 'ui-plane-arrive', height: 14 }),
35238
- ' ',
35239
- React__default.createElement('strong', null, getArrivalTime(returnFlight))
35240
- )
35241
- ),
35242
- React__default.createElement(
35243
- 'p',
35244
- { className: 'search__filter__itinerary__transport-details-time' },
35245
- React__default.createElement(
35246
- 'span',
35247
- null,
35248
- React__default.createElement(Icon$1, { name: 'ui-clock', height: 20 }),
35249
- ' ',
35250
- getDuration(returnFlight)
35251
- )
35252
- )
35403
+ { className: 'search__filter__itinerary__segment-details' },
35404
+ React__default.createElement('h6', null, getSegmentTitle(firstSegment)),
35405
+ firstSegment.serviceType === ACCOMMODATION_SERVICE_TYPE &&
35406
+ group.segments.map(function (segment, index) {
35407
+ return React__default.createElement(
35408
+ React__default.Fragment,
35409
+ { key: segment.guid },
35410
+ React__default.createElement('strong', null, translations.SHARED.ROOM, '\u00A0', index + 1),
35411
+ segment.productName &&
35412
+ segment.accommodationName &&
35413
+ React__default.createElement(
35414
+ 'div',
35415
+ { className: 'search__filter__itinerary__segment-details__room' },
35416
+ React__default.createElement(Icon$1, { name: 'ui-bed', width: 12, height: 12 }),
35417
+ segment.accommodationName
35418
+ ),
35419
+ segment.regimeName &&
35420
+ React__default.createElement(
35421
+ 'div',
35422
+ { className: 'search__filter__itinerary__segment-details__room' },
35423
+ React__default.createElement(Icon$1, { name: 'ui-utensils', width: 12, height: 12 }),
35424
+ segment.regimeName
35425
+ )
35426
+ );
35427
+ })
35253
35428
  )
35254
35429
  )
35430
+ )
35431
+ )
35432
+ );
35433
+ }),
35434
+ returnFlight &&
35435
+ returnFlight !== outboundFlight &&
35436
+ React__default.createElement(
35437
+ 'div',
35438
+ { className: 'search__filter__itinerary__transport' },
35439
+ React__default.createElement(
35440
+ 'div',
35441
+ { className: 'search__filter__itinerary__transport-timeline' },
35442
+ React__default.createElement('div', { className: 'search__filter__itinerary__transport-timeline-line' })
35443
+ ),
35444
+ React__default.createElement(
35445
+ 'div',
35446
+ { className: 'search__filter__itinerary__transport-item' },
35447
+ React__default.createElement(
35448
+ 'div',
35449
+ { className: 'search__filter__itinerary__transport-date' },
35450
+ React__default.createElement(
35451
+ 'p',
35452
+ { className: 'search__filter__itinerary__transport-date-date' },
35453
+ React__default.createElement('strong', null, format$1(new Date(returnFlight.from), 'd'))
35255
35454
  ),
35455
+ React__default.createElement('p', null, format$1(new Date(returnFlight.from), 'MMM'))
35456
+ ),
35457
+ React__default.createElement(
35458
+ 'div',
35459
+ { className: 'search__filter__itinerary__transport-badge' },
35460
+ React__default.createElement(Icon$1, { name: 'ui-plane', height: 15 })
35461
+ ),
35256
35462
  React__default.createElement(
35257
35463
  'div',
35258
- { className: 'search__filter__itinerary__country' },
35464
+ { className: 'search__filter__itinerary__transport-details' },
35465
+ React__default.createElement('h6', null, returnFlight.productName),
35259
35466
  React__default.createElement(
35260
- 'div',
35261
- { className: 'search__filter__itinerary__country-icon' },
35262
- React__default.createElement(Icon$1, { name: 'ui-flag', width: 17.5, height: 20 })
35467
+ 'p',
35468
+ { className: 'search__filter__itinerary__transport-details-plane' },
35469
+ React__default.createElement(
35470
+ 'span',
35471
+ null,
35472
+ React__default.createElement(Icon$1, { name: 'ui-plane-depart', height: 14 }),
35473
+ ' ',
35474
+ React__default.createElement('strong', null, getDepartureTime(returnFlight))
35475
+ ),
35476
+ ' ',
35477
+ '-',
35478
+ ' ',
35479
+ React__default.createElement(
35480
+ 'span',
35481
+ null,
35482
+ React__default.createElement(Icon$1, { name: 'ui-plane-arrive', height: 14 }),
35483
+ ' ',
35484
+ React__default.createElement('strong', null, getArrivalTime(returnFlight))
35485
+ )
35263
35486
  ),
35264
35487
  React__default.createElement(
35265
- 'div',
35266
- { className: 'search__filter__itinerary__country-content' },
35488
+ 'p',
35489
+ { className: 'search__filter__itinerary__transport-details-time' },
35267
35490
  React__default.createElement(
35268
- 'p',
35491
+ 'span',
35269
35492
  null,
35270
- format$1(new Date((lastEntryLine === null || lastEntryLine === void 0 ? void 0 : lastEntryLine.startDate) || ''), 'EEE. d MMM yyyy'),
35271
- ' - ',
35272
- React__default.createElement('strong', null, translations.SRP.END)
35493
+ React__default.createElement(Icon$1, { name: 'ui-clock', height: 20 }),
35494
+ ' ',
35495
+ getDuration(returnFlight)
35273
35496
  )
35274
35497
  )
35275
35498
  )
35276
35499
  )
35500
+ ),
35501
+ lastEntryLine &&
35502
+ React__default.createElement(
35503
+ 'div',
35504
+ { className: 'search__filter__itinerary__country' },
35505
+ React__default.createElement(
35506
+ 'div',
35507
+ { className: 'search__filter__itinerary__country-icon' },
35508
+ React__default.createElement(Icon$1, { name: 'ui-flag', width: 17.5, height: 20 })
35509
+ ),
35510
+ React__default.createElement(
35511
+ 'div',
35512
+ { className: 'search__filter__itinerary__country-content' },
35513
+ React__default.createElement(
35514
+ 'p',
35515
+ null,
35516
+ format$1(new Date(lastEntryLine.to), 'EEE. d MMM yyyy'),
35517
+ ' - ',
35518
+ React__default.createElement('strong', null, translations.SRP.END)
35519
+ )
35520
+ )
35277
35521
  )
35522
+ )
35278
35523
  )
35279
35524
  )
35280
35525
  );
@@ -38020,19 +38265,27 @@ var formatPrice$1 = function (price, currencyCode) {
38020
38265
  }).format(price);
38021
38266
  };
38022
38267
  var AccommodationFlyIn = function (_a) {
38023
- var _b;
38024
- _a.isLoading;
38025
- var isOpen = _a.isOpen,
38026
- setIsOpen = _a.setIsOpen;
38268
+ var _b, _c;
38269
+ var isLoading = _a.isLoading,
38270
+ handleConfirm = _a.handleConfirm;
38027
38271
  var dispatch = useDispatch();
38028
38272
  var context = useContext(SearchResultsConfigurationContext);
38029
- var language = (_b = context === null || context === void 0 ? void 0 : context.languageCode) !== null && _b !== void 0 ? _b : 'en-GB';
38273
+ if (isLoading) {
38274
+ return React__default.createElement(
38275
+ React__default.Fragment,
38276
+ null,
38277
+ (_b = context === null || context === void 0 ? void 0 : context.customSpinner) !== null && _b !== void 0
38278
+ ? _b
38279
+ : React__default.createElement(Spinner, null)
38280
+ );
38281
+ }
38282
+ var language = (_c = context === null || context === void 0 ? void 0 : context.languageCode) !== null && _c !== void 0 ? _c : 'en-GB';
38030
38283
  var translations = getTranslations(language);
38031
- var _c = useSelector(function (state) {
38284
+ var _d = useSelector(function (state) {
38032
38285
  return state.searchResults;
38033
38286
  }),
38034
- packagingAccoSearchDetails = _c.packagingAccoSearchDetails,
38035
- selectedPackagingAccoResultCode = _c.selectedPackagingAccoResultCode;
38287
+ packagingAccoSearchDetails = _d.packagingAccoSearchDetails,
38288
+ selectedPackagingAccoResultCode = _d.selectedPackagingAccoResultCode;
38036
38289
  var selectedPackagingAccoSearchDetails = useMemo(
38037
38290
  function () {
38038
38291
  return packagingAccoSearchDetails === null || packagingAccoSearchDetails === void 0
@@ -38123,11 +38376,6 @@ var AccommodationFlyIn = function (_a) {
38123
38376
  });
38124
38377
  dispatch(setPackagingAccoSearchDetails(updatedPackagingAccoSearchDetails));
38125
38378
  };
38126
- var handleConfirm = function () {
38127
- if (isOpen) {
38128
- setIsOpen(false);
38129
- }
38130
- };
38131
38379
  if (!selectedPackagingAccoSearchDetails) {
38132
38380
  return null;
38133
38381
  }
@@ -38287,7 +38535,13 @@ var AccommodationFlyIn = function (_a) {
38287
38535
  React__default.createElement(
38288
38536
  'div',
38289
38537
  { className: 'flyin__button-wrapper' },
38290
- React__default.createElement('button', { className: 'cta cta--select', onClick: handleConfirm }, translations.PRODUCT.BOOK_NOW)
38538
+ React__default.createElement(
38539
+ 'button',
38540
+ { className: 'cta cta--select', onClick: handleConfirm },
38541
+ (context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) == build.PortalQsmType.AccommodationAndFlight
38542
+ ? translations.QSM.CONFIRM
38543
+ : translations.PRODUCT.BOOK_NOW
38544
+ )
38291
38545
  )
38292
38546
  )
38293
38547
  );
@@ -38770,97 +39024,6 @@ var GroupTourFlyIn = function (_a) {
38770
39024
  );
38771
39025
  };
38772
39026
 
38773
- var FlyIn = function (_a) {
38774
- var title = _a.title,
38775
- srpType = _a.srpType,
38776
- isOpen = _a.isOpen,
38777
- setIsOpen = _a.setIsOpen,
38778
- _b = _a.className,
38779
- className = _b === void 0 ? '' : _b,
38780
- onPanelRef = _a.onPanelRef,
38781
- detailsLoading = _a.detailsLoading;
38782
- var dispatch = useDispatch();
38783
- var onCancelSearch = useFlightSearch().onCancelSearch;
38784
- var panelRef = useRef(null);
38785
- // expose DOM node if needed
38786
- useEffect(
38787
- function () {
38788
- onPanelRef === null || onPanelRef === void 0 ? void 0 : onPanelRef(panelRef.current);
38789
- return function () {
38790
- return onPanelRef === null || onPanelRef === void 0 ? void 0 : onPanelRef(null);
38791
- };
38792
- },
38793
- [onPanelRef]
38794
- );
38795
- useEffect(
38796
- function () {
38797
- // click outside detection
38798
- var handleClickOutside = function (event) {
38799
- if (isOpen && panelRef.current && !panelRef.current.contains(event.target)) {
38800
- handleClose();
38801
- }
38802
- };
38803
- document.addEventListener('mousedown', handleClickOutside);
38804
- return function () {
38805
- return document.removeEventListener('mousedown', handleClickOutside);
38806
- };
38807
- },
38808
- [isOpen, setIsOpen]
38809
- );
38810
- // body scroll lock
38811
- useEffect(
38812
- function () {
38813
- document.body.style.overflow = isOpen ? 'hidden' : '';
38814
- return function () {
38815
- document.body.style.overflow = '';
38816
- };
38817
- },
38818
- [isOpen]
38819
- );
38820
- var handleClose = function () {
38821
- if (isOpen && panelRef.current) {
38822
- if (srpType === build.PortalQsmType.Flight) {
38823
- dispatch(setSelectedFlight(null));
38824
- dispatch(setSelectedFlightDetails(null));
38825
- onCancelSearch();
38826
- }
38827
- setIsOpen(false);
38828
- }
38829
- };
38830
- return React__default.createElement(
38831
- 'div',
38832
- { className: 'flyin '.concat(isOpen ? 'flyin--active' : '', ' ').concat(className) },
38833
- React__default.createElement(
38834
- 'div',
38835
- { className: 'flyin__panel '.concat(isOpen ? 'flyin__panel--active' : ''), ref: panelRef },
38836
- React__default.createElement(
38837
- 'div',
38838
- { className: 'flyin__content' },
38839
- React__default.createElement(
38840
- 'div',
38841
- { className: 'flyin__content-title-row' },
38842
- React__default.createElement('h3', { className: 'flyin__content-title' }, title),
38843
- React__default.createElement(
38844
- 'span',
38845
- {
38846
- className: 'flyin__close',
38847
- onClick: function () {
38848
- return handleClose();
38849
- }
38850
- },
38851
- React__default.createElement(Icon, { name: 'ui-close', width: 30, height: 30, 'aria-hidden': 'true' })
38852
- )
38853
- )
38854
- ),
38855
- srpType === build.PortalQsmType.Flight && React__default.createElement(FlightsFlyIn, { isOpen: isOpen, setIsOpen: setIsOpen }),
38856
- srpType === build.PortalQsmType.Accommodation &&
38857
- React__default.createElement(AccommodationFlyIn, { isLoading: true, isOpen: isOpen, setIsOpen: setIsOpen }),
38858
- srpType === build.PortalQsmType.GroupTour &&
38859
- React__default.createElement(GroupTourFlyIn, { isLoading: detailsLoading, isOpen: isOpen, setIsOpen: setIsOpen })
38860
- )
38861
- );
38862
- };
38863
-
38864
39027
  var he$1 = { exports: {} };
38865
39028
 
38866
39029
  /*! https://mths.be/he v1.2.0 by @mathias | MIT license */
@@ -43333,6 +43496,132 @@ var HotelAccommodationResults = function (_a) {
43333
43496
  );
43334
43497
  };
43335
43498
 
43499
+ var FlyIn = function (_a) {
43500
+ var title = _a.title,
43501
+ srpType = _a.srpType,
43502
+ isOpen = _a.isOpen,
43503
+ setIsOpen = _a.setIsOpen,
43504
+ _b = _a.className,
43505
+ className = _b === void 0 ? '' : _b,
43506
+ onPanelRef = _a.onPanelRef,
43507
+ detailsLoading = _a.detailsLoading,
43508
+ accommodationStep = _a.accommodationStep,
43509
+ isPackageEditFlow = _a.isPackageEditFlow,
43510
+ handleConfirm = _a.handleConfirm;
43511
+ var dispatch = useDispatch();
43512
+ var onCancelSearch = useFlightSearch().onCancelSearch;
43513
+ var panelRef = useRef(null);
43514
+ // expose DOM node if needed
43515
+ useEffect(
43516
+ function () {
43517
+ onPanelRef === null || onPanelRef === void 0 ? void 0 : onPanelRef(panelRef.current);
43518
+ return function () {
43519
+ return onPanelRef === null || onPanelRef === void 0 ? void 0 : onPanelRef(null);
43520
+ };
43521
+ },
43522
+ [onPanelRef]
43523
+ );
43524
+ useEffect(
43525
+ function () {
43526
+ // click outside detection
43527
+ var handleClickOutside = function (event) {
43528
+ if (isOpen && panelRef.current && !panelRef.current.contains(event.target)) {
43529
+ handleClose();
43530
+ }
43531
+ };
43532
+ document.addEventListener('mousedown', handleClickOutside);
43533
+ return function () {
43534
+ return document.removeEventListener('mousedown', handleClickOutside);
43535
+ };
43536
+ },
43537
+ [isOpen, setIsOpen]
43538
+ );
43539
+ // body scroll lock
43540
+ useEffect(
43541
+ function () {
43542
+ document.body.style.overflow = isOpen ? 'hidden' : '';
43543
+ return function () {
43544
+ document.body.style.overflow = '';
43545
+ };
43546
+ },
43547
+ [isOpen]
43548
+ );
43549
+ var handleClose = function () {
43550
+ if (isOpen && panelRef.current) {
43551
+ if (srpType === build.PortalQsmType.Flight) {
43552
+ dispatch(setSelectedFlight(null));
43553
+ dispatch(setSelectedFlightDetails(null));
43554
+ onCancelSearch();
43555
+ } else {
43556
+ dispatch(setSelectedSearchResult(null));
43557
+ dispatch(setSelectedPackagingAccoResult(null));
43558
+ }
43559
+ dispatch(setAccommodationFlyInStep('details'));
43560
+ setIsOpen(false);
43561
+ }
43562
+ };
43563
+ var handleGoBack = function () {
43564
+ dispatch(setAccommodationFlyInStep('results'));
43565
+ };
43566
+ return React__default.createElement(
43567
+ 'div',
43568
+ {
43569
+ className: 'flyin '
43570
+ .concat(isOpen ? 'flyin--active' : '', ' ')
43571
+ .concat(className, ' ')
43572
+ .concat(isPackageEditFlow ? 'flyin--large' : '')
43573
+ },
43574
+ React__default.createElement(
43575
+ 'div',
43576
+ { className: 'flyin__panel '.concat(isOpen ? 'flyin__panel--active' : ''), ref: panelRef },
43577
+ React__default.createElement(
43578
+ 'div',
43579
+ { className: 'flyin__content' },
43580
+ React__default.createElement(
43581
+ 'div',
43582
+ { className: 'flyin__content-title-row' },
43583
+ React__default.createElement('h3', { className: 'flyin__content-title' }, title),
43584
+ React__default.createElement(
43585
+ 'span',
43586
+ {
43587
+ className: 'flyin__close',
43588
+ onClick: function () {
43589
+ return handleClose();
43590
+ }
43591
+ },
43592
+ React__default.createElement(Icon, { name: 'ui-close', width: 30, height: 30, 'aria-hidden': 'true' })
43593
+ )
43594
+ ),
43595
+ isPackageEditFlow &&
43596
+ accommodationStep === 'details' &&
43597
+ React__default.createElement(
43598
+ 'div',
43599
+ { className: 'flyin__content-title-row' },
43600
+ React__default.createElement(
43601
+ 'div',
43602
+ { onClick: handleGoBack, className: 'flyin__content-title__back' },
43603
+ React__default.createElement(Icon, { name: 'ui-chevron', width: 14, height: 14, 'aria-hidden': 'true' }),
43604
+ 'Go Back'
43605
+ )
43606
+ )
43607
+ ),
43608
+ srpType === build.PortalQsmType.Flight && React__default.createElement(FlightsFlyIn, { isOpen: isOpen, setIsOpen: setIsOpen }),
43609
+ (srpType === build.PortalQsmType.Accommodation || srpType === build.PortalQsmType.AccommodationAndFlight) &&
43610
+ accommodationStep === 'results' &&
43611
+ React__default.createElement(
43612
+ 'div',
43613
+ { className: 'flyin__content' },
43614
+ React__default.createElement(HotelAccommodationResults, { isLoading: detailsLoading })
43615
+ ),
43616
+ (srpType === build.PortalQsmType.Accommodation || srpType === build.PortalQsmType.AccommodationAndFlight) &&
43617
+ accommodationStep === 'details' &&
43618
+ React__default.createElement(AccommodationFlyIn, { isLoading: detailsLoading, handleConfirm: handleConfirm }),
43619
+ srpType === build.PortalQsmType.GroupTour &&
43620
+ React__default.createElement(GroupTourFlyIn, { isLoading: detailsLoading, isOpen: isOpen, setIsOpen: setIsOpen })
43621
+ )
43622
+ );
43623
+ };
43624
+
43336
43625
  var RoundTripResults = function () {
43337
43626
  var activeTab = useSelector(function (state) {
43338
43627
  return state.searchResults;
@@ -46683,42 +46972,140 @@ var applyFiltersToPackageAccoResults = function (results, filters, sortBy) {
46683
46972
  });
46684
46973
  };
46685
46974
 
46686
- var SearchResultsContainer = function () {
46975
+ var getSelectedOptionsPerRoom = function (details) {
46976
+ var _a;
46977
+ var firstResult = details[0];
46978
+ if (!((_a = firstResult === null || firstResult === void 0 ? void 0 : firstResult.rooms) === null || _a === void 0 ? void 0 : _a.length)) return [];
46979
+ return firstResult.rooms.map(function (room, roomIndex) {
46980
+ var _a;
46981
+ var selectedOption =
46982
+ (_a = room.options.find(function (option) {
46983
+ return option.isSelected;
46984
+ })) !== null && _a !== void 0
46985
+ ? _a
46986
+ : room.options[0];
46987
+ return {
46988
+ roomIndex: roomIndex,
46989
+ option: selectedOption !== null && selectedOption !== void 0 ? selectedOption : null
46990
+ };
46991
+ });
46992
+ };
46993
+ var getRoomIndexFromLine = function (line) {
46994
+ var _a, _b;
46995
+ if (!((_a = line.pax) === null || _a === void 0 ? void 0 : _a.length)) return 0;
46996
+ var firstPax = __spreadArray([], line.pax, true).sort(function (a, b) {
46997
+ return a.order - b.order;
46998
+ })[0];
46999
+ return (_b = firstPax === null || firstPax === void 0 ? void 0 : firstPax.room) !== null && _b !== void 0 ? _b : 0;
47000
+ };
47001
+ var getRequestRoomsFromPackagingSegments = function (entry, segments) {
46687
47002
  var _a;
47003
+ var accommodationLines = __spreadArray([], segments !== null && segments !== void 0 ? segments : [], true)
47004
+ .filter(function (line) {
47005
+ var _a;
47006
+ return line.serviceType === ACCOMMODATION_SERVICE_TYPE && ((_a = line.pax) === null || _a === void 0 ? void 0 : _a.length) > 0;
47007
+ })
47008
+ .sort(function (a, b) {
47009
+ return a.order - b.order;
47010
+ });
47011
+ var paxById = new Map(
47012
+ ((_a = entry.pax) !== null && _a !== void 0 ? _a : []).map(function (p) {
47013
+ return [p.id, p];
47014
+ })
47015
+ );
47016
+ if (!accommodationLines.length) {
47017
+ return [];
47018
+ }
47019
+ var roomGroups = [];
47020
+ accommodationLines.forEach(function (line) {
47021
+ var groupedByRoom = new Map();
47022
+ line.pax.forEach(function (linePax) {
47023
+ var _a, _b, _c, _d, _e, _f, _g;
47024
+ var roomIndexWithinLine = Number((_a = linePax.room) !== null && _a !== void 0 ? _a : 0);
47025
+ var paxId = Number(linePax.paxId);
47026
+ var paxSource = paxById.get(paxId);
47027
+ var pax = {
47028
+ id: (_b = paxSource === null || paxSource === void 0 ? void 0 : paxSource.id) !== null && _b !== void 0 ? _b : paxId,
47029
+ guid:
47030
+ (_d = (_c = paxSource === null || paxSource === void 0 ? void 0 : paxSource.id) === null || _c === void 0 ? void 0 : _c.toString()) !== null &&
47031
+ _d !== void 0
47032
+ ? _d
47033
+ : paxId.toString(),
47034
+ firstName: (_e = paxSource === null || paxSource === void 0 ? void 0 : paxSource.firstName) !== null && _e !== void 0 ? _e : '',
47035
+ lastName: (_f = paxSource === null || paxSource === void 0 ? void 0 : paxSource.lastName) !== null && _f !== void 0 ? _f : '',
47036
+ dateOfBirth: (_g = paxSource === null || paxSource === void 0 ? void 0 : paxSource.dateOfBirth) !== null && _g !== void 0 ? _g : undefined,
47037
+ age: (paxSource === null || paxSource === void 0 ? void 0 : paxSource.dateOfBirth) ? undefined : 30,
47038
+ isMainBooker: paxSource === null || paxSource === void 0 ? void 0 : paxSource.isMainBooker,
47039
+ email: ''
47040
+ };
47041
+ if (!groupedByRoom.has(roomIndexWithinLine)) {
47042
+ groupedByRoom.set(roomIndexWithinLine, []);
47043
+ }
47044
+ groupedByRoom.get(roomIndexWithinLine).push(pax);
47045
+ });
47046
+ var sortedGroups = Array.from(groupedByRoom.entries())
47047
+ .sort(function (_a, _b) {
47048
+ var a = _a[0];
47049
+ var b = _b[0];
47050
+ return a - b;
47051
+ })
47052
+ .map(function (_a) {
47053
+ var pax = _a[1];
47054
+ return pax;
47055
+ });
47056
+ roomGroups.push.apply(roomGroups, sortedGroups);
47057
+ });
47058
+ return roomGroups.map(function (pax, index) {
47059
+ return {
47060
+ index: index,
47061
+ pax: pax
47062
+ };
47063
+ });
47064
+ };
47065
+
47066
+ var SearchResultsContainer = function () {
47067
+ var _a, _b;
47068
+ var currentSearch = typeof window !== 'undefined' ? window.location.search : '';
46688
47069
  var dispatch = useDispatch();
46689
47070
  var context = useContext(SearchResultsConfigurationContext);
46690
47071
  var translations = getTranslations((_a = context === null || context === void 0 ? void 0 : context.languageCode) !== null && _a !== void 0 ? _a : 'en-GB');
46691
- var _b = useSelector(function (state) {
47072
+ var _c = useSelector(function (state) {
46692
47073
  return state.searchResults;
46693
47074
  }),
46694
- results = _b.results,
46695
- filteredResults = _b.filteredResults,
46696
- packagingAccoResults = _b.packagingAccoResults,
46697
- filteredPackagingAccoResults = _b.filteredPackagingAccoResults,
46698
- bookingPackageDetails = _b.bookingPackageDetails,
46699
- entry = _b.entry,
46700
- isLoading = _b.isLoading,
46701
- filters = _b.filters,
46702
- selectedSortType = _b.selectedSortType,
46703
- selectedSearchResult = _b.selectedSearchResult,
46704
- selectedPackagingAccoResultCode = _b.selectedPackagingAccoResultCode,
46705
- flyInIsOpen = _b.flyInIsOpen;
47075
+ results = _c.results,
47076
+ filteredResults = _c.filteredResults,
47077
+ packagingAccoResults = _c.packagingAccoResults,
47078
+ filteredPackagingAccoResults = _c.filteredPackagingAccoResults,
47079
+ bookingPackageDetails = _c.bookingPackageDetails,
47080
+ isLoading = _c.isLoading,
47081
+ filters = _c.filters,
47082
+ selectedSortType = _c.selectedSortType,
47083
+ selectedSearchResult = _c.selectedSearchResult,
47084
+ selectedPackagingAccoResultCode = _c.selectedPackagingAccoResultCode,
47085
+ flyInIsOpen = _c.flyInIsOpen,
47086
+ packagingAccoSearchDetails = _c.packagingAccoSearchDetails,
47087
+ editablePackagingEntry = _c.editablePackagingEntry,
47088
+ transactionId = _c.transactionId,
47089
+ accommodationFlyInStep = _c.accommodationFlyInStep;
46706
47090
  var isMobile = useMediaQuery('(max-width: 1200px)');
46707
- var _c = useState(false),
46708
- initialFiltersSet = _c[0],
46709
- setInitialFiltersSet = _c[1];
46710
- var _d = useState([]),
46711
- initialFilters = _d[0],
46712
- setInitialFilters = _d[1];
46713
- var _e = useState(false),
46714
- filtersOpen = _e[0],
46715
- setFiltersOpen = _e[1];
47091
+ var _d = useState(false),
47092
+ initialFiltersSet = _d[0],
47093
+ setInitialFiltersSet = _d[1];
47094
+ var _e = useState([]),
47095
+ initialFilters = _e[0],
47096
+ setInitialFilters = _e[1];
46716
47097
  var _f = useState(false),
46717
- detailsIsLoading = _f[0],
46718
- setDetailsIsLoading = _f[1];
47098
+ filtersOpen = _f[0],
47099
+ setFiltersOpen = _f[1];
46719
47100
  var _g = useState(false),
46720
- itineraryOpen = _g[0],
46721
- setItineraryOpen = _g[1];
47101
+ detailsIsLoading = _g[0],
47102
+ setDetailsIsLoading = _g[1];
47103
+ var _h = useState(false),
47104
+ itineraryOpen = _h[0],
47105
+ setItineraryOpen = _h[1];
47106
+ var _j = useState(null),
47107
+ selectedAccommodationSeed = _j[0],
47108
+ setSelectedAccommodationSeed = _j[1];
46722
47109
  var panelRef = useRef(null);
46723
47110
  var sortByTypes = [
46724
47111
  { direction: 'asc', label: 'default' },
@@ -46734,33 +47121,44 @@ var SearchResultsContainer = function () {
46734
47121
  dispatch(setSortType(newSortByType));
46735
47122
  }
46736
47123
  };
46737
- var buildSearchFromEntry = function (entry) {
47124
+ var getRequestRooms = function (rooms) {
47125
+ if (!rooms) {
47126
+ // Fall back to 2 adults
47127
+ var room = { index: 0, pax: [] };
47128
+ range(0, 2).forEach(function () {
47129
+ room.pax.push({
47130
+ age: 30
47131
+ });
47132
+ });
47133
+ return [room];
47134
+ }
47135
+ var requestRooms =
47136
+ rooms === null || rooms === void 0
47137
+ ? void 0
47138
+ : rooms.map(function (x, i) {
47139
+ var room = { index: i, pax: [] };
47140
+ range(0, x.adults).forEach(function () {
47141
+ room.pax.push({
47142
+ age: 30
47143
+ });
47144
+ });
47145
+ x.childAges.forEach(function (x) {
47146
+ room.pax.push({
47147
+ age: x
47148
+ });
47149
+ });
47150
+ return room;
47151
+ });
47152
+ return requestRooms;
47153
+ };
47154
+ var buildSearchFromSeed = function (seed) {
46738
47155
  var _a;
46739
- var from = new Date(
46740
- Math.min.apply(
46741
- Math,
46742
- entry.items.map(function (i) {
46743
- return i.startDate.getTime();
46744
- })
46745
- )
46746
- ).toISOString();
46747
- var to = new Date(
46748
- Math.max.apply(
46749
- Math,
46750
- entry.items.map(function (i) {
46751
- return i.endDate.getTime();
46752
- })
46753
- )
46754
- ).toISOString();
46755
- var rooms = entry.rooms;
46756
- var hotelItem = entry.items.find(function (i) {
46757
- return i.productType === 3;
46758
- });
46759
- var country = hotelItem ? hotelItem.countryId : null;
46760
- var region = hotelItem ? hotelItem.regionId : null;
46761
- var oord = hotelItem ? hotelItem.oordId : null;
46762
- var city = hotelItem ? hotelItem.locationId : null;
46763
- var hotel = hotelItem ? hotelItem.productCode : null;
47156
+ var country = seed.country;
47157
+ var region = seed.region;
47158
+ var oord = seed.oord;
47159
+ var city = seed.location;
47160
+ var hotel = seed.hotel;
47161
+ var tagId = seed.tagId;
46764
47162
  if (typeof window !== 'undefined') {
46765
47163
  window.scrollTo(0, 0);
46766
47164
  }
@@ -46782,83 +47180,7 @@ var SearchResultsContainer = function () {
46782
47180
  destinationId = city;
46783
47181
  destinationIsLocation = true;
46784
47182
  }
46785
- var searchRequest = {
46786
- officeId: 1,
46787
- agentId: context === null || context === void 0 ? void 0 : context.agentId,
46788
- payload: {
46789
- catalogueIds: (_a = context.tideConnection.catalogueIds) !== null && _a !== void 0 ? _a : [],
46790
- serviceType:
46791
- context.searchConfiguration.qsmType === build.PortalQsmType.Accommodation ||
46792
- context.searchConfiguration.qsmType === build.PortalQsmType.AccommodationAndFlight
46793
- ? 3
46794
- : context.searchConfiguration.qsmType === build.PortalQsmType.Flight
46795
- ? 7
46796
- : context.searchConfiguration.qsmType === build.PortalQsmType.RoundTrip
46797
- ? 1
46798
- : 0,
46799
- searchType: 0,
46800
- destination: {
46801
- id: Number(destinationId),
46802
- isCountry: destinationIsCountry,
46803
- isRegion: destinationIsRegion,
46804
- isOord: destinationIsOord,
46805
- isLocation: destinationIsLocation
46806
- },
46807
- rooms: getRequestRoomsFromEntry(rooms),
46808
- fromDate: from,
46809
- toDate: to,
46810
- earliestFromOffset: 0,
46811
- latestToOffset: 0,
46812
- includeFlights: true,
46813
- regimeCodes:
46814
- entry.items.map(function (i) {
46815
- return i.regimeCode;
46816
- }) || [],
46817
- useExactDates: true,
46818
- onlyCachedResults: false,
46819
- includeAllAllotments: true,
46820
- productCodes: hotel ? [hotel] : []
46821
- }
46822
- };
46823
- return searchRequest;
46824
- };
46825
- var buildSearchFromQueryParams = function (params) {
46826
- var _a;
46827
- var from = getDateFromParams(params, 'fromDate');
46828
- var to = getDateFromParams(params, 'toDate');
46829
- var rooms = getRoomsFromParams(params, 'rooms');
46830
- var country = getNumberFromParams(params, 'country');
46831
- var region = getNumberFromParams(params, 'region');
46832
- var oord = getNumberFromParams(params, 'oord');
46833
- var city = getNumberFromParams(params, 'location');
46834
- var hotel = getNumberFromParams(params, 'hotel');
46835
- var tagId = getNumberFromParams(params, 'tagId');
46836
- if (!from || !to) {
46837
- console.error('Missing fromDate or toDate in query params, using default values');
46838
- return null;
46839
- }
46840
- if (typeof window !== 'undefined') {
46841
- window.scrollTo(0, 0);
46842
- }
46843
- var destinationId = null;
46844
- var destinationIsCountry = false;
46845
- var destinationIsRegion = false;
46846
- var destinationIsOord = false;
46847
- var destinationIsLocation = false;
46848
- if (country) {
46849
- destinationId = country;
46850
- destinationIsCountry = true;
46851
- } else if (region) {
46852
- destinationId = region;
46853
- destinationIsRegion = true;
46854
- } else if (oord) {
46855
- destinationId = oord;
46856
- destinationIsOord = true;
46857
- } else if (city) {
46858
- destinationId = city;
46859
- destinationIsLocation = true;
46860
- }
46861
- var searchRequest = {
47183
+ return {
46862
47184
  officeId: 1,
46863
47185
  agentId: context === null || context === void 0 ? void 0 : context.agentId,
46864
47186
  payload: {
@@ -46866,11 +47188,11 @@ var SearchResultsContainer = function () {
46866
47188
  serviceType:
46867
47189
  context.searchConfiguration.qsmType === build.PortalQsmType.Accommodation ||
46868
47190
  context.searchConfiguration.qsmType === build.PortalQsmType.AccommodationAndFlight
46869
- ? 3
47191
+ ? ACCOMMODATION_SERVICE_TYPE
46870
47192
  : context.searchConfiguration.qsmType === build.PortalQsmType.Flight
46871
- ? 7
47193
+ ? FLIGHT_SERVICE_TYPE
46872
47194
  : context.searchConfiguration.qsmType === build.PortalQsmType.RoundTrip
46873
- ? 1
47195
+ ? GROUP_TOUR_SERVICE_TYPE
46874
47196
  : undefined,
46875
47197
  searchType: context.searchConfiguration.qsmType === build.PortalQsmType.GroupTour ? 1 : 0,
46876
47198
  destination: {
@@ -46880,19 +47202,12 @@ var SearchResultsContainer = function () {
46880
47202
  isOord: destinationIsOord,
46881
47203
  isLocation: destinationIsLocation
46882
47204
  },
46883
- rooms: getRequestRooms(rooms),
46884
- fromDate: from,
46885
- toDate: to,
47205
+ rooms: seed.rooms,
47206
+ fromDate: seed.fromDate,
47207
+ toDate: seed.toDate,
46886
47208
  earliestFromOffset: 0,
46887
47209
  latestToOffset: 0,
46888
- includeFlights: context.searchConfiguration.qsmType === build.PortalQsmType.AccommodationAndFlight ? true : false,
46889
- // regimeCodes:
46890
- // filters
46891
- // .find((f) => f.property === 'regime')
46892
- // ?.options?.filter((o) => o.isChecked)
46893
- // .flatMap((o) => o.value.toString()) || [],
46894
- // minPrice: filters.find((f) => f.property === 'price')?.selectedMin,
46895
- // maxPrice: filters.find((f) => f.property === 'price')?.selectedMax,
47210
+ includeFlights: context.searchConfiguration.qsmType === build.PortalQsmType.AccommodationAndFlight,
46896
47211
  useExactDates: (context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.GroupTour ? false : true,
46897
47212
  onlyCachedResults: false,
46898
47213
  includeAllAllotments: true,
@@ -46900,82 +47215,16 @@ var SearchResultsContainer = function () {
46900
47215
  productTagIds: tagId ? [tagId] : []
46901
47216
  }
46902
47217
  };
46903
- console.log('Built search request from query params', searchRequest);
46904
- return searchRequest;
46905
47218
  };
46906
- var getRequestRoomsFromEntry = function (rooms) {
46907
- if (!rooms) {
46908
- // Fall back to 2 adults
46909
- var room = { index: 0, pax: [] };
46910
- range(0, 2).forEach(function () {
46911
- room.pax.push({
46912
- age: 30
46913
- });
46914
- });
46915
- return [room];
46916
- }
46917
- var requestRooms =
46918
- rooms === null || rooms === void 0
46919
- ? void 0
46920
- : rooms.map(function (x, i) {
46921
- var room = { index: i, pax: [] };
46922
- x.travellers.forEach(function (p) {
46923
- room.pax.push({
46924
- age: p.age,
46925
- dateOfBirth: p.dateOfBirth
46926
- });
46927
- });
46928
- return room;
46929
- });
46930
- return requestRooms;
46931
- };
46932
- var getRequestRooms = function (rooms) {
46933
- if (!rooms) {
46934
- // Fall back to 2 adults
46935
- var room = { index: 0, pax: [] };
46936
- range(0, 2).forEach(function () {
46937
- room.pax.push({
46938
- age: 30
46939
- });
46940
- });
46941
- return [room];
46942
- }
46943
- var requestRooms =
46944
- rooms === null || rooms === void 0
46945
- ? void 0
46946
- : rooms.map(function (x, i) {
46947
- var room = { index: i, pax: [] };
46948
- range(0, x.adults).forEach(function () {
46949
- room.pax.push({
46950
- age: 30
46951
- });
46952
- });
46953
- x.childAges.forEach(function (x) {
46954
- room.pax.push({
46955
- age: x
46956
- });
46957
- });
46958
- return room;
46959
- });
46960
- return requestRooms;
46961
- };
46962
- var buildPackagingAccommodationRequestFromQueryParams = function (params) {
46963
- var _a, _b;
46964
- var from = getDateFromParams(params, 'fromDate');
46965
- var to = getDateFromParams(params, 'toDate');
46966
- var rooms = getRoomsFromParams(params, 'rooms');
46967
- var country = getNumberFromParams(params, 'country');
46968
- var region = getNumberFromParams(params, 'region');
46969
- var oord = getNumberFromParams(params, 'oord');
46970
- var city = getNumberFromParams(params, 'location');
46971
- var hotel = getNumberFromParams(params, 'hotel');
46972
- var tagId = getNumberFromParams(params, 'tagId');
46973
- var agentId = getNumberFromParams(params, 'agentId');
46974
- var destinationAirport = getStringFromParams(params, 'destinationAirport');
46975
- if (!from || !to) {
46976
- console.error('Missing fromDate or toDate in query params, using default values');
46977
- return null;
46978
- }
47219
+ var buildPackagingAccommodationRequestFromSeed = function (seed, currentTransactionId) {
47220
+ var _a, _b, _c, _d;
47221
+ var country = seed.country;
47222
+ var region = seed.region;
47223
+ var oord = seed.oord;
47224
+ var city = seed.location;
47225
+ (_a = seed.hotelCode) !== null && _a !== void 0 ? _a : seed.hotel ? seed.hotel.toString() : '';
47226
+ var tagId = seed.tagId;
47227
+ var destinationAirport = seed.destinationAirport;
46979
47228
  if (typeof window !== 'undefined') {
46980
47229
  window.scrollTo(0, 0);
46981
47230
  }
@@ -46986,31 +47235,32 @@ var SearchResultsContainer = function () {
46986
47235
  var destinationIsLocation = false;
46987
47236
  var destinationCode = null;
46988
47237
  var destinationIsAirport = false;
46989
- if (country) {
46990
- destinationId = country;
46991
- destinationIsCountry = true;
46992
- } else if (region) {
46993
- destinationId = region;
46994
- destinationIsRegion = true;
47238
+ if (city) {
47239
+ destinationId = city;
47240
+ destinationIsLocation = true;
46995
47241
  } else if (oord) {
46996
47242
  destinationId = oord;
46997
47243
  destinationIsOord = true;
46998
- } else if (city) {
46999
- destinationId = city;
47000
- destinationIsLocation = true;
47244
+ } else if (region) {
47245
+ destinationId = region;
47246
+ destinationIsRegion = true;
47247
+ } else if (country) {
47248
+ destinationId = country;
47249
+ destinationIsCountry = true;
47001
47250
  } else if (destinationAirport) {
47002
47251
  destinationCode = destinationAirport;
47003
47252
  destinationIsAirport = true;
47004
47253
  }
47005
- var searchRequest = {
47254
+ return {
47255
+ transactionId: currentTransactionId,
47006
47256
  officeId: 1,
47007
- agentId: agentId !== null && agentId !== void 0 ? agentId : null,
47008
- catalogueId: (_a = context.searchConfiguration.defaultCatalogueId) !== null && _a !== void 0 ? _a : 0,
47257
+ agentId: (_b = context === null || context === void 0 ? void 0 : context.agentId) !== null && _b !== void 0 ? _b : null,
47258
+ catalogueId: (_c = context.searchConfiguration.defaultCatalogueId) !== null && _c !== void 0 ? _c : 0,
47009
47259
  searchConfigurationId: context.searchConfiguration.id,
47010
- language: (_b = context.languageCode) !== null && _b !== void 0 ? _b : 'en-GB',
47011
- servicesType: 3, // accommodation
47012
- fromDate: from,
47013
- toDate: to,
47260
+ language: (_d = context.languageCode) !== null && _d !== void 0 ? _d : 'en-GB',
47261
+ serviceType: ACCOMMODATION_SERVICE_TYPE,
47262
+ fromDate: seed.fromDate,
47263
+ toDate: seed.toDate,
47014
47264
  destination: {
47015
47265
  id: Number(destinationId),
47016
47266
  isCountry: destinationIsCountry,
@@ -47020,43 +47270,135 @@ var SearchResultsContainer = function () {
47020
47270
  isAirport: destinationIsAirport,
47021
47271
  code: destinationCode
47022
47272
  },
47023
- productCode: hotel ? hotel.toString() : '',
47024
- rooms: getPackagingRequestRooms(rooms),
47273
+ productCode: '',
47274
+ rooms: getPackagingRequestRoomsFromBookingRooms(seed.rooms),
47025
47275
  tagIds: tagId ? [tagId] : []
47026
47276
  };
47027
- console.log('Search request for packaging accommodation from query params', searchRequest);
47028
- return searchRequest;
47029
47277
  };
47030
- var getPackagingRequestRooms = function (rooms) {
47031
- if (!rooms) {
47032
- // Fall back to 2 adults
47033
- var room = { index: 0, travellers: [] };
47034
- range(0, 2).forEach(function () {
47035
- room.travellers.push({
47036
- age: 30
47037
- });
47038
- });
47039
- return [room];
47278
+ var buildSearchSeedFromQueryParams = function (params) {
47279
+ var from = getDateFromParams(params, 'fromDate');
47280
+ var to = getDateFromParams(params, 'toDate');
47281
+ var rooms = getRoomsFromParams(params, 'rooms');
47282
+ var country = getNumberFromParams(params, 'country');
47283
+ var region = getNumberFromParams(params, 'region');
47284
+ var oord = getNumberFromParams(params, 'oord');
47285
+ var city = getNumberFromParams(params, 'location');
47286
+ var hotel = getNumberFromParams(params, 'hotel');
47287
+ var tagId = getNumberFromParams(params, 'tagId');
47288
+ var destinationAirport = getStringFromParams(params, 'destinationAirport');
47289
+ var departureAirport = getStringFromParams(params, 'departureAirport');
47290
+ if (!from || !to) {
47291
+ return null;
47040
47292
  }
47041
- var requestRooms =
47042
- rooms === null || rooms === void 0
47293
+ return {
47294
+ fromDate: from,
47295
+ toDate: to,
47296
+ country: country,
47297
+ region: region,
47298
+ oord: oord,
47299
+ location: city,
47300
+ hotel: hotel,
47301
+ hotelCode: hotel ? hotel.toString() : null,
47302
+ tagId: tagId,
47303
+ destinationAirport: destinationAirport,
47304
+ departureAirport: departureAirport,
47305
+ rooms: getRequestRooms(rooms)
47306
+ };
47307
+ };
47308
+ var handleConfirmHotelSwap = function () {
47309
+ var updatedEntry = swapHotelInPackagingEntry();
47310
+ console.log('Updated entry after hotel swap', updatedEntry);
47311
+ if (!updatedEntry) return;
47312
+ dispatch(setEditablePackagingEntry(updatedEntry));
47313
+ handleFlyInToggle(false);
47314
+ };
47315
+ var swapHotelInPackagingEntry = function () {
47316
+ var sourceEntry =
47317
+ editablePackagingEntry !== null && editablePackagingEntry !== void 0
47318
+ ? editablePackagingEntry
47319
+ : context === null || context === void 0
47043
47320
  ? void 0
47044
- : rooms.map(function (x, i) {
47045
- var room = { index: i, travellers: [] };
47046
- range(0, x.adults).forEach(function () {
47047
- room.travellers.push({
47048
- age: 30
47049
- });
47050
- });
47051
- x.childAges.forEach(function (x) {
47052
- room.travellers.push({
47053
- age: x
47054
- });
47055
- });
47056
- return room;
47057
- });
47058
- return requestRooms;
47321
+ : context.packagingEntry;
47322
+ var details = packagingAccoSearchDetails;
47323
+ if (!sourceEntry || !(details === null || details === void 0 ? void 0 : details.length)) return null;
47324
+ var selectedOptionsPerRoom = getSelectedOptionsPerRoom(details);
47325
+ if (!selectedOptionsPerRoom.length) return null;
47326
+ var selectedHotel = details[0];
47327
+ var updatedLines = sourceEntry.lines.map(function (line) {
47328
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
47329
+ if (line.serviceType !== ACCOMMODATION_SERVICE_TYPE) {
47330
+ return line;
47331
+ }
47332
+ // TODO: fix roomIndex
47333
+ var roomIndex = getRoomIndexFromLine(line);
47334
+ console.log('Processing line', line, 'with room index', roomIndex);
47335
+ var selectedRoom = selectedOptionsPerRoom.find(function (x) {
47336
+ return x.roomIndex === roomIndex;
47337
+ });
47338
+ var selectedOption = selectedRoom === null || selectedRoom === void 0 ? void 0 : selectedRoom.option;
47339
+ if (!selectedOption) {
47340
+ return line;
47341
+ }
47342
+ return __assign(__assign({}, line), {
47343
+ guid: selectedOption.guid,
47344
+ productName: selectedHotel.name,
47345
+ productCode: selectedHotel.code,
47346
+ accommodationName: selectedOption.accommodationName,
47347
+ accommodationCode: selectedOption.accommodationCode,
47348
+ regimeName: selectedOption.regimeName,
47349
+ regimeCode: selectedOption.regimeCode,
47350
+ country: line.country
47351
+ ? __assign(__assign({}, line.country), {
47352
+ id: (_a = selectedHotel.countryId) !== null && _a !== void 0 ? _a : line.country.id,
47353
+ name: (_b = selectedHotel.countryName) !== null && _b !== void 0 ? _b : line.country.name
47354
+ })
47355
+ : selectedHotel.countryId
47356
+ ? { id: selectedHotel.countryId, name: selectedHotel.countryName, localizations: [] }
47357
+ : line.country,
47358
+ region: line.region
47359
+ ? __assign(__assign({}, line.region), {
47360
+ id: (_c = selectedHotel.regionId) !== null && _c !== void 0 ? _c : line.region.id,
47361
+ name: (_d = selectedHotel.regionName) !== null && _d !== void 0 ? _d : line.region.name
47362
+ })
47363
+ : selectedHotel.regionId
47364
+ ? { id: selectedHotel.regionId, name: selectedHotel.regionName, localizations: [] }
47365
+ : line.region,
47366
+ oord: line.oord
47367
+ ? __assign(__assign({}, line.oord), {
47368
+ id: (_e = selectedHotel.oordId) !== null && _e !== void 0 ? _e : line.oord.id,
47369
+ name: (_f = selectedHotel.oordName) !== null && _f !== void 0 ? _f : line.oord.name
47370
+ })
47371
+ : selectedHotel.oordId
47372
+ ? { id: selectedHotel.oordId, name: selectedHotel.oordName, localizations: [] }
47373
+ : line.oord,
47374
+ location: line.location
47375
+ ? __assign(__assign({}, line.location), {
47376
+ id: (_g = selectedHotel.locationId) !== null && _g !== void 0 ? _g : line.location.id,
47377
+ name: (_h = selectedHotel.locationName) !== null && _h !== void 0 ? _h : line.location.name
47378
+ })
47379
+ : selectedHotel.locationId
47380
+ ? { id: selectedHotel.locationId, name: selectedHotel.locationName, localizations: [] }
47381
+ : line.location,
47382
+ latitude: (_j = selectedHotel.latitude) !== null && _j !== void 0 ? _j : line.latitude,
47383
+ longitude: (_k = selectedHotel.longitude) !== null && _k !== void 0 ? _k : line.longitude,
47384
+ from: (_l = selectedHotel.fromDate) !== null && _l !== void 0 ? _l : line.from,
47385
+ to: (_m = selectedHotel.toDate) !== null && _m !== void 0 ? _m : line.to,
47386
+ isChanged: true
47387
+ });
47388
+ });
47389
+ return __assign(__assign({}, sourceEntry), { lines: updatedLines });
47059
47390
  };
47391
+ var activeSearchSeed = React__default.useMemo(
47392
+ function () {
47393
+ if (selectedAccommodationSeed) {
47394
+ return selectedAccommodationSeed;
47395
+ }
47396
+ if (typeof window === 'undefined') return null;
47397
+ var params = new URLSearchParams(window.location.search);
47398
+ return buildSearchSeedFromQueryParams(params);
47399
+ },
47400
+ [selectedAccommodationSeed, currentSearch]
47401
+ );
47060
47402
  useEffect(
47061
47403
  function () {
47062
47404
  if (typeof document !== 'undefined') {
@@ -47065,189 +47407,232 @@ var SearchResultsContainer = function () {
47065
47407
  },
47066
47408
  [filtersOpen]
47067
47409
  );
47068
- // seperate Search
47069
- useEffect(
47070
- function () {
47071
- var runSearch = function () {
47072
- return __awaiter(void 0, void 0, void 0, function () {
47073
- var config, params, entryId, entryLight, searchRequest, rq, packageSearchResults, enrichedFilters, initialFilteredResults, matching, err_1;
47074
- var _a;
47075
- return __generator(this, function (_b) {
47076
- switch (_b.label) {
47077
- case 0:
47078
- dispatch(setIsLoading(true));
47079
- _b.label = 1;
47080
- case 1:
47081
- _b.trys.push([1, 6, , 7]);
47082
- if (!context) {
47083
- return [2 /*return*/];
47084
- }
47085
- config = {
47086
- host: context.tideConnection.host,
47087
- apiKey: context.tideConnection.apiKey
47088
- };
47089
- params = new URLSearchParams(location.search);
47090
- entryId = getStringFromParams(params, 'entryId');
47091
- entryLight = null;
47092
- searchRequest = void 0;
47093
- if (!entryId) return [3 /*break*/, 3];
47094
- return [4 /*yield*/, build.getEntryLight(config, entryId)];
47095
- case 2:
47096
- entryLight = _b.sent();
47097
- // populate itinerary store
47098
- dispatch(setEntry({ entry: entryLight }));
47099
- searchRequest = buildSearchFromEntry(entryLight);
47100
- return [3 /*break*/, 4];
47101
- case 3:
47102
- rq = buildSearchFromQueryParams(params);
47103
- if (!rq) {
47104
- throw new Error('Invalid search parameters');
47105
- }
47106
- searchRequest = rq;
47107
- _b.label = 4;
47108
- case 4:
47109
- return [4 /*yield*/, build.search(config, searchRequest)];
47110
- case 5:
47111
- packageSearchResults = _b.sent();
47112
- console.log('Search results', packageSearchResults);
47113
- enrichedFilters = enrichFiltersWithResults(packageSearchResults, context.filters, (_a = context.tags) !== null && _a !== void 0 ? _a : []);
47114
- if (!initialFiltersSet) {
47115
- dispatch(resetFilters(enrichedFilters));
47116
- setInitialFilters(enrichedFilters);
47117
- setInitialFiltersSet(true);
47118
- }
47119
- dispatch(setResults(packageSearchResults));
47120
- initialFilteredResults = applyFilters(packageSearchResults, filters, null);
47121
- dispatch(setFilteredResults(initialFilteredResults));
47122
- if ((packageSearchResults === null || packageSearchResults === void 0 ? void 0 : packageSearchResults.length) > 0) {
47123
- if (entryId) {
47124
- matching = packageSearchResults.find(function (r) {
47125
- return r.productId === (entry === null || entry === void 0 ? void 0 : entry.id);
47126
- });
47127
- if (matching) {
47128
- dispatch(setSelectedSearchResult(matching));
47129
- }
47130
- } else {
47131
- if (context.searchConfiguration.qsmType === build.PortalQsmType.AccommodationAndFlight) {
47132
- dispatch(setSelectedSearchResult(packageSearchResults[0]));
47133
- }
47134
- }
47135
- }
47136
- dispatch(setIsLoading(false));
47137
- return [3 /*break*/, 7];
47138
- case 6:
47139
- err_1 = _b.sent();
47140
- console.error('Search failed', err_1);
47141
- dispatch(setIsLoading(false));
47142
- return [3 /*break*/, 7];
47143
- case 7:
47144
- return [2 /*return*/];
47410
+ var runSearch = function () {
47411
+ return __awaiter(void 0, void 0, void 0, function () {
47412
+ var config, seed, searchRequest, packageSearchResults, enrichedFilters, initialFilteredResults, err_1;
47413
+ var _a;
47414
+ return __generator(this, function (_b) {
47415
+ switch (_b.label) {
47416
+ case 0:
47417
+ _b.trys.push([0, 2, 3, 4]);
47418
+ if (!context) return [2 /*return*/];
47419
+ dispatch(setIsLoading(true));
47420
+ config = {
47421
+ host: context.tideConnection.host,
47422
+ apiKey: context.tideConnection.apiKey
47423
+ };
47424
+ seed = activeSearchSeed;
47425
+ if (!seed) {
47426
+ throw new Error('Invalid search parameters');
47145
47427
  }
47146
- });
47147
- });
47148
- };
47149
- var runHotelSearch = function () {
47150
- return __awaiter(void 0, void 0, void 0, function () {
47151
- var config, params, searchRequest, rq, packageAccoSearchResults, enrichedFilters, initialFilteredResults, err_2;
47152
- var _a;
47153
- return __generator(this, function (_b) {
47154
- switch (_b.label) {
47155
- case 0:
47156
- dispatch(setIsLoading(true));
47157
- _b.label = 1;
47158
- case 1:
47159
- _b.trys.push([1, 3, , 4]);
47160
- if (!context) {
47161
- return [2 /*return*/];
47162
- }
47163
- config = {
47164
- host: context.tideConnection.host,
47165
- apiKey: context.tideConnection.apiKey
47166
- };
47167
- params = new URLSearchParams(location.search);
47168
- searchRequest = void 0;
47169
- rq = buildPackagingAccommodationRequestFromQueryParams(params);
47170
- if (!rq) {
47171
- throw new Error('Invalid search parameters');
47172
- }
47173
- searchRequest = rq;
47174
- searchRequest.portalId = context.portalId;
47175
- searchRequest.agentId = context.agentId;
47176
- return [4 /*yield*/, build.searchPackagingAccommodations(config, searchRequest)];
47177
- case 2:
47178
- packageAccoSearchResults = _b.sent();
47179
- console.log('package Acco SearchResults', packageAccoSearchResults);
47180
- enrichedFilters = enrichFiltersWithPackageAccoResults(
47181
- packageAccoSearchResults,
47182
- context.filters,
47183
- (_a = context.tags) !== null && _a !== void 0 ? _a : []
47184
- );
47185
- if (!initialFiltersSet) {
47186
- dispatch(resetFilters(enrichedFilters));
47187
- setInitialFilters(enrichedFilters);
47188
- setInitialFiltersSet(true);
47189
- }
47190
- dispatch(setPackagingAccoResults(packageAccoSearchResults));
47191
- initialFilteredResults = applyFiltersToPackageAccoResults(packageAccoSearchResults, filters, null);
47192
- dispatch(setFilteredPackagingAccoResults(initialFilteredResults));
47193
- dispatch(setIsLoading(false));
47194
- return [3 /*break*/, 4];
47195
- case 3:
47196
- err_2 = _b.sent();
47197
- console.error('Search failed', err_2);
47198
- dispatch(setIsLoading(false));
47199
- return [3 /*break*/, 4];
47200
- case 4:
47201
- return [2 /*return*/];
47428
+ searchRequest = buildSearchFromSeed(seed);
47429
+ return [4 /*yield*/, build.search(config, searchRequest)];
47430
+ case 1:
47431
+ packageSearchResults = _b.sent();
47432
+ console.log('Search results', packageSearchResults);
47433
+ enrichedFilters = enrichFiltersWithResults(packageSearchResults, context.filters, (_a = context.tags) !== null && _a !== void 0 ? _a : []);
47434
+ if (!initialFiltersSet) {
47435
+ dispatch(resetFilters(enrichedFilters));
47436
+ setInitialFilters(enrichedFilters);
47437
+ setInitialFiltersSet(true);
47202
47438
  }
47203
- });
47204
- });
47205
- };
47206
- if (!(context === null || context === void 0 ? void 0 : context.showMockup)) {
47207
- if (
47208
- (context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.GroupTour ||
47209
- ((context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.AccommodationAndFlight &&
47210
- !context.searchConfiguration.enableManualPackaging)
47211
- ) {
47212
- runSearch();
47439
+ dispatch(setResults(packageSearchResults));
47440
+ initialFilteredResults = applyFilters(packageSearchResults, filters, null);
47441
+ dispatch(setFilteredResults(initialFilteredResults));
47442
+ if ((packageSearchResults === null || packageSearchResults === void 0 ? void 0 : packageSearchResults.length) > 0) {
47443
+ if (context.searchConfiguration.qsmType === build.PortalQsmType.AccommodationAndFlight) {
47444
+ dispatch(setSelectedSearchResult(packageSearchResults[0]));
47445
+ }
47446
+ }
47447
+ return [3 /*break*/, 4];
47448
+ case 2:
47449
+ err_1 = _b.sent();
47450
+ console.error('Search failed', err_1);
47451
+ return [3 /*break*/, 4];
47452
+ case 3:
47453
+ dispatch(setIsLoading(false));
47454
+ return [7 /*endfinally*/];
47455
+ case 4:
47456
+ return [2 /*return*/];
47213
47457
  }
47214
- if ((context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.Accommodation) {
47215
- runHotelSearch();
47458
+ });
47459
+ });
47460
+ };
47461
+ var runStartTransaction = function () {
47462
+ return __awaiter(void 0, void 0, void 0, function () {
47463
+ var config, transaction, err_2;
47464
+ return __generator(this, function (_a) {
47465
+ switch (_a.label) {
47466
+ case 0:
47467
+ _a.trys.push([0, 2, , 3]);
47468
+ if (!context) return [2 /*return*/, null];
47469
+ config = {
47470
+ host: context.tideConnection.host,
47471
+ apiKey: context.tideConnection.apiKey
47472
+ };
47473
+ return [4 /*yield*/, build.startTransaction(config)];
47474
+ case 1:
47475
+ transaction = _a.sent();
47476
+ console.log('Transaction started', transaction);
47477
+ dispatch(setTransactionId(transaction.transactionId));
47478
+ return [2 /*return*/, transaction.transactionId];
47479
+ case 2:
47480
+ err_2 = _a.sent();
47481
+ console.error('Transaction failed', err_2);
47482
+ return [2 /*return*/, null];
47483
+ case 3:
47484
+ return [2 /*return*/];
47216
47485
  }
47217
- if (
47218
- (context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.AccommodationAndFlight &&
47219
- context.searchConfiguration.enableManualPackaging
47220
- ) {
47221
- // Manual packaging flow.
47222
- if (context.searchConfiguration.allowAccommodations) {
47223
- runHotelSearch();
47224
- }
47486
+ });
47487
+ });
47488
+ };
47489
+ var runHotelSearch = function (currentTransactionId, seed) {
47490
+ return __awaiter(void 0, void 0, void 0, function () {
47491
+ var config, searchRequest, packageAccoSearchResults, enrichedFilters, initialFilteredResults, err_3;
47492
+ var _a;
47493
+ return __generator(this, function (_b) {
47494
+ switch (_b.label) {
47495
+ case 0:
47496
+ _b.trys.push([0, 2, , 3]);
47497
+ if (!context) return [2 /*return*/];
47498
+ dispatch(setIsLoading(true));
47499
+ config = {
47500
+ host: context.tideConnection.host,
47501
+ apiKey: context.tideConnection.apiKey
47502
+ };
47503
+ searchRequest = buildPackagingAccommodationRequestFromSeed(seed, currentTransactionId);
47504
+ searchRequest.portalId = context.portalId;
47505
+ searchRequest.agentId = context.agentId;
47506
+ console.log('Packaging accommodation search request', searchRequest);
47507
+ return [4 /*yield*/, build.searchPackagingAccommodations(config, searchRequest)];
47508
+ case 1:
47509
+ packageAccoSearchResults = _b.sent();
47510
+ enrichedFilters = enrichFiltersWithPackageAccoResults(
47511
+ packageAccoSearchResults,
47512
+ context.filters,
47513
+ (_a = context.tags) !== null && _a !== void 0 ? _a : []
47514
+ );
47515
+ if (!initialFiltersSet) {
47516
+ dispatch(resetFilters(enrichedFilters));
47517
+ setInitialFilters(enrichedFilters);
47518
+ setInitialFiltersSet(true);
47519
+ }
47520
+ dispatch(setPackagingAccoResults(packageAccoSearchResults));
47521
+ initialFilteredResults = applyFiltersToPackageAccoResults(packageAccoSearchResults, filters, null);
47522
+ dispatch(setFilteredPackagingAccoResults(initialFilteredResults));
47523
+ dispatch(setIsLoading(false));
47524
+ return [3 /*break*/, 3];
47525
+ case 2:
47526
+ err_3 = _b.sent();
47527
+ console.error('Search failed', err_3);
47528
+ dispatch(setIsLoading(false));
47529
+ return [3 /*break*/, 3];
47530
+ case 3:
47531
+ return [2 /*return*/];
47225
47532
  }
47533
+ });
47534
+ });
47535
+ };
47536
+ var runAccommodationFlow = function (seed) {
47537
+ return __awaiter(void 0, void 0, void 0, function () {
47538
+ var currentTransactionId;
47539
+ var _a;
47540
+ return __generator(this, function (_b) {
47541
+ switch (_b.label) {
47542
+ case 0:
47543
+ if (!context || context.showMockup) return [2 /*return*/];
47544
+ currentTransactionId =
47545
+ ((_a = context === null || context === void 0 ? void 0 : context.packagingEntry) === null || _a === void 0 ? void 0 : _a.transactionId) ||
47546
+ transactionId;
47547
+ console.log('Current transaction ID', currentTransactionId);
47548
+ if (!!currentTransactionId) return [3 /*break*/, 2];
47549
+ dispatch(setIsLoading(true));
47550
+ return [4 /*yield*/, runStartTransaction()];
47551
+ case 1:
47552
+ currentTransactionId = _b.sent();
47553
+ _b.label = 2;
47554
+ case 2:
47555
+ if (!currentTransactionId) {
47556
+ dispatch(setIsLoading(false));
47557
+ return [2 /*return*/];
47558
+ }
47559
+ return [4 /*yield*/, runHotelSearch(currentTransactionId, seed)];
47560
+ case 3:
47561
+ _b.sent();
47562
+ return [2 /*return*/];
47563
+ }
47564
+ });
47565
+ });
47566
+ };
47567
+ // separate Search
47568
+ useEffect(
47569
+ function () {
47570
+ if (
47571
+ (context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.GroupTour ||
47572
+ ((context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.AccommodationAndFlight &&
47573
+ !context.searchConfiguration.enableManualPackaging)
47574
+ ) {
47575
+ runSearch();
47576
+ }
47577
+ if ((context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.Accommodation) {
47578
+ var seed = activeSearchSeed;
47579
+ if (seed) {
47580
+ runAccommodationFlow(seed);
47581
+ }
47582
+ }
47583
+ if (
47584
+ (context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.AccommodationAndFlight &&
47585
+ context.searchConfiguration.enableManualPackaging &&
47586
+ context.searchConfiguration.allowAccommodations &&
47587
+ !(context === null || context === void 0 ? void 0 : context.packagingEntry)
47588
+ ) {
47589
+ var seed = activeSearchSeed;
47590
+ if (seed) {
47591
+ runAccommodationFlow(seed);
47592
+ }
47593
+ }
47594
+ },
47595
+ [
47596
+ location.search,
47597
+ context === null || context === void 0 ? void 0 : context.showMockup,
47598
+ context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType,
47599
+ context === null || context === void 0 ? void 0 : context.searchConfiguration.enableManualPackaging,
47600
+ context === null || context === void 0 ? void 0 : context.searchConfiguration.allowAccommodations,
47601
+ (_b = context === null || context === void 0 ? void 0 : context.packagingEntry) === null || _b === void 0 ? void 0 : _b.transactionId,
47602
+ activeSearchSeed
47603
+ ]
47604
+ );
47605
+ useEffect(
47606
+ function () {
47607
+ if (context === null || context === void 0 ? void 0 : context.packagingEntry) {
47608
+ console.log('original packaging entry from context', context.packagingEntry);
47609
+ dispatch(setEditablePackagingEntry(structuredClone(context.packagingEntry)));
47610
+ dispatch(setTransactionId(context.packagingEntry.transactionId));
47226
47611
  }
47227
47612
  },
47228
- [location.search]
47613
+ [context === null || context === void 0 ? void 0 : context.packagingEntry]
47229
47614
  );
47230
- // Seperate detailsCall
47615
+ // separate detailsCall
47231
47616
  useEffect(
47232
47617
  function () {
47233
47618
  var fetchDetails = function () {
47234
47619
  return __awaiter(void 0, void 0, void 0, function () {
47235
- var config, selectedItem, params, entryId, requestRooms, rooms, detailsRequest, detailsResponse, detailsResponse, err_3;
47236
- return __generator(this, function (_a) {
47237
- switch (_a.label) {
47620
+ var config, selectedItem, requestRooms, seed, detailsRequest, detailsResponse, err_4;
47621
+ var _a;
47622
+ return __generator(this, function (_b) {
47623
+ switch (_b.label) {
47238
47624
  case 0:
47239
- setDetailsIsLoading(true);
47240
- console.log('Fetching details for selected search result', selectedSearchResult);
47241
47625
  if (!selectedSearchResult || !context) return [2 /*return*/];
47626
+ setDetailsIsLoading(true);
47242
47627
  if (
47243
47628
  (context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.Accommodation ||
47244
47629
  (context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.GroupTour
47245
47630
  ) {
47246
47631
  handleFlyInToggle(true);
47247
47632
  }
47248
- _a.label = 1;
47633
+ _b.label = 1;
47249
47634
  case 1:
47250
- _a.trys.push([1, 6, , 7]);
47635
+ _b.trys.push([1, 3, , 4]);
47251
47636
  config = {
47252
47637
  host: context.tideConnection.host,
47253
47638
  apiKey: context.tideConnection.apiKey
@@ -47259,14 +47644,14 @@ var SearchResultsContainer = function () {
47259
47644
  // TODO: handle this case better, show an error message to the user
47260
47645
  return [2 /*return*/];
47261
47646
  }
47262
- params = new URLSearchParams(location.search);
47263
- entryId = getStringFromParams(params, 'entryId');
47264
47647
  requestRooms = void 0;
47265
- if (entry && entryId) {
47266
- requestRooms = getRequestRoomsFromEntry(entry.rooms);
47648
+ if (context === null || context === void 0 ? void 0 : context.packagingEntry) {
47649
+ requestRooms = getRequestRoomsFromPackagingEntry(context.packagingEntry);
47267
47650
  } else {
47268
- rooms = getRoomsFromParams(params, 'rooms');
47269
- requestRooms = getRequestRooms(rooms);
47651
+ seed = activeSearchSeed;
47652
+ requestRooms = ((_a = seed === null || seed === void 0 ? void 0 : seed.rooms) === null || _a === void 0 ? void 0 : _a.length)
47653
+ ? seed.rooms
47654
+ : getRequestRooms(null);
47270
47655
  }
47271
47656
  detailsRequest = {
47272
47657
  officeId: 1,
@@ -47288,29 +47673,18 @@ var SearchResultsContainer = function () {
47288
47673
  },
47289
47674
  agentId: context.agentId
47290
47675
  };
47291
- if (!(entry && entryId)) return [3 /*break*/, 3];
47292
- requestRooms = getRequestRoomsFromEntry(entry.rooms);
47293
47676
  return [4 /*yield*/, build.details(config, detailsRequest)];
47294
47677
  case 2:
47295
- detailsResponse = _a.sent();
47296
- console.log('Details:', detailsResponse);
47297
- dispatch(setBookingPackageDetails({ details: detailsResponse === null || detailsResponse === void 0 ? void 0 : detailsResponse.payload }));
47298
- return [3 /*break*/, 5];
47299
- case 3:
47300
- return [4 /*yield*/, build.details(config, detailsRequest)];
47301
- case 4:
47302
- detailsResponse = _a.sent();
47678
+ detailsResponse = _b.sent();
47303
47679
  dispatch(setBookingPackageDetails({ details: detailsResponse === null || detailsResponse === void 0 ? void 0 : detailsResponse.payload }));
47304
47680
  setDetailsIsLoading(false);
47305
- _a.label = 5;
47306
- case 5:
47307
- return [3 /*break*/, 7];
47308
- case 6:
47309
- err_3 = _a.sent();
47310
- console.error('Failed to fetch package details', err_3);
47681
+ return [3 /*break*/, 4];
47682
+ case 3:
47683
+ err_4 = _b.sent();
47684
+ console.error('Failed to fetch package details', err_4);
47311
47685
  setDetailsIsLoading(false);
47312
- return [3 /*break*/, 7];
47313
- case 7:
47686
+ return [3 /*break*/, 4];
47687
+ case 4:
47314
47688
  return [2 /*return*/];
47315
47689
  }
47316
47690
  });
@@ -47320,8 +47694,7 @@ var SearchResultsContainer = function () {
47320
47694
  return __awaiter(void 0, void 0, void 0, function () {
47321
47695
  var config,
47322
47696
  selectedItem,
47323
- params,
47324
- rooms,
47697
+ seed,
47325
47698
  tagId,
47326
47699
  destinationAirport,
47327
47700
  destinationId,
@@ -47333,38 +47706,37 @@ var SearchResultsContainer = function () {
47333
47706
  destinationIsAirport,
47334
47707
  detailSearchRequest,
47335
47708
  packageAccoSearchDetails,
47336
- err_4;
47337
- var _a, _b;
47338
- return __generator(this, function (_c) {
47339
- switch (_c.label) {
47709
+ err_5;
47710
+ var _a, _b, _c, _d, _e;
47711
+ return __generator(this, function (_f) {
47712
+ switch (_f.label) {
47340
47713
  case 0:
47341
47714
  if (!selectedPackagingAccoResultCode || !context) return [2 /*return*/];
47715
+ setDetailsIsLoading(true);
47342
47716
  if (
47343
47717
  (context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.Accommodation ||
47718
+ (context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.AccommodationAndFlight ||
47344
47719
  (context === null || context === void 0 ? void 0 : context.searchConfiguration.qsmType) === build.PortalQsmType.GroupTour
47345
47720
  ) {
47346
47721
  handleFlyInToggle(true);
47347
47722
  }
47348
- _c.label = 1;
47723
+ _f.label = 1;
47349
47724
  case 1:
47350
- _c.trys.push([1, 3, , 4]);
47725
+ _f.trys.push([1, 3, , 4]);
47351
47726
  config = {
47352
47727
  host: context.tideConnection.host,
47353
47728
  apiKey: context.tideConnection.apiKey
47354
47729
  };
47355
- console.log('selectedPackagingAccoResultCode', selectedPackagingAccoResultCode);
47356
47730
  selectedItem = packagingAccoResults.find(function (r) {
47357
47731
  return r.code === selectedPackagingAccoResultCode;
47358
47732
  });
47359
- console.log('Selected packaging acco item', selectedItem);
47360
47733
  if (!selectedItem) {
47361
47734
  // TODO: handle this case better, show an error message to the user
47362
47735
  return [2 /*return*/];
47363
47736
  }
47364
- params = new URLSearchParams(location.search);
47365
- rooms = getRoomsFromParams(params, 'rooms');
47366
- tagId = getNumberFromParams(params, 'tagId');
47367
- destinationAirport = getStringFromParams(params, 'destinationAirport');
47737
+ seed = activeSearchSeed;
47738
+ tagId = (_a = seed === null || seed === void 0 ? void 0 : seed.tagId) !== null && _a !== void 0 ? _a : null;
47739
+ destinationAirport = (_b = seed === null || seed === void 0 ? void 0 : seed.destinationAirport) !== null && _b !== void 0 ? _b : null;
47368
47740
  destinationId = null;
47369
47741
  destinationIsCountry = false;
47370
47742
  destinationIsRegion = false;
@@ -47389,14 +47761,15 @@ var SearchResultsContainer = function () {
47389
47761
  destinationIsAirport = true;
47390
47762
  }
47391
47763
  detailSearchRequest = {
47764
+ transactionId: transactionId !== null && transactionId !== void 0 ? transactionId : '',
47392
47765
  officeId: 1,
47393
47766
  portalId: context.portalId,
47394
47767
  agentId: context.agentId,
47395
- catalogueId: (_a = context.searchConfiguration.defaultCatalogueId) !== null && _a !== void 0 ? _a : 0,
47768
+ catalogueId: (_c = context.searchConfiguration.defaultCatalogueId) !== null && _c !== void 0 ? _c : 0,
47396
47769
  searchConfigurationId: context.searchConfiguration.id,
47397
47770
  vendorConfigurationId: selectedItem.vendorId,
47398
- language: (_b = context.languageCode) !== null && _b !== void 0 ? _b : 'en-GB',
47399
- serviceType: 3,
47771
+ language: (_d = context.languageCode) !== null && _d !== void 0 ? _d : 'en-GB',
47772
+ serviceType: ACCOMMODATION_SERVICE_TYPE,
47400
47773
  fromDate: selectedItem.fromDate,
47401
47774
  toDate: selectedItem.toDate,
47402
47775
  destination: {
@@ -47409,18 +47782,22 @@ var SearchResultsContainer = function () {
47409
47782
  code: destinationCode
47410
47783
  },
47411
47784
  productCode: selectedItem.code ? selectedItem.code : '',
47412
- rooms: getPackagingRequestRooms(rooms),
47785
+ rooms: getPackagingRequestRoomsFromBookingRooms(
47786
+ (_e = seed === null || seed === void 0 ? void 0 : seed.rooms) !== null && _e !== void 0 ? _e : null
47787
+ ),
47413
47788
  tagIds: tagId ? [tagId] : []
47414
47789
  };
47415
47790
  return [4 /*yield*/, build.searchPackagingAccommodations(config, detailSearchRequest)];
47416
47791
  case 2:
47417
- packageAccoSearchDetails = _c.sent();
47792
+ packageAccoSearchDetails = _f.sent();
47418
47793
  console.log('Packaging Acco Search details', packageAccoSearchDetails);
47419
47794
  dispatch(setPackagingAccoSearchDetails(packageAccoSearchDetails));
47795
+ setDetailsIsLoading(false);
47420
47796
  return [3 /*break*/, 4];
47421
47797
  case 3:
47422
- err_4 = _c.sent();
47423
- console.error('Failed to fetch package details', err_4);
47798
+ err_5 = _f.sent();
47799
+ console.error('Failed to fetch package details', err_5);
47800
+ setDetailsIsLoading(false);
47424
47801
  return [3 /*break*/, 4];
47425
47802
  case 4:
47426
47803
  return [2 /*return*/];
@@ -47434,6 +47811,7 @@ var SearchResultsContainer = function () {
47434
47811
  if (selectedPackagingAccoResultCode) {
47435
47812
  fetchPackagingAccoSearchDetails();
47436
47813
  }
47814
+ dispatch(setAccommodationFlyInStep('details'));
47437
47815
  },
47438
47816
  [selectedSearchResult, selectedPackagingAccoResultCode]
47439
47817
  );
@@ -47449,6 +47827,64 @@ var SearchResultsContainer = function () {
47449
47827
  },
47450
47828
  [filters, results, packagingAccoResults, selectedSortType]
47451
47829
  );
47830
+ useEffect(
47831
+ function () {
47832
+ setInitialFiltersSet(false);
47833
+ },
47834
+ [activeSearchSeed]
47835
+ );
47836
+ var handleEditAccommodation = function (segments) {
47837
+ return __awaiter(void 0, void 0, void 0, function () {
47838
+ var sourceEntry, seed;
47839
+ return __generator(this, function (_a) {
47840
+ switch (_a.label) {
47841
+ case 0:
47842
+ sourceEntry =
47843
+ editablePackagingEntry !== null && editablePackagingEntry !== void 0
47844
+ ? editablePackagingEntry
47845
+ : context === null || context === void 0
47846
+ ? void 0
47847
+ : context.packagingEntry;
47848
+ if (!sourceEntry) return [2 /*return*/];
47849
+ seed = buildSearchSeedFromAccommodationSegments(sourceEntry, segments);
47850
+ if (!seed) return [2 /*return*/];
47851
+ setDetailsIsLoading(true);
47852
+ setSelectedAccommodationSeed(seed);
47853
+ dispatch(setAccommodationFlyInStep('results'));
47854
+ handleFlyInToggle(true);
47855
+ return [4 /*yield*/, runAccommodationFlow(seed)];
47856
+ case 1:
47857
+ _a.sent();
47858
+ setDetailsIsLoading(false);
47859
+ return [2 /*return*/];
47860
+ }
47861
+ });
47862
+ });
47863
+ };
47864
+ var buildSearchSeedFromAccommodationSegments = function (entry, segments) {
47865
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
47866
+ if (!(segments === null || segments === void 0 ? void 0 : segments.length)) return null;
47867
+ var sortedSegments = __spreadArray([], segments, true).sort(function (a, b) {
47868
+ return new Date(a.from).getTime() - new Date(b.from).getTime();
47869
+ });
47870
+ var firstSegment = first(sortedSegments);
47871
+ var lastSegment = last(sortedSegments);
47872
+ if (!firstSegment || !lastSegment) return null;
47873
+ return {
47874
+ fromDate: toDateOnlyString(firstSegment.from),
47875
+ toDate: toDateOnlyString(lastSegment.to),
47876
+ country: (_b = (_a = firstSegment.country) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : null,
47877
+ region: (_d = (_c = firstSegment.region) === null || _c === void 0 ? void 0 : _c.id) !== null && _d !== void 0 ? _d : null,
47878
+ oord: (_f = (_e = firstSegment.oord) === null || _e === void 0 ? void 0 : _e.id) !== null && _f !== void 0 ? _f : null,
47879
+ location: (_h = (_g = firstSegment.location) === null || _g === void 0 ? void 0 : _g.id) !== null && _h !== void 0 ? _h : null,
47880
+ hotel: parseHotelId(firstSegment),
47881
+ hotelCode: (_j = firstSegment.productCode) !== null && _j !== void 0 ? _j : null,
47882
+ tagId: null,
47883
+ destinationAirport: getDestinationAirportFromEntry((_k = entry.lines) !== null && _k !== void 0 ? _k : []),
47884
+ departureAirport: getDepartureAirportFromEntry((_l = entry.lines) !== null && _l !== void 0 ? _l : []),
47885
+ rooms: getRequestRoomsFromPackagingSegments(entry, sortedSegments)
47886
+ };
47887
+ };
47452
47888
  return React__default.createElement(
47453
47889
  'div',
47454
47890
  { id: 'tide-booking', className: 'search__bg' },
@@ -47500,7 +47936,8 @@ var SearchResultsContainer = function () {
47500
47936
  handleSetIsOpen: function () {
47501
47937
  return setItineraryOpen(!itineraryOpen);
47502
47938
  },
47503
- isLoading: isLoading
47939
+ isLoading: isLoading,
47940
+ onEditAccommodation: handleEditAccommodation
47504
47941
  }),
47505
47942
  React__default.createElement(
47506
47943
  'div',
@@ -47565,6 +48002,7 @@ var SearchResultsContainer = function () {
47565
48002
  'span',
47566
48003
  { className: 'search__result-row-text' },
47567
48004
  !isLoading &&
48005
+ !context.packagingEntry &&
47568
48006
  React__default.createElement(
47569
48007
  React__default.Fragment,
47570
48008
  null,
@@ -47580,7 +48018,8 @@ var SearchResultsContainer = function () {
47580
48018
  translations.SRP.TOTAL_RESULTS_LABEL
47581
48019
  )
47582
48020
  ),
47583
- !isMobile &&
48021
+ !context.packagingEntry &&
48022
+ !isMobile &&
47584
48023
  sortByTypes &&
47585
48024
  sortByTypes.length > 0 &&
47586
48025
  React__default.createElement(
@@ -47608,25 +48047,35 @@ var SearchResultsContainer = function () {
47608
48047
  React__default.createElement(
47609
48048
  'div',
47610
48049
  { className: 'search__results__wrapper' },
47611
- context.showTabViews && React__default.createElement(TabViews, null),
48050
+ context.showTabViews &&
48051
+ (context.searchConfiguration.qsmType === build.PortalQsmType.GroupTour ||
48052
+ context.searchConfiguration.qsmType === build.PortalQsmType.Accommodation) &&
48053
+ React__default.createElement(TabViews, null),
47612
48054
  context.showRoundTripResults && context.showMockup && React__default.createElement(RoundTripResults, null),
47613
48055
  context.searchConfiguration.qsmType === build.PortalQsmType.GroupTour &&
47614
48056
  React__default.createElement(GroupTourResults, { isLoading: isLoading }),
47615
48057
  context.searchConfiguration.qsmType === build.PortalQsmType.AccommodationAndFlight &&
48058
+ !context.packagingEntry &&
47616
48059
  context.showFlightResults &&
47617
48060
  (bookingPackageDetails === null || bookingPackageDetails === void 0 ? void 0 : bookingPackageDetails.outwardFlights) &&
47618
48061
  React__default.createElement(FlightResults, {
47619
48062
  flights: bookingPackageDetails === null || bookingPackageDetails === void 0 ? void 0 : bookingPackageDetails.outwardFlights,
47620
48063
  isDeparture: true
47621
48064
  }),
47622
- context.showHotelAccommodationResults && React__default.createElement(HotelAccommodationResults, { isLoading: isLoading }),
48065
+ context.showHotelAccommodationResults &&
48066
+ !context.packagingEntry &&
48067
+ React__default.createElement(HotelAccommodationResults, { isLoading: isLoading }),
47623
48068
  context.searchConfiguration.qsmType === build.PortalQsmType.AccommodationAndFlight &&
48069
+ !context.packagingEntry &&
47624
48070
  context.showFlightResults &&
47625
48071
  (bookingPackageDetails === null || bookingPackageDetails === void 0 ? void 0 : bookingPackageDetails.returnFlights) &&
47626
48072
  React__default.createElement(FlightResults, {
47627
48073
  flights: bookingPackageDetails === null || bookingPackageDetails === void 0 ? void 0 : bookingPackageDetails.returnFlights,
47628
48074
  isDeparture: false
47629
- })
48075
+ }),
48076
+ context.searchConfiguration.qsmType === build.PortalQsmType.AccommodationAndFlight &&
48077
+ context.packagingEntry &&
48078
+ React__default.createElement('span', null, 'TODO: Show Full Itinerary here')
47630
48079
  )
47631
48080
  ),
47632
48081
  React__default.createElement(FlyIn, {
@@ -47634,10 +48083,15 @@ var SearchResultsContainer = function () {
47634
48083
  srpType: context.searchConfiguration.qsmType,
47635
48084
  isOpen: flyInIsOpen,
47636
48085
  setIsOpen: handleFlyInToggle,
48086
+ handleConfirm: function () {
48087
+ return handleConfirmHotelSwap();
48088
+ },
47637
48089
  onPanelRef: function (el) {
47638
48090
  return (panelRef.current = el);
47639
48091
  },
47640
- detailsLoading: detailsIsLoading
48092
+ detailsLoading: detailsIsLoading,
48093
+ accommodationStep: accommodationFlyInStep,
48094
+ isPackageEditFlow: !!context.packagingEntry
47641
48095
  })
47642
48096
  )
47643
48097
  )