@qite/tide-booking-component 1.3.2 → 1.3.4

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 (133) 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/types.d.ts +1 -5
  5. package/build/build-cjs/index.js +58 -101
  6. package/build/build-esm/booking-wizard/types.d.ts +1 -5
  7. package/build/build-esm/index.js +58 -101
  8. package/package.json +75 -75
  9. package/rollup.config.js +23 -23
  10. package/src/booking-product/components/age-select.tsx +35 -35
  11. package/src/booking-product/components/amount-input.tsx +78 -78
  12. package/src/booking-product/components/date-range-picker/calendar-day.tsx +58 -58
  13. package/src/booking-product/components/date-range-picker/calendar.tsx +178 -178
  14. package/src/booking-product/components/date-range-picker/index.tsx +196 -196
  15. package/src/booking-product/components/dates.tsx +136 -136
  16. package/src/booking-product/components/footer.tsx +69 -69
  17. package/src/booking-product/components/header.tsx +79 -79
  18. package/src/booking-product/components/icon.tsx +251 -251
  19. package/src/booking-product/components/product.tsx +314 -314
  20. package/src/booking-product/components/rating.tsx +21 -21
  21. package/src/booking-product/components/rooms.tsx +195 -195
  22. package/src/booking-product/index.tsx +30 -30
  23. package/src/booking-product/settings-context.ts +14 -14
  24. package/src/booking-product/types.ts +28 -28
  25. package/src/booking-product/utils/api.ts +25 -25
  26. package/src/booking-product/utils/price.ts +29 -29
  27. package/src/booking-wizard/api-settings-slice.ts +24 -24
  28. package/src/booking-wizard/components/icon.tsx +508 -508
  29. package/src/booking-wizard/components/labeled-input.tsx +64 -64
  30. package/src/booking-wizard/components/labeled-select.tsx +69 -69
  31. package/src/booking-wizard/components/message.tsx +34 -34
  32. package/src/booking-wizard/components/multi-range-filter.tsx +113 -113
  33. package/src/booking-wizard/components/print-offer-button.tsx +63 -66
  34. package/src/booking-wizard/components/product-card.tsx +37 -37
  35. package/src/booking-wizard/components/step-indicator.tsx +51 -51
  36. package/src/booking-wizard/components/step-route.tsx +27 -27
  37. package/src/booking-wizard/declarations.d.ts +4 -4
  38. package/src/booking-wizard/features/booking/api.ts +49 -49
  39. package/src/booking-wizard/features/booking/booking-self-contained.tsx +389 -389
  40. package/src/booking-wizard/features/booking/booking-slice.ts +663 -663
  41. package/src/booking-wizard/features/booking/booking.tsx +361 -361
  42. package/src/booking-wizard/features/booking/constants.ts +16 -16
  43. package/src/booking-wizard/features/booking/selectors.ts +441 -441
  44. package/src/booking-wizard/features/confirmation/confirmation.tsx +97 -97
  45. package/src/booking-wizard/features/error/error.tsx +78 -78
  46. package/src/booking-wizard/features/flight-options/flight-filter.tsx +432 -432
  47. package/src/booking-wizard/features/flight-options/flight-option-flight.tsx +385 -385
  48. package/src/booking-wizard/features/flight-options/flight-option-modal.tsx +229 -229
  49. package/src/booking-wizard/features/flight-options/flight-option.tsx +81 -81
  50. package/src/booking-wizard/features/flight-options/flight-utils.ts +522 -516
  51. package/src/booking-wizard/features/flight-options/index.tsx +196 -196
  52. package/src/booking-wizard/features/price-details/price-details-api.ts +24 -24
  53. package/src/booking-wizard/features/price-details/price-details-slice.ts +178 -178
  54. package/src/booking-wizard/features/price-details/util.ts +155 -155
  55. package/src/booking-wizard/features/product-options/no-options.tsx +21 -21
  56. package/src/booking-wizard/features/product-options/none-option.tsx +120 -120
  57. package/src/booking-wizard/features/product-options/option-booking-airline-group.tsx +64 -64
  58. package/src/booking-wizard/features/product-options/option-booking-group.tsx +216 -216
  59. package/src/booking-wizard/features/product-options/option-item.tsx +317 -317
  60. package/src/booking-wizard/features/product-options/option-pax-card.tsx +201 -201
  61. package/src/booking-wizard/features/product-options/option-pax-group.tsx +175 -175
  62. package/src/booking-wizard/features/product-options/option-room.tsx +321 -321
  63. package/src/booking-wizard/features/product-options/option-unit-group.tsx +198 -198
  64. package/src/booking-wizard/features/product-options/option-units-card.tsx +185 -185
  65. package/src/booking-wizard/features/product-options/options-form.tsx +481 -563
  66. package/src/booking-wizard/features/room-options/index.tsx +187 -187
  67. package/src/booking-wizard/features/room-options/room-utils.ts +190 -190
  68. package/src/booking-wizard/features/room-options/room.tsx +160 -160
  69. package/src/booking-wizard/features/room-options/traveler-rooms.tsx +75 -75
  70. package/src/booking-wizard/features/sidebar/index.tsx +76 -76
  71. package/src/booking-wizard/features/sidebar/sidebar-flight.tsx +68 -68
  72. package/src/booking-wizard/features/sidebar/sidebar-util.ts +177 -177
  73. package/src/booking-wizard/features/sidebar/sidebar.tsx +364 -364
  74. package/src/booking-wizard/features/summary/summary-booking-option-pax.tsx +25 -25
  75. package/src/booking-wizard/features/summary/summary-booking-option-unit.tsx +25 -25
  76. package/src/booking-wizard/features/summary/summary-flight.tsx +39 -39
  77. package/src/booking-wizard/features/summary/summary-per-booking-option-group.tsx +69 -69
  78. package/src/booking-wizard/features/summary/summary-per-pax-option-group.tsx +63 -63
  79. package/src/booking-wizard/features/summary/summary-per-unit-option-group.tsx +66 -66
  80. package/src/booking-wizard/features/summary/summary-slice.ts +28 -28
  81. package/src/booking-wizard/features/summary/summary.tsx +674 -674
  82. package/src/booking-wizard/features/travelers-form/travelers-form-slice.ts +164 -164
  83. package/src/booking-wizard/features/travelers-form/travelers-form.tsx +754 -754
  84. package/src/booking-wizard/features/travelers-form/type-ahead-input.tsx +101 -101
  85. package/src/booking-wizard/features/travelers-form/validate-form.ts +245 -245
  86. package/src/booking-wizard/index.tsx +36 -36
  87. package/src/booking-wizard/settings-context.ts +62 -62
  88. package/src/booking-wizard/store.ts +31 -31
  89. package/src/booking-wizard/types.ts +279 -279
  90. package/src/booking-wizard/use-offer-printer.ts +117 -136
  91. package/src/index.ts +4 -4
  92. package/src/shared/components/loader.tsx +16 -16
  93. package/src/shared/translations/en-GB.json +237 -237
  94. package/src/shared/translations/fr-BE.json +238 -238
  95. package/src/shared/translations/nl-BE.json +237 -237
  96. package/src/shared/types.ts +4 -4
  97. package/src/shared/utils/class-util.ts +9 -9
  98. package/src/shared/utils/localization-util.ts +62 -62
  99. package/src/shared/utils/query-string-util.ts +119 -119
  100. package/src/shared/utils/tide-api-utils.ts +36 -36
  101. package/styles/booking-product-variables.scss +394 -394
  102. package/styles/booking-product.scss +446 -446
  103. package/styles/booking-wizard-variables.scss +873 -873
  104. package/styles/booking-wizard.scss +59 -59
  105. package/styles/components/_animations.scss +39 -39
  106. package/styles/components/_base.scss +107 -107
  107. package/styles/components/_booking.scss +879 -879
  108. package/styles/components/_button.scss +238 -238
  109. package/styles/components/_checkbox.scss +219 -219
  110. package/styles/components/_cta.scss +208 -208
  111. package/styles/components/_date-list.scss +41 -41
  112. package/styles/components/_date-range-picker.scss +225 -225
  113. package/styles/components/_decrement-increment.scss +35 -35
  114. package/styles/components/_dropdown.scss +72 -72
  115. package/styles/components/_flight-option.scss +1429 -1429
  116. package/styles/components/_form.scss +1583 -1583
  117. package/styles/components/_info-message.scss +71 -71
  118. package/styles/components/_input.scss +25 -25
  119. package/styles/components/_list.scss +187 -187
  120. package/styles/components/_loader.scss +72 -72
  121. package/styles/components/_mixins.scss +550 -550
  122. package/styles/components/_placeholders.scss +166 -166
  123. package/styles/components/_pricing-summary.scss +155 -155
  124. package/styles/components/_qsm.scss +17 -17
  125. package/styles/components/_radiobutton.scss +170 -170
  126. package/styles/components/_select-wrapper.scss +80 -80
  127. package/styles/components/_spinner.scss +29 -29
  128. package/styles/components/_step-indicators.scss +168 -168
  129. package/styles/components/_table.scss +81 -81
  130. package/styles/components/_tree.scss +530 -530
  131. package/styles/components/_typeahead.scss +281 -281
  132. package/styles/components/_variables.scss +89 -89
  133. package/tsconfig.json +24 -24
@@ -1,361 +1,361 @@
1
- import { navigate, Router, useLocation } from "@reach/router";
2
- import React, { useContext } from "react";
3
- import { useSelector } from "react-redux";
4
- import {
5
- getDateFromParams,
6
- getFlightsFromParams,
7
- getNumberFromParams,
8
- getNumbersFromParams,
9
- getRoomsFromParams,
10
- getStringFromParams,
11
- } from "../../../shared/utils/query-string-util";
12
- import {
13
- fetchPackage,
14
- setAccommodationViewId,
15
- setAgentAdressId,
16
- setBookingAttributes,
17
- setBookingNumber,
18
- setBookingOptions,
19
- setBookingType,
20
- setCalculateDeposit,
21
- setGeneratePaymentUrl,
22
- setIsRetry,
23
- setLanguageCode,
24
- setOfficeId,
25
- setProductAttributes,
26
- setSkipPayment,
27
- setTagIds,
28
- setTranslations,
29
- } from "./booking-slice";
30
-
31
- import { isNil } from "lodash";
32
- import { useEffect } from "react";
33
- import StepRoute from "../../components/step-route";
34
- import SettingsContext from "../../settings-context";
35
- import { useAppDispatch } from "../../store";
36
- import Confirmation from "../confirmation/confirmation";
37
- import Error from "../error/error";
38
- import FlightOptionsForm from "../flight-options";
39
- import OptionsForm from "../product-options/options-form";
40
- import RoomOptionsForm from "../room-options";
41
- import Sidebar from "../sidebar";
42
- import Summary from "../summary/summary";
43
- import TravelersForm from "../travelers-form/travelers-form";
44
- import {
45
- selectBookingAttributes,
46
- selectBookingNumber,
47
- selectBookingRooms,
48
- selectIsRetry,
49
- selectIsUnavailable,
50
- selectPackageDetails,
51
- selectProductAttributes,
52
- selectTranslations,
53
- } from "./selectors";
54
-
55
- interface BookingProps {
56
- productCode: string;
57
- productName: string;
58
- thumbnailUrl?: string;
59
- }
60
-
61
- const Booking: React.FC<BookingProps> = ({
62
- productCode,
63
- productName,
64
- thumbnailUrl,
65
- }) => {
66
- const {
67
- officeId,
68
- bookingOptions,
69
- basePath,
70
- roomOptions,
71
- flightOptions,
72
- options,
73
- travellers,
74
- summary,
75
- confirmation,
76
- error,
77
- showSidebarDeposit,
78
- includeFlights,
79
- loaderComponent,
80
- skipPaymentWithAgent,
81
- generatePaymentUrl,
82
- tagIds,
83
- agentAdressId,
84
- language,
85
- translationFiles,
86
- accommodationViewId,
87
- isOffer,
88
- } = useContext(SettingsContext);
89
-
90
- const dispatch = useAppDispatch();
91
- const location = useLocation();
92
-
93
- const productAttributes = useSelector(selectProductAttributes);
94
- const bookingAttributes = useSelector(selectBookingAttributes);
95
- const rooms = useSelector(selectBookingRooms);
96
- const bookingNumber = useSelector(selectBookingNumber);
97
- const isRetry = useSelector(selectIsRetry);
98
- const packageDetails = useSelector(selectPackageDetails);
99
- const isUnvailable = useSelector(selectIsUnavailable);
100
- const translations = useSelector(selectTranslations);
101
-
102
- useEffect(() => {
103
- dispatch(setSkipPayment(skipPaymentWithAgent ?? false));
104
- dispatch(setGeneratePaymentUrl(generatePaymentUrl ?? false));
105
- }, [skipPaymentWithAgent, generatePaymentUrl]);
106
-
107
- useEffect(() => {
108
- const params = new URLSearchParams(location.search);
109
- const startDate = getDateFromParams(params, "startDate");
110
- const endDate = getDateFromParams(params, "endDate");
111
- const catalog = getNumberFromParams(params, "catalog");
112
- const rooms = getRoomsFromParams(params, "rooms");
113
- const flight = getFlightsFromParams(params, "flight");
114
- const flightRouteId = getStringFromParams(params, "flightRouteId");
115
- const vendorConfigurationId = getNumberFromParams(
116
- params,
117
- "vendorConfigurationId"
118
- );
119
- const allotmentName = getStringFromParams(params, "allotmentName");
120
- const allotmentIds = getNumbersFromParams(params, "allotmentId");
121
- const tourCode = getStringFromParams(params, "tourCode");
122
- const bookingNumber = params.get("bookingNr") ?? undefined;
123
-
124
- if (typeof window !== "undefined") {
125
- window.scrollTo(0, 0);
126
- }
127
-
128
- if (!isNil(bookingNumber)) {
129
- dispatch(setBookingNumber(bookingNumber));
130
- navigate(
131
- `${basePath}${confirmation.pathSuffix}?bookingNr=${bookingNumber}`
132
- );
133
- }
134
-
135
- if (
136
- !isNil(startDate) &&
137
- !isNil(endDate) &&
138
- !isNil(catalog) &&
139
- !isNil(rooms)
140
- ) {
141
- dispatch(
142
- setBookingAttributes({
143
- startDate,
144
- endDate,
145
- catalog,
146
- rooms,
147
- flight,
148
- includeFlights,
149
- allotmentName,
150
- allotmentIds,
151
- tourCode,
152
- flightRouteId,
153
- vendorConfigurationId,
154
- })
155
- );
156
- } else {
157
- console.error(
158
- "Failure when setting booking attributes",
159
- startDate,
160
- endDate,
161
- catalog,
162
- rooms
163
- );
164
- }
165
- }, [location.search, setBookingAttributes, setBookingNumber, includeFlights]);
166
-
167
- useEffect(() => {
168
- if (
169
- !productAttributes ||
170
- !bookingAttributes ||
171
- !isNil(bookingNumber) ||
172
- !isRetry
173
- ) {
174
- return;
175
- }
176
-
177
- // Retried
178
- dispatch(setIsRetry(false));
179
-
180
- // Fetch data
181
- const promise = dispatch(fetchPackage());
182
- return () => {
183
- promise.abort();
184
- };
185
- }, [isRetry]);
186
-
187
- useEffect(() => {
188
- if (!isNil(productCode) && !isNil(productName)) {
189
- dispatch(
190
- setProductAttributes({
191
- productCode,
192
- productName,
193
- })
194
- );
195
- } else {
196
- console.error(
197
- "Failure when setting product attributes",
198
- productCode,
199
- productName
200
- );
201
- }
202
- }, [productCode, productName, setProductAttributes]);
203
-
204
- const getTranslations = async () => {
205
- const translations = translationFiles?.map((x) =>
206
- fetch(x.path)
207
- .then((y) => y.json())
208
- .then((z) => ({ language: x.language, value: z }))
209
- );
210
- return translations && (await Promise.all(translations));
211
- };
212
-
213
- useEffect(() => {
214
- const loadTranslations = async () => {
215
- const translations = await getTranslations();
216
- dispatch(setTranslations(translations)); // Now dispatch the resolved value
217
- };
218
-
219
- loadTranslations();
220
-
221
- dispatch(setOfficeId(officeId));
222
- dispatch(setLanguageCode(language));
223
- dispatch(setBookingOptions(bookingOptions));
224
- dispatch(setCalculateDeposit(showSidebarDeposit));
225
- if (tagIds && tagIds.length > 0) {
226
- dispatch(setTagIds(tagIds ?? undefined));
227
- }
228
- dispatch(setAgentAdressId(agentAdressId ?? undefined));
229
- if (agentAdressId && agentAdressId != 0) {
230
- dispatch(setBookingType("b2b"));
231
- }
232
- if (accommodationViewId && accommodationViewId != 0) {
233
- dispatch(setAccommodationViewId(accommodationViewId));
234
- }
235
- }, [
236
- officeId,
237
- language,
238
- bookingOptions,
239
- showSidebarDeposit,
240
- setOfficeId,
241
- setLanguageCode,
242
- setCalculateDeposit,
243
- tagIds,
244
- agentAdressId,
245
- accommodationViewId,
246
- ]);
247
-
248
- useEffect(() => {
249
- if (
250
- !productAttributes ||
251
- !bookingAttributes ||
252
- !rooms?.length ||
253
- !isNil(bookingNumber) ||
254
- !isNil(packageDetails)
255
- ) {
256
- return;
257
- }
258
- // Fetch data
259
- const promise = dispatch(fetchPackage());
260
- return () => {
261
- promise.abort();
262
- };
263
- }, [
264
- productAttributes,
265
- bookingAttributes,
266
- rooms,
267
- bookingNumber,
268
- packageDetails,
269
- ]);
270
-
271
- let numberIndex = 1;
272
-
273
- return (
274
- <>
275
- {((productAttributes && bookingAttributes && packageDetails) ||
276
- bookingNumber) && (
277
- <div className="booking">
278
- <div className="booking__content">
279
- <div className="booking__panel">
280
- <Router basepath={basePath}>
281
- {!flightOptions.isHidden && flightOptions.pathSuffix && (
282
- <StepRoute
283
- path={flightOptions.pathSuffix}
284
- number={numberIndex++}
285
- title={translations.STEPS.FLIGHT_OPTIONS}
286
- component={<FlightOptionsForm />}
287
- />
288
- )}
289
- {!roomOptions.isHidden && roomOptions.pathSuffix && (
290
- <StepRoute
291
- path={roomOptions.pathSuffix}
292
- number={numberIndex++}
293
- title={translations.STEPS.ROOM_OPTIONS}
294
- component={<RoomOptionsForm />}
295
- />
296
- )}
297
- <StepRoute
298
- path={options.pathSuffix}
299
- number={numberIndex++}
300
- title={translations.STEPS.EXTRA_OPTIONS}
301
- component={<OptionsForm />}
302
- />
303
- <StepRoute
304
- path={travellers.pathSuffix}
305
- number={numberIndex++}
306
- title={translations.STEPS.PERSONAL_DETAILS}
307
- component={<TravelersForm />}
308
- />
309
- <StepRoute
310
- path={summary.pathSuffix}
311
- number={numberIndex++}
312
- title={translations.STEPS.SUMMARY}
313
- component={<Summary />}
314
- />
315
- <StepRoute
316
- path={confirmation.pathSuffix}
317
- number={numberIndex++}
318
- title={translations.STEPS.CONFIRMATION}
319
- component={<Confirmation />}
320
- />
321
- <StepRoute
322
- path={error.pathSuffix}
323
- number={numberIndex++}
324
- title={translations.STEPS.ERROR}
325
- component={<Error />}
326
- />
327
- </Router>
328
- </div>
329
- <div className="backdrop" id="backdrop"></div>
330
- {packageDetails && (
331
- <Sidebar productName={productName} thumbnailUrl={thumbnailUrl} />
332
- )}
333
- </div>
334
- </div>
335
- )}
336
- {!packageDetails && !bookingNumber && !isUnvailable && (
337
- <div className="booking">
338
- <div className="booking__loader">
339
- {loaderComponent}
340
- <p className="booking__loader-text">
341
- {isOffer
342
- ? translations.MAIN.PREPARING_OFFER
343
- : translations.MAIN.PREPARING_BOOKING}
344
- </p>
345
- </div>
346
- </div>
347
- )}
348
- {isUnvailable && (
349
- <div className="booking">
350
- <div className="booking__loader">
351
- <p className="booking__loader-text">
352
- {translations.MAIN.PRODUCT_UNAVAILABLE}
353
- </p>
354
- </div>
355
- </div>
356
- )}
357
- </>
358
- );
359
- };
360
-
361
- export default Booking;
1
+ import { navigate, Router, useLocation } from "@reach/router";
2
+ import React, { useContext } from "react";
3
+ import { useSelector } from "react-redux";
4
+ import {
5
+ getDateFromParams,
6
+ getFlightsFromParams,
7
+ getNumberFromParams,
8
+ getNumbersFromParams,
9
+ getRoomsFromParams,
10
+ getStringFromParams,
11
+ } from "../../../shared/utils/query-string-util";
12
+ import {
13
+ fetchPackage,
14
+ setAccommodationViewId,
15
+ setAgentAdressId,
16
+ setBookingAttributes,
17
+ setBookingNumber,
18
+ setBookingOptions,
19
+ setBookingType,
20
+ setCalculateDeposit,
21
+ setGeneratePaymentUrl,
22
+ setIsRetry,
23
+ setLanguageCode,
24
+ setOfficeId,
25
+ setProductAttributes,
26
+ setSkipPayment,
27
+ setTagIds,
28
+ setTranslations,
29
+ } from "./booking-slice";
30
+
31
+ import { isNil } from "lodash";
32
+ import { useEffect } from "react";
33
+ import StepRoute from "../../components/step-route";
34
+ import SettingsContext from "../../settings-context";
35
+ import { useAppDispatch } from "../../store";
36
+ import Confirmation from "../confirmation/confirmation";
37
+ import Error from "../error/error";
38
+ import FlightOptionsForm from "../flight-options";
39
+ import OptionsForm from "../product-options/options-form";
40
+ import RoomOptionsForm from "../room-options";
41
+ import Sidebar from "../sidebar";
42
+ import Summary from "../summary/summary";
43
+ import TravelersForm from "../travelers-form/travelers-form";
44
+ import {
45
+ selectBookingAttributes,
46
+ selectBookingNumber,
47
+ selectBookingRooms,
48
+ selectIsRetry,
49
+ selectIsUnavailable,
50
+ selectPackageDetails,
51
+ selectProductAttributes,
52
+ selectTranslations,
53
+ } from "./selectors";
54
+
55
+ interface BookingProps {
56
+ productCode: string;
57
+ productName: string;
58
+ thumbnailUrl?: string;
59
+ }
60
+
61
+ const Booking: React.FC<BookingProps> = ({
62
+ productCode,
63
+ productName,
64
+ thumbnailUrl,
65
+ }) => {
66
+ const {
67
+ officeId,
68
+ bookingOptions,
69
+ basePath,
70
+ roomOptions,
71
+ flightOptions,
72
+ options,
73
+ travellers,
74
+ summary,
75
+ confirmation,
76
+ error,
77
+ showSidebarDeposit,
78
+ includeFlights,
79
+ loaderComponent,
80
+ skipPaymentWithAgent,
81
+ generatePaymentUrl,
82
+ tagIds,
83
+ agentAdressId,
84
+ language,
85
+ translationFiles,
86
+ accommodationViewId,
87
+ isOffer,
88
+ } = useContext(SettingsContext);
89
+
90
+ const dispatch = useAppDispatch();
91
+ const location = useLocation();
92
+
93
+ const productAttributes = useSelector(selectProductAttributes);
94
+ const bookingAttributes = useSelector(selectBookingAttributes);
95
+ const rooms = useSelector(selectBookingRooms);
96
+ const bookingNumber = useSelector(selectBookingNumber);
97
+ const isRetry = useSelector(selectIsRetry);
98
+ const packageDetails = useSelector(selectPackageDetails);
99
+ const isUnvailable = useSelector(selectIsUnavailable);
100
+ const translations = useSelector(selectTranslations);
101
+
102
+ useEffect(() => {
103
+ dispatch(setSkipPayment(skipPaymentWithAgent ?? false));
104
+ dispatch(setGeneratePaymentUrl(generatePaymentUrl ?? false));
105
+ }, [skipPaymentWithAgent, generatePaymentUrl]);
106
+
107
+ useEffect(() => {
108
+ const params = new URLSearchParams(location.search);
109
+ const startDate = getDateFromParams(params, "startDate");
110
+ const endDate = getDateFromParams(params, "endDate");
111
+ const catalog = getNumberFromParams(params, "catalog");
112
+ const rooms = getRoomsFromParams(params, "rooms");
113
+ const flight = getFlightsFromParams(params, "flight");
114
+ const flightRouteId = getStringFromParams(params, "flightRouteId");
115
+ const vendorConfigurationId = getNumberFromParams(
116
+ params,
117
+ "vendorConfigurationId"
118
+ );
119
+ const allotmentName = getStringFromParams(params, "allotmentName");
120
+ const allotmentIds = getNumbersFromParams(params, "allotmentId");
121
+ const tourCode = getStringFromParams(params, "tourCode");
122
+ const bookingNumber = params.get("bookingNr") ?? undefined;
123
+
124
+ if (typeof window !== "undefined") {
125
+ window.scrollTo(0, 0);
126
+ }
127
+
128
+ if (!isNil(bookingNumber)) {
129
+ dispatch(setBookingNumber(bookingNumber));
130
+ navigate(
131
+ `${basePath}${confirmation.pathSuffix}?bookingNr=${bookingNumber}`
132
+ );
133
+ }
134
+
135
+ if (
136
+ !isNil(startDate) &&
137
+ !isNil(endDate) &&
138
+ !isNil(catalog) &&
139
+ !isNil(rooms)
140
+ ) {
141
+ dispatch(
142
+ setBookingAttributes({
143
+ startDate,
144
+ endDate,
145
+ catalog,
146
+ rooms,
147
+ flight,
148
+ includeFlights,
149
+ allotmentName,
150
+ allotmentIds,
151
+ tourCode,
152
+ flightRouteId,
153
+ vendorConfigurationId,
154
+ })
155
+ );
156
+ } else {
157
+ console.error(
158
+ "Failure when setting booking attributes",
159
+ startDate,
160
+ endDate,
161
+ catalog,
162
+ rooms
163
+ );
164
+ }
165
+ }, [location.search, setBookingAttributes, setBookingNumber, includeFlights]);
166
+
167
+ useEffect(() => {
168
+ if (
169
+ !productAttributes ||
170
+ !bookingAttributes ||
171
+ !isNil(bookingNumber) ||
172
+ !isRetry
173
+ ) {
174
+ return;
175
+ }
176
+
177
+ // Retried
178
+ dispatch(setIsRetry(false));
179
+
180
+ // Fetch data
181
+ const promise = dispatch(fetchPackage());
182
+ return () => {
183
+ promise.abort();
184
+ };
185
+ }, [isRetry]);
186
+
187
+ useEffect(() => {
188
+ if (!isNil(productCode) && !isNil(productName)) {
189
+ dispatch(
190
+ setProductAttributes({
191
+ productCode,
192
+ productName,
193
+ })
194
+ );
195
+ } else {
196
+ console.error(
197
+ "Failure when setting product attributes",
198
+ productCode,
199
+ productName
200
+ );
201
+ }
202
+ }, [productCode, productName, setProductAttributes]);
203
+
204
+ const getTranslations = async () => {
205
+ const translations = translationFiles?.map((x) =>
206
+ fetch(x.path)
207
+ .then((y) => y.json())
208
+ .then((z) => ({ language: x.language, value: z }))
209
+ );
210
+ return translations && (await Promise.all(translations));
211
+ };
212
+
213
+ useEffect(() => {
214
+ const loadTranslations = async () => {
215
+ const translations = await getTranslations();
216
+ dispatch(setTranslations(translations)); // Now dispatch the resolved value
217
+ };
218
+
219
+ loadTranslations();
220
+
221
+ dispatch(setOfficeId(officeId));
222
+ dispatch(setLanguageCode(language));
223
+ dispatch(setBookingOptions(bookingOptions));
224
+ dispatch(setCalculateDeposit(showSidebarDeposit));
225
+ if (tagIds && tagIds.length > 0) {
226
+ dispatch(setTagIds(tagIds ?? undefined));
227
+ }
228
+ dispatch(setAgentAdressId(agentAdressId ?? undefined));
229
+ if (agentAdressId && agentAdressId != 0) {
230
+ dispatch(setBookingType("b2b"));
231
+ }
232
+ if (accommodationViewId && accommodationViewId != 0) {
233
+ dispatch(setAccommodationViewId(accommodationViewId));
234
+ }
235
+ }, [
236
+ officeId,
237
+ language,
238
+ bookingOptions,
239
+ showSidebarDeposit,
240
+ setOfficeId,
241
+ setLanguageCode,
242
+ setCalculateDeposit,
243
+ tagIds,
244
+ agentAdressId,
245
+ accommodationViewId,
246
+ ]);
247
+
248
+ useEffect(() => {
249
+ if (
250
+ !productAttributes ||
251
+ !bookingAttributes ||
252
+ !rooms?.length ||
253
+ !isNil(bookingNumber) ||
254
+ !isNil(packageDetails)
255
+ ) {
256
+ return;
257
+ }
258
+ // Fetch data
259
+ const promise = dispatch(fetchPackage());
260
+ return () => {
261
+ promise.abort();
262
+ };
263
+ }, [
264
+ productAttributes,
265
+ bookingAttributes,
266
+ rooms,
267
+ bookingNumber,
268
+ packageDetails,
269
+ ]);
270
+
271
+ let numberIndex = 1;
272
+
273
+ return (
274
+ <>
275
+ {((productAttributes && bookingAttributes && packageDetails) ||
276
+ bookingNumber) && (
277
+ <div className="booking">
278
+ <div className="booking__content">
279
+ <div className="booking__panel">
280
+ <Router basepath={basePath}>
281
+ {!flightOptions.isHidden && flightOptions.pathSuffix && (
282
+ <StepRoute
283
+ path={flightOptions.pathSuffix}
284
+ number={numberIndex++}
285
+ title={translations.STEPS.FLIGHT_OPTIONS}
286
+ component={<FlightOptionsForm />}
287
+ />
288
+ )}
289
+ {!roomOptions.isHidden && roomOptions.pathSuffix && (
290
+ <StepRoute
291
+ path={roomOptions.pathSuffix}
292
+ number={numberIndex++}
293
+ title={translations.STEPS.ROOM_OPTIONS}
294
+ component={<RoomOptionsForm />}
295
+ />
296
+ )}
297
+ <StepRoute
298
+ path={options.pathSuffix}
299
+ number={numberIndex++}
300
+ title={translations.STEPS.EXTRA_OPTIONS}
301
+ component={<OptionsForm />}
302
+ />
303
+ <StepRoute
304
+ path={travellers.pathSuffix}
305
+ number={numberIndex++}
306
+ title={translations.STEPS.PERSONAL_DETAILS}
307
+ component={<TravelersForm />}
308
+ />
309
+ <StepRoute
310
+ path={summary.pathSuffix}
311
+ number={numberIndex++}
312
+ title={translations.STEPS.SUMMARY}
313
+ component={<Summary />}
314
+ />
315
+ <StepRoute
316
+ path={confirmation.pathSuffix}
317
+ number={numberIndex++}
318
+ title={translations.STEPS.CONFIRMATION}
319
+ component={<Confirmation />}
320
+ />
321
+ <StepRoute
322
+ path={error.pathSuffix}
323
+ number={numberIndex++}
324
+ title={translations.STEPS.ERROR}
325
+ component={<Error />}
326
+ />
327
+ </Router>
328
+ </div>
329
+ <div className="backdrop" id="backdrop"></div>
330
+ {packageDetails && (
331
+ <Sidebar productName={productName} thumbnailUrl={thumbnailUrl} />
332
+ )}
333
+ </div>
334
+ </div>
335
+ )}
336
+ {!packageDetails && !bookingNumber && !isUnvailable && (
337
+ <div className="booking">
338
+ <div className="booking__loader">
339
+ {loaderComponent}
340
+ <p className="booking__loader-text">
341
+ {isOffer
342
+ ? translations.MAIN.PREPARING_OFFER
343
+ : translations.MAIN.PREPARING_BOOKING}
344
+ </p>
345
+ </div>
346
+ </div>
347
+ )}
348
+ {isUnvailable && (
349
+ <div className="booking">
350
+ <div className="booking__loader">
351
+ <p className="booking__loader-text">
352
+ {translations.MAIN.PRODUCT_UNAVAILABLE}
353
+ </p>
354
+ </div>
355
+ </div>
356
+ )}
357
+ </>
358
+ );
359
+ };
360
+
361
+ export default Booking;