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