@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
@@ -1,674 +1,674 @@
1
- import { book, validateVoucher } from "@qite/tide-client";
2
- import {
3
- BookingPackageRequest,
4
- BookingPackageVoucherRequest,
5
- } from "@qite/tide-client/build/types";
6
- import { Link, navigate, useLocation } from "@reach/router";
7
- import { compact, findIndex, isEmpty, isNil, uniqBy } from "lodash";
8
- import React, { useContext, useEffect, useState } from "react";
9
- import { useSelector } from "react-redux";
10
- import { buildClassName } from "../../../shared/utils/class-util";
11
- import { buildTideClientConfig } from "../../../shared/utils/tide-api-utils";
12
- import Icon from "../../components/icon";
13
- import SettingsContext from "../../settings-context";
14
- import { useAppDispatch } from "../../store";
15
- import { SummaryCheckbox } from "../../types";
16
- import {
17
- setBookingNumber,
18
- setBookingRemarks,
19
- setCurrentStep,
20
- setVoucherCodes,
21
- } from "../booking/booking-slice";
22
- import {
23
- CONFIRMATION_STEP,
24
- ERROR_STEP,
25
- TRAVELERS_FORM_STEP,
26
- } from "../booking/constants";
27
- import {
28
- selectActiveOption,
29
- selectAgentAdressId,
30
- selectApiSettings,
31
- selectBookingPackageBookRequest,
32
- selectBookingQueryString,
33
- selectLanguageCode,
34
- selectOfficeId,
35
- selectPackageDetails,
36
- selectTranslations,
37
- } from "../booking/selectors";
38
- import {
39
- fetchPriceDetails,
40
- selectNotifications,
41
- setNotifications,
42
- } from "../price-details/price-details-slice";
43
- import { getDateText } from "../sidebar/sidebar-util";
44
- import {
45
- selectRooms,
46
- selectTravelersFormValues,
47
- } from "../travelers-form/travelers-form-slice";
48
- import SummaryBookingOptionPax from "./summary-booking-option-pax";
49
- import SummaryBookingOptionUnit from "./summary-booking-option-unit";
50
- import SummaryFlight from "./summary-flight";
51
- import SummaryBookingOption from "./summary-per-booking-option-group";
52
- import { selectUserValidated, setUserValidated } from "./summary-slice";
53
-
54
- interface VoucherProps {
55
- code?: string;
56
- isValidated?: boolean;
57
- isValid?: boolean;
58
- }
59
-
60
- interface SummaryProps {}
61
-
62
- const Summary: React.FC<SummaryProps> = () => {
63
- const dispatch = useAppDispatch();
64
-
65
- const settings = useContext(SettingsContext);
66
-
67
- const [isSubmitting, setIsSubmitting] = useState(false);
68
- const [checkboxes, setCheckboxes] = useState<
69
- SummaryCheckbox[] | undefined | null
70
- >(settings.summary?.checkboxes);
71
- const [remarks, setRemarks] = useState<string>("");
72
-
73
- const [voucher, setVoucher] = useState<VoucherProps>({});
74
-
75
- const bookingQueryString = useSelector(selectBookingQueryString);
76
- const travelerFormValues = useSelector(selectTravelersFormValues);
77
- const packageDetails = useSelector(selectPackageDetails);
78
- const activeOption = useSelector(selectActiveOption);
79
- const apiSettings = useSelector(selectApiSettings);
80
- const languageCode = useSelector(selectLanguageCode);
81
- const officeId = useSelector(selectOfficeId);
82
- const agentId = useSelector(selectAgentAdressId);
83
-
84
- if (!travelerFormValues) {
85
- if (settings.skipRouter) {
86
- dispatch(setCurrentStep(TRAVELERS_FORM_STEP));
87
- } else {
88
- navigate(`${settings.basePath}?${bookingQueryString}`);
89
- }
90
- }
91
-
92
- const rooms = useSelector(selectRooms);
93
-
94
- const userValidated = useSelector(selectUserValidated);
95
- const notifications = useSelector(selectNotifications);
96
-
97
- const bookRequest = useSelector(selectBookingPackageBookRequest);
98
-
99
- useEffect(() => {
100
- // Every checkbox should be checked, or no checkboxes
101
- const checkboxesValidated = !isNil(checkboxes)
102
- ? checkboxes.every((checkbox) => checkbox.isSelected)
103
- : true;
104
-
105
- const notificationsValidated = !isNil(notifications)
106
- ? notifications
107
- .filter((x) => x.hasToBeConfirmed)
108
- .every((checkbox) => checkbox.isConfirmed)
109
- : true;
110
-
111
- dispatch(setUserValidated(checkboxesValidated && notificationsValidated));
112
- }, [checkboxes, notifications]);
113
-
114
- const handleSubmit: React.FormEventHandler<HTMLFormElement> = async (e) => {
115
- e.preventDefault();
116
- setIsSubmitting(true);
117
-
118
- if (typeof window !== "undefined") {
119
- window.scrollTo(0, 0);
120
- }
121
-
122
- const tideClientConfig = buildTideClientConfig(apiSettings);
123
-
124
- if (!bookRequest || !tideClientConfig) {
125
- return;
126
- }
127
-
128
- if (bookRequest.payload.returnPaymentUrl) {
129
- const location = useLocation();
130
- bookRequest.payload.redirectUrl = `${location.protocol}//${location.host}${settings.basePath}`;
131
- }
132
-
133
- try {
134
- const bookingResponse = await book(
135
- tideClientConfig,
136
- bookRequest,
137
- undefined,
138
- languageCode
139
- );
140
-
141
- // Booking successfull
142
- dispatch(setBookingNumber(bookingResponse.number));
143
-
144
- if (bookingResponse.paymentUrl) {
145
- window.location.href = bookingResponse.paymentUrl;
146
- } else {
147
- if (settings.skipRouter) {
148
- dispatch(setCurrentStep(CONFIRMATION_STEP));
149
- } else {
150
- navigate(
151
- `${settings.basePath}${settings.confirmation.pathSuffix}?${bookingQueryString}`
152
- );
153
- }
154
- }
155
- } catch (error) {
156
- if (settings.skipRouter) {
157
- dispatch(setCurrentStep(ERROR_STEP));
158
- } else {
159
- navigate(
160
- `${settings.basePath}${settings.error.pathSuffix}?${bookingQueryString}`
161
- );
162
- }
163
- } finally {
164
- setIsSubmitting(false);
165
- }
166
- };
167
-
168
- const handleNotificationChange = (id: number, checked: boolean) => {
169
- const updatedNotifications = notifications.map((notification) =>
170
- notification.id === id
171
- ? { ...notification, isConfirmed: checked }
172
- : notification
173
- );
174
-
175
- dispatch(setNotifications(updatedNotifications));
176
- };
177
-
178
- const handleCheckboxChange = (id: string, checked: boolean) => {
179
- if (isNil(checkboxes)) {
180
- return;
181
- }
182
-
183
- const newCheckboxes = [...checkboxes];
184
-
185
- const index = findIndex(checkboxes, (checkbox) => checkbox.id === id);
186
- newCheckboxes[index].isSelected = !newCheckboxes[index].isSelected;
187
-
188
- setCheckboxes(newCheckboxes);
189
- };
190
-
191
- const handleRemarksChange = (text: string) => {
192
- dispatch(setBookingRemarks(text));
193
-
194
- setRemarks(text);
195
- };
196
-
197
- const handleValidateVoucher = async () => {
198
- if (!voucher?.code) return;
199
-
200
- const request = {
201
- officeId: officeId,
202
- agentId: agentId,
203
- payload: {
204
- code: voucher.code,
205
- otherCodes: bookRequest?.payload.voucherCodes ?? [],
206
- },
207
- } as BookingPackageRequest<BookingPackageVoucherRequest>;
208
-
209
- const tideClientConfig = buildTideClientConfig(apiSettings);
210
- if (!tideClientConfig) return;
211
-
212
- const result = await validateVoucher(tideClientConfig, request);
213
-
214
- if (result) {
215
- setVoucher({
216
- ...voucher,
217
- isValidated: true,
218
- isValid: result.isValid,
219
- });
220
- }
221
- };
222
-
223
- const handleAddVoucher: React.MouseEventHandler<HTMLButtonElement> = (
224
- event
225
- ) => {
226
- if (!voucher.isValid) return;
227
-
228
- dispatch(
229
- setVoucherCodes(
230
- [
231
- ...(bookRequest?.payload.voucherCodes ?? []),
232
- voucher.code ?? "",
233
- ].filter((x) => x !== "")
234
- )
235
- );
236
-
237
- dispatch(fetchPriceDetails());
238
-
239
- setVoucher({});
240
- };
241
-
242
- const handleRemoveVoucher = (code: string) => {
243
- dispatch(
244
- setVoucherCodes(
245
- bookRequest?.payload.voucherCodes?.filter((x) => x !== code) ?? []
246
- )
247
- );
248
-
249
- dispatch(fetchPriceDetails());
250
- };
251
-
252
- const goPrevious = () => {
253
- dispatch(setCurrentStep(TRAVELERS_FORM_STEP));
254
- };
255
-
256
- const translations = useSelector(selectTranslations);
257
-
258
- return (
259
- <>
260
- {isSubmitting && settings.loaderComponent}
261
- {!isSubmitting && (
262
- <form
263
- className="form"
264
- name="booking--summary"
265
- id="booking--summary"
266
- onSubmit={handleSubmit}
267
- >
268
- <div className="form__booking--summary">
269
- <div className="form__region">
270
- <div className="form__row">
271
- <div className="form__group">
272
- <div className="form__region-header">
273
- <h5 className="form__region-heading">
274
- {translations.SUMMARY.PERSONAL_DETAILS}
275
- </h5>
276
- </div>
277
- </div>
278
- </div>
279
- {rooms.map((r, rIndex) => (
280
- <div className="form__row">
281
- <div className="form__group">
282
- <div className="form__region-header">
283
- <h5 className="form__region-heading">
284
- {translations.SHARED.ROOM} {rIndex + 1}
285
- </h5>
286
- <p className="form__region-label">
287
- {`${r.adults.length + r.children.length} ${
288
- r.adults.length + r.children.length === 1
289
- ? translations.SUMMARY.TRAVELER
290
- : translations.SUMMARY.TRAVELERS
291
- }: ${compact([
292
- r.adults.length,
293
- r.adults.length === 1 &&
294
- ` ${translations.SUMMARY.ADULT}`,
295
- r.adults.length > 1 &&
296
- ` ${translations.SUMMARY.ADULTS}`,
297
- r.adults &&
298
- r.adults.length &&
299
- r.children &&
300
- r.children.length &&
301
- ", ",
302
- r.children.length,
303
- r.children.length === 1 &&
304
- ` ${translations.SUMMARY.CHILD}`,
305
- r.children.length > 1 &&
306
- ` ${translations.SUMMARY.CHILDREN}`,
307
- ]).join("")}`}
308
- </p>
309
- </div>
310
- </div>
311
- {[...r.adults, ...r.children].map((traveler) => {
312
- const isMainBooker =
313
- traveler.id === travelerFormValues?.mainBookerId;
314
- return (
315
- <div
316
- className="form__group form__group--sm-50"
317
- key={traveler.id}
318
- >
319
- <ul className="list list--plain">
320
- <li className="list__item">
321
- <strong>
322
- {traveler.firstName} {traveler.lastName}
323
- </strong>{" "}
324
- {isMainBooker && (
325
- <em>({translations.SUMMARY.MAIN_BOOKER})</em>
326
- )}
327
- </li>
328
- <li className="list__item">
329
- {traveler.birthDate.split("-").reverse().join("/")}
330
- </li>
331
- {isMainBooker && (
332
- <>
333
- <li className="list__item">{`${
334
- travelerFormValues?.street
335
- } ${compact([
336
- travelerFormValues?.houseNumber,
337
- travelerFormValues?.box,
338
- ]).join(" ")}, ${travelerFormValues?.zipCode} ${
339
- travelerFormValues?.place
340
- }`}</li>
341
- <li className="list__item">
342
- {travelerFormValues?.phone}
343
- </li>
344
- <li className="list__item">
345
- {travelerFormValues?.email}
346
- </li>
347
- </>
348
- )}
349
- </ul>
350
- </div>
351
- );
352
- })}
353
- </div>
354
- ))}
355
- </div>
356
-
357
- <div className="form__region">
358
- <div className="form__row">
359
- <div className="form__group">
360
- <div className="form__region-header">
361
- <h5 className="form__region-heading">
362
- {translations.SUMMARY.OPTIONS}
363
- </h5>
364
- </div>
365
- </div>
366
- </div>
367
- <div className="form__row">
368
- <div className="form__group">
369
- <ul className="list list--booking-summary">
370
- <li>
371
- <h6>{activeOption?.name}</h6>
372
- <ul>
373
- {activeOption?.rooms.map((r, ri) => {
374
- const roomOption = r.options.find(
375
- (x) => x.isSelected
376
- );
377
- return (
378
- <li key={ri} className="list__item">
379
- {roomOption?.accommodationName}
380
- {!isNil(roomOption?.regimeName) && ", "}
381
- {roomOption?.regimeName}
382
- </li>
383
- );
384
- })}
385
- </ul>
386
- <p>
387
- ({getDateText(activeOption?.fromDate)} &gt;{" "}
388
- {getDateText(activeOption?.toDate)})
389
- </p>
390
- </li>
391
- {!isEmpty(activeOption?.groups) &&
392
- activeOption?.groups.map((x, i) => {
393
- if (!x.options.some((y) => y.isSelected)) return;
394
-
395
- return <SummaryBookingOption key={i} group={x} />;
396
- })}
397
- {!isEmpty(activeOption?.optionUnits) &&
398
- activeOption?.optionUnits.map((x) => (
399
- <SummaryBookingOptionUnit unit={x} />
400
- ))}
401
- {!isEmpty(activeOption?.optionPax) &&
402
- activeOption?.optionPax.map((x) => (
403
- <SummaryBookingOptionPax pax={x} />
404
- ))}
405
- {packageDetails?.outwardFlights &&
406
- packageDetails.outwardFlights
407
- .filter((x) => x.isSelected)
408
- .map((flight, i) => (
409
- <SummaryFlight
410
- key={i}
411
- flight={flight}
412
- header={translations.SIDEBAR.DEPARTURE_FLIGHT}
413
- />
414
- ))}
415
- {packageDetails?.returnFlights &&
416
- packageDetails.returnFlights
417
- .filter((x) => x.isSelected)
418
- .map((flight, i) => (
419
- <SummaryFlight
420
- key={i}
421
- flight={flight}
422
- header={translations.SIDEBAR.ARRIVAL_FLIGHT}
423
- />
424
- ))}
425
- </ul>
426
- </div>
427
- </div>
428
- </div>
429
-
430
- {settings.enableVoucher && (
431
- <div className="form__region">
432
- <div className="form__row">
433
- <div className="form__group">
434
- <div className="form__region-header">
435
- <h5 className="form__region-heading">
436
- {translations.SUMMARY.VOUCHERS}
437
- </h5>
438
- </div>
439
- </div>
440
- </div>
441
- <div className="form__row">
442
- <div className="form__group">
443
- <input
444
- type="text"
445
- className="form__input info-message__voucher__input"
446
- defaultValue={voucher.code}
447
- onChange={(e) => setVoucher({ code: e.target.value })}
448
- />
449
- <button
450
- type="button"
451
- className={buildClassName([
452
- "cta",
453
- !voucher.code && "cta--disabled",
454
- ])}
455
- onClick={(e) => handleValidateVoucher()}
456
- >
457
- {translations.SUMMARY.VOUCHER_VALIDATE}
458
- </button>
459
- </div>
460
- </div>
461
- <div className="form__row">
462
- <div className="form__group info-message__voucher">
463
- {voucher.isValid && voucher.isValidated && (
464
- <div className="info-message info-message__voucher__valid">
465
- <span>{translations.SUMMARY.VOUCHER_VALID}</span>
466
- <button
467
- type="button"
468
- className="cta cta--secondary"
469
- onClick={handleAddVoucher}
470
- >
471
- {translations.SUMMARY.ADD_VOUCHER}
472
- </button>
473
- </div>
474
- )}
475
- {!voucher.isValid && voucher.isValidated && (
476
- <div className="info-message--error">
477
- {translations.SUMMARY.VOUCHER_INVALID}
478
- </div>
479
- )}
480
- </div>
481
- </div>
482
- <div className="form__row">
483
- <ul className="info-message__voucher">
484
- {!isEmpty(bookRequest?.payload.voucherCodes) &&
485
- bookRequest?.payload.voucherCodes?.map((y) => (
486
- <li>
487
- <div className="info-message__voucher__list">
488
- {y}{" "}
489
- <button
490
- type="button"
491
- className="cta--add-remove"
492
- onClick={(e) => handleRemoveVoucher(y)}
493
- >
494
- <Icon height={16} name="ui-trashcan" />
495
- </button>
496
- </div>
497
- </li>
498
- ))}
499
- </ul>
500
- </div>
501
- </div>
502
- )}
503
-
504
- {!isEmpty(notifications) && (
505
- <div className="form__region">
506
- <div className="form__row">
507
- <div className="form__group">
508
- <div className="info-message">
509
- <Icon
510
- name="ui-tooltip"
511
- className="icon--secondary-color"
512
- />
513
- <div className="info-message__copy">
514
- <h5>{translations.SUMMARY.NOTIFICATIONS_TITLE}</h5>
515
- <>
516
- {uniqBy(
517
- notifications.filter((x) => !x.hasToBeConfirmed),
518
- "id"
519
- ).map((notification) => (
520
- <span
521
- key={notification.id}
522
- className="checkbox__label-text"
523
- >
524
- <strong className="checkbox__label-text--title">
525
- {notification.title}
526
- </strong>
527
- <span className="checkbox__label-text--description">
528
- {notification.description}
529
- </span>
530
- </span>
531
- ))}
532
- {uniqBy(
533
- notifications.filter((x) => x.hasToBeConfirmed),
534
- "id"
535
- ).map((notification) => (
536
- <div className="checkbox" key={notification.id}>
537
- <label className="checkbox__label">
538
- <input
539
- type="checkbox"
540
- className="checkbox__input"
541
- checked={notification.isConfirmed}
542
- onChange={(e) =>
543
- handleNotificationChange(
544
- notification.id,
545
- e.target.checked
546
- )
547
- }
548
- />
549
- <span className="checkbox__label-text">
550
- <strong className="checkbox__label-text--title">
551
- {notification.title}
552
- </strong>
553
- <span className="checkbox__label-text--description">
554
- {notification.description}
555
- </span>
556
- </span>
557
- </label>
558
- </div>
559
- ))}
560
- </>
561
- </div>
562
- </div>
563
- </div>
564
- </div>
565
- </div>
566
- )}
567
-
568
- <div className="form__region">
569
- <div className="form__row">
570
- <div className="form__group">
571
- <div className="form__region-header">
572
- <h5 className="form__region-heading">
573
- {translations.SUMMARY.REMARKS}
574
- </h5>
575
- </div>
576
- </div>
577
- </div>
578
- <div className="form__row">
579
- <div className="form__group">
580
- <textarea
581
- className="form__input"
582
- defaultValue={remarks}
583
- onChange={(e) => handleRemarksChange(e.target.value)}
584
- ></textarea>
585
- </div>
586
- </div>
587
- </div>
588
-
589
- <div className="form__region">
590
- <div className="form__row">
591
- <div className="form__group">
592
- <div className="info-message">
593
- <Icon name="ui-tooltip" className="icon--secondary-color" />
594
- <div className="info-message__copy">
595
- <h5>{translations.SUMMARY.VALIDATE_TITLE}</h5>
596
- <p>
597
- {settings.isOffer
598
- ? translations.SUMMARY.VALIDATE_TEXT_OFFER
599
- : translations.SUMMARY.VALIDATE_TEXT_BOOKING}
600
- </p>
601
- {checkboxes &&
602
- checkboxes.map((checkbox) => (
603
- <div className="checkbox" key={checkbox.id}>
604
- <label className="checkbox__label">
605
- <input
606
- type="checkbox"
607
- className="checkbox__input"
608
- checked={checkbox.isSelected}
609
- onChange={(e) =>
610
- handleCheckboxChange(
611
- checkbox.id,
612
- e.target.checked
613
- )
614
- }
615
- />
616
- <span
617
- className="checkbox__label-text"
618
- dangerouslySetInnerHTML={{
619
- __html: checkbox.text,
620
- }}
621
- />
622
- </label>
623
- </div>
624
- ))}
625
- </div>
626
- </div>
627
- </div>
628
- </div>
629
- </div>
630
- </div>
631
-
632
- <div className="booking__navigator">
633
- {settings.skipRouter ? (
634
- <button
635
- type="button"
636
- title={translations.STEPS.PREVIOUS}
637
- onClick={() => goPrevious()}
638
- className="cta cta--secondary"
639
- >
640
- {translations.STEPS.PREVIOUS}
641
- </button>
642
- ) : (
643
- <Link
644
- to={`${settings.basePath}${settings.travellers.pathSuffix}?${bookingQueryString}`}
645
- title={translations.STEPS.PREVIOUS}
646
- className="cta cta--secondary"
647
- >
648
- {translations.STEPS.PREVIOUS}
649
- </Link>
650
- )}
651
- <button
652
- title={
653
- settings.isOffer
654
- ? translations.STEPS.SUBMIT_OFFER
655
- : translations.STEPS.SUBMIT_BOOKING
656
- }
657
- className={buildClassName([
658
- "cta",
659
- !userValidated && "cta--disabled",
660
- ])}
661
- disabled={!userValidated}
662
- >
663
- {settings.isOffer
664
- ? translations.STEPS.SUBMIT_OFFER
665
- : translations.STEPS.SUBMIT_BOOKING}
666
- </button>
667
- </div>
668
- </form>
669
- )}
670
- </>
671
- );
672
- };
673
-
674
- export default Summary;
1
+ import { book, validateVoucher } from "@qite/tide-client";
2
+ import {
3
+ BookingPackageRequest,
4
+ BookingPackageVoucherRequest,
5
+ } from "@qite/tide-client/build/types";
6
+ import { Link, navigate, useLocation } from "@reach/router";
7
+ import { compact, findIndex, isEmpty, isNil, uniqBy } from "lodash";
8
+ import React, { useContext, useEffect, useState } from "react";
9
+ import { useSelector } from "react-redux";
10
+ import { buildClassName } from "../../../shared/utils/class-util";
11
+ import { buildTideClientConfig } from "../../../shared/utils/tide-api-utils";
12
+ import Icon from "../../components/icon";
13
+ import SettingsContext from "../../settings-context";
14
+ import { useAppDispatch } from "../../store";
15
+ import { SummaryCheckbox } from "../../types";
16
+ import {
17
+ setBookingNumber,
18
+ setBookingRemarks,
19
+ setCurrentStep,
20
+ setVoucherCodes,
21
+ } from "../booking/booking-slice";
22
+ import {
23
+ CONFIRMATION_STEP,
24
+ ERROR_STEP,
25
+ TRAVELERS_FORM_STEP,
26
+ } from "../booking/constants";
27
+ import {
28
+ selectActiveOption,
29
+ selectAgentAdressId,
30
+ selectApiSettings,
31
+ selectBookingPackageBookRequest,
32
+ selectBookingQueryString,
33
+ selectLanguageCode,
34
+ selectOfficeId,
35
+ selectPackageDetails,
36
+ selectTranslations,
37
+ } from "../booking/selectors";
38
+ import {
39
+ fetchPriceDetails,
40
+ selectNotifications,
41
+ setNotifications,
42
+ } from "../price-details/price-details-slice";
43
+ import { getDateText } from "../sidebar/sidebar-util";
44
+ import {
45
+ selectRooms,
46
+ selectTravelersFormValues,
47
+ } from "../travelers-form/travelers-form-slice";
48
+ import SummaryBookingOptionPax from "./summary-booking-option-pax";
49
+ import SummaryBookingOptionUnit from "./summary-booking-option-unit";
50
+ import SummaryFlight from "./summary-flight";
51
+ import SummaryBookingOption from "./summary-per-booking-option-group";
52
+ import { selectUserValidated, setUserValidated } from "./summary-slice";
53
+
54
+ interface VoucherProps {
55
+ code?: string;
56
+ isValidated?: boolean;
57
+ isValid?: boolean;
58
+ }
59
+
60
+ interface SummaryProps {}
61
+
62
+ const Summary: React.FC<SummaryProps> = () => {
63
+ const dispatch = useAppDispatch();
64
+
65
+ const settings = useContext(SettingsContext);
66
+
67
+ const [isSubmitting, setIsSubmitting] = useState(false);
68
+ const [checkboxes, setCheckboxes] = useState<
69
+ SummaryCheckbox[] | undefined | null
70
+ >(settings.summary?.checkboxes);
71
+ const [remarks, setRemarks] = useState<string>("");
72
+
73
+ const [voucher, setVoucher] = useState<VoucherProps>({});
74
+
75
+ const bookingQueryString = useSelector(selectBookingQueryString);
76
+ const travelerFormValues = useSelector(selectTravelersFormValues);
77
+ const packageDetails = useSelector(selectPackageDetails);
78
+ const activeOption = useSelector(selectActiveOption);
79
+ const apiSettings = useSelector(selectApiSettings);
80
+ const languageCode = useSelector(selectLanguageCode);
81
+ const officeId = useSelector(selectOfficeId);
82
+ const agentId = useSelector(selectAgentAdressId);
83
+
84
+ if (!travelerFormValues) {
85
+ if (settings.skipRouter) {
86
+ dispatch(setCurrentStep(TRAVELERS_FORM_STEP));
87
+ } else {
88
+ navigate(`${settings.basePath}?${bookingQueryString}`);
89
+ }
90
+ }
91
+
92
+ const rooms = useSelector(selectRooms);
93
+
94
+ const userValidated = useSelector(selectUserValidated);
95
+ const notifications = useSelector(selectNotifications);
96
+
97
+ const bookRequest = useSelector(selectBookingPackageBookRequest);
98
+
99
+ useEffect(() => {
100
+ // Every checkbox should be checked, or no checkboxes
101
+ const checkboxesValidated = !isNil(checkboxes)
102
+ ? checkboxes.every((checkbox) => checkbox.isSelected)
103
+ : true;
104
+
105
+ const notificationsValidated = !isNil(notifications)
106
+ ? notifications
107
+ .filter((x) => x.hasToBeConfirmed)
108
+ .every((checkbox) => checkbox.isConfirmed)
109
+ : true;
110
+
111
+ dispatch(setUserValidated(checkboxesValidated && notificationsValidated));
112
+ }, [checkboxes, notifications]);
113
+
114
+ const handleSubmit: React.FormEventHandler<HTMLFormElement> = async (e) => {
115
+ e.preventDefault();
116
+ setIsSubmitting(true);
117
+
118
+ if (typeof window !== "undefined") {
119
+ window.scrollTo(0, 0);
120
+ }
121
+
122
+ const tideClientConfig = buildTideClientConfig(apiSettings);
123
+
124
+ if (!bookRequest || !tideClientConfig) {
125
+ return;
126
+ }
127
+
128
+ if (bookRequest.payload.returnPaymentUrl) {
129
+ const location = useLocation();
130
+ bookRequest.payload.redirectUrl = `${location.protocol}//${location.host}${settings.basePath}`;
131
+ }
132
+
133
+ try {
134
+ const bookingResponse = await book(
135
+ tideClientConfig,
136
+ bookRequest,
137
+ undefined,
138
+ languageCode
139
+ );
140
+
141
+ // Booking successfull
142
+ dispatch(setBookingNumber(bookingResponse.number));
143
+
144
+ if (bookingResponse.paymentUrl) {
145
+ window.location.href = bookingResponse.paymentUrl;
146
+ } else {
147
+ if (settings.skipRouter) {
148
+ dispatch(setCurrentStep(CONFIRMATION_STEP));
149
+ } else {
150
+ navigate(
151
+ `${settings.basePath}${settings.confirmation.pathSuffix}?${bookingQueryString}`
152
+ );
153
+ }
154
+ }
155
+ } catch (error) {
156
+ if (settings.skipRouter) {
157
+ dispatch(setCurrentStep(ERROR_STEP));
158
+ } else {
159
+ navigate(
160
+ `${settings.basePath}${settings.error.pathSuffix}?${bookingQueryString}`
161
+ );
162
+ }
163
+ } finally {
164
+ setIsSubmitting(false);
165
+ }
166
+ };
167
+
168
+ const handleNotificationChange = (id: number, checked: boolean) => {
169
+ const updatedNotifications = notifications.map((notification) =>
170
+ notification.id === id
171
+ ? { ...notification, isConfirmed: checked }
172
+ : notification
173
+ );
174
+
175
+ dispatch(setNotifications(updatedNotifications));
176
+ };
177
+
178
+ const handleCheckboxChange = (id: string, checked: boolean) => {
179
+ if (isNil(checkboxes)) {
180
+ return;
181
+ }
182
+
183
+ const newCheckboxes = [...checkboxes];
184
+
185
+ const index = findIndex(checkboxes, (checkbox) => checkbox.id === id);
186
+ newCheckboxes[index].isSelected = !newCheckboxes[index].isSelected;
187
+
188
+ setCheckboxes(newCheckboxes);
189
+ };
190
+
191
+ const handleRemarksChange = (text: string) => {
192
+ dispatch(setBookingRemarks(text));
193
+
194
+ setRemarks(text);
195
+ };
196
+
197
+ const handleValidateVoucher = async () => {
198
+ if (!voucher?.code) return;
199
+
200
+ const request = {
201
+ officeId: officeId,
202
+ agentId: agentId,
203
+ payload: {
204
+ code: voucher.code,
205
+ otherCodes: bookRequest?.payload.voucherCodes ?? [],
206
+ },
207
+ } as BookingPackageRequest<BookingPackageVoucherRequest>;
208
+
209
+ const tideClientConfig = buildTideClientConfig(apiSettings);
210
+ if (!tideClientConfig) return;
211
+
212
+ const result = await validateVoucher(tideClientConfig, request);
213
+
214
+ if (result) {
215
+ setVoucher({
216
+ ...voucher,
217
+ isValidated: true,
218
+ isValid: result.isValid,
219
+ });
220
+ }
221
+ };
222
+
223
+ const handleAddVoucher: React.MouseEventHandler<HTMLButtonElement> = (
224
+ event
225
+ ) => {
226
+ if (!voucher.isValid) return;
227
+
228
+ dispatch(
229
+ setVoucherCodes(
230
+ [
231
+ ...(bookRequest?.payload.voucherCodes ?? []),
232
+ voucher.code ?? "",
233
+ ].filter((x) => x !== "")
234
+ )
235
+ );
236
+
237
+ dispatch(fetchPriceDetails());
238
+
239
+ setVoucher({});
240
+ };
241
+
242
+ const handleRemoveVoucher = (code: string) => {
243
+ dispatch(
244
+ setVoucherCodes(
245
+ bookRequest?.payload.voucherCodes?.filter((x) => x !== code) ?? []
246
+ )
247
+ );
248
+
249
+ dispatch(fetchPriceDetails());
250
+ };
251
+
252
+ const goPrevious = () => {
253
+ dispatch(setCurrentStep(TRAVELERS_FORM_STEP));
254
+ };
255
+
256
+ const translations = useSelector(selectTranslations);
257
+
258
+ return (
259
+ <>
260
+ {isSubmitting && settings.loaderComponent}
261
+ {!isSubmitting && (
262
+ <form
263
+ className="form"
264
+ name="booking--summary"
265
+ id="booking--summary"
266
+ onSubmit={handleSubmit}
267
+ >
268
+ <div className="form__booking--summary">
269
+ <div className="form__region">
270
+ <div className="form__row">
271
+ <div className="form__group">
272
+ <div className="form__region-header">
273
+ <h5 className="form__region-heading">
274
+ {translations.SUMMARY.PERSONAL_DETAILS}
275
+ </h5>
276
+ </div>
277
+ </div>
278
+ </div>
279
+ {rooms.map((r, rIndex) => (
280
+ <div className="form__row">
281
+ <div className="form__group">
282
+ <div className="form__region-header">
283
+ <h5 className="form__region-heading">
284
+ {translations.SHARED.ROOM} {rIndex + 1}
285
+ </h5>
286
+ <p className="form__region-label">
287
+ {`${r.adults.length + r.children.length} ${
288
+ r.adults.length + r.children.length === 1
289
+ ? translations.SUMMARY.TRAVELER
290
+ : translations.SUMMARY.TRAVELERS
291
+ }: ${compact([
292
+ r.adults.length,
293
+ r.adults.length === 1 &&
294
+ ` ${translations.SUMMARY.ADULT}`,
295
+ r.adults.length > 1 &&
296
+ ` ${translations.SUMMARY.ADULTS}`,
297
+ r.adults &&
298
+ r.adults.length &&
299
+ r.children &&
300
+ r.children.length &&
301
+ ", ",
302
+ r.children.length,
303
+ r.children.length === 1 &&
304
+ ` ${translations.SUMMARY.CHILD}`,
305
+ r.children.length > 1 &&
306
+ ` ${translations.SUMMARY.CHILDREN}`,
307
+ ]).join("")}`}
308
+ </p>
309
+ </div>
310
+ </div>
311
+ {[...r.adults, ...r.children].map((traveler) => {
312
+ const isMainBooker =
313
+ traveler.id === travelerFormValues?.mainBookerId;
314
+ return (
315
+ <div
316
+ className="form__group form__group--sm-50"
317
+ key={traveler.id}
318
+ >
319
+ <ul className="list list--plain">
320
+ <li className="list__item">
321
+ <strong>
322
+ {traveler.firstName} {traveler.lastName}
323
+ </strong>{" "}
324
+ {isMainBooker && (
325
+ <em>({translations.SUMMARY.MAIN_BOOKER})</em>
326
+ )}
327
+ </li>
328
+ <li className="list__item">
329
+ {traveler.birthDate.split("-").reverse().join("/")}
330
+ </li>
331
+ {isMainBooker && (
332
+ <>
333
+ <li className="list__item">{`${
334
+ travelerFormValues?.street
335
+ } ${compact([
336
+ travelerFormValues?.houseNumber,
337
+ travelerFormValues?.box,
338
+ ]).join(" ")}, ${travelerFormValues?.zipCode} ${
339
+ travelerFormValues?.place
340
+ }`}</li>
341
+ <li className="list__item">
342
+ {travelerFormValues?.phone}
343
+ </li>
344
+ <li className="list__item">
345
+ {travelerFormValues?.email}
346
+ </li>
347
+ </>
348
+ )}
349
+ </ul>
350
+ </div>
351
+ );
352
+ })}
353
+ </div>
354
+ ))}
355
+ </div>
356
+
357
+ <div className="form__region">
358
+ <div className="form__row">
359
+ <div className="form__group">
360
+ <div className="form__region-header">
361
+ <h5 className="form__region-heading">
362
+ {translations.SUMMARY.OPTIONS}
363
+ </h5>
364
+ </div>
365
+ </div>
366
+ </div>
367
+ <div className="form__row">
368
+ <div className="form__group">
369
+ <ul className="list list--booking-summary">
370
+ <li>
371
+ <h6>{activeOption?.name}</h6>
372
+ <ul>
373
+ {activeOption?.rooms.map((r, ri) => {
374
+ const roomOption = r.options.find(
375
+ (x) => x.isSelected
376
+ );
377
+ return (
378
+ <li key={ri} className="list__item">
379
+ {roomOption?.accommodationName}
380
+ {!isNil(roomOption?.regimeName) && ", "}
381
+ {roomOption?.regimeName}
382
+ </li>
383
+ );
384
+ })}
385
+ </ul>
386
+ <p>
387
+ ({getDateText(activeOption?.fromDate)} &gt;{" "}
388
+ {getDateText(activeOption?.toDate)})
389
+ </p>
390
+ </li>
391
+ {!isEmpty(activeOption?.groups) &&
392
+ activeOption?.groups.map((x, i) => {
393
+ if (!x.options.some((y) => y.isSelected)) return;
394
+
395
+ return <SummaryBookingOption key={i} group={x} />;
396
+ })}
397
+ {!isEmpty(activeOption?.optionUnits) &&
398
+ activeOption?.optionUnits.map((x) => (
399
+ <SummaryBookingOptionUnit unit={x} />
400
+ ))}
401
+ {!isEmpty(activeOption?.optionPax) &&
402
+ activeOption?.optionPax.map((x) => (
403
+ <SummaryBookingOptionPax pax={x} />
404
+ ))}
405
+ {packageDetails?.outwardFlights &&
406
+ packageDetails.outwardFlights
407
+ .filter((x) => x.isSelected)
408
+ .map((flight, i) => (
409
+ <SummaryFlight
410
+ key={i}
411
+ flight={flight}
412
+ header={translations.SIDEBAR.DEPARTURE_FLIGHT}
413
+ />
414
+ ))}
415
+ {packageDetails?.returnFlights &&
416
+ packageDetails.returnFlights
417
+ .filter((x) => x.isSelected)
418
+ .map((flight, i) => (
419
+ <SummaryFlight
420
+ key={i}
421
+ flight={flight}
422
+ header={translations.SIDEBAR.ARRIVAL_FLIGHT}
423
+ />
424
+ ))}
425
+ </ul>
426
+ </div>
427
+ </div>
428
+ </div>
429
+
430
+ {settings.enableVoucher && (
431
+ <div className="form__region">
432
+ <div className="form__row">
433
+ <div className="form__group">
434
+ <div className="form__region-header">
435
+ <h5 className="form__region-heading">
436
+ {translations.SUMMARY.VOUCHERS}
437
+ </h5>
438
+ </div>
439
+ </div>
440
+ </div>
441
+ <div className="form__row">
442
+ <div className="form__group">
443
+ <input
444
+ type="text"
445
+ className="form__input info-message__voucher__input"
446
+ defaultValue={voucher.code}
447
+ onChange={(e) => setVoucher({ code: e.target.value })}
448
+ />
449
+ <button
450
+ type="button"
451
+ className={buildClassName([
452
+ "cta",
453
+ !voucher.code && "cta--disabled",
454
+ ])}
455
+ onClick={(e) => handleValidateVoucher()}
456
+ >
457
+ {translations.SUMMARY.VOUCHER_VALIDATE}
458
+ </button>
459
+ </div>
460
+ </div>
461
+ <div className="form__row">
462
+ <div className="form__group info-message__voucher">
463
+ {voucher.isValid && voucher.isValidated && (
464
+ <div className="info-message info-message__voucher__valid">
465
+ <span>{translations.SUMMARY.VOUCHER_VALID}</span>
466
+ <button
467
+ type="button"
468
+ className="cta cta--secondary"
469
+ onClick={handleAddVoucher}
470
+ >
471
+ {translations.SUMMARY.ADD_VOUCHER}
472
+ </button>
473
+ </div>
474
+ )}
475
+ {!voucher.isValid && voucher.isValidated && (
476
+ <div className="info-message--error">
477
+ {translations.SUMMARY.VOUCHER_INVALID}
478
+ </div>
479
+ )}
480
+ </div>
481
+ </div>
482
+ <div className="form__row">
483
+ <ul className="info-message__voucher">
484
+ {!isEmpty(bookRequest?.payload.voucherCodes) &&
485
+ bookRequest?.payload.voucherCodes?.map((y) => (
486
+ <li>
487
+ <div className="info-message__voucher__list">
488
+ {y}{" "}
489
+ <button
490
+ type="button"
491
+ className="cta--add-remove"
492
+ onClick={(e) => handleRemoveVoucher(y)}
493
+ >
494
+ <Icon height={16} name="ui-trashcan" />
495
+ </button>
496
+ </div>
497
+ </li>
498
+ ))}
499
+ </ul>
500
+ </div>
501
+ </div>
502
+ )}
503
+
504
+ {!isEmpty(notifications) && (
505
+ <div className="form__region">
506
+ <div className="form__row">
507
+ <div className="form__group">
508
+ <div className="info-message">
509
+ <Icon
510
+ name="ui-tooltip"
511
+ className="icon--secondary-color"
512
+ />
513
+ <div className="info-message__copy">
514
+ <h5>{translations.SUMMARY.NOTIFICATIONS_TITLE}</h5>
515
+ <>
516
+ {uniqBy(
517
+ notifications.filter((x) => !x.hasToBeConfirmed),
518
+ "id"
519
+ ).map((notification) => (
520
+ <span
521
+ key={notification.id}
522
+ className="checkbox__label-text"
523
+ >
524
+ <strong className="checkbox__label-text--title">
525
+ {notification.title}
526
+ </strong>
527
+ <span className="checkbox__label-text--description">
528
+ {notification.description}
529
+ </span>
530
+ </span>
531
+ ))}
532
+ {uniqBy(
533
+ notifications.filter((x) => x.hasToBeConfirmed),
534
+ "id"
535
+ ).map((notification) => (
536
+ <div className="checkbox" key={notification.id}>
537
+ <label className="checkbox__label">
538
+ <input
539
+ type="checkbox"
540
+ className="checkbox__input"
541
+ checked={notification.isConfirmed}
542
+ onChange={(e) =>
543
+ handleNotificationChange(
544
+ notification.id,
545
+ e.target.checked
546
+ )
547
+ }
548
+ />
549
+ <span className="checkbox__label-text">
550
+ <strong className="checkbox__label-text--title">
551
+ {notification.title}
552
+ </strong>
553
+ <span className="checkbox__label-text--description">
554
+ {notification.description}
555
+ </span>
556
+ </span>
557
+ </label>
558
+ </div>
559
+ ))}
560
+ </>
561
+ </div>
562
+ </div>
563
+ </div>
564
+ </div>
565
+ </div>
566
+ )}
567
+
568
+ <div className="form__region">
569
+ <div className="form__row">
570
+ <div className="form__group">
571
+ <div className="form__region-header">
572
+ <h5 className="form__region-heading">
573
+ {translations.SUMMARY.REMARKS}
574
+ </h5>
575
+ </div>
576
+ </div>
577
+ </div>
578
+ <div className="form__row">
579
+ <div className="form__group">
580
+ <textarea
581
+ className="form__input"
582
+ defaultValue={remarks}
583
+ onChange={(e) => handleRemarksChange(e.target.value)}
584
+ ></textarea>
585
+ </div>
586
+ </div>
587
+ </div>
588
+
589
+ <div className="form__region">
590
+ <div className="form__row">
591
+ <div className="form__group">
592
+ <div className="info-message">
593
+ <Icon name="ui-tooltip" className="icon--secondary-color" />
594
+ <div className="info-message__copy">
595
+ <h5>{translations.SUMMARY.VALIDATE_TITLE}</h5>
596
+ <p>
597
+ {settings.isOffer
598
+ ? translations.SUMMARY.VALIDATE_TEXT_OFFER
599
+ : translations.SUMMARY.VALIDATE_TEXT_BOOKING}
600
+ </p>
601
+ {checkboxes &&
602
+ checkboxes.map((checkbox) => (
603
+ <div className="checkbox" key={checkbox.id}>
604
+ <label className="checkbox__label">
605
+ <input
606
+ type="checkbox"
607
+ className="checkbox__input"
608
+ checked={checkbox.isSelected}
609
+ onChange={(e) =>
610
+ handleCheckboxChange(
611
+ checkbox.id,
612
+ e.target.checked
613
+ )
614
+ }
615
+ />
616
+ <span
617
+ className="checkbox__label-text"
618
+ dangerouslySetInnerHTML={{
619
+ __html: checkbox.text,
620
+ }}
621
+ />
622
+ </label>
623
+ </div>
624
+ ))}
625
+ </div>
626
+ </div>
627
+ </div>
628
+ </div>
629
+ </div>
630
+ </div>
631
+
632
+ <div className="booking__navigator">
633
+ {settings.skipRouter ? (
634
+ <button
635
+ type="button"
636
+ title={translations.STEPS.PREVIOUS}
637
+ onClick={() => goPrevious()}
638
+ className="cta cta--secondary"
639
+ >
640
+ {translations.STEPS.PREVIOUS}
641
+ </button>
642
+ ) : (
643
+ <Link
644
+ to={`${settings.basePath}${settings.travellers.pathSuffix}?${bookingQueryString}`}
645
+ title={translations.STEPS.PREVIOUS}
646
+ className="cta cta--secondary"
647
+ >
648
+ {translations.STEPS.PREVIOUS}
649
+ </Link>
650
+ )}
651
+ <button
652
+ title={
653
+ settings.isOffer
654
+ ? translations.STEPS.SUBMIT_OFFER
655
+ : translations.STEPS.SUBMIT_BOOKING
656
+ }
657
+ className={buildClassName([
658
+ "cta",
659
+ !userValidated && "cta--disabled",
660
+ ])}
661
+ disabled={!userValidated}
662
+ >
663
+ {settings.isOffer
664
+ ? translations.STEPS.SUBMIT_OFFER
665
+ : translations.STEPS.SUBMIT_BOOKING}
666
+ </button>
667
+ </div>
668
+ </form>
669
+ )}
670
+ </>
671
+ );
672
+ };
673
+
674
+ export default Summary;