@qite/tide-booking-component 1.2.5 → 1.3.0

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 (141) hide show
  1. package/.vs/ProjectSettings.json +3 -3
  2. package/.vs/VSWorkspaceState.json +5 -5
  3. package/README.md +8 -8
  4. package/build/build-cjs/booking-wizard/components/print-offer-button.d.ts +17 -0
  5. package/build/build-cjs/booking-wizard/types.d.ts +7 -0
  6. package/build/build-cjs/booking-wizard/use-offer-printer.d.ts +13 -0
  7. package/build/build-cjs/index.js +223 -72
  8. package/build/build-cjs/shared/utils/localization-util.d.ts +5 -0
  9. package/build/build-cjs/shared/utils/tide-api-utils.d.ts +1 -0
  10. package/build/build-esm/booking-wizard/components/print-offer-button.d.ts +17 -0
  11. package/build/build-esm/booking-wizard/types.d.ts +7 -0
  12. package/build/build-esm/booking-wizard/use-offer-printer.d.ts +13 -0
  13. package/build/build-esm/index.js +224 -73
  14. package/build/build-esm/shared/utils/localization-util.d.ts +5 -0
  15. package/build/build-esm/shared/utils/tide-api-utils.d.ts +1 -0
  16. package/package.json +75 -75
  17. package/rollup.config.js +23 -23
  18. package/src/booking-product/components/age-select.tsx +35 -35
  19. package/src/booking-product/components/amount-input.tsx +78 -78
  20. package/src/booking-product/components/date-range-picker/calendar-day.tsx +58 -58
  21. package/src/booking-product/components/date-range-picker/calendar.tsx +178 -178
  22. package/src/booking-product/components/date-range-picker/index.tsx +196 -196
  23. package/src/booking-product/components/dates.tsx +136 -136
  24. package/src/booking-product/components/footer.tsx +69 -69
  25. package/src/booking-product/components/header.tsx +79 -79
  26. package/src/booking-product/components/icon.tsx +251 -251
  27. package/src/booking-product/components/product.tsx +314 -314
  28. package/src/booking-product/components/rating.tsx +21 -21
  29. package/src/booking-product/components/rooms.tsx +195 -195
  30. package/src/booking-product/index.tsx +30 -30
  31. package/src/booking-product/settings-context.ts +14 -14
  32. package/src/booking-product/types.ts +28 -28
  33. package/src/booking-product/utils/api.ts +25 -25
  34. package/src/booking-product/utils/price.ts +29 -29
  35. package/src/booking-wizard/api-settings-slice.ts +24 -24
  36. package/src/booking-wizard/components/icon.tsx +508 -508
  37. package/src/booking-wizard/components/labeled-input.tsx +64 -64
  38. package/src/booking-wizard/components/labeled-select.tsx +69 -69
  39. package/src/booking-wizard/components/message.tsx +34 -34
  40. package/src/booking-wizard/components/multi-range-filter.tsx +113 -113
  41. package/src/booking-wizard/components/print-offer-button.tsx +66 -0
  42. package/src/booking-wizard/components/product-card.tsx +37 -37
  43. package/src/booking-wizard/components/step-indicator.tsx +51 -51
  44. package/src/booking-wizard/components/step-route.tsx +27 -27
  45. package/src/booking-wizard/declarations.d.ts +4 -4
  46. package/src/booking-wizard/features/booking/api.ts +49 -49
  47. package/src/booking-wizard/features/booking/booking-self-contained.tsx +384 -384
  48. package/src/booking-wizard/features/booking/booking-slice.ts +662 -662
  49. package/src/booking-wizard/features/booking/booking.tsx +356 -356
  50. package/src/booking-wizard/features/booking/constants.ts +16 -16
  51. package/src/booking-wizard/features/booking/selectors.ts +441 -441
  52. package/src/booking-wizard/features/confirmation/confirmation.tsx +97 -97
  53. package/src/booking-wizard/features/error/error.tsx +78 -78
  54. package/src/booking-wizard/features/flight-options/flight-filter.tsx +432 -432
  55. package/src/booking-wizard/features/flight-options/flight-option-flight.tsx +385 -385
  56. package/src/booking-wizard/features/flight-options/flight-option-modal.tsx +229 -229
  57. package/src/booking-wizard/features/flight-options/flight-option.tsx +81 -81
  58. package/src/booking-wizard/features/flight-options/flight-utils.ts +516 -516
  59. package/src/booking-wizard/features/flight-options/index.tsx +196 -196
  60. package/src/booking-wizard/features/price-details/price-details-api.ts +24 -24
  61. package/src/booking-wizard/features/price-details/price-details-slice.ts +178 -178
  62. package/src/booking-wizard/features/price-details/util.ts +155 -155
  63. package/src/booking-wizard/features/product-options/no-options.tsx +21 -21
  64. package/src/booking-wizard/features/product-options/none-option.tsx +120 -120
  65. package/src/booking-wizard/features/product-options/option-booking-airline-group.tsx +64 -64
  66. package/src/booking-wizard/features/product-options/option-booking-group.tsx +216 -216
  67. package/src/booking-wizard/features/product-options/option-item.tsx +317 -317
  68. package/src/booking-wizard/features/product-options/option-pax-card.tsx +201 -201
  69. package/src/booking-wizard/features/product-options/option-pax-group.tsx +175 -175
  70. package/src/booking-wizard/features/product-options/option-room.tsx +321 -321
  71. package/src/booking-wizard/features/product-options/option-unit-group.tsx +198 -198
  72. package/src/booking-wizard/features/product-options/option-units-card.tsx +185 -185
  73. package/src/booking-wizard/features/product-options/options-form.tsx +563 -459
  74. package/src/booking-wizard/features/room-options/index.tsx +187 -187
  75. package/src/booking-wizard/features/room-options/room-utils.ts +190 -190
  76. package/src/booking-wizard/features/room-options/room.tsx +160 -160
  77. package/src/booking-wizard/features/room-options/traveler-rooms.tsx +75 -75
  78. package/src/booking-wizard/features/sidebar/index.tsx +76 -76
  79. package/src/booking-wizard/features/sidebar/sidebar-flight.tsx +68 -68
  80. package/src/booking-wizard/features/sidebar/sidebar-util.ts +177 -177
  81. package/src/booking-wizard/features/sidebar/sidebar.tsx +364 -364
  82. package/src/booking-wizard/features/summary/summary-booking-option-pax.tsx +25 -25
  83. package/src/booking-wizard/features/summary/summary-booking-option-unit.tsx +25 -25
  84. package/src/booking-wizard/features/summary/summary-flight.tsx +39 -39
  85. package/src/booking-wizard/features/summary/summary-per-booking-option-group.tsx +69 -69
  86. package/src/booking-wizard/features/summary/summary-per-pax-option-group.tsx +63 -63
  87. package/src/booking-wizard/features/summary/summary-per-unit-option-group.tsx +66 -66
  88. package/src/booking-wizard/features/summary/summary-slice.ts +28 -28
  89. package/src/booking-wizard/features/summary/summary.tsx +674 -674
  90. package/src/booking-wizard/features/travelers-form/travelers-form-slice.ts +164 -164
  91. package/src/booking-wizard/features/travelers-form/travelers-form.tsx +754 -754
  92. package/src/booking-wizard/features/travelers-form/type-ahead-input.tsx +101 -101
  93. package/src/booking-wizard/features/travelers-form/validate-form.ts +245 -245
  94. package/src/booking-wizard/index.tsx +36 -36
  95. package/src/booking-wizard/settings-context.ts +67 -60
  96. package/src/booking-wizard/store.ts +31 -31
  97. package/src/booking-wizard/types.ts +283 -276
  98. package/src/booking-wizard/use-offer-printer.ts +136 -0
  99. package/src/index.ts +4 -4
  100. package/src/shared/components/loader.tsx +16 -16
  101. package/src/shared/translations/en-GB.json +237 -232
  102. package/src/shared/translations/fr-BE.json +238 -233
  103. package/src/shared/translations/nl-BE.json +237 -232
  104. package/src/shared/types.ts +4 -4
  105. package/src/shared/utils/class-util.ts +9 -9
  106. package/src/shared/utils/localization-util.ts +62 -62
  107. package/src/shared/utils/query-string-util.ts +119 -119
  108. package/src/shared/utils/tide-api-utils.ts +36 -36
  109. package/styles/booking-product-variables.scss +394 -394
  110. package/styles/booking-product.scss +446 -446
  111. package/styles/booking-wizard-variables.scss +873 -871
  112. package/styles/booking-wizard.scss +59 -59
  113. package/styles/components/_animations.scss +39 -39
  114. package/styles/components/_base.scss +107 -107
  115. package/styles/components/_booking.scss +879 -879
  116. package/styles/components/_button.scss +238 -238
  117. package/styles/components/_checkbox.scss +219 -219
  118. package/styles/components/_cta.scss +208 -208
  119. package/styles/components/_date-list.scss +41 -41
  120. package/styles/components/_date-range-picker.scss +225 -225
  121. package/styles/components/_decrement-increment.scss +35 -35
  122. package/styles/components/_dropdown.scss +72 -72
  123. package/styles/components/_flight-option.scss +1429 -1429
  124. package/styles/components/_form.scss +1583 -1583
  125. package/styles/components/_info-message.scss +71 -71
  126. package/styles/components/_input.scss +25 -25
  127. package/styles/components/_list.scss +187 -187
  128. package/styles/components/_loader.scss +72 -72
  129. package/styles/components/_mixins.scss +550 -550
  130. package/styles/components/_placeholders.scss +166 -166
  131. package/styles/components/_pricing-summary.scss +155 -155
  132. package/styles/components/_qsm.scss +17 -17
  133. package/styles/components/_radiobutton.scss +170 -170
  134. package/styles/components/_select-wrapper.scss +80 -80
  135. package/styles/components/_spinner.scss +29 -29
  136. package/styles/components/_step-indicators.scss +168 -168
  137. package/styles/components/_table.scss +81 -81
  138. package/styles/components/_tree.scss +530 -530
  139. package/styles/components/_typeahead.scss +281 -281
  140. package/styles/components/_variables.scss +89 -89
  141. package/tsconfig.json +24 -24
@@ -2,29 +2,36 @@
2
2
  import { BookingPackageFlight } from "@qite/tide-client/build/types";
3
3
  export interface Settings {
4
4
  officeId: number;
5
+ token?: string;
5
6
  bookingOptions: BookingOptions;
6
7
  productPath: string;
7
8
  basePath: string;
8
9
  roomOptions: {
9
10
  isHidden?: boolean | null;
10
11
  pathSuffix?: string | null;
12
+ reportPrintActionId?: number | null;
11
13
  };
12
14
  flightOptions: {
13
15
  isHidden?: boolean | null;
14
16
  pathSuffix?: string | null;
17
+ reportPrintActionId?: number | null;
15
18
  };
16
19
  options: {
17
20
  pathSuffix: string;
21
+ reportPrintActionId?: number | null;
18
22
  };
19
23
  travellers: {
20
24
  pathSuffix: string;
25
+ reportPrintActionId?: number | null;
21
26
  };
22
27
  summary: {
23
28
  pathSuffix: string;
24
29
  checkboxes?: SummaryCheckbox[] | null;
30
+ reportPrintActionId?: number | null;
25
31
  };
26
32
  confirmation: {
27
33
  pathSuffix: string;
34
+ reportPrintActionId?: number | null;
28
35
  };
29
36
  error: {
30
37
  pathSuffix: string;
@@ -0,0 +1,13 @@
1
+ import type { BookingPackage, Pax } from "@qite/tide-client/build/types";
2
+ export interface UseOfferPrinterArgs {
3
+ bookingPackage?: BookingPackage;
4
+ getPax: () => Pax[] | undefined;
5
+ tagIds?: number[];
6
+ printActionId?: number | null;
7
+ onPrinted?: (pdfUrl: string) => void;
8
+ }
9
+ export declare function useOfferPrinter({ bookingPackage, getPax, tagIds, printActionId, onPrinted, }: UseOfferPrinterArgs): {
10
+ handlePrint: () => Promise<void>;
11
+ loading: boolean;
12
+ stage: "idle" | "creating" | "printing";
13
+ };
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable */
2
- import React, { useLayoutEffect as useLayoutEffect$1, useEffect, useContext, useState, useRef } from 'react';
2
+ import React, { useLayoutEffect as useLayoutEffect$1, useEffect, useContext, useState, useRef, useCallback } from 'react';
3
3
  import JsonURL from '@jsonurl/jsonurl';
4
4
  import { isToday, getDate, getYear, getMonth, startOfWeek, startOfMonth, endOfWeek, addWeeks, endOfMonth, eachDayOfInterval, format as format$1, getISOWeek, getISODay, isSameMonth, startOfDay, isAfter, isEqual, isWithinInterval, endOfDay, isBefore, addMonths, addDays, formatISO, differenceInYears, parseISO, differenceInMinutes, differenceInCalendarDays, parse } from 'date-fns';
5
5
  import { isNil, isArray, compact, isEmpty, range, chunk, isFunction, clamp, omit, sum, first, orderBy, uniq, uniqBy, sortBy, last, findIndex, set, get as get$2 } from 'lodash';
@@ -321,6 +321,11 @@ var ERROR$2 = {
321
321
  ERROR_TEXT3: ".",
322
322
  ERROR_ALT: "Contactez-nous"
323
323
  };
324
+ var PRINT_OFFER_BUTTON$2 = {
325
+ LABEL_IDLE: "Imprimer le devis",
326
+ LABEL_CREATING: "Génération du devis…",
327
+ LABEL_PRINTING: "Génération du PDF…"
328
+ };
324
329
  var frJson = {
325
330
  STEPS: STEPS$2,
326
331
  INPUT: INPUT$2,
@@ -334,7 +339,8 @@ var frJson = {
334
339
  ROOM_OPTIONS_FORM: ROOM_OPTIONS_FORM$2,
335
340
  SUMMARY: SUMMARY$2,
336
341
  CONFIRMATION: CONFIRMATION$2,
337
- ERROR: ERROR$2
342
+ ERROR: ERROR$2,
343
+ PRINT_OFFER_BUTTON: PRINT_OFFER_BUTTON$2
338
344
  };
339
345
 
340
346
  var STEPS$1 = {
@@ -567,6 +573,11 @@ var ERROR$1 = {
567
573
  ERROR_TEXT3: ".",
568
574
  ERROR_ALT: "Contacteer ons"
569
575
  };
576
+ var PRINT_OFFER_BUTTON$1 = {
577
+ LABEL_IDLE: "Print offerte",
578
+ LABEL_CREATING: "Offerte genereren...",
579
+ LABEL_PRINTING: "PDF genereren..."
580
+ };
570
581
  var nlJson = {
571
582
  STEPS: STEPS$1,
572
583
  INPUT: INPUT$1,
@@ -580,7 +591,8 @@ var nlJson = {
580
591
  ROOM_OPTIONS_FORM: ROOM_OPTIONS_FORM$1,
581
592
  SUMMARY: SUMMARY$1,
582
593
  CONFIRMATION: CONFIRMATION$1,
583
- ERROR: ERROR$1
594
+ ERROR: ERROR$1,
595
+ PRINT_OFFER_BUTTON: PRINT_OFFER_BUTTON$1
584
596
  };
585
597
 
586
598
  var STEPS = {
@@ -813,6 +825,11 @@ var ERROR = {
813
825
  ERROR_TEXT3: ".",
814
826
  ERROR_ALT: "Contact us"
815
827
  };
828
+ var PRINT_OFFER_BUTTON = {
829
+ LABEL_IDLE: "Print offer",
830
+ LABEL_CREATING: "Generating offer…",
831
+ LABEL_PRINTING: "Generating PDF…"
832
+ };
816
833
  var enJson = {
817
834
  STEPS: STEPS,
818
835
  INPUT: INPUT,
@@ -826,7 +843,8 @@ var enJson = {
826
843
  ROOM_OPTIONS_FORM: ROOM_OPTIONS_FORM,
827
844
  SUMMARY: SUMMARY,
828
845
  CONFIRMATION: CONFIRMATION,
829
- ERROR: ERROR
846
+ ERROR: ERROR,
847
+ PRINT_OFFER_BUTTON: PRINT_OFFER_BUTTON
830
848
  };
831
849
 
832
850
  var formatPrice = function (price, locale) {
@@ -7036,9 +7054,6 @@ var post = function (
7036
7054
  return [4 /*yield*/, response.text()];
7037
7055
  case 2:
7038
7056
  responseBody = _a.sent();
7039
- if (!responseBody) {
7040
- return [2 /*return*/, null];
7041
- }
7042
7057
  result = skipReviver
7043
7058
  ? JSON.parse(responseBody)
7044
7059
  : JSON.parse(responseBody, reviver);
@@ -7070,9 +7085,6 @@ var patch = function (
7070
7085
  return [4 /*yield*/, response.text()];
7071
7086
  case 2:
7072
7087
  responseBody = _a.sent();
7073
- if (!responseBody) {
7074
- return [2 /*return*/, {}];
7075
- }
7076
7088
  result = skipReviver
7077
7089
  ? JSON.parse(responseBody)
7078
7090
  : JSON.parse(responseBody, reviver);
@@ -7330,7 +7342,6 @@ var getMolliePayment = function (config, request, signal) {
7330
7342
 
7331
7343
  var ENDPOINT$4 = "/api/web/search";
7332
7344
  var ENDPOINT_COUNTRIES = ENDPOINT$4 + "/countries";
7333
- var ENDPOINT_AIRPORTS = ENDPOINT$4 + "/airports";
7334
7345
  /**
7335
7346
  * api/search/countries
7336
7347
  * Gets all Countries
@@ -7343,11 +7354,6 @@ var getCountries = function (config, signal) {
7343
7354
  var apiKey = config.apiKey;
7344
7355
  return get(url, apiKey, config.token, signal, true);
7345
7356
  };
7346
- var getAirports = function (config, signal) {
7347
- var url = "" + config.host + ENDPOINT_AIRPORTS;
7348
- var apiKey = config.apiKey;
7349
- return get(url, apiKey, config.token, signal, true);
7350
- };
7351
7357
 
7352
7358
  var createParams = function (filter, all, gridColumns, mode, forceToLower) {
7353
7359
  var params = {};
@@ -7591,7 +7597,6 @@ var changeEntryAgentSurcharge = function (config, request, signal) {
7591
7597
 
7592
7598
  var ENDPOINT$2 = "/api/web";
7593
7599
  var ENDPOINT_CREATE_CRM_CONTACT = ENDPOINT$2 + "/crmcontact";
7594
- var ENDPOINT_CONTACT_FORM$1 = ENDPOINT$2 + "/contactform";
7595
7600
  var ENDPOINT_CREATE_AFFILIATES = ENDPOINT$2 + "/affiliates";
7596
7601
  var ENDPOINT_TRANSLATION_DICTIONARY = ENDPOINT$2 + "/translation-dictionary";
7597
7602
  var ENDPOINT_BOOKING_ACCOMMODATION = ENDPOINT$2 + "/booking-accommodation";
@@ -7609,20 +7614,6 @@ var createCrmContact = function (config, request, signal) {
7609
7614
  var body = JSON.stringify(request);
7610
7615
  return post(url, apiKey, body, config.token, signal);
7611
7616
  };
7612
- /**
7613
- * api/web/contactform
7614
- * Sends a contact request mail
7615
- * @param config
7616
- * @param request
7617
- * @param signal
7618
- * @returns OK if succeeded.
7619
- */
7620
- var ContactForm = function (config, request, signal) {
7621
- var url = "" + config.host + ENDPOINT_CONTACT_FORM$1;
7622
- var apiKey = config.apiKey;
7623
- var body = JSON.stringify(request);
7624
- return post(url, apiKey, body, config.token, signal, true);
7625
- };
7626
7617
  /**
7627
7618
  * api/web/affiliates
7628
7619
  * Gets all Affiliates
@@ -7704,7 +7695,6 @@ var feedXmlFolder = function (config, slug, folder, signal) {
7704
7695
 
7705
7696
  build.AllotmentType = AllotmentType;
7706
7697
  build.AvailabilitySearchType = AvailabilitySearchType;
7707
- build.ContactForm = ContactForm;
7708
7698
  var Gender_1 = build.Gender = Gender;
7709
7699
  build.MetaDataType = MetaDataType;
7710
7700
  build.RequirementType = RequirementType;
@@ -7728,7 +7718,6 @@ build.feedXmlFolder = feedXmlFolder;
7728
7718
  build.forgotPassword = forgotPassword;
7729
7719
  var generateBookingAccommodations_1 = build.generateBookingAccommodations = generateBookingAccommodations;
7730
7720
  build.getAffiliates = getAffiliates;
7731
- build.getAirports = getAirports;
7732
7721
  build.getAllotmentAvailability = getAllotmentAvailability;
7733
7722
  build.getCountries = getCountries;
7734
7723
  build.getCustomEntryStatus = getCustomEntryStatus;
@@ -7743,7 +7732,7 @@ build.login = login;
7743
7732
  build.logout = logout;
7744
7733
  var priceDetails_1 = build.priceDetails = priceDetails;
7745
7734
  build.prices = prices;
7746
- build.print = print;
7735
+ var print_1 = build.print = print;
7747
7736
  build.resetPassword = resetPassword;
7748
7737
  build.search = search;
7749
7738
  build.searchFlightPool = searchFlightPool;
@@ -10792,6 +10781,7 @@ var bookingReducer = bookingSlice.reducer;
10792
10781
 
10793
10782
  var SettingsContext = React.createContext({
10794
10783
  language: "nl-BE",
10784
+ token: "",
10795
10785
  generatePaymentUrl: false,
10796
10786
  currency: "EUR",
10797
10787
  officeId: 1,
@@ -10803,22 +10793,28 @@ var SettingsContext = React.createContext({
10803
10793
  basePath: "/boeken",
10804
10794
  roomOptions: {
10805
10795
  pathSuffix: "/",
10796
+ reportPrintActionId: null,
10806
10797
  },
10807
10798
  flightOptions: {
10808
10799
  pathSuffix: "/vluchten",
10800
+ reportPrintActionId: null,
10809
10801
  },
10810
10802
  options: {
10811
10803
  pathSuffix: "/opties",
10804
+ reportPrintActionId: null,
10812
10805
  },
10813
10806
  travellers: {
10814
10807
  pathSuffix: "/reizigers",
10808
+ reportPrintActionId: null,
10815
10809
  },
10816
10810
  summary: {
10817
10811
  pathSuffix: "/samenvatting",
10818
10812
  checkboxes: null,
10813
+ reportPrintActionId: null,
10819
10814
  },
10820
10815
  confirmation: {
10821
10816
  pathSuffix: "/bevestiging",
10817
+ reportPrintActionId: null,
10822
10818
  },
10823
10819
  error: {
10824
10820
  pathSuffix: "/mislukt",
@@ -13141,9 +13137,135 @@ var OptionRoom = function (_a) {
13141
13137
  ]) }))))))))))));
13142
13138
  };
13143
13139
 
13140
+ function useOfferPrinter(_a) {
13141
+ var _this = this;
13142
+ var bookingPackage = _a.bookingPackage, getPax = _a.getPax, _b = _a.tagIds, tagIds = _b === void 0 ? [] : _b, _c = _a.printActionId, printActionId = _c === void 0 ? null : _c, onPrinted = _a.onPrinted;
13143
+ var settings = useContext(SettingsContext);
13144
+ if (!settings)
13145
+ throw new Error("useOfferPrinter must be used inside <BookingWizard>");
13146
+ var language = settings.language, officeId = settings.officeId;
13147
+ var agentId = settings.agentAdressId;
13148
+ if (typeof agentId !== "number" || agentId <= 0) {
13149
+ throw new Error("Missing agentAdressId in wizard settings");
13150
+ }
13151
+ var _d = useState("idle"), stage = _d[0], setStage = _d[1];
13152
+ var loading = stage !== "idle";
13153
+ var createOffer = useCallback(function () { return __awaiter$1(_this, void 0, void 0, function () {
13154
+ var paxRaw, pax, request, cfg;
13155
+ return __generator$1(this, function (_a) {
13156
+ paxRaw = getPax();
13157
+ if (!bookingPackage || !(paxRaw === null || paxRaw === void 0 ? void 0 : paxRaw.length)) {
13158
+ throw new Error("Missing booking package or pax");
13159
+ }
13160
+ pax = paxRaw;
13161
+ request = {
13162
+ officeId: officeId,
13163
+ agentId: agentId,
13164
+ payload: {
13165
+ package: bookingPackage,
13166
+ status: 0,
13167
+ pax: pax,
13168
+ nonTravelPax: [],
13169
+ notifications: [],
13170
+ tagIds: tagIds,
13171
+ customerRequests: [],
13172
+ },
13173
+ };
13174
+ cfg = buildTideClientConfig();
13175
+ return [2 /*return*/, book_1(cfg, request, undefined, language)];
13176
+ });
13177
+ }); }, [
13178
+ agentId,
13179
+ bookingPackage,
13180
+ getPax,
13181
+ language,
13182
+ officeId,
13183
+ tagIds,
13184
+ ]);
13185
+ var languageData = [
13186
+ { code: "nl-BE", tideId: 1 },
13187
+ { code: "fr-BE", tideId: 2 },
13188
+ { code: "en-GB", tideId: 3 },
13189
+ ];
13190
+ function getTideLanguageId(code) {
13191
+ var _a;
13192
+ return (((_a = languageData.find(function (l) { return l.code === code; })) === null || _a === void 0 ? void 0 : _a.tideId) || 1);
13193
+ }
13194
+ var printOffer = useCallback(function (offer) { return __awaiter$1(_this, void 0, void 0, function () {
13195
+ var cfg, req, res, buf, url;
13196
+ var _a;
13197
+ return __generator$1(this, function (_b) {
13198
+ switch (_b.label) {
13199
+ case 0:
13200
+ cfg = buildTideClientConfig();
13201
+ req = {
13202
+ id: printActionId !== null && printActionId !== void 0 ? printActionId : 0,
13203
+ dossierNumber: (_a = offer.dossierNumber) !== null && _a !== void 0 ? _a : offer.number,
13204
+ languageId: getTideLanguageId(language),
13205
+ };
13206
+ return [4 /*yield*/, print_1(cfg, req)];
13207
+ case 1:
13208
+ res = _b.sent();
13209
+ return [4 /*yield*/, res.arrayBuffer()];
13210
+ case 2:
13211
+ buf = _b.sent();
13212
+ url = URL.createObjectURL(new Blob([buf], { type: "application/pdf" }));
13213
+ onPrinted === null || onPrinted === void 0 ? void 0 : onPrinted(url);
13214
+ window.open(url);
13215
+ return [2 /*return*/];
13216
+ }
13217
+ });
13218
+ }); }, [language, onPrinted]);
13219
+ var handlePrint = useCallback(function () { return __awaiter$1(_this, void 0, void 0, function () {
13220
+ var offer, err_1;
13221
+ return __generator$1(this, function (_a) {
13222
+ switch (_a.label) {
13223
+ case 0:
13224
+ _a.trys.push([0, 3, 4, 5]);
13225
+ setStage("creating");
13226
+ return [4 /*yield*/, createOffer()];
13227
+ case 1:
13228
+ offer = _a.sent();
13229
+ setStage("printing");
13230
+ return [4 /*yield*/, printOffer(offer)];
13231
+ case 2:
13232
+ _a.sent();
13233
+ return [3 /*break*/, 5];
13234
+ case 3:
13235
+ err_1 = _a.sent();
13236
+ console.error("Offer print failed:", err_1);
13237
+ throw err_1;
13238
+ case 4:
13239
+ setStage("idle");
13240
+ return [7 /*endfinally*/];
13241
+ case 5: return [2 /*return*/];
13242
+ }
13243
+ });
13244
+ }); }, [createOffer, printOffer]);
13245
+ return { handlePrint: handlePrint, loading: loading, stage: stage };
13246
+ }
13247
+
13248
+ var PrintOfferButton = function (_a) {
13249
+ var bookingPackage = _a.bookingPackage, getPax = _a.getPax, tagIds = _a.tagIds, _b = _a.printActionId, printActionId = _b === void 0 ? null : _b, onPrinted = _a.onPrinted, _c = _a.labelIdle, labelIdle = _c === void 0 ? "Print offer" : _c, _d = _a.labelCreating, labelCreating = _d === void 0 ? "Generating offer…" : _d, _e = _a.labelPrinting, labelPrinting = _e === void 0 ? "Generating PDF…" : _e, _f = _a.disabled, disabled = _f === void 0 ? false : _f, className = _a.className;
13250
+ var _g = useOfferPrinter({
13251
+ bookingPackage: bookingPackage,
13252
+ getPax: getPax,
13253
+ tagIds: tagIds,
13254
+ onPrinted: onPrinted,
13255
+ printActionId: printActionId,
13256
+ }), handlePrint = _g.handlePrint, stage = _g.stage, loading = _g.loading;
13257
+ var label = stage === "creating"
13258
+ ? labelCreating
13259
+ : stage === "printing"
13260
+ ? labelPrinting
13261
+ : labelIdle;
13262
+ return (React.createElement("button", { type: 'button', onClick: handlePrint, disabled: disabled || loading, className: className }, label));
13263
+ };
13264
+
13144
13265
  var OptionsForm = function () {
13145
13266
  var _a;
13146
13267
  var settings = useContext(SettingsContext);
13268
+ var token = settings.token;
13147
13269
  var translations = useSelector(selectTranslations);
13148
13270
  var dispatch = useAppDispatch();
13149
13271
  var packageDetails = useSelector(selectPackageDetails);
@@ -13167,7 +13289,9 @@ var OptionsForm = function () {
13167
13289
  var bookingPackagePax = pax.filter(function (x) {
13168
13290
  return room === null || room === void 0 ? void 0 : room.pax.some(function (y) { return y.id == x.id; });
13169
13291
  });
13170
- return bookingPackagePax.length > 0 ? bookingPackagePax : (_a = room === null || room === void 0 ? void 0 : room.pax) !== null && _a !== void 0 ? _a : [];
13292
+ return bookingPackagePax.length > 0
13293
+ ? bookingPackagePax
13294
+ : (_a = room === null || room === void 0 ? void 0 : room.pax) !== null && _a !== void 0 ? _a : [];
13171
13295
  };
13172
13296
  var handleOnRoomChange = function (index, accommodationCode, regimeCode) {
13173
13297
  if (!packageRooms)
@@ -13176,8 +13300,17 @@ var OptionsForm = function () {
13176
13300
  dispatch(setPackageRooms(updatedPackageRooms));
13177
13301
  dispatch(fetchPriceDetails());
13178
13302
  };
13303
+ var getPax = function () {
13304
+ var _a;
13305
+ if (!packageDetails)
13306
+ return undefined;
13307
+ var selectedOption = (_a = packageDetails.options.find(function (o) { return o.isSelected; })) !== null && _a !== void 0 ? _a : packageDetails.options[0];
13308
+ return selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.requestRooms.flatMap(function (r) { return r.pax; });
13309
+ };
13179
13310
  // TAGS
13180
- var packageTags = settings.hideTags ? [] : useSelector(selectPackageTags);
13311
+ var packageTags = settings.hideTags
13312
+ ? []
13313
+ : useSelector(selectPackageTags);
13181
13314
  var tagIds = (_a = useSelector(selectTagIds)) !== null && _a !== void 0 ? _a : [];
13182
13315
  var handleSubmit = function (e) {
13183
13316
  if (settings.skipRouter) {
@@ -13249,11 +13382,13 @@ var OptionsForm = function () {
13249
13382
  var desiredReturnFlight_1 = packageDetails.returnFlights.find(function (x) { return x.entryLineGuid == returnFlight_1; });
13250
13383
  if (desiredOutwardFlight_1 && desiredReturnFlight_1) {
13251
13384
  dispatch(setPackage(__assign(__assign({}, packageDetails), { outwardFlights: packageDetails.outwardFlights.map(function (flight) {
13252
- return __assign(__assign({}, flight), { isSelected: flight.entryLineGuid == desiredOutwardFlight_1.entryLineGuid
13385
+ return __assign(__assign({}, flight), { isSelected: flight.entryLineGuid ==
13386
+ desiredOutwardFlight_1.entryLineGuid
13253
13387
  ? true
13254
13388
  : false });
13255
13389
  }), returnFlights: packageDetails.returnFlights.map(function (flight) {
13256
- return __assign(__assign({}, flight), { isSelected: flight.entryLineGuid == desiredReturnFlight_1.entryLineGuid
13390
+ return __assign(__assign({}, flight), { isSelected: flight.entryLineGuid ==
13391
+ desiredReturnFlight_1.entryLineGuid
13257
13392
  ? true
13258
13393
  : false });
13259
13394
  }) })));
@@ -13273,57 +13408,73 @@ var OptionsForm = function () {
13273
13408
  var previousUrl = settings.roomOptions.isHidden
13274
13409
  ? "".concat(settings.basePath).concat(settings.flightOptions.pathSuffix, "?").concat(bookingQueryString)
13275
13410
  : "".concat(settings.basePath).concat(settings.roomOptions.pathSuffix, "?").concat(bookingQueryString);
13276
- var hasPrevious = !settings.roomOptions.isHidden || !settings.flightOptions.isHidden;
13277
- var showPackageTagsOrRoomoptions = showRoomOptions || (packageTags && !isEmpty(packageTags));
13411
+ var hasPrevious = !settings.roomOptions.isHidden ||
13412
+ !settings.flightOptions.isHidden;
13413
+ var showPackageTagsOrRoomoptions = showRoomOptions ||
13414
+ (packageTags && !isEmpty(packageTags));
13278
13415
  return (React.createElement(React.Fragment, null,
13279
- React.createElement("form", { className: "form", name: "booking--options", id: "booking--options", noValidate: true, onSubmit: handleSubmit },
13416
+ React.createElement("form", { className: 'form', name: 'booking--options', id: 'booking--options', noValidate: true, onSubmit: handleSubmit },
13280
13417
  isLoading && settings.loaderComponent,
13281
- !isLoading && (React.createElement("div", { className: "form__region" },
13282
- showPackageTagsOrRoomoptions && (React.createElement("div", { className: "form__group" },
13283
- React.createElement("div", { className: "booking-card" },
13284
- React.createElement("div", { className: "booking-card__body" },
13418
+ !isLoading && (React.createElement("div", { className: 'form__region' },
13419
+ showPackageTagsOrRoomoptions && (React.createElement("div", { className: 'form__group' },
13420
+ React.createElement("div", { className: 'booking-card' },
13421
+ React.createElement("div", { className: 'booking-card__body' },
13285
13422
  React.createElement("div", { className: buildClassName([
13286
13423
  "booking-card__group",
13287
13424
  "booking-card__group--package",
13288
13425
  ]) },
13289
- showRoomOptions && (React.createElement("span", { className: "booking-card__tag" }, translations.OPTIONS_FORM.PACKAGE)),
13290
- React.createElement("div", { className: "booking-card__group-body" },
13291
- showRoomOptions && (React.createElement("table", { className: "table table--striped" },
13426
+ showRoomOptions && (React.createElement("span", { className: 'booking-card__tag' }, translations.OPTIONS_FORM
13427
+ .PACKAGE)),
13428
+ React.createElement("div", { className: 'booking-card__group-body' },
13429
+ showRoomOptions && (React.createElement("table", { className: 'table table--striped' },
13292
13430
  React.createElement("tbody", null, packageRooms &&
13293
13431
  packageRooms.map(function (room) { return (React.createElement(OptionRoom, { key: room.index, packageRoom: room, pax: getRoomPax(room.index), optionPax: optionPax, onRoomChange: handleOnRoomChange })); })))),
13294
- packageTags && !isEmpty(packageTags) && (React.createElement("div", { className: "booking-card__tag-translations" }, packageTags.map(function (tag, index) { return (React.createElement("label", { key: index, htmlFor: "tag-translation-".concat(index, "-").concat(tag.title), className: "checkbox__label tag-translation" },
13295
- React.createElement("div", { className: "tag-translation-input__container" },
13296
- React.createElement("input", { type: "checkbox", id: "tag-translation-".concat(index, "-").concat(tag.title), name: "tag-translation-".concat(index, "-").concat(tag.title), className: "checkbox__input", checked: tagIds === null || tagIds === void 0 ? void 0 : tagIds.includes(tag.id), onChange: function (e) {
13432
+ packageTags &&
13433
+ !isEmpty(packageTags) && (React.createElement("div", { className: 'booking-card__tag-translations' }, packageTags.map(function (tag, index) { return (React.createElement("label", { key: index, htmlFor: "tag-translation-".concat(index, "-").concat(tag.title), className: 'checkbox__label tag-translation' },
13434
+ React.createElement("div", { className: 'tag-translation-input__container' },
13435
+ React.createElement("input", { type: 'checkbox', id: "tag-translation-".concat(index, "-").concat(tag.title), name: "tag-translation-".concat(index, "-").concat(tag.title), className: 'checkbox__input', checked: tagIds === null || tagIds === void 0 ? void 0 : tagIds.includes(tag.id), onChange: function (e) {
13297
13436
  return handleOnTagChange(tag.id, e.target.checked);
13298
13437
  } })),
13299
- React.createElement("span", { className: "tag-translation__title" }, tag.title),
13438
+ React.createElement("span", { className: 'tag-translation__title' }, tag.title),
13300
13439
  "\u00A0",
13301
- React.createElement("span", { className: "tag-translation__description" }, tag.description))); }))))))))),
13302
- optionUnits && !isEmpty(optionUnits) && (React.createElement("div", { className: "form__group" },
13303
- React.createElement("div", { className: "booking-card" },
13304
- React.createElement("div", { className: "booking-card__header" },
13305
- React.createElement("h2", { className: "booking-card__header-heading" }, translations.OPTIONS_FORM.PER_UNIT_TITLE)),
13306
- React.createElement("div", { className: "booking-card__body" },
13440
+ React.createElement("span", { className: 'tag-translation__description' }, tag.description))); }))))))))),
13441
+ optionUnits && !isEmpty(optionUnits) && (React.createElement("div", { className: 'form__group' },
13442
+ React.createElement("div", { className: 'booking-card' },
13443
+ React.createElement("div", { className: 'booking-card__header' },
13444
+ React.createElement("h2", { className: 'booking-card__header-heading' }, translations.OPTIONS_FORM
13445
+ .PER_UNIT_TITLE)),
13446
+ React.createElement("div", { className: 'booking-card__body' },
13307
13447
  React.createElement(OptionUnitsCard, { units: optionUnits, onUnitsChange: handleOnUnitsChange }))))),
13308
- optionPax && !isEmpty(optionPax) && (React.createElement("div", { className: "form__group" },
13309
- React.createElement("div", { className: "booking-card" },
13310
- React.createElement("div", { className: "booking-card__header" },
13311
- React.createElement("h2", { className: "booking-card__header-heading" }, translations.OPTIONS_FORM.PER_PAX_TITLE)),
13312
- React.createElement("div", { className: "booking-card__body" },
13448
+ optionPax && !isEmpty(optionPax) && (React.createElement("div", { className: 'form__group' },
13449
+ React.createElement("div", { className: 'booking-card' },
13450
+ React.createElement("div", { className: 'booking-card__header' },
13451
+ React.createElement("h2", { className: 'booking-card__header-heading' }, translations.OPTIONS_FORM
13452
+ .PER_PAX_TITLE)),
13453
+ React.createElement("div", { className: 'booking-card__body' },
13313
13454
  React.createElement(OptionPaxCard, { pax: optionPax, onPaxChange: handleOnPaxChange, requestRoomsPax: requestRoomsPax }))))),
13314
- groups && !isEmpty(groups) && (React.createElement("div", { className: "form__group" },
13315
- React.createElement("div", { className: "booking-card" },
13316
- React.createElement("div", { className: "booking-card__header" },
13317
- React.createElement("h2", { className: "booking-card__header-heading" }, translations.OPTIONS_FORM.PER_BOOKING_TITLE)),
13318
- React.createElement("div", { className: "booking-card__body" },
13319
- React.createElement("div", { className: "booking-card__group booking-card__group--active" },
13455
+ groups && !isEmpty(groups) && (React.createElement("div", { className: 'form__group' },
13456
+ React.createElement("div", { className: 'booking-card' },
13457
+ React.createElement("div", { className: 'booking-card__header' },
13458
+ React.createElement("h2", { className: 'booking-card__header-heading' }, translations.OPTIONS_FORM
13459
+ .PER_BOOKING_TITLE)),
13460
+ React.createElement("div", { className: 'booking-card__body' },
13461
+ React.createElement("div", { className: 'booking-card__group booking-card__group--active' },
13320
13462
  groups.map(function (group, i) { return (React.createElement(OptionBookingGroup, { key: "".concat(group.name, "_").concat(i), group: group, firstClassName: "booking-card__group-body", secondClassName: "booking-card__group-heading", parentId: "booking_".concat(group.name), onGroupChange: handleOnGroupChange })); }), airlineGroups === null || airlineGroups === void 0 ? void 0 :
13321
13463
  airlineGroups.map(function (group, i) { return (React.createElement(OptionBookingAirlineGroup, { key: "".concat(group.label, "_").concat(i), airGroup: group, onGroupChange: handleOnAirlineGroupChange })); }), airportGroups === null || airportGroups === void 0 ? void 0 :
13322
13464
  airportGroups.map(function (group, i) { return (React.createElement(OptionBookingAirlineGroup, { key: "".concat(group.label, "_").concat(i), airGroup: group, onGroupChange: handleOnAirportGroupChange })); })))))),
13323
- isEmpty(groups) && isEmpty(optionUnits) && isEmpty(optionPax) && (React.createElement(NoOptions, null)))),
13324
- React.createElement("div", { className: "booking__navigator" },
13325
- hasPrevious && (React.createElement(React.Fragment, null, settings.skipRouter ? (React.createElement("button", { type: "button", title: translations.STEPS.PREVIOUS, onClick: function () { return goPrevious(); }, className: "cta cta--secondary" }, translations.STEPS.PREVIOUS)) : (React.createElement(Link, { to: previousUrl, title: translations.STEPS.PREVIOUS, className: "cta cta--secondary" }, translations.STEPS.PREVIOUS)))),
13326
- React.createElement("button", { type: "submit", title: translations.STEPS.NEXT, disabled: isLoading, className: buildClassName(["cta", isLoading && "cta--disabled"]) }, translations.STEPS.NEXT)))));
13465
+ isEmpty(groups) &&
13466
+ isEmpty(optionUnits) &&
13467
+ isEmpty(optionPax) && React.createElement(NoOptions, null))),
13468
+ React.createElement("div", { className: 'booking__navigator' },
13469
+ hasPrevious && (React.createElement(React.Fragment, null, settings.skipRouter ? (React.createElement("button", { type: 'button', title: translations.STEPS.PREVIOUS, onClick: function () { return goPrevious(); }, className: 'cta cta--secondary' }, translations.STEPS.PREVIOUS)) : (React.createElement(Link, { to: previousUrl, title: translations.STEPS.PREVIOUS, className: 'cta cta--secondary' }, translations.STEPS.PREVIOUS)))),
13470
+ token &&
13471
+ settings.options.reportPrintActionId && (React.createElement(PrintOfferButton, { bookingPackage: packageDetails, getPax: getPax, tagIds: tagIds, printActionId: settings.options.reportPrintActionId, labelIdle: translations.PRINT_OFFER_BUTTON.LABEL_IDLE, labelCreating: translations.PRINT_OFFER_BUTTON
13472
+ .LABEL_CREATING, labelPrinting: translations.PRINT_OFFER_BUTTON
13473
+ .LABEL_PRINTING, className: 'cta spinner-button' })),
13474
+ React.createElement("button", { type: 'submit', title: translations.STEPS.NEXT, disabled: isLoading, className: buildClassName([
13475
+ "cta",
13476
+ isLoading && "cta--disabled",
13477
+ ]) }, translations.STEPS.NEXT)))));
13327
13478
  };
13328
13479
 
13329
13480
  var RoomOption = function (_a) {
@@ -232,6 +232,11 @@ export declare const getTranslations: (language: string) => {
232
232
  ERROR_TEXT3: string;
233
233
  ERROR_ALT: string;
234
234
  };
235
+ PRINT_OFFER_BUTTON: {
236
+ LABEL_IDLE: string;
237
+ LABEL_CREATING: string;
238
+ LABEL_PRINTING: string;
239
+ };
235
240
  };
236
241
  export declare const locales: {
237
242
  "nl-BE": Locale;
@@ -1,3 +1,4 @@
1
1
  import { TideClientConfig } from "@qite/tide-client";
2
2
  import { ApiSettingsState } from "../types";
3
3
  export declare function buildTideClientConfig(settings?: ApiSettingsState): TideClientConfig;
4
+ export declare const selectAgentToken: () => string | undefined;