@sabstravtech/obtservices 0.0.3 → 0.0.19020100

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 (92) hide show
  1. package/angular/fetchers.d.ts +1 -0
  2. package/angular/lib/vendor/classes/helpers.d.ts +6 -3
  3. package/angular/lib/vendor/fetchers/conferma-office.fetcher.d.ts +6 -0
  4. package/angular/lib/vendor/fetchers/search-irl-stations.fetcher.d.ts +7 -0
  5. package/angular/lib/vendor/services/search.service.d.ts +5 -3
  6. package/angular/lib/vendor/types/graphql.angular.types.d.ts +268 -6
  7. package/angular/obtservices.module.d.ts +1 -1
  8. package/angular/sabstravtech-obtservices-angular.d.ts +6 -5
  9. package/angular/sabstravtech-obtservices-angular.metadata.json +1 -1
  10. package/base/fetchers.d.ts +2 -0
  11. package/base/lib/vendor/classes/base-enterprise.d.ts +4 -0
  12. package/base/lib/vendor/classes/bookable-basket.d.ts +1 -1
  13. package/base/lib/vendor/classes/cabhire-enterprise-search.d.ts +6 -1
  14. package/base/lib/vendor/classes/carhire-enterprise-search.d.ts +2 -1
  15. package/base/lib/vendor/classes/eurostar-enterprise-search.d.ts +21 -5
  16. package/base/lib/vendor/classes/flight-enterprise-search.d.ts +22 -75
  17. package/base/lib/vendor/classes/helpers.d.ts +3 -0
  18. package/base/lib/vendor/classes/hotel-enterprise-search.d.ts +1 -0
  19. package/base/lib/vendor/classes/irl-enterprise-search.d.ts +21 -10
  20. package/base/lib/vendor/classes/lounges-enterprise-search.d.ts +1 -0
  21. package/base/lib/vendor/classes/parking-enterprise-search.d.ts +1 -0
  22. package/base/lib/vendor/classes/rail-enterprise-search.d.ts +1 -0
  23. package/base/lib/vendor/fetchers/conferma-office.fetcher.d.ts +20 -0
  24. package/base/lib/vendor/fetchers/irl-quote-fetcher.d.ts +1 -1
  25. package/base/lib/vendor/fetchers/search-irl-stations.fetcher.d.ts +20 -0
  26. package/base/lib/vendor/interfaces/Icabhire-enterprise-search.d.ts +1 -0
  27. package/base/lib/vendor/interfaces/Ienterprise-basket.service.d.ts +1 -1
  28. package/base/lib/vendor/interfaces/Ieurostar-enterprise-search.d.ts +4 -35
  29. package/base/lib/vendor/interfaces/Iflight-enterprise-search.d.ts +4 -40
  30. package/base/lib/vendor/interfaces/Iirl-enterprise-search.d.ts +9 -2
  31. package/base/lib/vendor/interfaces/Isearch.service.d.ts +3 -1
  32. package/base/lib/vendor/interfaces/flight-filters.interface.d.ts +21 -25
  33. package/base/lib/vendor/interfaces/hotel-recent-search-args.interface.d.ts +23 -0
  34. package/base/lib/vendor/interfaces/value-display.d.ts +2 -2
  35. package/base/lib/vendor/models/traveller.object.d.ts +7 -0
  36. package/base/lib/vendor/services/enterprise-basket.service.d.ts +1 -1
  37. package/base/lib/vendor/services/search.service.d.ts +10 -3
  38. package/base/lib/vendor/types/graphql.types.d.ts +253 -6
  39. package/base/lib/vendor/types/types.d.ts +11 -2
  40. package/base/sabstravtech-obtservices-base.metadata.json +1 -1
  41. package/bundles/sabstravtech-obtservices-angular.umd.js +200 -64
  42. package/bundles/sabstravtech-obtservices-angular.umd.js.map +1 -1
  43. package/bundles/sabstravtech-obtservices-angular.umd.min.js +1 -1
  44. package/bundles/sabstravtech-obtservices-angular.umd.min.js.map +1 -1
  45. package/bundles/sabstravtech-obtservices-base.umd.js +1632 -1085
  46. package/bundles/sabstravtech-obtservices-base.umd.js.map +1 -1
  47. package/bundles/sabstravtech-obtservices-base.umd.min.js +2 -2
  48. package/bundles/sabstravtech-obtservices-base.umd.min.js.map +1 -1
  49. package/esm2015/angular/fetchers.js +2 -1
  50. package/esm2015/angular/lib/vendor/classes/helpers.js +25 -4
  51. package/esm2015/angular/lib/vendor/fetchers/conferma-office.fetcher.js +22 -0
  52. package/esm2015/angular/lib/vendor/fetchers/search-irl-stations.fetcher.js +25 -0
  53. package/esm2015/angular/lib/vendor/services/search.service.js +35 -29
  54. package/esm2015/angular/lib/vendor/types/graphql.angular.types.js +174 -6
  55. package/esm2015/angular/obtservices.module.js +3 -3
  56. package/esm2015/angular/sabstravtech-obtservices-angular.js +7 -6
  57. package/esm2015/base/fetchers.js +3 -1
  58. package/esm2015/base/lib/vendor/classes/base-enterprise.js +49 -2
  59. package/esm2015/base/lib/vendor/classes/bookable-basket.js +2 -2
  60. package/esm2015/base/lib/vendor/classes/cabhire-enterprise-search.js +95 -15
  61. package/esm2015/base/lib/vendor/classes/carhire-enterprise-search.js +2 -1
  62. package/esm2015/base/lib/vendor/classes/eurostar-enterprise-search.js +262 -52
  63. package/esm2015/base/lib/vendor/classes/flight-enterprise-search.js +439 -713
  64. package/esm2015/base/lib/vendor/classes/helpers.js +239 -24
  65. package/esm2015/base/lib/vendor/classes/hotel-enterprise-search.js +74 -70
  66. package/esm2015/base/lib/vendor/classes/irl-enterprise-search.js +153 -118
  67. package/esm2015/base/lib/vendor/classes/lounges-enterprise-search.js +2 -1
  68. package/esm2015/base/lib/vendor/classes/management-info-and-valid.js +58 -1
  69. package/esm2015/base/lib/vendor/classes/parking-enterprise-search.js +6 -3
  70. package/esm2015/base/lib/vendor/classes/rail-enterprise-search.js +2 -1
  71. package/esm2015/base/lib/vendor/fetchers/conferma-office.fetcher.js +11 -0
  72. package/esm2015/base/lib/vendor/fetchers/irl-quote-fetcher.js +2 -2
  73. package/esm2015/base/lib/vendor/fetchers/search-irl-stations.fetcher.js +11 -0
  74. package/esm2015/base/lib/vendor/interfaces/Icabhire-enterprise-search.js +1 -1
  75. package/esm2015/base/lib/vendor/interfaces/Ienterprise-basket.service.js +1 -1
  76. package/esm2015/base/lib/vendor/interfaces/Ieurostar-enterprise-search.js +1 -1
  77. package/esm2015/base/lib/vendor/interfaces/Iflight-enterprise-search.js +43 -2
  78. package/esm2015/base/lib/vendor/interfaces/Iirl-enterprise-search.js +1 -1
  79. package/esm2015/base/lib/vendor/interfaces/Isearch.service.js +1 -1
  80. package/esm2015/base/lib/vendor/interfaces/flight-filters.interface.js +2 -1
  81. package/esm2015/base/lib/vendor/interfaces/hotel-recent-search-args.interface.js +2 -0
  82. package/esm2015/base/lib/vendor/interfaces/value-display.js +1 -1
  83. package/esm2015/base/lib/vendor/models/traveller.object.js +8 -1
  84. package/esm2015/base/lib/vendor/services/enterprise-basket.service.js +3 -2
  85. package/esm2015/base/lib/vendor/services/search.service.js +67 -12
  86. package/esm2015/base/lib/vendor/types/graphql.types.js +13 -2
  87. package/esm2015/base/lib/vendor/types/types.js +1 -1
  88. package/fesm2015/sabstravtech-obtservices-angular.js +238 -16
  89. package/fesm2015/sabstravtech-obtservices-angular.js.map +1 -1
  90. package/fesm2015/sabstravtech-obtservices-base.js +1561 -1045
  91. package/fesm2015/sabstravtech-obtservices-base.js.map +1 -1
  92. package/package.json +4 -4
@@ -14,6 +14,7 @@ class BaseEnterpriseSearch {
14
14
  };
15
15
  this.isValid = new BehaviorSubject(false);
16
16
  this.results = new BehaviorSubject([]);
17
+ this.multiResults = new BehaviorSubject([]);
17
18
  this.messages = new BehaviorSubject([]);
18
19
  this.messagesInfo = new BehaviorSubject([]);
19
20
  this.validationMessages = [];
@@ -22,6 +23,7 @@ class BaseEnterpriseSearch {
22
23
  this.tempParams = {};
23
24
  this.doChecks = true;
24
25
  this.fullResults = []; // should be an array of type specified by O
26
+ this.fullMultiResults = []; // an array of arrays of type specified by O
25
27
  this.mapper = (results) => {
26
28
  return results;
27
29
  };
@@ -48,7 +50,7 @@ class BaseEnterpriseSearch {
48
50
  try {
49
51
  results.pipe(take(1)).subscribe((results1) => {
50
52
  console.log('Got results', cloneDeep(results1));
51
- this.fullResults = this.mapper(results1);
53
+ this.fullResults = Object.freeze(this.mapper(results1));
52
54
  this._cheapestResultPrice = this.updateLowestPrice(this.fullResults);
53
55
  this.storageService.setSessionItem(this.resultsSessionName, this.makeSessionResults(this.fullResults));
54
56
  this.results.next(this.fullResults);
@@ -69,10 +71,55 @@ class BaseEnterpriseSearch {
69
71
  }
70
72
  });
71
73
  }
74
+ _startMultiSearch(resultsArray) {
75
+ this.isLoading.next(true);
76
+ this.fullMultiResults = [];
77
+ const allQueries = [];
78
+ resultsArray.forEach((results, index) => {
79
+ allQueries.push(new Promise((resolve, reject) => {
80
+ try {
81
+ results.pipe(take(1)).subscribe((results1) => {
82
+ console.log('Got results', cloneDeep(results1));
83
+ const mappedResults = this.mapper(results1);
84
+ this.fullMultiResults[index] = mappedResults;
85
+ // this._cheapestResultPrice = this.updateLowestPrice( // perform these after all searches complete
86
+ // this.fullResults
87
+ // );
88
+ // this.results.next(this.fullResults);
89
+ resolve(mappedResults.length !== 0);
90
+ }, (error) => {
91
+ this.multiResults.next([]);
92
+ resolve(false);
93
+ });
94
+ }
95
+ catch (err) {
96
+ this.storageService.setSessionItem(this.resultsSessionName, []);
97
+ this.multiResults.next([]);
98
+ reject(err);
99
+ }
100
+ }));
101
+ });
102
+ return Promise.all(allQueries).then((value) => {
103
+ this.isLoading.next(false);
104
+ console.log('+++ Multiloading Complete +++');
105
+ console.log('+++ Multi Results: ', this.fullMultiResults, ' +++');
106
+ // store the full results
107
+ this.storageService.setSessionItem(this.multiResultsSessionName, this.fullMultiResults);
108
+ this.multiResults.next(this.fullMultiResults);
109
+ return true;
110
+ });
111
+ }
72
112
  reset() {
73
113
  this.storageService.removeSessionItem(this.resultsSessionName);
114
+ try {
115
+ this.storageService.removeSessionItem(this.multiResultsSessionName);
116
+ }
117
+ catch (error) {
118
+ }
74
119
  this.fullResults = [];
120
+ this.fullMultiResults = [];
75
121
  this.results.next([]);
122
+ this.multiResults.next([]);
76
123
  this.resetQuery();
77
124
  }
78
125
  makeSessionResults(data) {
@@ -457,9 +504,10 @@ var FlightCabinClass;
457
504
  (function (FlightCabinClass) {
458
505
  FlightCabinClass["Any"] = "Any";
459
506
  FlightCabinClass["LiteEconomy"] = "LiteEconomy";
507
+ FlightCabinClass["Economy"] = "Economy";
460
508
  FlightCabinClass["EconomyRestricted"] = "EconomyRestricted";
461
509
  FlightCabinClass["EconomyNoBags"] = "EconomyNoBags";
462
- FlightCabinClass["Economy"] = "Economy";
510
+ FlightCabinClass["EconomyFlexi"] = "EconomyFlexi";
463
511
  FlightCabinClass["PremiumEconomy"] = "PremiumEconomy";
464
512
  FlightCabinClass["Business"] = "Business";
465
513
  FlightCabinClass["PremiumBusiness"] = "PremiumBusiness";
@@ -495,6 +543,15 @@ var IrlTravellerStatus;
495
543
  IrlTravellerStatus["Placeholder"] = "placeholder";
496
544
  IrlTravellerStatus["Complete"] = "complete";
497
545
  })(IrlTravellerStatus || (IrlTravellerStatus = {}));
546
+ var MessageTarget;
547
+ (function (MessageTarget) {
548
+ MessageTarget["Login"] = "LOGIN";
549
+ MessageTarget["SearchForm"] = "SEARCH_FORM";
550
+ MessageTarget["Results"] = "RESULTS";
551
+ MessageTarget["MiForm"] = "MI_FORM";
552
+ MessageTarget["BasketBeforeConfirm"] = "BASKET_BEFORE_CONFIRM";
553
+ MessageTarget["Dashboard"] = "DASHBOARD";
554
+ })(MessageTarget || (MessageTarget = {}));
498
555
  var PassengerType;
499
556
  (function (PassengerType) {
500
557
  PassengerType["Adult"] = "ADULT";
@@ -580,6 +637,7 @@ var UiPresentation;
580
637
  (function (UiPresentation) {
581
638
  UiPresentation["FreeText"] = "FREE_TEXT";
582
639
  UiPresentation["AutoSuggest"] = "AUTO_SUGGEST";
640
+ UiPresentation["Dropdown"] = "DROPDOWN";
583
641
  UiPresentation["Hidden"] = "HIDDEN";
584
642
  })(UiPresentation || (UiPresentation = {}));
585
643
 
@@ -740,6 +798,58 @@ class HiddenManagementInfo extends ManagementInfoAndIsValid {
740
798
  setValue(val) { }
741
799
  save(basketid, userId) { }
742
800
  }
801
+ class DropdownManagementInfo extends ManagementInfoAndIsValid {
802
+ constructor(managementInfo, basketService) {
803
+ var _a;
804
+ super(managementInfo);
805
+ this.basketService = basketService;
806
+ if (((_a = this.values) === null || _a === void 0 ? void 0 : _a.length) > 0) {
807
+ this.avaliableItems = this.values;
808
+ }
809
+ else {
810
+ console.error('No values for Dropdown MI field ');
811
+ }
812
+ }
813
+ getValue() {
814
+ return this.selectedValues[0] ? this.selectedValues[0].value.id : '__NONE';
815
+ }
816
+ hasErrors(id) {
817
+ return __awaiter(this, void 0, void 0, function* () {
818
+ return !this.avaliableItems.find((value1) => {
819
+ return value1.id === id;
820
+ })
821
+ ? { hasErrors: true }
822
+ : null;
823
+ });
824
+ }
825
+ setValue(id) {
826
+ const value = this.avaliableItems.find((value1) => {
827
+ return value1.id === id;
828
+ });
829
+ if (!!value) {
830
+ this.selectedValues = [
831
+ {
832
+ value: {
833
+ id: value.id,
834
+ label: value.label,
835
+ value: value.value,
836
+ default: value.default,
837
+ fixed: value.fixed,
838
+ agentOnly: value.agentOnly
839
+ },
840
+ basketLevelValue: this.perBooking,
841
+ userLevelValue: this.perPassenger
842
+ }
843
+ ];
844
+ }
845
+ else {
846
+ this.selectedValues = [];
847
+ }
848
+ }
849
+ save(basketid, userid) {
850
+ this.basketService.setMiSelectedValue(basketid, this, this.selectedValues[0].value.id, userid);
851
+ }
852
+ }
743
853
  const makeManagamentInfo = (managementInfo, basketService) => {
744
854
  switch (managementInfo.uiPresentation) {
745
855
  case UiPresentation.FreeText:
@@ -748,6 +858,11 @@ const makeManagamentInfo = (managementInfo, basketService) => {
748
858
  return new AutoSugestManagementInfo(managementInfo, basketService);
749
859
  case UiPresentation.Hidden:
750
860
  return new HiddenManagementInfo(managementInfo);
861
+ case UiPresentation.Dropdown:
862
+ return new DropdownManagementInfo(managementInfo, basketService);
863
+ default:
864
+ const tmp = managementInfo.uiPresentation;
865
+ console.log(tmp);
751
866
  }
752
867
  return null;
753
868
  };
@@ -1027,7 +1142,7 @@ class BookableBasket {
1027
1142
  }
1028
1143
  }
1029
1144
  sendBasketForApproval() {
1030
- this.basketService.sendBasketForApproval(this.id);
1145
+ return this.basketService.sendBasketForApproval(this.id);
1031
1146
  }
1032
1147
  workoutApprovedState(basket) {
1033
1148
  let status = BookingStatus.ApprovedBook;
@@ -1245,13 +1360,17 @@ class CabHireEnterpriseSearch extends BaseEnterpriseSearch {
1245
1360
  { enabled: false, key: 'wait_and_return', value: 'Wait And Return' }
1246
1361
  ];
1247
1362
  this.searchTypes = [
1248
- 'One-way'
1249
- // , 'Return'
1363
+ 'One-way', 'Return'
1250
1364
  ];
1251
1365
  this.airportSearchTypes = ['Airport drop off', 'Airport Pick Up'];
1252
1366
  this.criteria = ['Pick Up Time'];
1253
1367
  this.mode = TaxiFormMode.ADDRESS;
1254
1368
  this.minSelectDate = moment();
1369
+ this.minReturnSelectDate = {
1370
+ day: moment().date(),
1371
+ month: moment().month() + 1,
1372
+ year: moment().year()
1373
+ };
1255
1374
  // getters and setters
1256
1375
  this._date = null;
1257
1376
  this.selectedPlaces = [];
@@ -1286,6 +1405,7 @@ class CabHireEnterpriseSearch extends BaseEnterpriseSearch {
1286
1405
  this._terminal = null;
1287
1406
  this._time = null;
1288
1407
  this.resultsSessionName = CabHireEnterpriseSearch.STORAGE_SESSION_RESULTS;
1408
+ this.multiResultsSessionName = CabHireEnterpriseSearch.MULTI_STORAGE_SESSION_RESULTS;
1289
1409
  this.getPassengers = () => {
1290
1410
  const adults = this.adults;
1291
1411
  const children = this.children;
@@ -1305,10 +1425,17 @@ class CabHireEnterpriseSearch extends BaseEnterpriseSearch {
1305
1425
  const data = storageService.getSessionItem(CabHireEnterpriseSearch.STORAGE_SESSION_PARAMS) || {
1306
1426
  tempParams: {}
1307
1427
  };
1308
- // const momentDateTime = data.query.departs
1309
- // ? moment(data.query.departs)
1310
- // : moment();
1311
1428
  this.updateTempParams(searchService.makeCabHireQuery(data.tempParams));
1429
+ try {
1430
+ const returnData = storageService.getSessionItem(CabHireEnterpriseSearch.SECONDARY_STORAGE_SESSION_PARAMS);
1431
+ if (returnData) {
1432
+ this.returnDateTime = moment(returnData.tempParams.departs);
1433
+ this.searchType = this.searchTypes[1];
1434
+ }
1435
+ }
1436
+ catch (error) {
1437
+ console.error('+++ Error recovering return data: ', error, ' +++');
1438
+ }
1312
1439
  if (data.tempParams.fromAddress) {
1313
1440
  this.fromAddress = data.tempParams.fromAddress;
1314
1441
  }
@@ -1328,6 +1455,9 @@ class CabHireEnterpriseSearch extends BaseEnterpriseSearch {
1328
1455
  this.fullResults = results;
1329
1456
  this._cheapestResultPrice = this.updateLowestPrice(results);
1330
1457
  this.results.next(results || []);
1458
+ const secondaryResults = storageService.getSessionItemAsList(this.multiResultsSessionName) || [];
1459
+ this.fullMultiResults = secondaryResults;
1460
+ this.multiResults.next(secondaryResults);
1331
1461
  this._isValid();
1332
1462
  this.outboundVisibility = new BehaviorSubject(false);
1333
1463
  this.inboundVisibility = new BehaviorSubject(false);
@@ -1350,6 +1480,7 @@ class CabHireEnterpriseSearch extends BaseEnterpriseSearch {
1350
1480
  }
1351
1481
  set searchType(value) {
1352
1482
  this._searchType = value;
1483
+ this._isValid();
1353
1484
  }
1354
1485
  get airportSearchType() {
1355
1486
  return this._airportSearchType;
@@ -1392,6 +1523,7 @@ class CabHireEnterpriseSearch extends BaseEnterpriseSearch {
1392
1523
  }
1393
1524
  set returnDateTime(value) {
1394
1525
  this._returnDateTime = value;
1526
+ this._isValid();
1395
1527
  }
1396
1528
  get flightNumber() {
1397
1529
  return this._flightNumber;
@@ -1430,6 +1562,14 @@ class CabHireEnterpriseSearch extends BaseEnterpriseSearch {
1430
1562
  this._date = this.helpers.momentToNgDate(value);
1431
1563
  this._time = this.helpers.formatTimeColon(value);
1432
1564
  }
1565
+ this.minReturnSelectDate = {
1566
+ day: moment(value).date(),
1567
+ month: moment(value).month() + 1,
1568
+ year: moment(value).year(),
1569
+ };
1570
+ if (value.isAfter(this.returnDateTime)) {
1571
+ this.returnDateTime.set('date', value.date());
1572
+ }
1433
1573
  this._isValid();
1434
1574
  }
1435
1575
  // get fromLocation(): CabHireLocation {
@@ -1548,12 +1688,19 @@ class CabHireEnterpriseSearch extends BaseEnterpriseSearch {
1548
1688
  }
1549
1689
  resetQuery() {
1550
1690
  this.updateTempParams(this.searchService.makeCabHireQuery());
1691
+ try {
1692
+ this.storageService.removeSessionItem(CabHireEnterpriseSearch.SECONDARY_STORAGE_SESSION_PARAMS);
1693
+ }
1694
+ catch (error) {
1695
+ }
1696
+ this._searchType = this.searchTypes[0]; // reset to one-way
1551
1697
  this._isValid();
1552
1698
  }
1553
1699
  resetParams() {
1554
1700
  this.reset();
1555
1701
  this.resetQuery();
1556
1702
  this.results.next([]);
1703
+ this.multiResults.next([]);
1557
1704
  }
1558
1705
  _isValid() {
1559
1706
  if (!this.doChecks) {
@@ -1575,6 +1722,9 @@ class CabHireEnterpriseSearch extends BaseEnterpriseSearch {
1575
1722
  if (this.tempParams.adults + this.tempParams.children < 1) {
1576
1723
  this.validationMessages.push('There must be at least 1 traveller');
1577
1724
  }
1725
+ if (this.searchType === this.searchTypes[1] && this.returnDateTime.isSameOrBefore(this.departs)) {
1726
+ this.validationMessages.push('Return Date/Time must be after outbound date/time');
1727
+ }
1578
1728
  this.isValid.next(this.validationMessages.length === 0);
1579
1729
  this.messages.next(this.validationMessages);
1580
1730
  }
@@ -1585,10 +1735,26 @@ class CabHireEnterpriseSearch extends BaseEnterpriseSearch {
1585
1735
  }
1586
1736
  startSearch() {
1587
1737
  this.results.next([]);
1738
+ this.multiResults.next([]);
1588
1739
  if (this.isValid.value) {
1589
- const query = this.getSearchQuery();
1590
- this.searchService.saveRecentSearch(this.getRecentSearchQuery(query));
1591
- return this._startSearch(this.cabfetcher.fetchList(this.helpers.removeNulls(query)));
1740
+ if (this.searchType === this.searchTypes[1]) { // return - kick off two searches
1741
+ const query = this.getSearchQuery();
1742
+ const returnQuery = this.getReturnSearchQuery();
1743
+ console.log('+++ Search Query: ', query, ' +++');
1744
+ console.log('+++ Search Return Query: ', returnQuery, ' +++');
1745
+ this.storageService.setSessionItem(CabHireEnterpriseSearch.SECONDARY_STORAGE_SESSION_PARAMS, {
1746
+ tempParams: returnQuery
1747
+ });
1748
+ return this._startMultiSearch([
1749
+ this.cabfetcher.fetchList(this.helpers.removeNulls(query)),
1750
+ this.cabfetcher.fetchList(this.helpers.removeNulls(returnQuery))
1751
+ ]);
1752
+ }
1753
+ else {
1754
+ const query = this.getSearchQuery();
1755
+ this.searchService.saveRecentSearch(this.getRecentSearchQuery(query));
1756
+ return this._startSearch(this.cabfetcher.fetchList(this.helpers.removeNulls(query)));
1757
+ }
1592
1758
  }
1593
1759
  else {
1594
1760
  return Promise.resolve(false);
@@ -1661,6 +1827,19 @@ class CabHireEnterpriseSearch extends BaseEnterpriseSearch {
1661
1827
  };
1662
1828
  return this.helpers.removeNulls(query);
1663
1829
  }
1830
+ getReturnSearchQuery() {
1831
+ const query = {
1832
+ adults: this.tempParams.adults,
1833
+ children: this.tempParams.children,
1834
+ departs: this._returnDateTime,
1835
+ fromLocation: this.createCabHireLocation(this.tempParams.toAddress),
1836
+ toLocation: this.createCabHireLocation(this.tempParams.fromAddress),
1837
+ infants: 0,
1838
+ vehicleType: this.vehicleType,
1839
+ vias: this._vias,
1840
+ };
1841
+ return this.helpers.removeNulls(query);
1842
+ }
1664
1843
  updateOutboundAddress(location, placeDescription) {
1665
1844
  this.tempParams.fromAddress = this.getAddressFormat(location, placeDescription);
1666
1845
  }
@@ -1686,15 +1865,29 @@ class CabHireEnterpriseSearch extends BaseEnterpriseSearch {
1686
1865
  this._fromLocation = this.createCabHireLocation(this.tempParams.fromAddress);
1687
1866
  this._isValid();
1688
1867
  }
1689
- sortBy(asc) {
1690
- let results = this.helpers.clone(this.fullResults);
1691
- if (asc) {
1692
- results = results.sort((a, b) => b.price - a.price);
1868
+ sortBy(asc, returnIndex) {
1869
+ if (returnIndex >= 0) {
1870
+ console.log('here');
1871
+ let results = this.helpers.clone(this.fullMultiResults[returnIndex]);
1872
+ if (asc) {
1873
+ results = results.sort((a, b) => b.price - a.price);
1874
+ }
1875
+ else {
1876
+ results = results.sort((a, b) => a.price - b.price);
1877
+ }
1878
+ this.fullMultiResults[returnIndex] = results;
1879
+ this.multiResults.next(this.fullMultiResults);
1693
1880
  }
1694
1881
  else {
1695
- results = results.sort((a, b) => a.price - b.price);
1882
+ let results = this.helpers.clone(this.fullResults);
1883
+ if (asc) {
1884
+ results = results.sort((a, b) => b.price - a.price);
1885
+ }
1886
+ else {
1887
+ results = results.sort((a, b) => a.price - b.price);
1888
+ }
1889
+ this.results.next(results);
1696
1890
  }
1697
- this.results.next(results);
1698
1891
  }
1699
1892
  // ! stuff to go in a postcode servie
1700
1893
  getAddressFormat(location, placeDescription) {
@@ -1883,7 +2076,9 @@ class CabHireEnterpriseSearch extends BaseEnterpriseSearch {
1883
2076
  }
1884
2077
  }
1885
2078
  CabHireEnterpriseSearch.STORAGE_SESSION_PARAMS = 'search_cab';
1886
- CabHireEnterpriseSearch.STORAGE_SESSION_RESULTS = 'results_cab';
2079
+ CabHireEnterpriseSearch.SECONDARY_STORAGE_SESSION_PARAMS = 'secondary_search_cab';
2080
+ CabHireEnterpriseSearch.STORAGE_SESSION_RESULTS = 'results_cab';
2081
+ CabHireEnterpriseSearch.MULTI_STORAGE_SESSION_RESULTS = 'multi_results_cab';
1887
2082
 
1888
2083
  var SortTypesCar;
1889
2084
  (function (SortTypesCar) {
@@ -2096,6 +2291,7 @@ class CarhireEnterpriseSearch extends BaseEnterpriseSearch {
2096
2291
  this._dropoff_date = null;
2097
2292
  this._dropoff_time = null;
2098
2293
  this.resultsSessionName = CarhireEnterpriseSearch.STORAGE_SESSION_RESULTS;
2294
+ this.multiResultsSessionName = CarhireEnterpriseSearch.STORAGE_SESSION_RESULTS;
2099
2295
  const data = storageService.getSessionItem(CarhireEnterpriseSearch.STORAGE_SESSION_PARAMS) || {
2100
2296
  tempParams: {}
2101
2297
  };
@@ -3109,6 +3305,49 @@ class BaseEventMessenager {
3109
3305
  }
3110
3306
  }
3111
3307
 
3308
+ const DEFAULT_FLIGHT_FILTERS = Object.freeze({
3309
+ stops: {},
3310
+ mustInclude: {},
3311
+ classes: {},
3312
+ airlines: {},
3313
+ travelPolicy: {},
3314
+ depatureAirport: {},
3315
+ depatureReturnAirport: {},
3316
+ arrivalAirport: {},
3317
+ arrivalReturnAirport: {},
3318
+ baggage: {},
3319
+ fareTypes: {},
3320
+ price: {
3321
+ min: Number.MAX_SAFE_INTEGER,
3322
+ max: Number.MIN_SAFE_INTEGER
3323
+ },
3324
+ duration: {
3325
+ min: Number.MAX_SAFE_INTEGER,
3326
+ max: Number.MIN_SAFE_INTEGER
3327
+ },
3328
+ returnDuration: {
3329
+ min: Number.MAX_SAFE_INTEGER,
3330
+ max: Number.MIN_SAFE_INTEGER
3331
+ },
3332
+ departureTime: {
3333
+ min: 0,
3334
+ max: 24
3335
+ },
3336
+ arrivalTime: {
3337
+ min: 0,
3338
+ max: 24
3339
+ },
3340
+ returnDepartureTime: {
3341
+ min: 0,
3342
+ max: 24
3343
+ },
3344
+ returnArrivalTime: {
3345
+ min: 0,
3346
+ max: 24
3347
+ },
3348
+ flightNumber: ''
3349
+ });
3350
+
3112
3351
  var FlightSearchType;
3113
3352
  (function (FlightSearchType) {
3114
3353
  FlightSearchType["return"] = "return";
@@ -3122,23 +3361,28 @@ var TimeWindow;
3122
3361
  TimeWindow["Depart"] = "Depart By";
3123
3362
  TimeWindow["Arrive"] = "Arrive By";
3124
3363
  })(TimeWindow || (TimeWindow = {}));
3125
- var SortTypes;
3126
- (function (SortTypes) {
3127
- SortTypes["CheapestFirst"] = "C";
3128
- SortTypes["MostExpensiveFirst"] = "M";
3129
- SortTypes["FastestFirst"] = "F";
3130
- SortTypes["PreferredFirst"] = "P";
3131
- SortTypes["LowestEmissions"] = "L";
3132
- })(SortTypes || (SortTypes = {}));
3364
+ var FlightSortTypes;
3365
+ (function (FlightSortTypes) {
3366
+ FlightSortTypes["Cheapest"] = "Cheapest";
3367
+ FlightSortTypes["MostExpensive"] = "Most Expensive";
3368
+ FlightSortTypes["Fastest"] = "Fastest";
3369
+ FlightSortTypes["Preferred"] = "Preferred";
3370
+ FlightSortTypes["LowestEmissions"] = "Lowest Emissions";
3371
+ FlightSortTypes["DepartureTime"] = "Departure Time";
3372
+ FlightSortTypes["ArrivalTime"] = "Arrival Time";
3373
+ FlightSortTypes["Quickest"] = "Quickest";
3374
+ FlightSortTypes["MostDirect"] = "Most Direct";
3375
+ })(FlightSortTypes || (FlightSortTypes = {}));
3133
3376
  class FlightEnterpriseSearch extends BaseEnterpriseSearch {
3134
3377
  constructor(flightfetcher, helpers, userService, basketService, storageService, searchService) {
3135
3378
  super(storageService, (results) => {
3136
3379
  this.flightsToGroup = {};
3137
3380
  this.grouped = results.grouped || [];
3138
3381
  this.resultQuery = this.getSearchQuery();
3382
+ this.filters.next(this.helpers.createFlightFilters(results.journeys, DEFAULT_FLIGHT_FILTERS));
3139
3383
  delete this.resultQuery.withGrouped;
3140
3384
  if (results && this.searchService.isFlightsGrouped()) {
3141
- this.groupedObject = (results.multi || [])
3385
+ this.groupedObject = []
3142
3386
  .reduce((previousItems, nextItem) => {
3143
3387
  return previousItems.concat(nextItem.results);
3144
3388
  }, results.journeys)
@@ -3148,11 +3392,12 @@ class FlightEnterpriseSearch extends BaseEnterpriseSearch {
3148
3392
  const returnData = (results.grouped || []).reduce((acc, item, groupNumber) => {
3149
3393
  const isOutBound = item.boundIndicator === FlightDirectionEnum.Outbound;
3150
3394
  const returnObject = {
3395
+ type: 'FlightGroupedQuoteResult',
3151
3396
  direction: item.boundIndicator,
3152
3397
  classes: {
3153
3398
  [FlightCabinClass.EconomyNoBags]: null,
3154
3399
  [FlightCabinClass.EconomyRestricted]: null,
3155
- [FlightCabinClass.Economy]: null,
3400
+ [FlightCabinClass.EconomyFlexi]: null,
3156
3401
  [FlightCabinClass.Business]: null,
3157
3402
  [FlightCabinClass.First]: null,
3158
3403
  [FlightCabinClass.PremiumEconomy]: null
@@ -3175,7 +3420,11 @@ class FlightEnterpriseSearch extends BaseEnterpriseSearch {
3175
3420
  operator: '',
3176
3421
  operatorFull: '',
3177
3422
  inboundFlightNumber: '',
3178
- isReturn: false
3423
+ isReturn: false,
3424
+ minPrice: Number.MAX_SAFE_INTEGER,
3425
+ maxPrice: Number.MAX_SAFE_INTEGER,
3426
+ co2PerItem: 0,
3427
+ co2PerPassenger: 0
3179
3428
  };
3180
3429
  const brands = item.flights;
3181
3430
  Object.keys(brands)
@@ -3190,62 +3439,78 @@ class FlightEnterpriseSearch extends BaseEnterpriseSearch {
3190
3439
  (this.flightsToGroup[flightNum] =
3191
3440
  this.flightsToGroup[flightNum] || []).push(groupNumber);
3192
3441
  const flight = this.groupedObject[flightNum];
3193
- if (isOutBound) {
3194
- this.createGroupedItem(returnObject, flight.source, flight.outboundFlights, flight.outboundTotalDuration, flight.inboundFlights, flight.inboundTotalDuration);
3195
- }
3196
- else {
3197
- this.createGroupedItem(returnObject, flight.source, flight.inboundFlights, flight.inboundTotalDuration, flight.outboundFlights, flight.outboundTotalDuration);
3198
- }
3199
3442
  if (flight) {
3443
+ if (isOutBound) {
3444
+ this.createGroupedItem(returnObject, flight.source, flight.outboundFlights, flight.outboundTotalDuration, flight.inboundFlights, flight.inboundTotalDuration, flight.co2PerItem, flight.co2PerPassenger);
3445
+ }
3446
+ else {
3447
+ this.createGroupedItem(returnObject, flight.source, flight.inboundFlights, flight.inboundTotalDuration, flight.outboundFlights, flight.outboundTotalDuration, flight.co2PerItem, flight.co2PerPassenger);
3448
+ }
3200
3449
  acc1.push(flight);
3201
3450
  }
3451
+ else {
3452
+ // console.error(
3453
+ // 'Unable to find flight with uid ' + flightNum
3454
+ // );
3455
+ }
3202
3456
  return acc1;
3203
3457
  }, []);
3204
- let correctBrand;
3205
- switch (brand) {
3206
- case FlightCabinClass.LiteEconomy:
3207
- case FlightCabinClass.Economy:
3208
- correctBrand = FlightCabinClass.Economy;
3209
- break;
3210
- case FlightCabinClass.EconomyNoBags:
3211
- correctBrand = FlightCabinClass.EconomyNoBags;
3212
- break;
3213
- case FlightCabinClass.EconomyRestricted:
3214
- correctBrand = FlightCabinClass.EconomyRestricted;
3215
- break;
3216
- case FlightCabinClass.PremiumBusiness:
3217
- case FlightCabinClass.Business:
3218
- correctBrand = FlightCabinClass.Business;
3219
- break;
3220
- case FlightCabinClass.PremiumFirst:
3221
- case FlightCabinClass.First:
3222
- correctBrand = FlightCabinClass.First;
3223
- break;
3224
- case FlightCabinClass.PremiumEconomy:
3225
- correctBrand = FlightCabinClass.PremiumEconomy;
3226
- break;
3227
- default:
3228
- console.log('something went wrong');
3229
- break;
3230
- }
3231
- const minprice = this.getMinFlightPriceForBrand(matchingBrandFlights);
3232
- const maxprice = this.getMaxFlightPriceForBrand(matchingBrandFlights);
3233
- if ((_b = (_a = returnObject.classes[correctBrand]) === null || _a === void 0 ? void 0 : _a.flights) === null || _b === void 0 ? void 0 : _b.length) {
3234
- returnObject.classes[correctBrand].flights.concat(matchingBrandFlights);
3235
- returnObject.classes[correctBrand].minprice = Math.min(returnObject.classes[correctBrand].minprice, minprice);
3236
- returnObject.classes[correctBrand].maxprice = Math.max(returnObject.classes[correctBrand].maxprice, maxprice);
3237
- }
3238
- else {
3239
- returnObject.classes[correctBrand] = {
3240
- flights: matchingBrandFlights,
3241
- minprice,
3242
- maxprice,
3243
- currency: matchingBrandFlights[0].total.currency
3244
- };
3458
+ if (matchingBrandFlights.length > 0) {
3459
+ let correctBrand;
3460
+ switch (brand) {
3461
+ case FlightCabinClass.EconomyNoBags:
3462
+ correctBrand = FlightCabinClass.EconomyNoBags;
3463
+ break;
3464
+ case FlightCabinClass.EconomyRestricted:
3465
+ correctBrand = FlightCabinClass.EconomyRestricted;
3466
+ break;
3467
+ case FlightCabinClass.EconomyFlexi:
3468
+ correctBrand = FlightCabinClass.EconomyFlexi;
3469
+ break;
3470
+ case FlightCabinClass.Business:
3471
+ correctBrand = FlightCabinClass.Business;
3472
+ break;
3473
+ case FlightCabinClass.First:
3474
+ correctBrand = FlightCabinClass.First;
3475
+ break;
3476
+ case FlightCabinClass.PremiumEconomy:
3477
+ correctBrand = FlightCabinClass.PremiumEconomy;
3478
+ break;
3479
+ default:
3480
+ console.log('something went wrong');
3481
+ break;
3482
+ }
3483
+ const minprice = this.getMinFlightPriceForBrand(matchingBrandFlights);
3484
+ const maxprice = this.getMaxFlightPriceForBrand(matchingBrandFlights);
3485
+ returnObject.minPrice =
3486
+ returnObject.minPrice < minprice
3487
+ ? returnObject.minPrice
3488
+ : minprice;
3489
+ returnObject.maxPrice =
3490
+ returnObject.maxPrice < maxprice
3491
+ ? returnObject.maxPrice
3492
+ : maxprice;
3493
+ if ((_b = (_a = returnObject.classes[correctBrand]) === null || _a === void 0 ? void 0 : _a.flights) === null || _b === void 0 ? void 0 : _b.length) {
3494
+ returnObject.classes[correctBrand].flights.concat(matchingBrandFlights);
3495
+ returnObject.classes[correctBrand].minprice = Math.min(returnObject.classes[correctBrand].minprice, minprice);
3496
+ returnObject.classes[correctBrand].maxprice = Math.max(returnObject.classes[correctBrand].maxprice, maxprice);
3497
+ }
3498
+ else {
3499
+ returnObject.classes[correctBrand] = {
3500
+ flights: matchingBrandFlights,
3501
+ minprice,
3502
+ maxprice,
3503
+ currency: matchingBrandFlights[0].total.currency
3504
+ };
3505
+ }
3245
3506
  }
3246
3507
  });
3247
- if (returnObject) {
3248
- acc.push(returnObject);
3508
+ if (returnObject &&
3509
+ !!Object.values(returnObject.classes).find((clas) => {
3510
+ var _a;
3511
+ return ((_a = clas === null || clas === void 0 ? void 0 : clas.flights) === null || _a === void 0 ? void 0 : _a.length) > 0;
3512
+ })) {
3513
+ acc[groupNumber] = returnObject;
3249
3514
  }
3250
3515
  return acc;
3251
3516
  }, []);
@@ -3267,12 +3532,139 @@ class FlightEnterpriseSearch extends BaseEnterpriseSearch {
3267
3532
  this._negotiated = false;
3268
3533
  this._nearby_airports = false;
3269
3534
  this._sortArray = [
3270
- { display: 'Cheapest First', value: SortTypes.CheapestFirst },
3271
- { display: 'Most Expensive First', value: SortTypes.MostExpensiveFirst },
3272
- { display: 'Fastest First', value: SortTypes.FastestFirst },
3273
- { display: 'Preferred Fares First', value: SortTypes.PreferredFirst },
3274
- { display: 'Lowest Co2 Emissions First', value: SortTypes.LowestEmissions }
3535
+ { display: 'Cheapest First', value: FlightSortTypes.Cheapest },
3536
+ {
3537
+ display: 'Most Expensive First',
3538
+ value: FlightSortTypes.MostExpensive
3539
+ },
3540
+ { display: 'Fastest First', value: FlightSortTypes.Fastest },
3541
+ { display: 'Preferred Fares First', value: FlightSortTypes.Preferred },
3542
+ {
3543
+ display: 'Lowest Co2 Emissions First',
3544
+ value: FlightSortTypes.LowestEmissions
3545
+ }
3275
3546
  ];
3547
+ this._sortItinaryRoutines = {
3548
+ [FlightSortTypes.Cheapest]: (a, b) => {
3549
+ return a.total.price - b.total.price;
3550
+ },
3551
+ [FlightSortTypes.MostExpensive]: (a, b) => {
3552
+ return b.total.price - a.total.price;
3553
+ },
3554
+ [FlightSortTypes.Fastest]: (a, b) => {
3555
+ return (a.outboundTotalDuration +
3556
+ (a.inboundTotalDuration ? a.inboundTotalDuration : 0) -
3557
+ (b.outboundTotalDuration +
3558
+ (b.inboundTotalDuration ? b.inboundTotalDuration : 0)));
3559
+ },
3560
+ [FlightSortTypes.Preferred]: (a, b) => {
3561
+ return (a.tmcPreferred ? 1 : 0) - (b.tmcPreferred ? 1 : 0);
3562
+ },
3563
+ [FlightSortTypes.LowestEmissions]: (a, b) => {
3564
+ return a.co2PerItem - b.co2PerItem;
3565
+ },
3566
+ [FlightSortTypes.DepartureTime]: (a, b) => {
3567
+ const aTime = moment(a.outboundFlights[0].dateTimeDeparting);
3568
+ const bTime = moment(b.outboundFlights[0].dateTimeDeparting);
3569
+ if (aTime.isBefore(bTime)) {
3570
+ return -1;
3571
+ }
3572
+ return aTime.isSame(bTime) ? 0 : 1;
3573
+ },
3574
+ [FlightSortTypes.ArrivalTime]: (a, b) => {
3575
+ const aTime = moment(a.outboundFlights[0].dateTimeArriving);
3576
+ const bTime = moment(b.outboundFlights[0].dateTimeArriving);
3577
+ if (aTime.isBefore(bTime)) {
3578
+ return -1;
3579
+ }
3580
+ return aTime.isSame(bTime) ? 0 : 1;
3581
+ },
3582
+ [FlightSortTypes.Quickest]: (a, b) => {
3583
+ return (a.outboundTotalDuration +
3584
+ (a.inboundTotalDuration ? a.inboundTotalDuration : 0) -
3585
+ (b.outboundTotalDuration +
3586
+ (b.inboundTotalDuration ? b.inboundTotalDuration : 0)));
3587
+ },
3588
+ [FlightSortTypes.MostDirect]: (a, b) => {
3589
+ return (a.outboundFlights.length +
3590
+ (a.outboundFlights ? a.outboundFlights.length : 0) -
3591
+ (b.outboundFlights.length +
3592
+ (b.outboundFlights ? b.outboundFlights.length : 0)));
3593
+ }
3594
+ };
3595
+ this._sortGroupedRoutines = {
3596
+ [FlightSortTypes.Cheapest]: (a, b) => {
3597
+ if (a.direction !== b.direction) {
3598
+ return a.direction - b.direction;
3599
+ }
3600
+ return a.minPrice - b.minPrice;
3601
+ },
3602
+ [FlightSortTypes.MostExpensive]: (a, b) => {
3603
+ if (a.direction !== b.direction) {
3604
+ return a.direction - b.direction;
3605
+ }
3606
+ return b.minPrice - a.maxPrice;
3607
+ },
3608
+ [FlightSortTypes.Fastest]: (a, b) => {
3609
+ if (a.direction !== b.direction) {
3610
+ return a.direction - b.direction;
3611
+ }
3612
+ return a.direction === FlightDirectionEnum.Outbound
3613
+ ? a.outboundTotalDuration - b.outboundTotalDuration
3614
+ : a.inboundTotalDuration - b.inboundTotalDuration;
3615
+ },
3616
+ [FlightSortTypes.Preferred]: (a, b) => {
3617
+ if (a.direction !== b.direction) {
3618
+ return a.direction - b.direction;
3619
+ }
3620
+ return (a.preferred ? 1 : 0) - (b.preferred ? 1 : 0);
3621
+ },
3622
+ [FlightSortTypes.LowestEmissions]: (a, b) => {
3623
+ if (a.direction !== b.direction) {
3624
+ return a.direction - b.direction;
3625
+ }
3626
+ return a.co2PerItem - b.co2PerItem;
3627
+ },
3628
+ [FlightSortTypes.DepartureTime]: (a, b) => {
3629
+ if (a.direction !== b.direction) {
3630
+ return a.direction - b.direction;
3631
+ }
3632
+ const aTime = moment(a.departDateTime);
3633
+ const bTime = moment(b.departDateTime);
3634
+ if (aTime.isBefore(bTime)) {
3635
+ return -1;
3636
+ }
3637
+ return aTime.isSame(bTime) ? 0 : 1;
3638
+ },
3639
+ [FlightSortTypes.ArrivalTime]: (a, b) => {
3640
+ if (a.direction !== b.direction) {
3641
+ return a.direction - b.direction;
3642
+ }
3643
+ const aTime = moment(a.arrivalDateTime);
3644
+ const bTime = moment(b.arrivalDateTime);
3645
+ if (aTime.isBefore(bTime)) {
3646
+ return -1;
3647
+ }
3648
+ return aTime.isSame(bTime) ? 0 : 1;
3649
+ },
3650
+ [FlightSortTypes.Quickest]: (a, b) => {
3651
+ if (a.direction !== b.direction) {
3652
+ return a.direction - b.direction;
3653
+ }
3654
+ return a.direction === FlightDirectionEnum.Outbound
3655
+ ? a.outboundTotalDuration - b.outboundTotalDuration
3656
+ : (a.inboundTotalDuration ? a.inboundTotalDuration : 0) -
3657
+ (b.inboundTotalDuration ? b.inboundTotalDuration : 0);
3658
+ },
3659
+ [FlightSortTypes.MostDirect]: (a, b) => {
3660
+ if (a.direction !== b.direction) {
3661
+ return a.direction - b.direction;
3662
+ }
3663
+ return a.direction === FlightDirectionEnum.Outbound
3664
+ ? a.outlegs.length - b.outlegs.length
3665
+ : (a.inlegs || []).length - (b.inlegs || []).length;
3666
+ }
3667
+ };
3276
3668
  this._fareTypeArray = [
3277
3669
  { value: FareType.Flexible, display: 'Flexible' },
3278
3670
  { value: FareType.Leisure, display: 'Leisure' },
@@ -3296,8 +3688,10 @@ class FlightEnterpriseSearch extends BaseEnterpriseSearch {
3296
3688
  this.grouped = null;
3297
3689
  this.travellers = null;
3298
3690
  this.resultsSessionName = FlightEnterpriseSearch.STORAGE_SESSION_RESULTS;
3691
+ this.multiResultsSessionName = FlightEnterpriseSearch.STORAGE_SESSION_RESULTS;
3299
3692
  this._showHotelForm = false;
3300
3693
  this._hotelSearchRequested = false;
3694
+ this.filters = new BehaviorSubject(DEFAULT_FLIGHT_FILTERS);
3301
3695
  this._multiDestination = [];
3302
3696
  const data = storageService.getSessionItem(FlightEnterpriseSearch.STORAGE_SESSION_PARAMS) || {
3303
3697
  tempParams: {},
@@ -3329,22 +3723,28 @@ class FlightEnterpriseSearch extends BaseEnterpriseSearch {
3329
3723
  this.updateAvaliableClasses();
3330
3724
  });
3331
3725
  this.updateTravellers();
3332
- if (this.isValid.value) {
3333
- const results = storageService.getSessionItem(this.resultsSessionName) || {
3334
- results: [],
3335
- groupData: {},
3336
- grouped: [],
3337
- query: {}
3338
- };
3339
- this.fullResults = this.helpers.clone(results.results);
3340
- this.flightsToGroup = results.groupData || {};
3341
- this.resultQuery = results.query;
3342
- // if (results == null && this.isValid) {
3343
- // searchService.startSearches();
3344
- // }
3345
- // this._cheapestResultPrice = this.updateLowestPrice(results);
3346
- this.results.next(results.results || []);
3347
- }
3726
+ // Removing results from storage, as the results are nearly always too big to be stored.
3727
+ // if (this.isValid.value) {
3728
+ // const results: FlightSessionType = storageService.getSessionItem(
3729
+ // this.resultsSessionName
3730
+ // ) || {
3731
+ // results: [],
3732
+ // groupData: {},
3733
+ // grouped: [],
3734
+ // query: {} as SearchFlightsV2QueryVariables
3735
+ // };
3736
+ // this.fullResults = this.helpers.clone(results.results);
3737
+ // this.flightsToGroup = results.groupData || {};
3738
+ // this.resultQuery = results.query;
3739
+ // // if (results == null && this.isValid) {
3740
+ // // searchService.startSearches();
3741
+ // // }
3742
+ // const isFlightsGrouped = this.searchService.isFlightsGrouped();
3743
+ // if (!isFlightsGrouped) {
3744
+ // this._cheapestResultPrice = this.updateLowestPrice(results.results);
3745
+ // }
3746
+ // this.results.next(results.results || ([] as FlightQuoteResultArray));
3747
+ // }
3348
3748
  this.negotiated =
3349
3749
  this.tempParams.fareType === FareType.Negotiated ? true : false;
3350
3750
  }
@@ -3615,7 +4015,7 @@ class FlightEnterpriseSearch extends BaseEnterpriseSearch {
3615
4015
  set includeNearbyAirports(value) {
3616
4016
  this.tempParams.includeNearbyAirports = value;
3617
4017
  }
3618
- createGroupedItem(returnObject, source, outboundFlights, outboundTotalDuration, inboundFlights, inboundTotalDuration) {
4018
+ createGroupedItem(returnObject, source, outboundFlights, outboundTotalDuration, inboundFlights, inboundTotalDuration, co2PerItem, co2PerPassenger) {
3619
4019
  if ((outboundFlights === null || outboundFlights === void 0 ? void 0 : outboundFlights.length) && !returnObject.departDateTime) {
3620
4020
  const first = outboundFlights[0];
3621
4021
  const last = outboundFlights[outboundFlights.length - 1];
@@ -3634,6 +4034,8 @@ class FlightEnterpriseSearch extends BaseEnterpriseSearch {
3634
4034
  returnObject.outboundFlightNumber =
3635
4035
  this.helpers.joinFromAttribute('-', 'marketingFlightNumber', outboundFlights);
3636
4036
  returnObject.isReturn = false;
4037
+ returnObject.co2PerItem = co2PerItem;
4038
+ returnObject.co2PerPassenger = co2PerPassenger;
3637
4039
  }
3638
4040
  if ((inboundFlights === null || inboundFlights === void 0 ? void 0 : inboundFlights.length) && !returnObject.inboundTotalDuration) {
3639
4041
  returnObject.inboundTotalDuration = inboundTotalDuration;
@@ -3830,7 +4232,7 @@ class FlightEnterpriseSearch extends BaseEnterpriseSearch {
3830
4232
  countryCode: (_m = (_l = arriveLocation.iataMatch) === null || _l === void 0 ? void 0 : _l.locationDetails) === null || _m === void 0 ? void 0 : _m.countryCode
3831
4233
  };
3832
4234
  if (recentSearch.searchArgs.preferredCarriers) {
3833
- let preferredCarriers = [];
4235
+ const preferredCarriers = [];
3834
4236
  recentSearch.searchArgs.preferredCarriers.map((preferredCarry) => {
3835
4237
  this.searchService
3836
4238
  .getAirlinesList(preferredCarry)
@@ -3867,7 +4269,7 @@ class FlightEnterpriseSearch extends BaseEnterpriseSearch {
3867
4269
  convertRecentSearchDateTime(date, timeWindow) {
3868
4270
  if (timeWindow) {
3869
4271
  const flightTime = timeWindow.split('-');
3870
- let timeAndDate = moment(date).add(moment.duration(this.helpers.hhmmToTime(flightTime[0])));
4272
+ const timeAndDate = moment(date).add(moment.duration(this.helpers.hhmmToTime(flightTime[0])));
3871
4273
  // add 2 hour
3872
4274
  return timeAndDate.clone().add(2, 'hour');
3873
4275
  }
@@ -3938,43 +4340,6 @@ class FlightEnterpriseSearch extends BaseEnterpriseSearch {
3938
4340
  { name: 'First', type: FlightCabinClass.First }
3939
4341
  ]);
3940
4342
  }
3941
- /**
3942
- * @description - sort the flight results
3943
- * @todo - Fill out Preferred and Co2 sorting when we have that data
3944
- */
3945
- sortResults(sortMethodValue, givenResults) {
3946
- let results = this.helpers.clone(givenResults
3947
- ? givenResults
3948
- : this.fullResults);
3949
- switch (sortMethodValue) {
3950
- case SortTypes.CheapestFirst:
3951
- results = results.sort((a, b) => {
3952
- return a.total.price - b.total.price;
3953
- });
3954
- break;
3955
- case SortTypes.MostExpensiveFirst:
3956
- results = results.sort((a, b) => {
3957
- return b.total.price - a.total.price;
3958
- });
3959
- break;
3960
- case SortTypes.FastestFirst:
3961
- results = results.sort((a, b) => {
3962
- return (a.outboundTotalDuration +
3963
- (a.inboundTotalDuration ? a.inboundTotalDuration : 0) -
3964
- (b.outboundTotalDuration +
3965
- (b.inboundTotalDuration ? b.inboundTotalDuration : 0)));
3966
- });
3967
- break;
3968
- case SortTypes.LowestEmissions:
3969
- results = results.sort((a, b) => {
3970
- return a.co2PerItem - b.co2PerItem;
3971
- });
3972
- break;
3973
- default:
3974
- console.error(`+++ Unknown sorting method: ${sortMethodValue} +++`);
3975
- }
3976
- return results;
3977
- }
3978
4343
  updateFromPreviousSearches(previousItems) {
3979
4344
  // Flights can not be search after other products so no defaults can be set.
3980
4345
  }
@@ -4000,613 +4365,210 @@ class FlightEnterpriseSearch extends BaseEnterpriseSearch {
4000
4365
  }
4001
4366
  return total;
4002
4367
  }
4368
+ isGroupedFlights(toTest) {
4369
+ var _a;
4370
+ return ((_a = toTest[0]) === null || _a === void 0 ? void 0 : _a.type) === 'FlightGroupedQuoteResult';
4371
+ }
4003
4372
  /**
4004
4373
  * @description - filter the results, then sort the remainder
4005
4374
  * @todo - Add filters for travel policy, fare types and ancilliaries
4006
4375
  */
4007
- filterResults(filters, sortValue, givenResults) {
4008
- console.log('+++ Applying Filters to flights: ', filters, ' +++');
4009
- let results = this.helpers.clone(givenResults);
4010
- if (this.isReturn) {
4011
- results = results.filter((result) => result.inboundFlights && result.inboundFlights.length);
4012
- }
4013
- // Add In Filters Here
4014
- // filter stops
4015
- results = this.filterResultsByStops(filters.stops, results);
4016
- results = this.filterResultsByAirline(filters.airlines, results);
4017
- results = this.filterResultsByClass(filters.classes, results);
4018
- results = this.filterByDepartureAirport(filters.depatureAirport, results);
4019
- results = this.filterByDepartureReturnAirport(filters.depatureReturnAirport, results);
4020
- results = this.filterByArrivalAirport(filters.arrivalAirport, results);
4021
- results = this.filterByArrivalReturnAirport(filters.arrivalReturnAirport, results);
4022
- results = this.filterByPrice(filters.minPrice, filters.maxPrice, results);
4023
- results = this.filterByFlightNumber(filters.flightNumber, results);
4024
- results = this.filterByBaggage(filters.baggage, results);
4025
- results = this.filterByDepartureTime(filters.minDepartureTime, filters.maxDepartureTime, results);
4026
- results = this.filterByReturnDepartureTime(filters.minReturnDepartureTime, filters.maxReturnDepartureTime, results);
4027
- results = this.filterByArrivalTime(filters.minArrivalTime, filters.maxArrivalTime, results);
4028
- results = this.filterByReturnArrivalTime(filters.minReturnArrivalTime, filters.maxReturnArrivalTime, results);
4029
- results = this.filterByDuration(filters.minDuration, filters.maxDuration, results);
4030
- results = this.filterByDuration(filters.minReturnDuration, filters.maxReturnDuration, results, true); // return duration
4031
- results = this.sortResults(sortValue, results);
4032
- return results;
4033
- }
4034
- /**
4035
- * @description - give the correct format for transfering minuetes on the sliders
4036
- * @param min - the min in 100th's to transform onto 60th's
4037
- */
4038
- transformMin(min) {
4039
- let num = (Number(min) * 60) / 100;
4040
- // console.log('+++ Num Copy: ', _.clone(num), ' +++');
4041
- if (num % 1 < 0.5) {
4042
- num = Math.floor(num);
4043
- }
4044
- else {
4045
- num = Math.ceil(num);
4046
- }
4047
- return num.toString().padStart(2, '0');
4048
- }
4049
- filterByDuration(minDuration, maxDuration, results, isReturn = false) {
4050
- results = results.filter((result) => {
4051
- var _a;
4052
- let dur = 0;
4053
- if (!isReturn) {
4054
- result.outboundFlights.forEach((out) => {
4055
- dur += out.totalDuration;
4056
- });
4376
+ applyFilters(filters, sortValue) {
4377
+ // console.log('+++ Applying Filters to flights: ', filters, ' +++');
4378
+ if (this.fullResults.length === 0) {
4379
+ this.results.next([]);
4380
+ }
4381
+ const tester = (filtersTotest, testFunction) => {
4382
+ const selected = Object.values(filtersTotest).filter((filter) => filter.selected);
4383
+ if (selected.length) {
4384
+ return (flightItinerary) => {
4385
+ return !!selected.find((filter) => {
4386
+ return testFunction(flightItinerary, filter.value);
4387
+ });
4388
+ };
4057
4389
  }
4058
- if (((_a = result.inboundFlights) === null || _a === void 0 ? void 0 : _a.length) && isReturn) {
4059
- result.inboundFlights.forEach((inb) => {
4060
- dur += inb.totalDuration;
4061
- });
4390
+ else {
4391
+ return (flightItinerary) => {
4392
+ return true;
4393
+ };
4062
4394
  }
4063
- return dur >= minDuration && dur <= maxDuration;
4064
- });
4065
- return results;
4066
- }
4067
- filterByDepartureTime(minDep, maxDep, results) {
4068
- results = results.filter((result) => {
4069
- const departureTime = Number(moment(result.outboundFlights[0].dateTimeDeparting).format('HHmm'));
4070
- const newNumString1 = Number(Math.floor(Number(minDep / 100)).toString() +
4071
- this.transformMin(Math.ceil(Number(minDep % 100))));
4072
- const newNumString2 = Number(Math.floor(Number(maxDep / 100)).toString() +
4073
- this.transformMin(Math.ceil(Number(maxDep % 100))));
4074
- return departureTime >= newNumString1 && departureTime <= newNumString2;
4075
- });
4076
- return results;
4077
- }
4078
- filterByReturnDepartureTime(minDep, maxDep, results) {
4079
- if (!minDep && !maxDep) {
4080
- return results;
4081
- }
4082
- const newNumString1 = Number(Math.floor(Number(minDep / 100)).toString() +
4083
- this.transformMin(Math.ceil(Number(minDep % 100))));
4084
- const newNumString2 = Number(Math.floor(Number(maxDep / 100)).toString() +
4085
- this.transformMin(Math.ceil(Number(maxDep % 100))));
4086
- results = results.filter((result) => {
4087
- if (!result.inboundFlights || !result.inboundFlights[0]) {
4088
- return true;
4089
- }
4090
- const departureTime = Number(moment(result.inboundFlights[0].dateTimeDeparting).format('HHmm'));
4091
- return departureTime >= newNumString1 && departureTime <= newNumString2;
4092
- });
4093
- return results;
4094
- }
4095
- filterByReturnArrivalTime(minArr, maxArr, results) {
4096
- if (!minArr && !maxArr) {
4097
- return results;
4098
- }
4099
- const newNumString1 = Number(Math.floor(Number(minArr / 100)).toString() +
4100
- this.transformMin(Math.ceil(Number(minArr % 100))));
4101
- const newNumString2 = Number(Math.floor(Number(maxArr / 100)).toString() +
4102
- this.transformMin(Math.ceil(Number(maxArr % 100))));
4103
- results = results.filter((result) => {
4104
- if (!result.inboundFlights || !result.inboundFlights[0]) {
4105
- return true;
4106
- }
4107
- const arrivalTime = Number(moment(result.inboundFlights[result.inboundFlights.length - 1]
4108
- .dateTimeArriving).format('HHmm'));
4109
- const retVal = arrivalTime >= newNumString1 && arrivalTime <= newNumString2;
4110
- // for debugging
4111
- // if (!retVal) {
4112
- // console.warn(`+++ Filtering Out: ${arrivalTime} +++`);
4113
- // }
4114
- return retVal;
4115
- });
4116
- return results;
4117
- }
4118
- filterByArrivalTime(minArr, maxArr, results) {
4119
- const newNumString1 = Number(Math.floor(Number(minArr / 100)).toString() +
4120
- this.transformMin(Math.ceil(Number(minArr % 100))));
4121
- const newNumString2 = Number(Math.floor(Number(maxArr / 100)).toString() +
4122
- this.transformMin(Math.ceil(Number(maxArr % 100))));
4123
- results = results.filter((result) => {
4124
- const arrivalTime = Number(moment(result.outboundFlights[result.outboundFlights.length - 1]
4125
- .dateTimeArriving).format('HHmm'));
4126
- return arrivalTime >= newNumString1 && arrivalTime <= newNumString2;
4127
- });
4128
- return results;
4129
- }
4130
- filterByBaggage(baggageFilters, results) {
4131
- const selected = baggageFilters.filter((x) => x.selected);
4132
- if ((selected === null || selected === void 0 ? void 0 : selected.length) >= 1 && selected.length !== baggageFilters.length) {
4133
- results = results.filter((result) => {
4134
- try {
4135
- const totalBags = this.getTotalBaggage(result);
4136
- return selected.find((x) => x.value === totalBags);
4137
- }
4138
- catch (error) {
4139
- console.error('+++ Error determening baggage: ${error} +++');
4140
- return false;
4141
- }
4142
- });
4143
- }
4144
- return results;
4145
- }
4146
- filterByPrice(minPrice, maxPrice, results) {
4147
- results = results.filter((result) => {
4148
- // console.log(`+++ Price: ${result.total.price} is between: ${minPrice} and ${maxPrice}: ${result.total.price >= minPrice && result.total.price <= maxPrice} +++`)
4149
- return result.total.price >= minPrice && result.total.price <= maxPrice;
4150
- });
4151
- return results;
4152
- }
4153
- /**
4154
- * @description - filter the results by the number of stops
4155
- * @param stopFilters - the selected stops
4156
- * @param fullResults - all of our results so far
4157
- */
4158
- filterResultsByStops(stopFilters, fullResults) {
4159
- const selected = stopFilters.filter((x) => x.selected);
4160
- if ((selected === null || selected === void 0 ? void 0 : selected.length) >= 1 && selected.length !== stopFilters.length) {
4161
- fullResults = fullResults.filter((result) => {
4162
- const totalStops = result.outboundFlights.length - 1;
4163
- const haveStop = selected.find((selected1) => selected1.value === totalStops);
4164
- return haveStop;
4165
- });
4166
- }
4167
- return fullResults;
4168
- }
4169
- filterResultsByAirline(airlineFilters, results) {
4170
- const selected = airlineFilters.filter((x) => x.selected);
4171
- if ((selected === null || selected === void 0 ? void 0 : selected.length) >= 1 && selected.length !== airlineFilters.length) {
4172
- results = results.filter((result) => {
4173
- return selected.find((x) => x.value === result.outboundFlights[0].operatingCarrier);
4174
- });
4175
- }
4176
- return results;
4177
- }
4178
- filterResultsByClass(classFilters, results) {
4179
- const selected = classFilters.filter((x) => x.selected);
4180
- if ((selected === null || selected === void 0 ? void 0 : selected.length) >= 1 && selected.length !== classFilters.length) {
4181
- results = results.filter((result) => {
4182
- return selected.find((x) => x.value === result.outboundFlights[0].cabinClass);
4183
- });
4184
- }
4185
- return results;
4186
- }
4187
- filterByDepartureAirport(departureAirports, results) {
4188
- const selected = departureAirports.filter((x) => x.selected);
4189
- if ((selected === null || selected === void 0 ? void 0 : selected.length) >= 1 && selected.length !== departureAirports.length) {
4190
- results = results.filter((result) => {
4191
- return selected.find((x) => x.value === result.outboundFlights[0].originAirport);
4192
- });
4193
- }
4194
- return results;
4195
- }
4196
- filterByArrivalAirport(arrivalAirports, results) {
4197
- const selected = arrivalAirports.filter((x) => x.selected);
4198
- if ((selected === null || selected === void 0 ? void 0 : selected.length) >= 1 && selected.length !== arrivalAirports.length) {
4199
- results = results.filter((result) => {
4200
- const destinationAirport = result.outboundFlights[result.outboundFlights.length - 1]
4201
- .destinationAirport;
4202
- return selected.find((x) => x.value === destinationAirport);
4203
- });
4204
- }
4205
- return results;
4206
- }
4207
- filterByDepartureReturnAirport(departureAirports, results) {
4208
- const selected = departureAirports.filter((x) => x.selected);
4209
- if ((selected === null || selected === void 0 ? void 0 : selected.length) >= 1 && selected.length !== departureAirports.length) {
4210
- results = results.filter((result) => {
4211
- var _a;
4212
- if (!((_a = result.inboundFlights) === null || _a === void 0 ? void 0 : _a.length)) {
4213
- return true;
4214
- }
4215
- return selected.find((x) => x.value === result.inboundFlights[0].originAirport);
4216
- });
4217
- }
4218
- return results;
4219
- }
4220
- filterByArrivalReturnAirport(arrivalAirports, results) {
4221
- const selected = arrivalAirports.filter((x) => x.selected);
4222
- if ((selected === null || selected === void 0 ? void 0 : selected.length) >= 1 && selected.length !== arrivalAirports.length) {
4223
- results = results.filter((result) => {
4224
- var _a;
4225
- if (!((_a = result.inboundFlights) === null || _a === void 0 ? void 0 : _a.length)) {
4226
- return true;
4227
- }
4228
- const destinationAirport = result.inboundFlights[result.inboundFlights.length - 1]
4229
- .destinationAirport;
4230
- return selected.find((x) => x.value === destinationAirport);
4231
- });
4232
- }
4233
- return results;
4234
- }
4235
- filterByFlightNumber(flightNumber, results) {
4236
- if (flightNumber) {
4237
- // make sure to check both outbound and inbound
4238
- results = results.filter((result) => {
4239
- var _a;
4240
- const inOutbound = result.outboundFlights.find((out) => {
4241
- return out.operatingFlightNumber
4242
- .toUpperCase()
4243
- .includes(flightNumber.toUpperCase());
4244
- });
4245
- let inInbound;
4246
- if ((_a = result.inboundFlights) === null || _a === void 0 ? void 0 : _a.length) {
4247
- inInbound = result.inboundFlights.find((inB) => {
4248
- return inB.operatingFlightNumber
4249
- .toUpperCase()
4250
- .includes(flightNumber.toUpperCase());
4251
- });
4252
- }
4253
- return inOutbound || inInbound;
4254
- });
4255
- }
4256
- return results;
4257
- }
4258
- createFilters(results = []) {
4259
- const minPrice = this.getMinPrice(results);
4260
- const maxPrice = this.getMaxPrice(results);
4261
- const newFilters = {
4262
- stops: this.getAllStops(results),
4263
- mustInclude: [],
4264
- classes: this.getAllClasses(results),
4265
- airlines: this.getAllAirlines(results),
4266
- travelPolicy: [],
4267
- depatureAirport: this.getAllDepartureAirports(results),
4268
- arrivalAirport: this.getAllArrivalAirports(results),
4269
- minPrice,
4270
- maxPrice,
4271
- depatureReturnAirport: this.getAllDepartureAirports(results, true),
4272
- arrivalReturnAirport: this.getAllArrivalAirports(results, true),
4273
- baggage: this.getBaggage(results),
4274
- fareTypes: [],
4275
- minDuration: this.getMinDuration(results),
4276
- maxDuration: this.getMaxDuration(results),
4277
- minReturnDuration: this.getMinDuration(results, true),
4278
- maxReturnDuration: this.getMaxDuration(results, true),
4279
- minDepartureTime: this.getMinDepartureTime(results),
4280
- maxDepartureTime: this.getMaxDepartureTime(results),
4281
- minArrivalTime: this.getMinArrivalTime(results),
4282
- maxArrivalTime: this.getMaxArrivalTime(results),
4283
- minReturnDepartureTime: this.getMinReturnDepartureTime(results),
4284
- maxReturnDepartureTime: this.getMaxReturnDepartureTime(results),
4285
- maxReturnArrivalTime: this.getMaxReturnArrivalTime(results),
4286
- minReturnArrivalTime: this.getMinReturnArrivalTime(results),
4287
- flightNumber: ''
4288
4395
  };
4289
- return newFilters;
4290
- }
4291
- getMinDuration(results, isReturn = false) {
4292
- let min = 0;
4293
- results.forEach((result) => {
4396
+ const replaceFields = (field, flightItinerary) => {
4397
+ return field
4398
+ .replace('OUTBOUND_DEPARTURE', 'outboundFlights.0')
4399
+ .replace('OUTBOUND_ARRIVAL', 'outboundFlights.' + (flightItinerary.outboundFlights.length - 1))
4400
+ .replace('INBOUND_DEPARTURE', 'inboundFlights.0')
4401
+ .replace('INBOUND_ARRIVAL', 'inboundFlights.' +
4402
+ ((flightItinerary.inboundFlights || []).length - 1));
4403
+ };
4404
+ const isBetween = (minmax, field) => {
4405
+ return (flightItinerary) => {
4406
+ const val = this.helpers.fromObject(flightItinerary, ...replaceFields(field, flightItinerary).split('.'));
4407
+ return val >= minmax.min && val <= minmax.max;
4408
+ };
4409
+ };
4410
+ const isHourBetween = (minmax, field) => {
4411
+ return (flightItinerary) => {
4412
+ const val = moment(this.helpers.fromObject(flightItinerary, ...replaceFields(field, flightItinerary).split('.'))).get('hour');
4413
+ return val >= minmax.min && val <= minmax.max;
4414
+ };
4415
+ };
4416
+ const hasValue = (field) => {
4417
+ return (flightItinerary, toTest) => {
4418
+ const val = this.helpers.fromObject(flightItinerary, ...replaceFields(field, flightItinerary).split('.'));
4419
+ return val === toTest;
4420
+ };
4421
+ };
4422
+ const fieldHasValue = (field) => {
4423
+ return (flight, value) => {
4424
+ return flight[field] === value;
4425
+ };
4426
+ };
4427
+ const outItineraryTesters = [];
4428
+ const inItineraryTesters = [];
4429
+ outItineraryTesters.push(isHourBetween(filters.arrivalTime, 'OUTBOUND_ARRIVAL.dateTimeArriving'));
4430
+ outItineraryTesters.push(isHourBetween(filters.departureTime, 'OUTBOUND_ARRIVAL.dateTimeDeparting'));
4431
+ outItineraryTesters.push(isBetween(filters.duration, 'outboundTotalDuration'));
4432
+ outItineraryTesters.push(isBetween(filters.price, 'total.price'));
4433
+ outItineraryTesters.push(tester(filters.stops, (flightItinerary, value) => {
4434
+ return (flightItinerary.outboundFlights.length === value ||
4435
+ (flightItinerary.inboundFlights || []).length === value);
4436
+ }));
4437
+ outItineraryTesters.push(isHourBetween(filters.arrivalTime, 'OUTBOUND_ARRIVAL.dateTimeArriving'));
4438
+ outItineraryTesters.push(tester(filters.depatureAirport, (flightItinerary, value) => {
4294
4439
  var _a;
4295
- let dur = 0;
4296
- if (!isReturn) {
4297
- result.outboundFlights.forEach((out) => {
4298
- dur += out.totalDuration;
4299
- });
4300
- }
4301
- if (((_a = result.inboundFlights) === null || _a === void 0 ? void 0 : _a.length) && isReturn) {
4302
- result.inboundFlights.forEach((inb) => {
4303
- dur += inb.totalDuration;
4304
- });
4305
- }
4306
- if (!min || dur < min) {
4307
- min = dur;
4308
- }
4309
- });
4310
- return min;
4311
- }
4312
- getMaxDuration(results, isReturn = false) {
4313
- let max = 0;
4314
- results.forEach((result) => {
4440
+ return ((_a = flightItinerary.outboundFlights[0]) === null || _a === void 0 ? void 0 : _a.originAirport) === value;
4441
+ }));
4442
+ outItineraryTesters.push(tester(filters.arrivalAirport, (flightItinerary, value) => {
4315
4443
  var _a;
4316
- let dur = 0;
4317
- if (!isReturn) {
4318
- result.outboundFlights.forEach((out) => {
4319
- dur += out.totalDuration;
4320
- });
4321
- }
4322
- if (((_a = result.inboundFlights) === null || _a === void 0 ? void 0 : _a.length) && isReturn) {
4323
- result.inboundFlights.forEach((inb) => {
4324
- dur += inb.totalDuration;
4325
- });
4326
- }
4327
- if (!max || dur > max) {
4328
- max = dur;
4329
- }
4330
- });
4331
- return max;
4332
- }
4333
- getMinArrivalTime(results) {
4334
- let min;
4335
- results.forEach((result) => {
4336
- let minDepTime = Number(moment(result.outboundFlights[result.outboundFlights.length - 1]
4337
- .dateTimeArriving).format('HHmm'));
4338
- minDepTime = Math.floor(minDepTime / 100) * 100;
4339
- if (!min || minDepTime < min) {
4340
- min = minDepTime;
4341
- }
4342
- });
4343
- return min;
4344
- }
4345
- getMinReturnArrivalTime(results) {
4346
- let min;
4347
- results.forEach((result) => {
4348
- if (result.inboundFlights && result.inboundFlights.length) {
4349
- let minDepTime = Number(moment(result.inboundFlights[result.inboundFlights.length - 1]
4350
- .dateTimeArriving).format('HHmm'));
4351
- minDepTime = Math.floor(minDepTime / 100) * 100;
4352
- if (!min || minDepTime < min) {
4353
- min = minDepTime;
4354
- }
4355
- }
4356
- });
4357
- return min;
4358
- }
4359
- getMaxReturnArrivalTime(results) {
4360
- let max;
4361
- results.forEach((result) => {
4362
- if (result.inboundFlights && result.inboundFlights.length) {
4363
- let maxDepTime = Number(moment(result.inboundFlights[result.inboundFlights.length - 1]
4364
- .dateTimeArriving).format('HHmm'));
4365
- maxDepTime = Math.ceil(maxDepTime / 100) * 100;
4366
- if (!max || maxDepTime > max) {
4367
- max = maxDepTime;
4444
+ return (((_a = flightItinerary.outboundFlights[flightItinerary.outboundFlights.length - 1]) === null || _a === void 0 ? void 0 : _a.destinationAirport) === value);
4445
+ }));
4446
+ inItineraryTesters.push(isBetween(filters.duration, 'outboundTotalDuration'));
4447
+ inItineraryTesters.push(isBetween(filters.price, 'total.price'));
4448
+ inItineraryTesters.push(isHourBetween(filters.arrivalTime, 'INBOUND_ARRIVAL.dateTimeArriving'));
4449
+ inItineraryTesters.push(isHourBetween(filters.departureTime, 'INBOUND_ARRIVAL.dateTimeDeparting'));
4450
+ inItineraryTesters.push(isBetween(filters.returnDuration, 'inboundTotalDuration'));
4451
+ inItineraryTesters.push(tester(filters.stops, (flightItinerary, value) => {
4452
+ return (flightItinerary.outboundFlights.length === value ||
4453
+ (flightItinerary.inboundFlights || []).length === value);
4454
+ }));
4455
+ inItineraryTesters.push(isHourBetween(filters.arrivalTime, 'INBOUND_ARRIVAL.dateTimeArriving'));
4456
+ inItineraryTesters.push(tester(filters.depatureReturnAirport, (flightItinerary, value) => {
4457
+ var _a;
4458
+ return ((_a = flightItinerary.inboundFlights[0]) === null || _a === void 0 ? void 0 : _a.originAirport) === value;
4459
+ }));
4460
+ inItineraryTesters.push(tester(filters.arrivalReturnAirport, (flightItinerary, value) => {
4461
+ var _a;
4462
+ return (((_a = flightItinerary.inboundFlights[flightItinerary.inboundFlights.length - 1]) === null || _a === void 0 ? void 0 : _a.destinationAirport) === value);
4463
+ }));
4464
+ const outJourneyTesters = [];
4465
+ outJourneyTesters.push(tester(filters.classes, fieldHasValue('cabinClass')));
4466
+ outJourneyTesters.push(tester(filters.airlines, fieldHasValue('marketingCarrier')));
4467
+ const inJourneyTesters = [];
4468
+ inJourneyTesters.push(tester(filters.classes, fieldHasValue('cabinClass')));
4469
+ inJourneyTesters.push(tester(filters.airlines, fieldHasValue('marketingCarrier')));
4470
+ const outFilterItineraries = (flightItinerary) => {
4471
+ return (outItineraryTesters.reduce((acc, tester1) => {
4472
+ acc = acc && tester1(flightItinerary);
4473
+ return acc;
4474
+ }, true) &&
4475
+ (!flightItinerary.outboundFlights ||
4476
+ !!(flightItinerary.outboundFlights || []).find((flightJourney) => {
4477
+ return !!outJourneyTesters.reduce((acc, tester2) => {
4478
+ return acc && tester2(flightJourney);
4479
+ }, true);
4480
+ })));
4481
+ };
4482
+ const inFilterItineraries = (flightItinerary) => {
4483
+ return (inItineraryTesters.reduce((acc, tester1) => {
4484
+ return acc && tester1(flightItinerary);
4485
+ }, true) &&
4486
+ (!flightItinerary.inboundFlights ||
4487
+ !!(flightItinerary.inboundFlights || []).find((flightJourney) => {
4488
+ return !!inJourneyTesters.reduce((acc, tester2) => {
4489
+ return acc && tester2(flightJourney);
4490
+ }, true);
4491
+ })));
4492
+ };
4493
+ if (this.isGroupedFlights(this.fullResults)) {
4494
+ this.results.next(this.helpers
4495
+ .clone(this.fullResults)
4496
+ .filter((result) => {
4497
+ return !!result;
4498
+ })
4499
+ .map((result) => {
4500
+ var _a, _b, _c, _d, _e, _f;
4501
+ const filterItineraries = result.direction === FlightDirectionEnum.Outbound
4502
+ ? outFilterItineraries
4503
+ : inFilterItineraries;
4504
+ if (result.classes.EconomyNoBags) {
4505
+ result.classes.EconomyNoBags.flights = (((_a = result.classes.EconomyNoBags) === null || _a === void 0 ? void 0 : _a.flights) || [])
4506
+ .filter((flightItinerary) => !!flightItinerary)
4507
+ .filter(filterItineraries);
4368
4508
  }
4369
- }
4370
- });
4371
- return max;
4372
- }
4373
- getMaxArrivalTime(results) {
4374
- let max;
4375
- results.forEach((result) => {
4376
- let maxDepTime = Number(moment(result.outboundFlights[result.outboundFlights.length - 1]
4377
- .dateTimeArriving).format('HHmm'));
4378
- maxDepTime = Math.ceil(maxDepTime / 100) * 100;
4379
- if (!max || maxDepTime > max) {
4380
- max = maxDepTime;
4381
- }
4382
- });
4383
- return max;
4384
- }
4385
- getMinDepartureTime(results) {
4386
- let min;
4387
- results.forEach((result) => {
4388
- let minDepTime = Number(moment(result.outboundFlights[0].dateTimeDeparting).format('HHmm'));
4389
- minDepTime = Math.floor(minDepTime / 100) * 100;
4390
- if (!min || minDepTime < min) {
4391
- min = minDepTime;
4392
- }
4393
- });
4394
- return min;
4395
- }
4396
- getMinReturnDepartureTime(results) {
4397
- let min;
4398
- results.forEach((result) => {
4399
- if (result.inboundFlights && result.inboundFlights[0]) {
4400
- let minDepTime = Number(moment(result.inboundFlights[0].dateTimeDeparting).format('HHmm'));
4401
- minDepTime = Math.floor(minDepTime / 100) * 100;
4402
- if (!min || minDepTime < min) {
4403
- min = minDepTime;
4509
+ if (result.classes.EconomyRestricted) {
4510
+ result.classes.EconomyRestricted.flights = (((_b = result.classes.EconomyRestricted) === null || _b === void 0 ? void 0 : _b.flights) || [])
4511
+ .filter((flightItinerary) => !!flightItinerary)
4512
+ .filter(filterItineraries);
4404
4513
  }
4405
- }
4406
- });
4407
- return min;
4408
- }
4409
- getMaxReturnDepartureTime(results) {
4410
- let max;
4411
- results.forEach((result) => {
4412
- if (result.inboundFlights && result.inboundFlights[0]) {
4413
- let maxDepTime = Number(moment(result.inboundFlights[0].dateTimeDeparting).format('HHmm'));
4414
- maxDepTime = Math.ceil(maxDepTime / 100) * 100;
4415
- if (!max || maxDepTime > max) {
4416
- max = maxDepTime;
4514
+ if (result.classes.EconomyFlexi) {
4515
+ result.classes.EconomyFlexi.flights = (((_c = result.classes.EconomyFlexi) === null || _c === void 0 ? void 0 : _c.flights) || [])
4516
+ .filter((flightItinerary) => !!flightItinerary)
4517
+ .filter(filterItineraries);
4417
4518
  }
4418
- }
4419
- });
4420
- return max;
4421
- }
4422
- getMaxDepartureTime(results) {
4423
- let max;
4424
- results.forEach((result) => {
4425
- let maxDepTime = Number(moment(result.outboundFlights[0].dateTimeDeparting).format('HHmm'));
4426
- maxDepTime = Math.ceil(maxDepTime / 100) * 100;
4427
- if (!max || maxDepTime > max) {
4428
- max = maxDepTime;
4429
- }
4430
- });
4431
- return max;
4432
- }
4433
- getBaggage(results) {
4434
- const baggage = {};
4435
- results.forEach((result) => {
4436
- var _a, _b, _c, _d, _e, _f;
4437
- try {
4438
- if (result.baggageAllowance.length) {
4439
- let total = +((_a = result.baggageAllowance[0]) === null || _a === void 0 ? void 0 : _a.qty);
4440
- if (result.inboundFlights.length) {
4441
- // ! assuming second item is inbound if the airlines are different, steven said he would sort this out
4442
- if (result.baggageAllowance[1] &&
4443
- +result.baggageAllowance[1].qty > total) {
4444
- total = +((_b = result.baggageAllowance[1]) === null || _b === void 0 ? void 0 : _b.qty);
4445
- }
4446
- else if (+((_c = result.baggageAllowance[0]) === null || _c === void 0 ? void 0 : _c.qty) > total) {
4447
- total = +((_d = result.baggageAllowance[0]) === null || _d === void 0 ? void 0 : _d.qty);
4448
- }
4449
- }
4450
- if (+((_e = result.baggageAllowance[0]) === null || _e === void 0 ? void 0 : _e.qty) > total) {
4451
- total = +((_f = result.baggageAllowance[0]) === null || _f === void 0 ? void 0 : _f.qty);
4452
- }
4453
- baggage[total] = {
4454
- selected: false,
4455
- value: total,
4456
- display: `${total} bag${total !== 1 ? 's' : ''}`
4457
- };
4519
+ if (result.classes.PremiumEconomy) {
4520
+ result.classes.PremiumEconomy.flights = (((_d = result.classes.PremiumEconomy) === null || _d === void 0 ? void 0 : _d.flights) || [])
4521
+ .filter((flightItinerary) => !!flightItinerary)
4522
+ .filter(filterItineraries);
4458
4523
  }
4459
- }
4460
- catch (error) {
4461
- console.error(`+++ Error parsing additional flight data: ${error} +++`);
4462
- }
4463
- });
4464
- return Object.values(baggage);
4465
- }
4466
- getMinPrice(results) {
4467
- let minPrice;
4468
- results.forEach((result) => {
4469
- if (!minPrice || result.total.price < minPrice) {
4470
- minPrice = result.total.price;
4471
- }
4472
- });
4473
- return minPrice;
4474
- }
4475
- getMaxPrice(results) {
4476
- let maxPrice;
4477
- results.forEach((result) => {
4478
- if (!maxPrice || result.total.price > maxPrice) {
4479
- maxPrice = result.total.price;
4480
- }
4481
- });
4482
- return maxPrice;
4483
- }
4484
- getAllStops(results) {
4485
- const allStops = {};
4486
- results.forEach((result) => {
4487
- const totalStops = result.outboundFlights.length - 1; // might have to recalculate this
4488
- allStops[totalStops] = {
4489
- value: totalStops,
4490
- display: `${totalStops} stop` + (totalStops !== 1 ? 's' : ''),
4491
- selected: false
4492
- };
4493
- });
4494
- return Object.values(allStops);
4495
- }
4496
- getAllClasses(results) {
4497
- const allClasses = [];
4498
- results.forEach((result) => {
4499
- result.outboundFlights.forEach((outFlight) => {
4500
- allClasses[outFlight.cabinClass] = {
4501
- value: outFlight.cabinClass,
4502
- display: outFlight.cabinClass,
4503
- selected: false
4504
- };
4505
- });
4506
- if (result.inboundFlights) {
4507
- result.inboundFlights.forEach((inFlight) => {
4508
- allClasses[inFlight.cabinClass] = {
4509
- value: inFlight.cabinClass,
4510
- display: inFlight.cabinClass,
4511
- selected: false
4512
- };
4513
- });
4514
- }
4515
- });
4516
- return Object.values(allClasses);
4517
- }
4518
- /**
4519
- * @description - create select filters for all unique departure airports returned in the search
4520
- * @param results - the flight results
4521
- */
4522
- getAllDepartureAirports(results, inbound = false) {
4523
- const allAirports = {};
4524
- results.forEach((result) => {
4525
- var _a;
4526
- if (result.outboundFlights.length && !inbound) {
4527
- allAirports[result.outboundFlights[0].originAirport] = {
4528
- value: result.outboundFlights[0].originAirport,
4529
- display: result.outboundFlights[0].originAirportName,
4530
- selected: false
4531
- };
4532
- }
4533
- if (((_a = result.inboundFlights) === null || _a === void 0 ? void 0 : _a.length) && inbound) {
4534
- allAirports[result.inboundFlights[0].originAirport] = {
4535
- value: result.inboundFlights[0].originAirport,
4536
- display: result.inboundFlights[0].originAirportName,
4537
- selected: false
4538
- };
4539
- }
4540
- });
4541
- return Object.values(allAirports);
4542
- }
4543
- /**
4544
- * @description - create select filters for all unique departure airports returned in the search
4545
- * @param results - the flight results
4546
- */
4547
- getAllArrivalAirports(results, inbound = false) {
4548
- const allAirports = {};
4549
- results.forEach((result) => {
4550
- var _a;
4551
- if (result.outboundFlights.length && !inbound) {
4552
- allAirports[result.outboundFlights[result.outboundFlights.length - 1].destinationAirport] = {
4553
- value: result.outboundFlights[result.outboundFlights.length - 1]
4554
- .destinationAirport,
4555
- display: result.outboundFlights[result.outboundFlights.length - 1]
4556
- .destinationAirportName,
4557
- selected: false
4558
- };
4559
- }
4560
- if (((_a = result.inboundFlights) === null || _a === void 0 ? void 0 : _a.length) && inbound) {
4561
- allAirports[result.inboundFlights[result.inboundFlights.length - 1].destinationAirport] = {
4562
- value: result.inboundFlights[result.inboundFlights.length - 1]
4563
- .destinationAirport,
4564
- display: result.inboundFlights[result.inboundFlights.length - 1]
4565
- .destinationAirportName,
4566
- selected: false
4567
- };
4568
- }
4569
- });
4570
- return Object.values(allAirports);
4571
- }
4572
- /**
4573
- * @description - create select filters for all unique airlines returned in the search
4574
- * @param results - the flight results
4575
- */
4576
- getAllAirlines(results) {
4577
- const allAirlines = {};
4578
- results.forEach((result) => {
4579
- result.outboundFlights.forEach((outFlight) => {
4580
- allAirlines[outFlight.operatingCarrier] = {
4581
- value: outFlight.operatingCarrier,
4582
- display: outFlight.operatingCarrierName,
4583
- selected: false
4584
- };
4585
- });
4586
- if (result.inboundFlights) {
4587
- result.inboundFlights.forEach((inFlight) => {
4588
- allAirlines[inFlight.operatingCarrier] = {
4589
- value: inFlight.operatingCarrier,
4590
- display: inFlight.operatingCarrierName,
4591
- selected: false
4592
- };
4593
- });
4594
- }
4595
- });
4596
- return Object.values(allAirlines);
4524
+ if (result.classes.Business) {
4525
+ result.classes.Business.flights = (((_e = result.classes.Business) === null || _e === void 0 ? void 0 : _e.flights) || [])
4526
+ .filter((flightItinerary) => !!flightItinerary)
4527
+ .filter(filterItineraries);
4528
+ }
4529
+ if (result.classes.First) {
4530
+ result.classes.First.flights = (((_f = result.classes.First) === null || _f === void 0 ? void 0 : _f.flights) || [])
4531
+ .filter((flightItinerary) => !!flightItinerary)
4532
+ .filter(filterItineraries);
4533
+ }
4534
+ return result;
4535
+ })
4536
+ .filter((result) => {
4537
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
4538
+ return ((((_b = (_a = result.classes) === null || _a === void 0 ? void 0 : _a.EconomyNoBags) === null || _b === void 0 ? void 0 : _b.flights.length) || 0) +
4539
+ (((_d = (_c = result.classes) === null || _c === void 0 ? void 0 : _c.EconomyRestricted) === null || _d === void 0 ? void 0 : _d.flights.length) || 0) +
4540
+ (((_f = (_e = result.classes) === null || _e === void 0 ? void 0 : _e.EconomyFlexi) === null || _f === void 0 ? void 0 : _f.flights.length) || 0) +
4541
+ (((_h = (_g = result.classes) === null || _g === void 0 ? void 0 : _g.PremiumEconomy) === null || _h === void 0 ? void 0 : _h.flights.length) || 0) +
4542
+ (((_k = (_j = result.classes) === null || _j === void 0 ? void 0 : _j.Business) === null || _k === void 0 ? void 0 : _k.flights.length) || 0) +
4543
+ (((_m = (_l = result.classes) === null || _l === void 0 ? void 0 : _l.First) === null || _m === void 0 ? void 0 : _m.flights.length) || 0) >
4544
+ 0);
4545
+ })
4546
+ .sort(this._sortGroupedRoutines[sortValue]));
4547
+ }
4548
+ else {
4549
+ this.results.next(Object.freeze(this.helpers
4550
+ .clone(this.fullResults)
4551
+ .map((result) => {
4552
+ // return {
4553
+ // type: 'FlightAllQuoteResult',
4554
+ // journeys: result.journeys.filter(filterItineraries)
4555
+ // };
4556
+ return result;
4557
+ })));
4558
+ }
4597
4559
  }
4598
4560
  updateLowestPrice(results) {
4599
- return null;
4600
- // add in once filght result is updated///
4601
- // const results = this.storageService.getSessionItemAsList<FlightQuoteResultArray>(this.resultsSessionName) || [] as FlightQuoteResultArray;
4602
- // if(!results.length) return;
4603
- // this._cheapestResultPrice.currencyCode = results[0].total.currency;
4604
- // results.map(result => {
4605
- // const price = result.total.price;
4606
- // if( this._cheapestResultPrice.amount > price || this._cheapestResultPrice.amount === null){
4607
- // this._cheapestResultPrice.amount = price;
4608
- // }
4609
- // })
4561
+ if (!results.length || this.searchService.isFlightsGrouped()) {
4562
+ return;
4563
+ }
4564
+ const journeys = results[0].journeys;
4565
+ const currency = journeys[0].total.currency;
4566
+ return journeys.reduce((cheapestPrice, result) => {
4567
+ const price = result.total.price;
4568
+ if (cheapestPrice.amount > price)
4569
+ cheapestPrice.amount = price;
4570
+ return cheapestPrice;
4571
+ }, { amount: Number.MAX_SAFE_INTEGER, currencyCode: currency });
4610
4572
  }
4611
4573
  selectGroupedFlight(selectedFlight, direction) {
4612
4574
  return __awaiter(this, void 0, void 0, function* () {
@@ -4698,7 +4660,9 @@ class FlightEnterpriseSearch extends BaseEnterpriseSearch {
4698
4660
  operatingCarrier: selectedFlight.operatingCarrier,
4699
4661
  operatingFlightNumber: selectedFlight.operatingFlightNumber,
4700
4662
  originAirport: selectedFlight.originAirport,
4701
- totalDuration: selectedFlight.totalDuration
4663
+ totalDuration: selectedFlight.totalDuration,
4664
+ originTerminal: selectedFlight.originTerminal,
4665
+ destinationTerminal: selectedFlight.destinationTerminal
4702
4666
  };
4703
4667
  }
4704
4668
  addFlightJourneysToBasket(flightQuote) {
@@ -5443,22 +5407,42 @@ class BaseHelperRoutines {
5443
5407
  };
5444
5408
  }
5445
5409
  removeNulls(query) {
5446
- return Object.keys(query).reduce((accum, key) => {
5447
- const value = query[key];
5448
- const data = Array.isArray(value)
5449
- ? value.filter((item) => !!item) || null
5450
- : value;
5451
- if ((data !== null && data !== undefined && data !== 'null') ||
5452
- (Array.isArray(data) && data.length > 0)) {
5453
- accum[key] = data;
5454
- }
5455
- return accum;
5456
- }, {});
5410
+ if (!query) {
5411
+ return query;
5412
+ }
5413
+ if (moment.isMoment(query)) {
5414
+ return query;
5415
+ }
5416
+ else if (Array.isArray(query)) {
5417
+ return (query
5418
+ .map((item) => {
5419
+ return this.removeNulls(item);
5420
+ })
5421
+ .filter((item1) => {
5422
+ return !!item1;
5423
+ }) || null);
5424
+ }
5425
+ else if (typeof query === 'object') {
5426
+ return Object.keys(query).reduce((accum, key) => {
5427
+ const value = query[key];
5428
+ const data = this.removeNulls(value);
5429
+ if ((data !== null && data !== undefined && data !== 'null') ||
5430
+ (Array.isArray(data) && data.length > 0)) {
5431
+ accum[key] = data;
5432
+ }
5433
+ return accum;
5434
+ }, {});
5435
+ }
5436
+ else {
5437
+ return query;
5438
+ }
5457
5439
  }
5458
5440
  getTravellersId(travellers) {
5459
5441
  if (travellers) {
5460
5442
  return travellers.reduce((previousValue, currentValue, idx) => {
5461
- return idx === 0 ? [currentValue.id] : [...previousValue, currentValue.id];
5443
+ return idx === 0
5444
+ ? [currentValue.id]
5445
+ : [...previousValue, currentValue.id];
5462
5446
  }, []);
5463
5447
  }
5464
5448
  }
@@ -5657,7 +5641,6 @@ class BaseHelperRoutines {
5657
5641
  * @desc - generates ics file body content based on the provided basketItems param
5658
5642
  */
5659
5643
  generateIcsFileBodyContent(basketItems) {
5660
- // TODO: currently only basket items with ServiceType.Lounge are handled. See below to TODOs for remaining tasks
5661
5644
  const bodyContent = [];
5662
5645
  // generate calendar data for each basket item
5663
5646
  basketItems.map((basketItem, index) => {
@@ -5671,11 +5654,12 @@ class BaseHelperRoutines {
5671
5654
  serviceType: '',
5672
5655
  summary: ''
5673
5656
  };
5657
+ const dateFormat = 'DD MMMM YYYY HH:mm';
5674
5658
  const { type } = basketItem.service;
5659
+ const { adults, children, bookingThirdPartyReference, detail, service } = basketItem;
5675
5660
  // populate data object depending on the service type in the basket
5676
5661
  switch (type) {
5677
5662
  case ServiceType.Lounge:
5678
- const { adults, children, bookingThirdPartyReference, detail, service } = basketItem;
5679
5663
  data.basketId = basketItem.id;
5680
5664
  data.dStart = detail === null || detail === void 0 ? void 0 : detail.arrivalDatetime;
5681
5665
  data.dEnd = '';
@@ -5683,31 +5667,113 @@ class BaseHelperRoutines {
5683
5667
  data.serviceType = service.type.toLowerCase();
5684
5668
  data.description = [
5685
5669
  `Lounge: ${detail.name}\r\n`,
5686
- `Starts: ${detail.arrivalDatetime}\r\n`,
5670
+ `Starts: ${moment(detail.arrivalDatetime).format(dateFormat)}\r\n`,
5687
5671
  `Adults: ${adults}\r\n`,
5688
5672
  `Children: ${children}\r\n`,
5689
5673
  `Booking Ref: ${bookingThirdPartyReference}`
5690
5674
  ].join('');
5691
5675
  break;
5692
- case ServiceType.Cab:
5693
- // TODO: handle this case
5694
- // hint: see logic in icalendar.component.ts file on lighting current version
5695
- case ServiceType.Car:
5696
- // TODO: handle this case
5676
+ case ServiceType.Cab:
5677
+ data.basketId = basketItem.id;
5678
+ data.serviceType = service.type.toLowerCase();
5679
+ data.dStart = detail === null || detail === void 0 ? void 0 : detail.departs;
5680
+ data.dEnd = '';
5681
+ data.summary = `Taxi booking - from ${detail.fromLocation.address} to ${detail.toLocation.address}`;
5682
+ data.description = [
5683
+ `Pickup Point: ${detail.fromLocation.address}\r\n`,
5684
+ `Time: ${moment(detail.departs).format(dateFormat)}\r\n`,
5685
+ `Booking Ref: ${bookingThirdPartyReference}`
5686
+ ].join('');
5687
+ break;
5688
+ case ServiceType.Car:
5689
+ data.basketId = basketItem.id;
5690
+ data.serviceType = service.type.toLowerCase();
5691
+ data.dStart = detail === null || detail === void 0 ? void 0 : detail.pickUpDatetime;
5692
+ data.dEnd = detail === null || detail === void 0 ? void 0 : detail.dropOffDatetime;
5693
+ data.summary = `Car booking - from ${detail.pickUpLocation.address} to ${detail.dropOffLocation.address}`;
5694
+ data.description = [
5695
+ `Pickup Point: ${detail.pickUpLocation.address}\r\n`,
5696
+ `Time: ${moment(detail.pickUpDatetime).format(dateFormat)}\r\n`,
5697
+ `Arrival Point: ${detail.dropOffLocation.address}\r\n`,
5698
+ `Booking Ref: ${bookingThirdPartyReference}`
5699
+ ].join('');
5700
+ (data.locationFrom = detail.pickUpLocation.address),
5701
+ (data.locationTo = detail.dropOffLocation.address);
5702
+ break;
5697
5703
  case ServiceType.Coach:
5698
5704
  // TODO: handle this case
5699
5705
  case ServiceType.FastTrack:
5700
5706
  // TODO: handle this case
5701
5707
  case ServiceType.Flight:
5702
- // TODO: handle this case
5708
+ data.basketId = basketItem.id;
5709
+ data.serviceType = service.type.toLowerCase();
5710
+ data.dStart = detail === null || detail === void 0 ? void 0 : detail.outboundFlights[0].dateTimeDeparting;
5711
+ data.dEnd = detail === null || detail === void 0 ? void 0 : detail.outboundFlights[0].dateTimeArriving;
5712
+ data.summary = `Flight Booking - From ${detail.outboundFlights[0].originAirport} to ${detail.outboundFlights[0].destinationAirport}`;
5713
+ data.description = [
5714
+ `From: ${detail.outboundFlights[0].originAirport}\r\n`,
5715
+ `Depart: ${moment(detail.outboundFlights[0].dateTimeDeparting).format(dateFormat)}\r\n`,
5716
+ `To: ${detail.outboundFlights[0].destinationAirport}\r\n`,
5717
+ `Arrive: ${moment(detail.outboundFlights[0].dateTimeArriving).format(dateFormat)}\r\n`,
5718
+ `Booking Ref: ${bookingThirdPartyReference}`
5719
+ ].join('');
5720
+ break;
5703
5721
  case ServiceType.Hotel:
5704
- // TODO: handle this case
5722
+ data.basketId = basketItem.id;
5723
+ data.serviceType = service.type.toLowerCase();
5724
+ data.dStart = detail === null || detail === void 0 ? void 0 : detail.checkIn;
5725
+ data.dEnd = detail === null || detail === void 0 ? void 0 : detail.checkOut;
5726
+ data.summary = `Hotel booking - ${detail.hotelName}`;
5727
+ data.description = [
5728
+ `Hotel: ${detail.hotelName}\r\n`,
5729
+ `Arrival: ${moment(detail.checkIn).format(dateFormat)}\r\n`,
5730
+ `Departure: ${moment(detail.checkOut).format(dateFormat)}\r\n`,
5731
+ `Booking Ref: ${bookingThirdPartyReference}`
5732
+ ].join('');
5733
+ break;
5705
5734
  case ServiceType.InternationalRail:
5706
- // TODO: handle this case
5735
+ data.basketId = basketItem.id;
5736
+ data.serviceType = service.type.toLowerCase();
5737
+ data.dStart = detail === null || detail === void 0 ? void 0 : detail.outwardDetail.departureDateTime;
5738
+ data.dEnd = detail === null || detail === void 0 ? void 0 : detail.outwardDetail.arrivalDateTime;
5739
+ data.locationFrom = detail.outwardDetail.departureStationName;
5740
+ data.locationTo = detail.outwardDetail.arrivalDateTime;
5741
+ data.summary = `Train Booking - From ${detail.outwardDetail.departureStationName} to ${detail.outwardDetail.arrivalStationName}`;
5742
+ data.description = [
5743
+ `From ${detail.outwardDetail.departureStationName}\r\n`,
5744
+ `To ${detail.outwardDetail.arrivalStationName}\r\n`,
5745
+ `Departure ${moment(detail.outwardDetail.departureDateTime).format(dateFormat)}\r\n`,
5746
+ `Arrival ${moment(detail.outwardDetail.arrivalDateTime).format(dateFormat)}\r\n`,
5747
+ `Booking Ref: ${bookingThirdPartyReference}`
5748
+ ].join('');
5749
+ break;
5707
5750
  case ServiceType.Parking:
5708
- // TODO: handle this case
5751
+ data.basketId = basketItem.id;
5752
+ data.serviceType = service.type.toLowerCase();
5753
+ data.dStart = detail === null || detail === void 0 ? void 0 : detail.arrivalDatetime;
5754
+ data.dEnd = detail === null || detail === void 0 ? void 0 : detail.departDatetime;
5755
+ data.summary = `Airport parking - ${detail.name}`;
5756
+ data.description = [
5757
+ `Airport Parking: ${detail.name}\r\n`,
5758
+ `Booking Ref: ${bookingThirdPartyReference}`
5759
+ ].join('');
5760
+ break;
5709
5761
  case ServiceType.Rail:
5710
- // TODO: handle this case
5762
+ data.basketId = basketItem.id;
5763
+ data.serviceType = service.type.toLowerCase();
5764
+ data.dStart = detail === null || detail === void 0 ? void 0 : detail.outwardDetail.departureDateTime;
5765
+ data.dEnd = detail === null || detail === void 0 ? void 0 : detail.outwardDetail.arrivalDateTime;
5766
+ data.locationFrom = detail.outwardDetail.departureStationName;
5767
+ data.locationTo = detail.outwardDetail.arrivalDateTime;
5768
+ data.summary = `Train Booking - From ${detail.outwardDetail.departureStationName} to ${detail.outwardDetail.arrivalStationName}`;
5769
+ data.description = [
5770
+ `From ${detail.outwardDetail.departureStationName}\r\n`,
5771
+ `To ${detail.outwardDetail.arrivalStationName}\r\n`,
5772
+ `Departure ${moment(detail.outwardDetail.departureDateTime).format(dateFormat)}\r\n`,
5773
+ `Arrival ${moment(detail.outwardDetail.arrivalDateTime).format(dateFormat)}\r\n`,
5774
+ `Booking Ref: ${bookingThirdPartyReference}`
5775
+ ].join('');
5776
+ break;
5711
5777
  }
5712
5778
  bodyContent.push([
5713
5779
  'BEGIN:VEVENT\r\n',
@@ -5756,6 +5822,119 @@ class BaseHelperRoutines {
5756
5822
  }
5757
5823
  return splitString;
5758
5824
  }
5825
+ createFlightFilters(journeys, defaultFilters) {
5826
+ return journeys.reduce((filters, result1) => {
5827
+ const totalStops = result1.outboundFlights.length - 1;
5828
+ filters.stops[totalStops] = filters.stops[totalStops] || {
5829
+ display: `${totalStops} stop` + (totalStops !== 1 ? 's' : ''),
5830
+ selected: false,
5831
+ value: totalStops + 1
5832
+ };
5833
+ const updateFlightItems = (flight) => {
5834
+ filters.classes[flight.cabinClass] = filters.classes[flight.cabinClass] || {
5835
+ display: flight.cabinClass,
5836
+ selected: false,
5837
+ value: flight.cabinClass
5838
+ };
5839
+ filters.airlines[flight.marketingCarrier] = filters.airlines[flight.marketingCarrier] || {
5840
+ display: flight.marketingCarrierName,
5841
+ selected: false,
5842
+ value: flight.marketingCarrier
5843
+ };
5844
+ };
5845
+ result1.outboundFlights.forEach(updateFlightItems);
5846
+ const baggage = Math.min(...result1.baggageAllowance.map((baggageAllowance) => baggageAllowance.qty));
5847
+ filters.baggage[baggage] = filters.baggage[baggage] || {
5848
+ selected: false,
5849
+ display: `${baggage} bag${baggage !== 1 ? 's' : ''}`,
5850
+ value: baggage
5851
+ };
5852
+ const indexedFlight = (flights, filterAttribute, flightAttribute, flightAttributeName, index) => {
5853
+ const temp = flights[index][flightAttribute];
5854
+ filters[filterAttribute][temp] = filters[filterAttribute][temp] || {
5855
+ value: flights[index][flightAttribute],
5856
+ display: flights[index][flightAttributeName],
5857
+ selected: false
5858
+ };
5859
+ };
5860
+ indexedFlight(result1.outboundFlights, 'depatureAirport', 'originAirport', 'originAirportName', 0);
5861
+ indexedFlight(result1.outboundFlights, 'arrivalAirport', 'destinationAirport', 'destinationAirportName', result1.outboundFlights.length - 1);
5862
+ filters.price.min =
5863
+ filters.price.min < result1.total.price
5864
+ ? filters.price.min
5865
+ : result1.total.price;
5866
+ filters.price.max =
5867
+ filters.price.max > result1.total.price
5868
+ ? filters.price.max
5869
+ : result1.total.price;
5870
+ filters.duration.min =
5871
+ filters.duration.min < result1.outboundTotalDuration
5872
+ ? filters.duration.min
5873
+ : result1.outboundTotalDuration;
5874
+ filters.duration.max =
5875
+ filters.duration.max > result1.outboundTotalDuration
5876
+ ? filters.duration.max
5877
+ : result1.outboundTotalDuration;
5878
+ const departTime = moment(result1.outboundFlights[0].dateTimeDeparting).get('hour');
5879
+ filters.departureTime.min =
5880
+ filters.departureTime.min < departTime
5881
+ ? filters.departureTime.min
5882
+ : departTime;
5883
+ filters.departureTime.max =
5884
+ filters.departureTime.max > departTime
5885
+ ? filters.departureTime.max
5886
+ : departTime;
5887
+ const arrivalTime = moment(result1.outboundFlights[result1.outboundFlights.length - 1]
5888
+ .dateTimeArriving).get('hour');
5889
+ filters.arrivalTime.min =
5890
+ filters.arrivalTime.min < arrivalTime
5891
+ ? filters.arrivalTime.min
5892
+ : arrivalTime;
5893
+ filters.arrivalTime.max =
5894
+ filters.arrivalTime.max > arrivalTime
5895
+ ? filters.arrivalTime.max
5896
+ : arrivalTime;
5897
+ if (result1.inboundFlights && result1.outboundFlights.length > 0) {
5898
+ filters.returnDuration.min =
5899
+ filters.returnDuration.min < result1.inboundTotalDuration
5900
+ ? filters.returnDuration.min
5901
+ : result1.inboundTotalDuration;
5902
+ filters.returnDuration.max =
5903
+ filters.returnDuration.max > result1.inboundTotalDuration
5904
+ ? filters.returnDuration.max
5905
+ : result1.inboundTotalDuration;
5906
+ const departTimeReturn = moment(result1.inboundFlights[0].dateTimeDeparting).get('hour');
5907
+ filters.returnDepartureTime.min =
5908
+ filters.returnDepartureTime.min < departTimeReturn
5909
+ ? filters.returnDepartureTime.min
5910
+ : departTimeReturn;
5911
+ filters.returnDepartureTime.max =
5912
+ filters.returnDepartureTime.max > departTimeReturn
5913
+ ? filters.returnDepartureTime.max
5914
+ : departTimeReturn;
5915
+ const arrivalTimeReturn = moment(result1.outboundFlights[result1.outboundFlights.length - 1]
5916
+ .dateTimeArriving).get('hour');
5917
+ filters.returnArrivalTime.min =
5918
+ filters.returnArrivalTime.min < arrivalTimeReturn
5919
+ ? filters.returnArrivalTime.min
5920
+ : arrivalTimeReturn;
5921
+ filters.returnArrivalTime.max =
5922
+ filters.returnArrivalTime.max > arrivalTimeReturn
5923
+ ? filters.returnArrivalTime.max
5924
+ : arrivalTimeReturn;
5925
+ (result1.inboundFlights || []).forEach(updateFlightItems);
5926
+ indexedFlight(result1.inboundFlights, 'depatureReturnAirport', 'originAirport', 'originAirportName', 0);
5927
+ indexedFlight(result1.inboundFlights, 'arrivalReturnAirport', 'destinationAirport', 'destinationAirportName', result1.outboundFlights.length - 1);
5928
+ }
5929
+ return filters;
5930
+ }, this.clone(defaultFilters));
5931
+ }
5932
+ mapOverObject(items, callback) {
5933
+ return Object.entries(items).reduce((accum, entries) => {
5934
+ accum[entries[0]] = callback(entries[1], entries[0]);
5935
+ return accum;
5936
+ }, {});
5937
+ }
5759
5938
  }
5760
5939
  BaseHelperRoutines.READ_DATE_FORMAT = 'dd, D MMM YYYY';
5761
5940
  BaseHelperRoutines.READ_TIME_FORMAT = 'HH:mm';
@@ -5900,6 +6079,7 @@ class HotelEnterpriseSearch extends BaseEnterpriseSearch {
5900
6079
  this._distance_list = [1, 2, 5, 10, 20, 25]; // copied from old frontend for now
5901
6080
  this._default_currency = null;
5902
6081
  this.resultsSessionName = HotelEnterpriseSearch.STORAGE_SESSION_RESULTS;
6082
+ this.multiResultsSessionName = HotelEnterpriseSearch.STORAGE_SESSION_RESULTS;
5903
6083
  this.query = {};
5904
6084
  this.filterResults = () => {
5905
6085
  this.results.next(this.fullResults.filter((hotel) => {
@@ -6189,7 +6369,7 @@ class HotelEnterpriseSearch extends BaseEnterpriseSearch {
6189
6369
  this._isValid();
6190
6370
  }
6191
6371
  _isValid() {
6192
- var _a, _b, _c, _d, _e;
6372
+ var _a, _b, _c, _d, _e, _f;
6193
6373
  if (!this.doChecks) {
6194
6374
  return;
6195
6375
  }
@@ -6211,7 +6391,7 @@ class HotelEnterpriseSearch extends BaseEnterpriseSearch {
6211
6391
  }
6212
6392
  break;
6213
6393
  case LocationTypes.Office:
6214
- if (!((_a = this.tempParams.location) === null || _a === void 0 ? void 0 : _a.office)) {
6394
+ if (((_a = this.tempParams.location) === null || _a === void 0 ? void 0 : _a.type) !== 'Office' && !this.office) {
6215
6395
  this.validationMessages.push('Please select an office.');
6216
6396
  }
6217
6397
  break;
@@ -6227,13 +6407,7 @@ class HotelEnterpriseSearch extends BaseEnterpriseSearch {
6227
6407
  }
6228
6408
  break;
6229
6409
  case LocationTypes.TrainStation:
6230
- if ((_d = this.tempParams) === null || _d === void 0 ? void 0 : _d.location) {
6231
- if (!((_e = this.tempParams.location.railstation) === null || _e === void 0 ? void 0 : _e.stationCode)) {
6232
- this.validationMessages.push('Please select a train station.');
6233
- }
6234
- break;
6235
- }
6236
- else {
6410
+ if (!((_e = (_d = this.tempParams.location) === null || _d === void 0 ? void 0 : _d.railstation) === null || _e === void 0 ? void 0 : _e.stationCode) && !((_f = this.trainsStation) === null || _f === void 0 ? void 0 : _f.stationCode)) {
6237
6411
  this.validationMessages.push('Please select a train station.');
6238
6412
  }
6239
6413
  break;
@@ -6285,17 +6459,20 @@ class HotelEnterpriseSearch extends BaseEnterpriseSearch {
6285
6459
  }
6286
6460
  getRecentSearchQuery(query) {
6287
6461
  var _a;
6462
+ const recentSearchQuery = query;
6463
+ recentSearchQuery.location_type_select = this.location_type_select;
6288
6464
  if ((_a = this.location) === null || _a === void 0 ? void 0 : _a.name) {
6289
- query.cityName = this.location.name;
6465
+ recentSearchQuery.cityName = this.location.name;
6290
6466
  }
6291
6467
  return {
6292
6468
  serviceType: ServiceType.Hotel,
6293
- searchArgs: query,
6469
+ searchArgs: recentSearchQuery,
6294
6470
  travelDate: this.checkin_date.format(),
6295
6471
  travellers: this.helpers.getTravellersId(this.travellers)
6296
6472
  };
6297
6473
  }
6298
6474
  startRecentSearch(recentSearch) {
6475
+ this.location_type_select = recentSearch.searchArgs.location_type_select;
6299
6476
  this.currency = recentSearch.searchArgs.currency;
6300
6477
  this.distance = recentSearch.searchArgs.distance;
6301
6478
  this.no_of_rooms = recentSearch.searchArgs.rooms;
@@ -6308,67 +6485,63 @@ class HotelEnterpriseSearch extends BaseEnterpriseSearch {
6308
6485
  };
6309
6486
  }
6310
6487
  // get location_type_select
6311
- if (recentSearch.searchArgs.iata) {
6312
- this.location_type_select = LocationTypes.Airport;
6313
- this.searchService.getAirportByCode(recentSearch.searchArgs.iata).subscribe((iata) => {
6314
- let airport = {
6315
- airport: {
6316
- gateway: iata.iataMatch.iata
6317
- }
6488
+ switch (this.location_type_select) {
6489
+ case LocationTypes.Airport:
6490
+ this.searchService.getAirportByCode(recentSearch.searchArgs.iata).subscribe((iata) => {
6491
+ let airport = {
6492
+ airport: {
6493
+ gateway: iata.iataMatch.iata
6494
+ }
6495
+ };
6496
+ this.location = Object.assign(Object.assign({}, airport), iata.iataMatch);
6497
+ this.searchService.startSearches();
6498
+ });
6499
+ break;
6500
+ case LocationTypes.City:
6501
+ this.country = {
6502
+ cCode: recentSearch.searchArgs.countryCode,
6503
+ cName: ''
6318
6504
  };
6319
- this.location = Object.assign(Object.assign({}, airport), iata.iataMatch);
6505
+ // should be one search metod for the city search: location or postcode
6506
+ if (recentSearch.searchArgs.latitude && recentSearch.searchArgs.longitude) {
6507
+ this.location = {
6508
+ name: recentSearch.searchArgs.cityName,
6509
+ latitude: recentSearch.searchArgs.latitude,
6510
+ longitude: recentSearch.searchArgs.longitude
6511
+ };
6512
+ }
6513
+ else if (recentSearch.searchArgs.postOrZipCode) {
6514
+ this.postcode = {
6515
+ name: recentSearch.searchArgs.postOrZipCode,
6516
+ type: LocationTypes.Postcode
6517
+ };
6518
+ }
6320
6519
  this.searchService.startSearches();
6321
- });
6322
- }
6323
- else if ((recentSearch.searchArgs.latitude && recentSearch.searchArgs.longitude) || recentSearch.searchArgs.postOrZipCode) {
6324
- this.location_type_select = LocationTypes.City;
6325
- this.country = {
6326
- cCode: recentSearch.searchArgs.countryCode,
6327
- cName: ''
6328
- };
6329
- // should be one search metod for the city search: location or postcode
6330
- if (recentSearch.searchArgs.latitude && recentSearch.searchArgs.longitude) {
6331
- this.location = {
6332
- name: recentSearch.searchArgs.cityName,
6333
- latitude: recentSearch.searchArgs.latitude,
6334
- longitude: recentSearch.searchArgs.longitude
6335
- };
6336
- }
6337
- else if (recentSearch.searchArgs.postOrZipCode) {
6338
- this.postcode = {
6339
- name: recentSearch.searchArgs.postOrZipCode,
6340
- type: LocationTypes.Postcode
6341
- };
6342
- }
6343
- this.searchService.startSearches();
6344
- }
6345
- else if (recentSearch.searchArgs.officeId) {
6346
- this.location_type_select = LocationTypes.Office;
6347
- this.searchService.getOfficeNames(this.isLoading).pipe(take(1)).subscribe((offices) => {
6348
- if (offices) {
6349
- let office = offices.find((office) => office.id === recentSearch.searchArgs.officeId);
6520
+ break;
6521
+ case LocationTypes.Office:
6522
+ this.searchService.getOffice(recentSearch.searchArgs.officeId).pipe(take(1)).subscribe((office) => {
6350
6523
  this.office = {
6351
- id: recentSearch.searchArgs.officeId,
6524
+ id: office.id,
6352
6525
  name: office.name
6353
6526
  };
6354
6527
  this.searchService.startSearches();
6355
- }
6356
- });
6357
- }
6358
- else if (recentSearch.searchArgs.trainStationCode) {
6359
- this.location_type_select = LocationTypes.TrainStation;
6360
- this.getRailStationByCode(recentSearch.searchArgs.trainStationCode).subscribe((trainsStation) => {
6361
- this.trainsStation = trainsStation;
6528
+ });
6529
+ break;
6530
+ case LocationTypes.TrainStation:
6531
+ this.getRailStationByCode(recentSearch.searchArgs.trainStationCode).subscribe((trainsStation) => {
6532
+ this.trainsStation = trainsStation;
6533
+ this.searchService.startSearches();
6534
+ });
6535
+ break;
6536
+ case LocationTypes.Shortlist:
6537
+ this.country = {
6538
+ cCode: recentSearch.searchArgs.countryCode,
6539
+ cName: ''
6540
+ };
6362
6541
  this.searchService.startSearches();
6363
- });
6364
- }
6365
- else {
6366
- this.location_type_select = LocationTypes.Shortlist;
6367
- this.country = {
6368
- cCode: recentSearch.searchArgs.countryCode,
6369
- cName: ''
6370
- };
6371
- this.searchService.startSearches();
6542
+ break;
6543
+ default:
6544
+ break;
6372
6545
  }
6373
6546
  }
6374
6547
  getRailStationByCode(code) {
@@ -6384,7 +6557,7 @@ class HotelEnterpriseSearch extends BaseEnterpriseSearch {
6384
6557
  return this.helpers.removeNulls(this.query);
6385
6558
  }
6386
6559
  buildQuery() {
6387
- var _a, _b;
6560
+ var _a, _b, _c, _d, _e, _f;
6388
6561
  const query = {
6389
6562
  startDate: this.tempParams.checkin_date.format('YYYY-MM-DD'),
6390
6563
  endDate: this.tempParams.checkout_date.format('YYYY-MM-DD'),
@@ -6413,10 +6586,20 @@ class HotelEnterpriseSearch extends BaseEnterpriseSearch {
6413
6586
  }
6414
6587
  break;
6415
6588
  case LocationTypes.TrainStation:
6416
- query.trainStationCode = this.location.railstation.stationCode;
6589
+ if ((_b = (_a = this.location) === null || _a === void 0 ? void 0 : _a.railstation) === null || _b === void 0 ? void 0 : _b.stationCode) {
6590
+ query.trainStationCode = this.location.railstation.stationCode;
6591
+ }
6592
+ else if ((_c = this.trainsStation) === null || _c === void 0 ? void 0 : _c.stationCode) {
6593
+ query.trainStationCode = this.trainsStation.stationCode;
6594
+ }
6417
6595
  break;
6418
6596
  case LocationTypes.Office: // Needs to fix in next PR
6419
- query.officeId = +((_a = this.location.office) === null || _a === void 0 ? void 0 : _a.id);
6597
+ if ((_d = this.location) === null || _d === void 0 ? void 0 : _d.id) {
6598
+ query.officeId = +this.location.id;
6599
+ }
6600
+ else if ((_e = this.office) === null || _e === void 0 ? void 0 : _e.id) {
6601
+ query.officeId = +this.office.id;
6602
+ }
6420
6603
  break;
6421
6604
  case LocationTypes.Shortlist:
6422
6605
  query.countryCode = this.country.cCode;
@@ -6428,7 +6611,7 @@ class HotelEnterpriseSearch extends BaseEnterpriseSearch {
6428
6611
  }
6429
6612
  // add chain or group name int he query
6430
6613
  if (this.hotel_chain) {
6431
- query.groupName = (_b = this.tempParams.hotel_chain) === null || _b === void 0 ? void 0 : _b.name;
6614
+ query.groupName = (_f = this.tempParams.hotel_chain) === null || _f === void 0 ? void 0 : _f.name;
6432
6615
  }
6433
6616
  this.query = query;
6434
6617
  }
@@ -6848,6 +7031,7 @@ class LoungesEnterpriseSearch extends BaseEnterpriseSearch {
6848
7031
  this._date = null;
6849
7032
  this._time = null;
6850
7033
  this.resultsSessionName = LoungesEnterpriseSearch.STORAGE_SESSION_RESULTS;
7034
+ this.multiResultsSessionName = LoungesEnterpriseSearch.STORAGE_SESSION_RESULTS;
6851
7035
  const data = storageService.getSessionItem(LoungesEnterpriseSearch.STORAGE_SESSION_PARAMS) || {
6852
7036
  tempParams: {}
6853
7037
  };
@@ -7182,6 +7366,7 @@ class ParkingEnterpriseSearch extends BaseEnterpriseSearch {
7182
7366
  day: moment().date() + 1 // min 1 night stay
7183
7367
  };
7184
7368
  this.resultsSessionName = ParkingEnterpriseSearch.STORAGE_SESSION_RESULTS;
7369
+ this.multiResultsSessionName = ParkingEnterpriseSearch.STORAGE_SESSION_RESULTS;
7185
7370
  this._outdate = null;
7186
7371
  this._outtime = null;
7187
7372
  this._indate = null;
@@ -7447,7 +7632,9 @@ class ParkingEnterpriseSearch extends BaseEnterpriseSearch {
7447
7632
  this.departDatetime = moment(recentSearch.searchArgs.departDatetime);
7448
7633
  this.outFlightNumber = recentSearch.searchArgs.outFlightNumber;
7449
7634
  this.terminal = recentSearch.searchArgs.terminal;
7450
- this.searchService.getAirportByCode(recentSearch.searchArgs.locationCode).subscribe((airport) => {
7635
+ this.searchService
7636
+ .getAirportByCode(recentSearch.searchArgs.locationCode)
7637
+ .subscribe((airport) => {
7451
7638
  var _a, _b, _c, _d, _e, _f;
7452
7639
  if (airport) {
7453
7640
  this.locationCode = {
@@ -7456,7 +7643,7 @@ class ParkingEnterpriseSearch extends BaseEnterpriseSearch {
7456
7643
  destination: airport.iataMatch.name,
7457
7644
  gateway: airport.iataMatch.iata,
7458
7645
  postcode: (_f = (_e = airport.iataMatch) === null || _e === void 0 ? void 0 : _e.locationDetails) === null || _f === void 0 ? void 0 : _f.postcode,
7459
- terminals: this.searchService.processTerminals(airport.iataMatch.terminals),
7646
+ terminals: this.searchService.processTerminals(airport.iataMatch.terminals)
7460
7647
  };
7461
7648
  this.searchService.startSearches();
7462
7649
  }
@@ -7550,10 +7737,53 @@ var EurostarSearchType;
7550
7737
  EurostarSearchType["oneWay"] = "oneWay";
7551
7738
  })(EurostarSearchType || (EurostarSearchType = {}));
7552
7739
 
7740
+ const DEFAULT_FILTERS = Object.freeze({
7741
+ stops: {},
7742
+ mustInclude: {},
7743
+ classes: {},
7744
+ airlines: {},
7745
+ travelPolicy: {},
7746
+ depatureAirport: {},
7747
+ depatureReturnAirport: {},
7748
+ arrivalAirport: {},
7749
+ arrivalReturnAirport: {},
7750
+ baggage: {},
7751
+ fareTypes: {},
7752
+ price: {
7753
+ min: Number.MAX_SAFE_INTEGER,
7754
+ max: Number.MIN_SAFE_INTEGER
7755
+ },
7756
+ duration: {
7757
+ min: Number.MAX_SAFE_INTEGER,
7758
+ max: Number.MIN_SAFE_INTEGER
7759
+ },
7760
+ returnDuration: {
7761
+ min: Number.MAX_SAFE_INTEGER,
7762
+ max: Number.MIN_SAFE_INTEGER
7763
+ },
7764
+ departureTime: {
7765
+ min: 0,
7766
+ max: 2359
7767
+ },
7768
+ arrivalTime: {
7769
+ min: 0,
7770
+ max: 2359
7771
+ },
7772
+ returnDepartureTime: {
7773
+ min: 0,
7774
+ max: 2359
7775
+ },
7776
+ returnArrivalTime: {
7777
+ min: 0,
7778
+ max: 2359
7779
+ },
7780
+ flightNumber: ''
7781
+ });
7553
7782
  var SortTypesEurostar;
7554
7783
  (function (SortTypesEurostar) {
7555
7784
  SortTypesEurostar["CheapestFirst"] = "C";
7556
7785
  SortTypesEurostar["EarliestFirst"] = "E";
7786
+ SortTypesEurostar["LatestFirst"] = "L";
7557
7787
  })(SortTypesEurostar || (SortTypesEurostar = {}));
7558
7788
  var SortMethod;
7559
7789
  (function (SortMethod) {
@@ -7565,6 +7795,7 @@ class EurostarEnterpriseSearch extends BaseEnterpriseSearch {
7565
7795
  super(storageService, (results1) => {
7566
7796
  this.resultQuery = this.getSearchQuery();
7567
7797
  delete this.resultQuery.withGrouped;
7798
+ this.filters.next(this.helpers.createFlightFilters(results1.journeys, DEFAULT_FILTERS));
7568
7799
  if (results1 && this.searchService.isFlightsGrouped()) {
7569
7800
  const returndata = (results1.journeys || []).reduce((acc, result) => {
7570
7801
  if (result.outboundFlights.length) {
@@ -7621,6 +7852,13 @@ class EurostarEnterpriseSearch extends BaseEnterpriseSearch {
7621
7852
  icon: 'ico-calendar',
7622
7853
  dir: true,
7623
7854
  code: SortTypesEurostar.EarliestFirst
7855
+ },
7856
+ {
7857
+ title: 'Time (Descending)',
7858
+ method: SortMethod.sortByDate,
7859
+ icon: 'ico-calendar',
7860
+ dir: true,
7861
+ code: SortTypesEurostar.LatestFirst
7624
7862
  }
7625
7863
  ];
7626
7864
  this._fareTypeArray = [
@@ -7644,13 +7882,15 @@ class EurostarEnterpriseSearch extends BaseEnterpriseSearch {
7644
7882
  };
7645
7883
  this.searchTypes = [
7646
7884
  { value: EurostarSearchType.return, display: 'Return' },
7647
- { value: EurostarSearchType.oneWay, display: 'One-way' },
7885
+ { value: EurostarSearchType.oneWay, display: 'One-way' }
7648
7886
  ];
7649
7887
  this.flightsToGroup = {};
7650
7888
  this.grouped = null;
7651
7889
  this.travellers = null;
7652
7890
  this.resultsSessionName = EurostarEnterpriseSearch.STORAGE_SESSION_RESULTS;
7891
+ this.multiResultsSessionName = EurostarEnterpriseSearch.STORAGE_SESSION_RESULTS;
7653
7892
  this._displayAddHotel = false;
7893
+ this.filters = new BehaviorSubject(DEFAULT_FILTERS);
7654
7894
  this._multiDestination = [];
7655
7895
  this.minToHour = (dur) => `${Math.floor(dur / 60)}h ${dur % 60}m`;
7656
7896
  const data = storageService.getSessionItem(EurostarEnterpriseSearch.STORAGE_SESSION_PARAMS) || {
@@ -7691,6 +7931,10 @@ class EurostarEnterpriseSearch extends BaseEnterpriseSearch {
7691
7931
  this.fullResults = this.helpers.clone(results.results);
7692
7932
  this.flightsToGroup = results.groupData || {};
7693
7933
  this.resultQuery = results.query;
7934
+ const isFlightsGrouped = this.searchService.isFlightsGrouped();
7935
+ if (!isFlightsGrouped) {
7936
+ this._cheapestResultPrice = this.updateLowestPrice(results.results);
7937
+ }
7694
7938
  this.results.next(results.results || []);
7695
7939
  this._isValid();
7696
7940
  this.negotiated =
@@ -8081,13 +8325,102 @@ class EurostarEnterpriseSearch extends BaseEnterpriseSearch {
8081
8325
  tempParams: this.tempParams,
8082
8326
  originalUserSearch: this.originalUserSearch
8083
8327
  });
8328
+ const query = this.getSearchQuery();
8329
+ this.searchService.saveRecentSearch(this.getRecentSearchQuery(query));
8084
8330
  return this._startSearch(this.eurostarFetcher.fetchList(this.getSearchQuery()));
8085
8331
  }
8086
8332
  else {
8087
8333
  return Promise.resolve(false);
8088
8334
  }
8089
8335
  }
8090
- startRecentSearch(recentSearch) { }
8336
+ getRecentSearchQuery(query) {
8337
+ return {
8338
+ serviceType: ServiceType.Eurostar,
8339
+ searchArgs: query,
8340
+ travelDate: this.outBoundDate.format(),
8341
+ travellers: this.helpers.getTravellersId(this.travellers)
8342
+ };
8343
+ }
8344
+ startRecentSearch(recentSearch) {
8345
+ if (recentSearch.searchArgs.outboundDate) {
8346
+ this.outBoundDate = this.convertRecentSearchDateTime(recentSearch.searchArgs.outboundDate, recentSearch.searchArgs.outboundDepartureTimeWindow);
8347
+ }
8348
+ if (recentSearch.searchArgs.returnDate) {
8349
+ this.inboundDate = this.convertRecentSearchDateTime(recentSearch.searchArgs.returnDate, recentSearch.searchArgs.returnDepartureTimeWindow);
8350
+ }
8351
+ this.fareType = recentSearch.searchArgs.fareType;
8352
+ this.maxConnections = recentSearch.searchArgs.maxConnections;
8353
+ if (recentSearch.searchArgs.outboundCabinClass) {
8354
+ this.cabinClass = recentSearch.searchArgs.outboundCabinClass[0];
8355
+ }
8356
+ if (recentSearch.searchArgs.returnCabinClass) {
8357
+ this.returnCabinClass = recentSearch.searchArgs.returnCabinClass[0];
8358
+ }
8359
+ this.includeNearbyAirports = recentSearch.searchArgs.includeNearbyAirports;
8360
+ this.chosenSearchType = recentSearch.searchArgs.returnTrip
8361
+ ? EurostarSearchType.return
8362
+ : EurostarSearchType.oneWay;
8363
+ if (recentSearch.searchArgs.outboundDepartureTimeWindow) {
8364
+ this.outTimeCriteria = TimeWindow.Depart;
8365
+ }
8366
+ else if (recentSearch.searchArgs.outboundArrivalTimeWindow) {
8367
+ this.outTimeCriteria = TimeWindow.Arrive;
8368
+ }
8369
+ else {
8370
+ this.outTimeCriteria = TimeWindow.Anytime;
8371
+ }
8372
+ if (recentSearch.searchArgs.returnDepartureTimeWindow) {
8373
+ this.inTimeCriteria = TimeWindow.Depart;
8374
+ }
8375
+ else if (recentSearch.searchArgs.returnArrivalTimeWindow) {
8376
+ this.inTimeCriteria = TimeWindow.Arrive;
8377
+ }
8378
+ else {
8379
+ this.inTimeCriteria = TimeWindow.Anytime;
8380
+ }
8381
+ combineLatest([
8382
+ this.searchService.getAirportByCode(recentSearch.searchArgs.originAirport),
8383
+ this.searchService.getAirportByCode(recentSearch.searchArgs.destinationAirport)
8384
+ ]).subscribe(([departLocation, arriveLocation]) => {
8385
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
8386
+ if (departLocation && arriveLocation) {
8387
+ this.departLocation = {
8388
+ destination: departLocation.iataMatch.name,
8389
+ gateway: departLocation.iataMatch.iata,
8390
+ terminals: this.searchService.processTerminals(departLocation.iataMatch.terminals),
8391
+ country: (_b = (_a = departLocation.iataMatch) === null || _a === void 0 ? void 0 : _a.locationDetails) === null || _b === void 0 ? void 0 : _b.country,
8392
+ postcode: (_d = (_c = departLocation.iataMatch) === null || _c === void 0 ? void 0 : _c.locationDetails) === null || _d === void 0 ? void 0 : _d.postcode,
8393
+ countryCode: (_f = (_e = departLocation.iataMatch) === null || _e === void 0 ? void 0 : _e.locationDetails) === null || _f === void 0 ? void 0 : _f.countryCode
8394
+ };
8395
+ this.arriveLocation = {
8396
+ destination: arriveLocation.iataMatch.name,
8397
+ gateway: arriveLocation.iataMatch.iata,
8398
+ terminals: this.searchService.processTerminals(arriveLocation.iataMatch.terminals),
8399
+ country: (_h = (_g = arriveLocation.iataMatch) === null || _g === void 0 ? void 0 : _g.locationDetails) === null || _h === void 0 ? void 0 : _h.country,
8400
+ postcode: (_k = (_j = arriveLocation.iataMatch) === null || _j === void 0 ? void 0 : _j.locationDetails) === null || _k === void 0 ? void 0 : _k.postcode,
8401
+ countryCode: (_m = (_l = arriveLocation.iataMatch) === null || _l === void 0 ? void 0 : _l.locationDetails) === null || _m === void 0 ? void 0 : _m.countryCode
8402
+ };
8403
+ if (recentSearch.searchArgs.preferredCarriers) {
8404
+ let preferredCarriers = [];
8405
+ recentSearch.searchArgs.preferredCarriers.map((preferredCarry) => {
8406
+ this.searchService
8407
+ .getAirlinesList(preferredCarry)
8408
+ .subscribe((items) => {
8409
+ items.map((item) => {
8410
+ if (item.code === preferredCarry) {
8411
+ preferredCarriers.push(item);
8412
+ }
8413
+ });
8414
+ this.preferredCarriers = preferredCarriers;
8415
+ this.searchService.startSearches();
8416
+ });
8417
+ });
8418
+ }
8419
+ this.searchService.startSearches();
8420
+ }
8421
+ });
8422
+ this.searchService.startSearches();
8423
+ }
8091
8424
  makeDepartureTimeWindow(dateTime, window) {
8092
8425
  return window === TimeWindow.Depart
8093
8426
  ? this.helpers.makeTimeWindow(dateTime, -2, 2)
@@ -8099,6 +8432,17 @@ class EurostarEnterpriseSearch extends BaseEnterpriseSearch {
8099
8432
  }
8100
8433
  return this.helpers.makeTimeWindow(dateTime, -2, 2);
8101
8434
  }
8435
+ convertRecentSearchDateTime(date, timeWindow) {
8436
+ if (timeWindow) {
8437
+ const flightTime = timeWindow.split('-');
8438
+ let timeAndDate = moment(date).add(moment.duration(this.helpers.hhmmToTime(flightTime[0])));
8439
+ // add 2 hour
8440
+ return timeAndDate.clone().add(2, 'hour');
8441
+ }
8442
+ else {
8443
+ return moment(date);
8444
+ }
8445
+ }
8102
8446
  getSearchQuery() {
8103
8447
  return this.helpers.removeNulls(Object.assign({}, {
8104
8448
  originAirport: this._originAirport,
@@ -8180,6 +8524,52 @@ class EurostarEnterpriseSearch extends BaseEnterpriseSearch {
8180
8524
  }
8181
8525
  this.results.next(results);
8182
8526
  }
8527
+ sortResultsFlightJourneys(sortMethodValue, inbound = false, givenResults) {
8528
+ let results = this.helpers.clone(givenResults);
8529
+ switch (sortMethodValue) {
8530
+ case SortTypesEurostar.CheapestFirst:
8531
+ results = this.sortByPriceFlight(results);
8532
+ break;
8533
+ case SortTypesEurostar.EarliestFirst:
8534
+ results = this.sortByDateFlight(results, inbound);
8535
+ break;
8536
+ case SortTypesEurostar.LatestFirst:
8537
+ results = this.sortByDateFlightDecending(results, inbound);
8538
+ break;
8539
+ default:
8540
+ console.error(`+++ Unknown sorting method: ${sortMethodValue} +++`);
8541
+ }
8542
+ return results;
8543
+ }
8544
+ sortByPriceFlight(results) {
8545
+ return results.sort((a, b) => {
8546
+ return Number(a.total.price) - Number(b.total.price);
8547
+ });
8548
+ }
8549
+ sortByDateFlight(results, inbound) {
8550
+ return results.sort((a, b) => {
8551
+ if (inbound) {
8552
+ return (moment(a.inboundFlights[0].dateTimeDeparting).unix() -
8553
+ moment(b.inboundFlights[0].dateTimeDeparting).unix());
8554
+ }
8555
+ else {
8556
+ return (moment(a.outboundFlights[0].dateTimeDeparting).unix() -
8557
+ moment(b.outboundFlights[0].dateTimeDeparting).unix());
8558
+ }
8559
+ });
8560
+ }
8561
+ sortByDateFlightDecending(results, inbound) {
8562
+ return results.sort((a, b) => {
8563
+ if (inbound) {
8564
+ return (moment(b.inboundFlights[0].dateTimeDeparting).unix() -
8565
+ moment(a.inboundFlights[0].dateTimeDeparting).unix());
8566
+ }
8567
+ else {
8568
+ return (moment(b.outboundFlights[0].dateTimeDeparting).unix() -
8569
+ moment(a.outboundFlights[0].dateTimeDeparting).unix());
8570
+ }
8571
+ });
8572
+ }
8183
8573
  /**
8184
8574
  * Sort results by departure time
8185
8575
  *
@@ -8268,6 +8658,46 @@ class EurostarEnterpriseSearch extends BaseEnterpriseSearch {
8268
8658
  }
8269
8659
  return num.toString().padStart(2, '0');
8270
8660
  }
8661
+ /**
8662
+ * @description - apply all filters to results
8663
+ * @param filters
8664
+ * @param inbound
8665
+ * @param results
8666
+ * @returns
8667
+ */
8668
+ applyFilters(filters, inbound = false) {
8669
+ // let newResults = this.helpers.clone(results);
8670
+ // if (inbound) {
8671
+ // newResults = this.filterByReturnDepartureTime(
8672
+ // filters.minReturnDepartureTime,
8673
+ // filters.maxReturnDepartureTime,
8674
+ // newResults
8675
+ // );
8676
+ // newResults = this.filterByReturnArrivalTime(
8677
+ // filters.minReturnArrivalTime,
8678
+ // filters.maxReturnArrivalTime,
8679
+ // newResults
8680
+ // );
8681
+ // }
8682
+ // // Global (apply to both inbound and outbound results) filters
8683
+ // newResults = this.filterByDepartureTime(
8684
+ // filters.minDepartureTime,
8685
+ // filters.maxDepartureTime,
8686
+ // newResults
8687
+ // );
8688
+ // newResults = this.filterByArrivalTime(
8689
+ // filters.minArrivalTime,
8690
+ // filters.maxArrivalTime,
8691
+ // newResults
8692
+ // );
8693
+ // newResults = this.filterResultsByStops(filters.stops, newResults);
8694
+ // newResults = this.filterByPrice(
8695
+ // filters.minPrice,
8696
+ // filters.maxPrice,
8697
+ // newResults
8698
+ // );
8699
+ // return newResults;
8700
+ }
8271
8701
  filterByDuration(minDuration, maxDuration, results, isReturn = false) {
8272
8702
  results = results.filter((result) => {
8273
8703
  var _a;
@@ -8454,39 +8884,6 @@ class EurostarEnterpriseSearch extends BaseEnterpriseSearch {
8454
8884
  }
8455
8885
  return results;
8456
8886
  }
8457
- createFilters(results = []) {
8458
- const minPrice = this.getMinPrice(results);
8459
- const maxPrice = this.getMaxPrice(results);
8460
- const newFilters = {
8461
- stops: this.getAllStops(results),
8462
- mustInclude: [],
8463
- classes: this.getAllClasses(results),
8464
- airlines: this.getAllAirlines(results),
8465
- travelPolicy: [],
8466
- depatureAirport: this.getAllDepartureAirports(results),
8467
- arrivalAirport: this.getAllArrivalAirports(results),
8468
- minPrice,
8469
- maxPrice,
8470
- depatureReturnAirport: this.getAllDepartureAirports(results, true),
8471
- arrivalReturnAirport: this.getAllArrivalAirports(results, true),
8472
- baggage: this.getBaggage(results),
8473
- fareTypes: [],
8474
- minDuration: this.getMinDuration(results),
8475
- maxDuration: this.getMaxDuration(results),
8476
- minReturnDuration: this.getMinDuration(results, true),
8477
- maxReturnDuration: this.getMaxDuration(results, true),
8478
- minDepartureTime: this.getMinDepartureTime(results),
8479
- maxDepartureTime: this.getMaxDepartureTime(results),
8480
- minArrivalTime: this.getMinArrivalTime(results),
8481
- maxArrivalTime: this.getMaxArrivalTime(results),
8482
- minReturnDepartureTime: this.getMinReturnDepartureTime(results),
8483
- maxReturnDepartureTime: this.getMaxReturnDepartureTime(results),
8484
- maxReturnArrivalTime: this.getMaxReturnArrivalTime(results),
8485
- minReturnArrivalTime: this.getMinReturnArrivalTime(results),
8486
- flightNumber: ''
8487
- };
8488
- return newFilters;
8489
- }
8490
8887
  getMinDuration(results, isReturn = false) {
8491
8888
  let min = 0;
8492
8889
  results.forEach((result) => {
@@ -8829,9 +9226,7 @@ class EurostarEnterpriseSearch extends BaseEnterpriseSearch {
8829
9226
  outboundFlights: [
8830
9227
  this.makeSchemaFlights(this.selectedEurostarFare.fare, 'outbound', 0)
8831
9228
  ],
8832
- inboundFlights: [
8833
- this.makeSchemaFlights(fare.fare, 'inbound', 0)
8834
- ],
9229
+ inboundFlights: [this.makeSchemaFlights(fare.fare, 'inbound', 0)],
8835
9230
  journeyType: 'roundtrip'
8836
9231
  }, selectedEurostar.dateDeparture, this.selectedGroupEurostar.dateArrival);
8837
9232
  this.results.next(this.fullResults);
@@ -8839,17 +9234,17 @@ class EurostarEnterpriseSearch extends BaseEnterpriseSearch {
8839
9234
  });
8840
9235
  }
8841
9236
  updateLowestPrice(results) {
8842
- return null;
8843
- // add in once filght result is updated///
8844
- // const results = this.storageService.getSessionItemAsList<FlightQuoteResultArray>(this.resultsSessionName) || [] as FlightQuoteResultArray;
8845
- // if(!results.length) return;
8846
- // this._cheapestResultPrice.currencyCode = results[0].total.currency;
8847
- // results.map(result => {
8848
- // const price = result.total.price;
8849
- // if( this._cheapestResultPrice.amount > price || this._cheapestResultPrice.amount === null){
8850
- // this._cheapestResultPrice.amount = price;
8851
- // }
8852
- // })
9237
+ if (!results.length)
9238
+ return;
9239
+ const result = results[0];
9240
+ const journeys = result.journeys;
9241
+ const currency = journeys[0].total.currency;
9242
+ return journeys.reduce((cheapestPrice, result) => {
9243
+ const price = result.total.price;
9244
+ if (cheapestPrice.amount > price)
9245
+ cheapestPrice.amount = price;
9246
+ return cheapestPrice;
9247
+ }, { amount: Number.MAX_SAFE_INTEGER, currencyCode: currency });
8853
9248
  }
8854
9249
  doBooking(intBasket, selectedFlight, schemaDetails, outboundDate, inboundDate) {
8855
9250
  const { sourceId, co2PerItem, co2PerPassenger, total } = selectedFlight;
@@ -8968,7 +9363,9 @@ class EurostarEnterpriseSearch extends BaseEnterpriseSearch {
8968
9363
  if (basket) {
8969
9364
  const { sourceId, co2PerItem, co2PerPassenger, total } = eurostarQuote;
8970
9365
  const outboundDate = moment(eurostarQuote.outboundFlights[0].dateTimeDeparting);
8971
- const inboundDate = eurostarQuote.inboundFlights.length ? moment(eurostarQuote.inboundFlights[0].dateTimeDeparting) : null;
9366
+ const inboundDate = eurostarQuote.inboundFlights.length
9367
+ ? moment(eurostarQuote.inboundFlights[0].dateTimeDeparting)
9368
+ : null;
8972
9369
  const schemaDetails = {
8973
9370
  outboundFlights: [
8974
9371
  ...eurostarQuote.outboundFlights.map((flight, segmentIndex) => this.makeSchemaFlights(flight, 'outbound', 0, segmentIndex))
@@ -9023,6 +9420,7 @@ class RailEnterpriseSearch extends BaseEnterpriseSearch {
9023
9420
  this.basketService = basketService;
9024
9421
  this.searchService = searchService;
9025
9422
  this.resultsSessionName = RailEnterpriseSearch.STORAGE_SESSION_RESULTS;
9423
+ this.multiResultsSessionName = RailEnterpriseSearch.STORAGE_SESSION_RESULTS;
9026
9424
  this.searchTypes = [
9027
9425
  { display: 'Return', value: RailJourneyType.ReturnJourney },
9028
9426
  { display: 'One-Way', value: RailJourneyType.SingleJourney }
@@ -10321,21 +10719,66 @@ RailEnterpriseSearch.STORAGE_SESSION_PARAMS = 'search_rail';
10321
10719
  RailEnterpriseSearch.STORAGE_SESSION_RESULTS = 'rail_results';
10322
10720
  RailEnterpriseSearch.PASSING_POINT = 'Passing';
10323
10721
 
10722
+ var ages;
10723
+ (function (ages) {
10724
+ ages["Child"] = "Child";
10725
+ ages["Youth"] = "Youth";
10726
+ ages["Adult"] = "Adult";
10727
+ ages["Senior"] = "Senior";
10728
+ })(ages || (ages = {}));
10729
+ // @dynamic
10730
+ class TravellerObject {
10731
+ static hasItem(item) {
10732
+ return !!item;
10733
+ }
10734
+ static fullname(traveller) {
10735
+ return [traveller.title, traveller.forename, traveller.surname].filter(this.hasItem).join(' ');
10736
+ }
10737
+ static makeTravellerObjectFromUser(user) {
10738
+ return {
10739
+ id: user.user_id.toString(),
10740
+ forename: user.forename,
10741
+ surname: user.surname,
10742
+ email: user.username,
10743
+ title: user.title,
10744
+ isChild: false,
10745
+ isInfant: false,
10746
+ childDOB: null,
10747
+ guest: false,
10748
+ name: user.surname + ' ' + user.forename
10749
+ };
10750
+ }
10751
+ static equals(first, second) {
10752
+ return first.email === second.email;
10753
+ }
10754
+ static compare(first, second) {
10755
+ const name1 = TravellerObject.fullname(first);
10756
+ const name2 = TravellerObject.fullname(second);
10757
+ if (name1 === name2) {
10758
+ return 0;
10759
+ }
10760
+ if (name1 < name2) {
10761
+ return -1;
10762
+ }
10763
+ return 1;
10764
+ }
10765
+ }
10766
+
10324
10767
  var IrlSearchCriteria;
10325
10768
  (function (IrlSearchCriteria) {
10326
10769
  IrlSearchCriteria["Depart"] = "Depart After";
10327
10770
  IrlSearchCriteria["Arrive"] = "Arrive Before";
10328
10771
  })(IrlSearchCriteria || (IrlSearchCriteria = {}));
10329
10772
  class IRLEnterpriseSearch extends BaseEnterpriseSearch {
10330
- constructor(Irlfetcher,
10331
- // private getRailStationFetcher: BaseGetRailStationFetcher<GRS_Q>, // doesnt exist yet
10332
- helpers, basketService, storageService, searchService) {
10773
+ constructor(Irlfetcher, searchIrlStationsFetcher, helpers, basketService, storageService, searchService) {
10333
10774
  super(storageService);
10334
10775
  this.Irlfetcher = Irlfetcher;
10776
+ this.searchIrlStationsFetcher = searchIrlStationsFetcher;
10335
10777
  this.helpers = helpers;
10336
10778
  this.basketService = basketService;
10337
10779
  this.searchService = searchService;
10338
10780
  this.resultsSessionName = IRLEnterpriseSearch.STORAGE_SESSION_RESULTS;
10781
+ this.multiResultsSessionName = IRLEnterpriseSearch.STORAGE_SESSION_RESULTS;
10339
10782
  this.searchTypes = [
10340
10783
  { display: 'Return', value: IrlJourneyType.ReturnJourney },
10341
10784
  { display: 'One-Way', value: IrlJourneyType.SingleJourney }
@@ -10347,8 +10790,8 @@ class IRLEnterpriseSearch extends BaseEnterpriseSearch {
10347
10790
  { display: 'Standard', value: IrlClass.Standard },
10348
10791
  { display: 'First', value: IrlClass.First }
10349
10792
  ];
10350
- this.ageRanges = [{ key: 'child', value: 'Child (0-3)' }, { key: 'child', value: 'Child (4-5)' }, { key: 'child', value: 'Child (6-11)' }, { key: 'youth', value: 'Youth (12-14)' }, { key: 'youth', value: 'Youth (15-25)' }, { key: 'adult', value: 'Adult (26-59)' }, { key: 'senior', value: 'Senior (60+)' }];
10351
- this.railCriteria = [IrlSearchCriteria.Depart, IrlSearchCriteria.Arrive];
10793
+ this.ageRanges = [{ key: ages.Child, value: 'Child (0-3)' }, { key: ages.Child, value: 'Child (4-5)' }, { key: ages.Child, value: 'Child (6-11)' }, { key: ages.Youth, value: 'Youth (12-14)' }, { key: ages.Youth, value: 'Youth (15-25)' }, { key: ages.Adult, value: 'Adult (26-59)' }, { key: ages.Youth, value: 'Senior (60+)' }];
10794
+ this.irlCriteria = [IrlSearchCriteria.Depart, IrlSearchCriteria.Arrive];
10352
10795
  this.travelCards = [
10353
10796
  { display: 'Young persons railcard', value: 'YNG' },
10354
10797
  { display: 'Disability railcard', value: 'DIS' },
@@ -10377,22 +10820,6 @@ class IRLEnterpriseSearch extends BaseEnterpriseSearch {
10377
10820
  this._children = 0;
10378
10821
  this._returnDepartureDateTime = null;
10379
10822
  this._ageRange = null;
10380
- // get outboundCriteria(): IrlSearchCriteria {
10381
- // return this.tempParams.outboundCriteria;
10382
- // }
10383
- // set outboundCriteria(newCrit: IrlSearchCriteria) {
10384
- // // console.warn(`+++ Setting New Criteria: ${newCrit} +++`);
10385
- // this.tempParams.outboundCriteria = newCrit;
10386
- // this._isValid();
10387
- // }
10388
- // ! might not need this?
10389
- // get inBoundDateTime(): moment.Moment {
10390
- // return this.tempParams.inBoundDateTime;
10391
- // }
10392
- // set inBoundDateTime(newDateTime: moment.Moment) {
10393
- // this.tempParams.inBoundDateTime = moment(newDateTime);
10394
- // this._isValid();
10395
- // }
10396
10823
  // !date and time is handled differently for LU
10397
10824
  this._outbound_date = null;
10398
10825
  this._outbound_time = null;
@@ -10401,7 +10828,7 @@ class IRLEnterpriseSearch extends BaseEnterpriseSearch {
10401
10828
  this._cheapestStandard = null;
10402
10829
  this._cheapestFirst = null;
10403
10830
  this._irlClass = null;
10404
- this._journeytype = null;
10831
+ this._journeytype = IrlJourneyType.SingleJourney;
10405
10832
  const data = storageService.getSessionItem(IRLEnterpriseSearch.STORAGE_SESSION_PARAMS) || {
10406
10833
  query: {},
10407
10834
  tempParams: {},
@@ -10412,7 +10839,10 @@ class IRLEnterpriseSearch extends BaseEnterpriseSearch {
10412
10839
  if (searchService.shouldAddTravellerSubscription()) {
10413
10840
  searchService.travellerInformation.subscribe((travellers) => {
10414
10841
  this.travellers = travellers;
10415
- const splitTravellers = this.helpers.selectedTravellers(travellers, ServiceType.Rail);
10842
+ if (this.travellers[0] && !this.travellers[0].ageType) {
10843
+ this.travellers[0].ageType = ages.Adult;
10844
+ }
10845
+ const splitTravellers = this.helpers.selectedTravellers(travellers, ServiceType.InternationalRail);
10416
10846
  this.tempParams.adults = splitTravellers.adults.length;
10417
10847
  this.tempParams.children = splitTravellers.children.length;
10418
10848
  this.travellers = travellers;
@@ -10510,6 +10940,7 @@ class IRLEnterpriseSearch extends BaseEnterpriseSearch {
10510
10940
  this._travellingFrom = '';
10511
10941
  if ((_a = tt === null || tt === void 0 ? void 0 : tt.railstation) === null || _a === void 0 ? void 0 : _a.id) {
10512
10942
  this._travellingFrom = tt.railstation.id;
10943
+ this.supplier = tt.railstation.supplier;
10513
10944
  }
10514
10945
  this._isValid();
10515
10946
  }
@@ -10534,8 +10965,13 @@ class IRLEnterpriseSearch extends BaseEnterpriseSearch {
10534
10965
  get outboundDepartureDateTime() {
10535
10966
  return this._outboundDepartureDateTime;
10536
10967
  }
10537
- set outboundDepartureDateTime(data) {
10538
- this._outboundDepartureDateTime = data;
10968
+ set outboundDepartureDateTime(newDateTime) {
10969
+ this._outboundDepartureDateTime = newDateTime;
10970
+ this._outbound_date = this.helpers.momentToNgDate(newDateTime);
10971
+ this._outbound_time = moment(newDateTime).format('HHmm')
10972
+ ? moment(newDateTime).format('HHmm')
10973
+ : '0700';
10974
+ this._updateOutboundDateTime();
10539
10975
  }
10540
10976
  get departureLocationId() {
10541
10977
  return this._departureLocationId;
@@ -10564,8 +11000,13 @@ class IRLEnterpriseSearch extends BaseEnterpriseSearch {
10564
11000
  get returnDepartureDateTime() {
10565
11001
  return this._returnDepartureDateTime;
10566
11002
  }
10567
- set returnDepartureDateTime(data) {
10568
- this._returnDepartureDateTime = data;
11003
+ set returnDepartureDateTime(newDateTime) {
11004
+ this._returnDepartureDateTime = newDateTime;
11005
+ this._return_date = this.helpers.momentToNgDate(newDateTime);
11006
+ this._return_time = moment(newDateTime).format('HHmm')
11007
+ ? moment(newDateTime).format('HHmm')
11008
+ : '0700';
11009
+ this._updateReturnDateTime();
10569
11010
  }
10570
11011
  get ageRange() {
10571
11012
  return this._ageRange;
@@ -10593,13 +11034,38 @@ class IRLEnterpriseSearch extends BaseEnterpriseSearch {
10593
11034
  month: newDateTime.month() + 1,
10594
11035
  day: newDateTime.date()
10595
11036
  };
10596
- // if (
10597
- // this.outBoundDateTime &&
10598
- // // this.inBoundDateTime &&
10599
- // this.outBoundDateTime.isAfter(this.inBoundDateTime)
10600
- // ) {
10601
- // this.inBoundDateTime = this.outBoundDateTime.clone().add(1, 'day');
10602
- // }
11037
+ if (newDateTime && newDateTime.isValid()) {
11038
+ this._outbound_date = this.helpers.momentToNgDate(newDateTime);
11039
+ this._outbound_time = moment(newDateTime).format('HHmm')
11040
+ ? moment(newDateTime).format('HHmm')
11041
+ : '0700';
11042
+ }
11043
+ if (this.outBoundDateTime &&
11044
+ this.inBoundDateTime &&
11045
+ this.outBoundDateTime.isAfter(this.inBoundDateTime)) {
11046
+ this.inBoundDateTime = this.outBoundDateTime.clone().add(1, 'day');
11047
+ }
11048
+ this._isValid();
11049
+ }
11050
+ get outboundCriteria() {
11051
+ return this.tempParams.outboundCriteria;
11052
+ }
11053
+ set outboundCriteria(newCrit) {
11054
+ // console.warn(`+++ Setting New Criteria: ${newCrit} +++`);
11055
+ this.tempParams.outboundCriteria = newCrit;
11056
+ this._isValid();
11057
+ }
11058
+ get inBoundDateTime() {
11059
+ return this.tempParams.returnDepartureDateTime;
11060
+ }
11061
+ set inBoundDateTime(newDateTime) {
11062
+ this.tempParams.returnDepartureDateTime = newDateTime;
11063
+ if (newDateTime && newDateTime.isValid()) {
11064
+ this._return_date = this.helpers.momentToNgDate(newDateTime);
11065
+ this._return_time = moment(newDateTime).format('HHmm')
11066
+ ? moment(newDateTime).format('HHmm')
11067
+ : '1600';
11068
+ }
10603
11069
  this._isValid();
10604
11070
  }
10605
11071
  get outbound_date() {
@@ -10630,13 +11096,13 @@ class IRLEnterpriseSearch extends BaseEnterpriseSearch {
10630
11096
  this._return_time = value;
10631
11097
  this._updateReturnDateTime();
10632
11098
  }
10633
- // get returnCriteria(): IrlSearchCriteria {
10634
- // return this.tempParams.returnCriteria;
10635
- // }
10636
- // set returnCriteria(newCrit: IrlSearchCriteria) {
10637
- // this.tempParams.returnCriteria = newCrit;
10638
- // this._isValid();
10639
- // }
11099
+ get returnCriteria() {
11100
+ return this.tempParams.returnCriteria;
11101
+ }
11102
+ set returnCriteria(newCrit) {
11103
+ this.tempParams.returnCriteria = newCrit;
11104
+ this._isValid();
11105
+ }
10640
11106
  // set railCards(newRailCards: string[]) {
10641
11107
  // this.tempParams.railCards = newRailCards;
10642
11108
  // this._isValid();
@@ -10769,11 +11235,14 @@ class IRLEnterpriseSearch extends BaseEnterpriseSearch {
10769
11235
  _updateReturnDateTime() {
10770
11236
  if (this._return_date && this._return_time) {
10771
11237
  const time = this.helpers.ngDateToMoment(this._return_date, this._return_time);
10772
- // this.inBoundDateTime = time.isValid() ? time : null;
11238
+ this.inBoundDateTime = time.isValid() ? time : null;
10773
11239
  this._isValid();
10774
11240
  }
10775
11241
  }
10776
11242
  getSearchQuery() {
11243
+ // this.travellers = travellers;
11244
+ this.noOfAdults = this.travellers.filter((traveller) => traveller.ageType === ages.Adult || traveller.ageType === ages.Youth || traveller.ageType === ages.Senior).length;
11245
+ this.noOfChildren = this.travellers.filter((traveller) => traveller.ageType === ages.Child).length;
10777
11246
  const query = {
10778
11247
  supplier: this.supplier,
10779
11248
  countryCode: 'GB',
@@ -10785,14 +11254,14 @@ class IRLEnterpriseSearch extends BaseEnterpriseSearch {
10785
11254
  adults: this.tempParams.adults,
10786
11255
  children: this.tempParams.children,
10787
11256
  returnDepartureDateTime: this.tempParams.returnDepartureDateTime,
10788
- journeyType: this.tempParams.journeyType,
11257
+ journeyType: this.journeyType,
10789
11258
  };
10790
11259
  if (this.tempParams.children === 0) {
10791
11260
  query.children = null;
10792
11261
  }
10793
11262
  // switch (this.tempParams.outboundCriteria) {
10794
11263
  // case IrlSearchCriteria.Depart:
10795
- // query.outboundArrivalDateTime = null;
11264
+ // query.outboundDepartureDateTime = null;
10796
11265
  // break;
10797
11266
  // case IrlSearchCriteria.Arrive:
10798
11267
  // query.outboundDepartureDateTime = null;
@@ -10804,7 +11273,7 @@ class IRLEnterpriseSearch extends BaseEnterpriseSearch {
10804
11273
  // }
10805
11274
  // switch (this.tempParams.returnCriteria) {
10806
11275
  // case IrlSearchCriteria.Depart:
10807
- // query.returnArrivalDateTime = null;
11276
+ // query.returnDepartureDateTime = null;
10808
11277
  // break;
10809
11278
  // case IrlSearchCriteria.Arrive:
10810
11279
  // query.returnDepartureDateTime = null;
@@ -11205,78 +11674,85 @@ class IRLEnterpriseSearch extends BaseEnterpriseSearch {
11205
11674
  }
11206
11675
  return legs;
11207
11676
  }
11208
- // async addSingleJourneyToBasket(
11209
- // serviceId: string,
11210
- // railQuery: SearchRailQueryVariables,
11211
- // railJourneyOption: RailJourneyOption,
11212
- // railTicketGroup: RailTicketGroup
11213
- // ): Promise<boolean> {
11214
- // if (railJourneyOption.unsellable) {
11215
- // return Promise.resolve(false);
11216
- // }
11217
- // const intBasket: InternalBasketInterface =
11218
- // await this.basketService.getDefaultBasket();
11219
- // const basket = intBasket?.subject.value;
11220
- // if (basket) {
11221
- // const selectedRailTicketOption = this.getSelectedRailTicketOption(
11222
- // railJourneyOption,
11223
- // railTicketGroup,
11224
- // 0
11225
- // );
11226
- // const legs = this.getLegsFromRailJourneyOption(railJourneyOption);
11227
- // const ticketQueueList = selectedRailTicketOption.ticketQueueList.map(
11228
- // (ticketQueueList) => {
11229
- // return {
11230
- // id: ticketQueueList.id,
11231
- // name: ticketQueueList.name,
11232
- // type: ticketQueueList.type
11233
- // };
11234
- // }
11235
- // );
11236
- // return this.basketService.addToBasket(
11237
- // {
11238
- // basket: basket.id,
11239
- // service: serviceId,
11240
- // detail: {
11241
- // outwardDetail: {
11242
- // arrivalDateTime: railJourneyOption.arriveDateTime,
11243
- // arrivalStationName: railJourneyOption.to,
11244
- // departureDateTime: railJourneyOption.departDateTime,
11245
- // departureStationName: railJourneyOption.from,
11246
- // supplierTickets: [
11247
- // {
11248
- // supplierName: railJourneyOption.providers[0].name,
11249
- // ticketDescription: selectedRailTicketOption.type,
11250
- // price: selectedRailTicketOption.price,
11251
- // legs
11252
- // }
11253
- // ]
11254
- // },
11255
- // transactionIdentifier:
11256
- // railJourneyOption.identifiers.transactionIdentifier,
11257
- // outbound: {
11258
- // fareIdentifiers: [
11259
- // selectedRailTicketOption.identifiers.fareIdentifier
11260
- // ],
11261
- // journeyIdentifier:
11262
- // selectedRailTicketOption.identifiers.journeyIdentifier
11263
- // },
11264
- // ticketQueueList
11265
- // },
11266
- // adults: railQuery.adults,
11267
- // price: selectedRailTicketOption.price,
11268
- // currency: selectedRailTicketOption.currency as CurrencyCode,
11269
- // searchQuery: railQuery,
11270
- // co2PerItem: railJourneyOption.co2PerItem,
11271
- // co2PerPassenger: railJourneyOption.co2PerPassenger
11272
- // },
11273
- // intBasket,
11274
- // this.searchService,
11275
- // this.travellers
11276
- // );
11277
- // }
11278
- // return Promise.resolve(false);
11279
- // }
11677
+ addSingleJourneyToBasket(serviceId, railQuery, irlJourneyOption) {
11678
+ return __awaiter(this, void 0, void 0, function* () {
11679
+ console.log(serviceId, railQuery, irlJourneyOption);
11680
+ // if (irlJourneyOption.unsellable) {
11681
+ // return Promise.resolve(false);
11682
+ // }
11683
+ const intBasket = yield this.basketService.getDefaultBasket();
11684
+ const basket = intBasket === null || intBasket === void 0 ? void 0 : intBasket.subject.value;
11685
+ if (basket) {
11686
+ // const selectedIrlTicketOption = this.getSelectedIrlTicketOption(
11687
+ // irlJourneyOption,
11688
+ // railTicketGroup,
11689
+ // 0
11690
+ // );
11691
+ // const legs = this.getLegsFromRailJourneyOption(railJourneyOption);
11692
+ // const ticketQueueList = selectedIrlTicketOption.ticketQueueList.map(
11693
+ // (ticketQueueList) => {
11694
+ // return {
11695
+ // id: ticketQueueList.id,
11696
+ // name: ticketQueueList.name,
11697
+ // type: ticketQueueList.type
11698
+ // };
11699
+ // }
11700
+ // );
11701
+ // const basketItem = {
11702
+ // basket: basket.id,
11703
+ // service: serviceId,
11704
+ // detail: {
11705
+ // // accountsList: irlJourneyOption.accountsList.map(
11706
+ // // (account: RailAccount) => {
11707
+ // // return { id: account.id, description: account.description };
11708
+ // // }
11709
+ // // ),
11710
+ // outwardDetail: {
11711
+ // arrivalDateTime: railJourneyOption.arriveDateTime,
11712
+ // arrivalStationName: railJourneyOption.to,
11713
+ // departureDateTime: railJourneyOption.departDateTime,
11714
+ // departureStationName: railJourneyOption.from,
11715
+ // supplierTickets: [
11716
+ // {
11717
+ // supplierName: railJourneyOption.providers[0].name,
11718
+ // ticketDescription: selectedRailTicketOption.type,
11719
+ // price: selectedRailTicketOption.price,
11720
+ // legs
11721
+ // }
11722
+ // ]
11723
+ // },
11724
+ // transactionIdentifier:
11725
+ // railJourneyOption.identifiers.transactionIdentifier,
11726
+ // outbound: {
11727
+ // fareIdentifiers: [
11728
+ // selectedRailTicketOption.identifiers.fareIdentifier
11729
+ // ],
11730
+ // journeyIdentifier: selectedRailTicketOption.identifiers.journeyIdentifier
11731
+ // },
11732
+ // ticketQueueList
11733
+ // },
11734
+ // adults: railQuery.adults,
11735
+ // price: selectedRailTicketOption.price,
11736
+ // currency: selectedRailTicketOption.currency as CurrencyCode,
11737
+ // searchQuery: railQuery,
11738
+ // // co2PerItem: irlJourneyOption.co2PerItem,
11739
+ // // co2PerPassenger: irlJourneyOption.co2PerPassenger,
11740
+ // outboundDate: irlJourneyOption.
11741
+ // }
11742
+ // // if outTicketExtras exists add the object to basketItem
11743
+ // if (outTicketExtras) {
11744
+ // basketItem.detail.outbound.ticketExtras = outTicketExtras;
11745
+ // }
11746
+ // return this.basketService.addToBasket(
11747
+ // basketItem,
11748
+ // intBasket,
11749
+ // this.searchService,
11750
+ // this.travellers
11751
+ // );
11752
+ }
11753
+ return Promise.resolve(false);
11754
+ });
11755
+ }
11280
11756
  // async addReturnJourneyToBasket(
11281
11757
  // serviceId: string,
11282
11758
  // railQuery: SearchRailQueryVariables,
@@ -11890,7 +12366,7 @@ class BaseIrlQuoteFetcher extends FetchableList {
11890
12366
  }
11891
12367
  getDataFromResult(results) {
11892
12368
  var _a, _b;
11893
- return (_b = (_a = results === null || results === void 0 ? void 0 : results.data) === null || _a === void 0 ? void 0 : _a.searchIrl) === null || _b === void 0 ? void 0 : _b.results;
12369
+ return (_b = (_a = results === null || results === void 0 ? void 0 : results.data) === null || _a === void 0 ? void 0 : _a.searchIRL) === null || _b === void 0 ? void 0 : _b.results;
11894
12370
  }
11895
12371
  }
11896
12372
 
@@ -12051,6 +12527,16 @@ class BaseConfermaOfficeNamesFetcher extends FetchableList {
12051
12527
  }
12052
12528
  }
12053
12529
 
12530
+ class BaseConfermaOfficeFetcher extends FetchableObject {
12531
+ constructor(getUserAddressGQL, modalService) {
12532
+ super(getUserAddressGQL, modalService);
12533
+ }
12534
+ getDataFromResult(results) {
12535
+ var _a;
12536
+ return (_a = results === null || results === void 0 ? void 0 : results.data) === null || _a === void 0 ? void 0 : _a.getConfermaOffice;
12537
+ }
12538
+ }
12539
+
12054
12540
  class BaseGetUserCurrentCarbonAllowanceFetcher extends FetchableList {
12055
12541
  constructor(getUserBasketsGQL, helpers, modalService) {
12056
12542
  super(getUserBasketsGQL, helpers, modalService);
@@ -12100,6 +12586,18 @@ class BaseEurostarQuoteFetcher extends FetchableList {
12100
12586
  }
12101
12587
  }
12102
12588
 
12589
+ class BaseSearchIrlStationsFetcher extends FetchableList {
12590
+ constructor(gql, helpers, modalService) {
12591
+ super(gql, helpers, modalService);
12592
+ }
12593
+ getDataFromResult(results) {
12594
+ var _a;
12595
+ return (_a = results === null || results === void 0 ? void 0 : results.data) === null || _a === void 0 ? void 0 : _a.searchIRLSupplierStations;
12596
+ }
12597
+ }
12598
+
12599
+ // | 'fareTypes';
12600
+
12103
12601
  /**
12104
12602
  * @desc Known reg expresions
12105
12603
  */
@@ -12183,44 +12681,6 @@ class AuthInfo {
12183
12681
  }
12184
12682
  }
12185
12683
 
12186
- // @dynamic
12187
- class TravellerObject {
12188
- static hasItem(item) {
12189
- return !!item;
12190
- }
12191
- static fullname(traveller) {
12192
- return [traveller.title, traveller.forename, traveller.surname].filter(this.hasItem).join(' ');
12193
- }
12194
- static makeTravellerObjectFromUser(user) {
12195
- return {
12196
- id: user.user_id.toString(),
12197
- forename: user.forename,
12198
- surname: user.surname,
12199
- email: user.username,
12200
- title: user.title,
12201
- isChild: false,
12202
- isInfant: false,
12203
- childDOB: null,
12204
- guest: false,
12205
- name: user.surname + ' ' + user.forename
12206
- };
12207
- }
12208
- static equals(first, second) {
12209
- return first.email === second.email;
12210
- }
12211
- static compare(first, second) {
12212
- const name1 = TravellerObject.fullname(first);
12213
- const name2 = TravellerObject.fullname(second);
12214
- if (name1 === name2) {
12215
- return 0;
12216
- }
12217
- if (name1 < name2) {
12218
- return -1;
12219
- }
12220
- return 1;
12221
- }
12222
- }
12223
-
12224
12684
  const TEMPID = 'TEMPID_';
12225
12685
  class InternalBasket {
12226
12686
  constructor(basket, helpers, basketService, getUserFetcher) {
@@ -12635,6 +13095,7 @@ class BaseEnterpriseBasketService {
12635
13095
  const validateSearchSchema = ajv.compile(serviceToCheck.searchQuerySchema);
12636
13096
  // if there are any moment date objects in the searchQuery object convert these to date-time strings
12637
13097
  item.searchQuery = this.helpers.sanitizeMomentDates(item.searchQuery);
13098
+ item.detail = this.helpers.removeNulls(item.detail);
12638
13099
  if (!validateSearchSchema(item.searchQuery)) {
12639
13100
  const error = `Item searchQuery is not valid for ${serviceToCheck.name} search schema.`;
12640
13101
  console.warn('searchSchema', serviceToCheck.searchQuerySchema);
@@ -12823,7 +13284,7 @@ class BaseEnterpriseBasketService {
12823
13284
  });
12824
13285
  }
12825
13286
  sendBasketForApproval(basketid) {
12826
- this.updateBasket(basketid, this.sendBasketForApprovalUpdater
13287
+ return this.updateBasket(basketid, this.sendBasketForApprovalUpdater
12827
13288
  .updateOne({ basket: basketid })
12828
13289
  .pipe(take(1)));
12829
13290
  }
@@ -14841,7 +15302,7 @@ var TravellerSearchTypes;
14841
15302
  TravellerSearchTypes["employeeNumber"] = "employeeNumber";
14842
15303
  })(TravellerSearchTypes || (TravellerSearchTypes = {}));
14843
15304
  class BaseEnterpriseSearchService {
14844
- constructor(searchAirportsFetcher, searchAirlinesFetcher, storageService, userService, router, helpers, hotelAvalibilityService, citiesFetcher, confermaCitiesFetcher, postcodeFetcher, railStationFetcher, saveUserAddressUpdater, userAddressesFetcher, basketService, getUserCompanyOfficesFetcher, searchHotelChainsFetcher, baseValidateIsPostcodeValidTester, depotFetcher, confermaOfficeNamesFetcher, baseDeleteUserAddressUpdater, baseDeleteRecentSearchUpdater, baseSaveRecentSearchUpdater, getUserCurrentCarbonAllowanceFetcher, environment, loungeFetcher, parkingFetcher, httpCallService, flightFetcher, hotelFetcher, carhireFetcher, carHireAvailabilityDetailFetcher, cabhireFetcher, railFetcher, irlFetcher, getRailStationFetcher, baseWebTokenService, riskAlertsFetcher, quicklistFetcher, getUserRecentSearchesFetcher, getRailCardsFetcher, eurostarFetcher, searchUsersCanBookForFetcher) {
15305
+ constructor(searchAirportsFetcher, searchAirlinesFetcher, storageService, userService, router, helpers, hotelAvalibilityService, citiesFetcher, confermaCitiesFetcher, postcodeFetcher, railStationFetcher, saveUserAddressUpdater, userAddressesFetcher, basketService, getUserCompanyOfficesFetcher, searchHotelChainsFetcher, baseValidateIsPostcodeValidTester, depotFetcher, confermaOfficeNamesFetcher, confermaOfficeFetcher, baseDeleteUserAddressUpdater, baseDeleteRecentSearchUpdater, baseSaveRecentSearchUpdater, getUserCurrentCarbonAllowanceFetcher, environment, loungeFetcher, parkingFetcher, httpCallService, flightFetcher, hotelFetcher, carhireFetcher, carHireAvailabilityDetailFetcher, cabhireFetcher, railFetcher, irlFetcher, getRailStationFetcher, baseWebTokenService, riskAlertsFetcher, quicklistFetcher, getUserRecentSearchesFetcher, getRailCardsFetcher, eurostarFetcher, searchUsersCanBookForFetcher, searchIrlStationsFetcher) {
14845
15306
  this.searchAirportsFetcher = searchAirportsFetcher;
14846
15307
  this.searchAirlinesFetcher = searchAirlinesFetcher;
14847
15308
  this.storageService = storageService;
@@ -14861,6 +15322,7 @@ class BaseEnterpriseSearchService {
14861
15322
  this.baseValidateIsPostcodeValidTester = baseValidateIsPostcodeValidTester;
14862
15323
  this.depotFetcher = depotFetcher;
14863
15324
  this.confermaOfficeNamesFetcher = confermaOfficeNamesFetcher;
15325
+ this.confermaOfficeFetcher = confermaOfficeFetcher;
14864
15326
  this.baseDeleteUserAddressUpdater = baseDeleteUserAddressUpdater;
14865
15327
  this.baseDeleteRecentSearchUpdater = baseDeleteRecentSearchUpdater;
14866
15328
  this.baseSaveRecentSearchUpdater = baseSaveRecentSearchUpdater;
@@ -14871,6 +15333,7 @@ class BaseEnterpriseSearchService {
14871
15333
  this.getUserRecentSearchesFetcher = getUserRecentSearchesFetcher;
14872
15334
  this.getRailCardsFetcher = getRailCardsFetcher;
14873
15335
  this.searchUsersCanBookForFetcher = searchUsersCanBookForFetcher;
15336
+ this.searchIrlStationsFetcher = searchIrlStationsFetcher;
14874
15337
  this.traveller_error = false;
14875
15338
  this.travellerInformation = new BehaviorSubject([]);
14876
15339
  this.errors = new BehaviorSubject([]);
@@ -14895,9 +15358,7 @@ class BaseEnterpriseSearchService {
14895
15358
  [ServiceType.Hotel]: new HotelEnterpriseSearch(hotelFetcher, helpers, userService, environment, hotelAvalibilityService, basketService, storageService, this, httpCallService, quicklistFetcher, getRailStationFetcher),
14896
15359
  [ServiceType.Car]: new CarhireEnterpriseSearch(carhireFetcher, carHireAvailabilityDetailFetcher, helpers, basketService, storageService, this),
14897
15360
  [ServiceType.Cab]: new CabHireEnterpriseSearch(cabhireFetcher, helpers, storageService, this, basketService),
14898
- [ServiceType.InternationalRail]: new IRLEnterpriseSearch(irlFetcher,
14899
- // getRailStationFetcher,
14900
- helpers, basketService, storageService, this),
15361
+ [ServiceType.InternationalRail]: new IRLEnterpriseSearch(irlFetcher, searchIrlStationsFetcher, helpers, basketService, storageService, this),
14901
15362
  [ServiceType.FastTrack]: null,
14902
15363
  [ServiceType.Coach]: null,
14903
15364
  [ServiceType.Rail]: new RailEnterpriseSearch(railFetcher, getRailStationFetcher, helpers, basketService, storageService, this),
@@ -15153,6 +15614,23 @@ class BaseEnterpriseSearchService {
15153
15614
  getSelectedPlaceById(placeId) {
15154
15615
  return this.selectedPlaces.find((place) => place.place_id === placeId);
15155
15616
  }
15617
+ getConfirmaOffices(term) {
15618
+ if ((term === null || term === void 0 ? void 0 : term.length) > 2) {
15619
+ const obs = this.confermaOfficeNamesFetcher.fetchList();
15620
+ const func = (results) => {
15621
+ const data = results.results.map((result) => {
15622
+ return {
15623
+ name: result.name,
15624
+ type: LocationTypes.Office,
15625
+ id: result.id
15626
+ };
15627
+ });
15628
+ return data;
15629
+ };
15630
+ return obs.pipe(take(1), map(func));
15631
+ }
15632
+ return of([]);
15633
+ }
15156
15634
  /*
15157
15635
  * @description - get the list of Office locations based on search term given
15158
15636
  * @todo - fill this out so that it actually performs a http call
@@ -15200,6 +15678,31 @@ class BaseEnterpriseSearchService {
15200
15678
  return of([]);
15201
15679
  }
15202
15680
  }
15681
+ searchIrlStationsLocations(term, isLoading) {
15682
+ if (term.length > 2) {
15683
+ isLoading === null || isLoading === void 0 ? void 0 : isLoading.next(true);
15684
+ return this.searchIrlStationsFetcher
15685
+ .fetchList({
15686
+ query: term
15687
+ })
15688
+ .pipe(take(1), map((results) => {
15689
+ if (isLoading) {
15690
+ isLoading.next(false);
15691
+ }
15692
+ return results
15693
+ .map((result) => {
15694
+ return {
15695
+ type: LocationTypes.TrainStation,
15696
+ name: `${result.name} (${result.supplier})`,
15697
+ railstation: result
15698
+ };
15699
+ });
15700
+ }));
15701
+ }
15702
+ else {
15703
+ return of([]);
15704
+ }
15705
+ }
15203
15706
  /**
15204
15707
  * @description - get hotel locations, these should be city, office, airport, railstation
15205
15708
  * @todo - fill this out for the other location types, may need to mergeMap them or some other rxjs magic
@@ -15218,7 +15721,7 @@ class BaseEnterpriseSearchService {
15218
15721
  this.getAirportLocations(term, countryCode, isLoading),
15219
15722
  this.getCityLocations(term, countryCode, isLoading),
15220
15723
  this.getStationLocations(term, isLoading),
15221
- this.getOfficeLocations(term)
15724
+ this.getConfirmaOffices(term)
15222
15725
  ]).pipe(map((results) => {
15223
15726
  if (isLoading === null || isLoading === void 0 ? void 0 : isLoading.value) {
15224
15727
  isLoading.next(false);
@@ -15649,6 +16152,18 @@ class BaseEnterpriseSearchService {
15649
16152
  }));
15650
16153
  isLoading === null || isLoading === void 0 ? void 0 : isLoading.next(false);
15651
16154
  }
16155
+ getOffice(officeId) {
16156
+ if (officeId) {
16157
+ return this.confermaOfficeFetcher.fetchOne({ officeId }).pipe(take(1), map((results) => {
16158
+ if (results) {
16159
+ return results.results;
16160
+ }
16161
+ }));
16162
+ }
16163
+ else {
16164
+ return of();
16165
+ }
16166
+ }
15652
16167
  getRailCards() {
15653
16168
  return this.getRailCardsFetcher.fetchList().pipe(take(1), map((results) => {
15654
16169
  if (results) {
@@ -15934,23 +16449,24 @@ class BaseEnterpriseSearchService {
15934
16449
  }
15935
16450
  /*
15936
16451
  * Creates a Rail search query with supplied params, auto fills with defaults if fields are empty.
15937
- * @param {any} ...args Example - searchService.makeRailQuery(data.query, { override: "property" })
16452
+ * @param {any} ...args Example - searchService.makeIrlQuery(data.query, { override: "property" })
15938
16453
  * @return {QuerySearchRailArgs} Returns QuerySearchRailArgs type
15939
16454
  */
15940
16455
  makeIrlQuery(...args) {
15941
16456
  const time = this.helpers.momentRoundMinutes(moment(), 30);
15942
16457
  const defaultVal = {
16458
+ returnCriteria: IrlSearchCriteria.Depart,
16459
+ outboundCriteria: IrlSearchCriteria.Depart,
15943
16460
  supplier: null,
15944
16461
  countryCode: '',
15945
- // journeyType: this.journeyType, // IRLJourneyType!
16462
+ journeyType: IrlJourneyType.ReturnJourney,
15946
16463
  class: null,
15947
16464
  outboundDepartureDateTime: time,
15948
16465
  departureLocationId: null,
15949
16466
  arrivalLocationId: null,
15950
16467
  adults: 0,
15951
16468
  children: 0,
15952
- returnDepartureDateTime: time,
15953
- journeyType: null
16469
+ returnDepartureDateTime: time
15954
16470
  };
15955
16471
  return this.helpers.sanatizeReturns(defaultVal, Object.assign({}, ...args), ['returnDepartureDateTime', 'outboundDepartureDateTime']);
15956
16472
  }
@@ -16569,5 +17085,5 @@ class BaseSetPaymentOptionUpdater extends UpdateableObject {
16569
17085
  * Generated bundle index. Do not edit.
16570
17086
  */
16571
17087
 
16572
- export { AbstractHttpCallService, ActionType, AddressImpl, AirportSearchMode, AuthInfo, BaseAcceptNewPriceUpdater, BaseAddItemToBasketUpdater, BaseAddUserToBasketItemUpdater, BaseBookBasketUpdater, BaseCabhireQuoteFetcher, BaseCarHireAvailabilityDetailFetcher, BaseCarhireQuoteFetcher, BaseConfermaOfficeNamesFetcher, BaseCreateBasketUpdater, BaseDeleteBasketUpdater, BaseDeleteRecentSearchUpdater, BaseDeleteUserAddressUpdater, BaseEnterpriseBasketService, BaseEnterpriseMyBookingsService, BaseEnterpriseSearch, BaseEnterpriseSearchService, BaseEnvironment, BaseEurostarQuoteFetcher, BaseEventMessenager, BaseFlightQuoteFetcher, BaseGetBasketFetcher, BaseGetMiAutoSugestionFetcher, BaseGetRailStationFetcher, BaseGetRailcardsFetcher, BaseGetRiskAlertsFetcher, BaseGetUserBasketsFetcher, BaseGetUserCompanyOfficesFetcher, BaseGetUserCurrentCarbonAllowanceFetcher, BaseGetUserFetcher, BaseGetUserRecentSearchesFetcher, BaseHelperRoutines, BaseHotelAvalibilityQuoteFetcher, BaseHotelAvalibilityService, BaseHotelQuoteFetcher, BaseIrlQuoteFetcher, BaseLogonService, BaseLoungeQuoteFetcher, BaseModalOpenerService, BaseNetworkCall, BaseParkingQuoteFetcher, BaseRailQuoteFetcher, BaseRemoveItemFromBasketUpdater, BaseRevalidateBasketUpdater, BaseRouteHappyService, BaseSaveRecentSearchUpdater, BaseSaveUserAddressUpdater, BaseSearchAirlinesFetcher, BaseSearchAirportsFetcher, BaseSearchCityFetcher, BaseSearchConfermaCityFetcher, BaseSearchConfermaQuicklistFetcher, BaseSearchDepotFetcher, BaseSearchHotelChainsFetcher, BaseSearchPostcodeFetcher, BaseSearchRailStationsFetcher, BaseSearchUsersCanBookForFetcher, BaseSendBasketForApprovalUpdater, BaseSetBasketItemLeadPassengerUpdater, BaseSetBasketItemMiGroupUpdater, BaseSetBasketItemMiValueUpdater, BaseSetPaymentOptionUpdater, BaseStorageService, BaseUpdateBasketNoteUpdater, BaseUpdateBasketTitleUpdater, BaseUserAddressesFetcher, BaseUserMessagesFetcher, BaseUserProductsFetcher, BaseUserService, BaseUserUiConfigsFetcher, BaseValidateIsPostcodeValidTester, BaseValidateMiFreeValueTester, BaseWebTokenService, BasemoveBasketItemToBasket, BasketInfoMiDetailsImpl, BookableBasket, BookingStatus, BreatfastTypes, CabHireEnterpriseSearch, CarhireEnterpriseSearch, EurostarClassEnum, EurostarEnterpriseSearch, EurostarSearchType, FlightDirectionEnum, FlightEnterpriseSearch, FlightSearchType, HotelEnterpriseSearch, HotelFilters, HotelPolicyEnum, HotelView, IRLEnterpriseSearch, IncludedType, InternalBasket, IrlSearchCriteria, LimitedCache, LocationTypes, LoginError, LoginErrorReason, LogoutEnum, LoungesEnterpriseSearch, MAX_TRAVELLERS, ManagementInfoAndIsValid, Memorise, MenuSlideEnum, ModalTypes, ParkingEnterpriseSearch, PhoneNumberImpl, RailDirection, RailEnterpriseSearch, RailSearchCriteria, RailTicketOptionType, RegExps, RiskLevelRanking, SchemaFormat, SearchHandler, ServiceProvider, SortMethod, SortTypes, SortTypesCar, SortTypesEurostar, SortTypesHotel, SupplementaryBookingInfoImpl, Suppliers, TaxiFormMode, TimeWindow, TravellerObject, TravellerSearchTypes, URLS, USER_SIGNEDIN, USER_SIGNEDOUT, UserFavorurite, UserInfoImpl, ValidatorChecker, Widgets, defaultValidations, excludedExpression, filtersKeys, includedExpression, makeManagamentInfo, ɵ0, FetchableList as ɵd, FetchableObject as ɵe, UpdateableObject as ɵf, BaseTester as ɵg };
17088
+ export { AbstractHttpCallService, ActionType, AddressImpl, AirportSearchMode, AuthInfo, BaseAcceptNewPriceUpdater, BaseAddItemToBasketUpdater, BaseAddUserToBasketItemUpdater, BaseBookBasketUpdater, BaseCabhireQuoteFetcher, BaseCarHireAvailabilityDetailFetcher, BaseCarhireQuoteFetcher, BaseConfermaOfficeFetcher, BaseConfermaOfficeNamesFetcher, BaseCreateBasketUpdater, BaseDeleteBasketUpdater, BaseDeleteRecentSearchUpdater, BaseDeleteUserAddressUpdater, BaseEnterpriseBasketService, BaseEnterpriseMyBookingsService, BaseEnterpriseSearch, BaseEnterpriseSearchService, BaseEnvironment, BaseEurostarQuoteFetcher, BaseEventMessenager, BaseFlightQuoteFetcher, BaseGetBasketFetcher, BaseGetMiAutoSugestionFetcher, BaseGetRailStationFetcher, BaseGetRailcardsFetcher, BaseGetRiskAlertsFetcher, BaseGetUserBasketsFetcher, BaseGetUserCompanyOfficesFetcher, BaseGetUserCurrentCarbonAllowanceFetcher, BaseGetUserFetcher, BaseGetUserRecentSearchesFetcher, BaseHelperRoutines, BaseHotelAvalibilityQuoteFetcher, BaseHotelAvalibilityService, BaseHotelQuoteFetcher, BaseIrlQuoteFetcher, BaseLogonService, BaseLoungeQuoteFetcher, BaseModalOpenerService, BaseNetworkCall, BaseParkingQuoteFetcher, BaseRailQuoteFetcher, BaseRemoveItemFromBasketUpdater, BaseRevalidateBasketUpdater, BaseRouteHappyService, BaseSaveRecentSearchUpdater, BaseSaveUserAddressUpdater, BaseSearchAirlinesFetcher, BaseSearchAirportsFetcher, BaseSearchCityFetcher, BaseSearchConfermaCityFetcher, BaseSearchConfermaQuicklistFetcher, BaseSearchDepotFetcher, BaseSearchHotelChainsFetcher, BaseSearchIrlStationsFetcher, BaseSearchPostcodeFetcher, BaseSearchRailStationsFetcher, BaseSearchUsersCanBookForFetcher, BaseSendBasketForApprovalUpdater, BaseSetBasketItemLeadPassengerUpdater, BaseSetBasketItemMiGroupUpdater, BaseSetBasketItemMiValueUpdater, BaseSetPaymentOptionUpdater, BaseStorageService, BaseUpdateBasketNoteUpdater, BaseUpdateBasketTitleUpdater, BaseUserAddressesFetcher, BaseUserMessagesFetcher, BaseUserProductsFetcher, BaseUserService, BaseUserUiConfigsFetcher, BaseValidateIsPostcodeValidTester, BaseValidateMiFreeValueTester, BaseWebTokenService, BasemoveBasketItemToBasket, BasketInfoMiDetailsImpl, BookableBasket, BookingStatus, BreatfastTypes, CabHireEnterpriseSearch, CarhireEnterpriseSearch, DEFAULT_FLIGHT_FILTERS, EurostarClassEnum, EurostarEnterpriseSearch, EurostarSearchType, FlightDirectionEnum, FlightEnterpriseSearch, FlightSearchType, FlightSortTypes, HotelEnterpriseSearch, HotelFilters, HotelPolicyEnum, HotelView, IRLEnterpriseSearch, IncludedType, InternalBasket, IrlSearchCriteria, LimitedCache, LocationTypes, LoginError, LoginErrorReason, LogoutEnum, LoungesEnterpriseSearch, MAX_TRAVELLERS, ManagementInfoAndIsValid, Memorise, MenuSlideEnum, ModalTypes, ParkingEnterpriseSearch, PhoneNumberImpl, RailDirection, RailEnterpriseSearch, RailSearchCriteria, RailTicketOptionType, RegExps, RiskLevelRanking, SchemaFormat, SearchHandler, ServiceProvider, SortMethod, SortTypesCar, SortTypesEurostar, SortTypesHotel, SupplementaryBookingInfoImpl, Suppliers, TaxiFormMode, TimeWindow, TravellerObject, TravellerSearchTypes, URLS, USER_SIGNEDIN, USER_SIGNEDOUT, UserFavorurite, UserInfoImpl, ValidatorChecker, Widgets, ages, defaultValidations, excludedExpression, filtersKeys, includedExpression, makeManagamentInfo, ɵ0, FetchableList as ɵd, FetchableObject as ɵe, UpdateableObject as ɵf, BaseTester as ɵg };
16573
17089
  //# sourceMappingURL=sabstravtech-obtservices-base.js.map