@qite/tide-booking-component 0.0.2-preview.58 → 0.0.2-preview.60
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/build/build-cjs/booking-wizard/features/booking/booking-slice.d.ts +3 -1
- package/build/build-cjs/booking-wizard/features/booking/selectors.d.ts +3 -1
- package/build/build-cjs/booking-wizard/types.d.ts +2 -0
- package/build/build-cjs/index.js +31 -5
- package/build/build-esm/booking-wizard/features/booking/booking-slice.d.ts +3 -1
- package/build/build-esm/booking-wizard/features/booking/selectors.d.ts +3 -1
- package/build/build-esm/booking-wizard/types.d.ts +2 -0
- package/build/build-esm/index.js +31 -5
- package/package.json +71 -71
- package/src/booking-wizard/components/product-card.tsx +1 -1
- package/src/booking-wizard/features/booking/booking-slice.ts +289 -277
- package/src/booking-wizard/features/booking/booking.tsx +291 -283
- package/src/booking-wizard/features/booking/selectors.ts +258 -249
- package/src/booking-wizard/features/travelers-form/travelers-form.tsx +659 -650
- package/src/booking-wizard/settings-context.ts +40 -38
- package/src/booking-wizard/types.ts +105 -103
|
@@ -1,283 +1,291 @@
|
|
|
1
|
-
import React, { useContext } from "react";
|
|
2
|
-
import { navigate, Router, useLocation } from "@reach/router";
|
|
3
|
-
import {
|
|
4
|
-
getDateFromParams,
|
|
5
|
-
getNumberFromParams,
|
|
6
|
-
getNumbersFromParams,
|
|
7
|
-
getRoomsFromParams,
|
|
8
|
-
getStringFromParams,
|
|
9
|
-
} from "../../utils/query-string-util";
|
|
10
|
-
import {
|
|
11
|
-
fetchPackage,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
import
|
|
26
|
-
|
|
27
|
-
import
|
|
28
|
-
import
|
|
29
|
-
import
|
|
30
|
-
import
|
|
31
|
-
import
|
|
32
|
-
import
|
|
33
|
-
import
|
|
34
|
-
import
|
|
35
|
-
import
|
|
36
|
-
import {
|
|
37
|
-
import {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
const
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
const
|
|
82
|
-
const
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const
|
|
96
|
-
const
|
|
97
|
-
const
|
|
98
|
-
const
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
1
|
+
import React, { useContext } from "react";
|
|
2
|
+
import { navigate, Router, useLocation } from "@reach/router";
|
|
3
|
+
import {
|
|
4
|
+
getDateFromParams,
|
|
5
|
+
getNumberFromParams,
|
|
6
|
+
getNumbersFromParams,
|
|
7
|
+
getRoomsFromParams,
|
|
8
|
+
getStringFromParams,
|
|
9
|
+
} from "../../utils/query-string-util";
|
|
10
|
+
import {
|
|
11
|
+
fetchPackage,
|
|
12
|
+
setAgentAdressId,
|
|
13
|
+
setBookingAttributes,
|
|
14
|
+
setBookingNumber,
|
|
15
|
+
setCalculateDeposit,
|
|
16
|
+
setCustomEntryStatusId,
|
|
17
|
+
setEntryStatus,
|
|
18
|
+
setGeneratePaymentUrl,
|
|
19
|
+
setIsRetry,
|
|
20
|
+
setOfficeId,
|
|
21
|
+
setProductAttributes,
|
|
22
|
+
setSkipPayment,
|
|
23
|
+
setTagIds,
|
|
24
|
+
} from "./booking-slice";
|
|
25
|
+
import { useSelector } from "react-redux";
|
|
26
|
+
|
|
27
|
+
import Confirmation from "../confirmation/confirmation";
|
|
28
|
+
import Error from "../error/error";
|
|
29
|
+
import OptionsForm from "../product-options/options-form";
|
|
30
|
+
import SettingsContext from "../../settings-context";
|
|
31
|
+
import Sidebar from "../sidebar";
|
|
32
|
+
import StepRoute from "../../components/step-route";
|
|
33
|
+
import Summary from "../summary/summary";
|
|
34
|
+
import TravelersForm from "../travelers-form/travelers-form";
|
|
35
|
+
import translations from "../../translations/translations.json";
|
|
36
|
+
import { useEffect } from "react";
|
|
37
|
+
import { isNil } from "lodash";
|
|
38
|
+
import { useAppDispatch } from "../../store";
|
|
39
|
+
import {
|
|
40
|
+
selectBookingAttributes,
|
|
41
|
+
selectBookingNumber,
|
|
42
|
+
selectBookingRooms,
|
|
43
|
+
selectIsRetry,
|
|
44
|
+
selectIsUnavailable,
|
|
45
|
+
selectPackageDetails,
|
|
46
|
+
selectProductAttributes,
|
|
47
|
+
} from "./selectors";
|
|
48
|
+
|
|
49
|
+
interface BookingProps {
|
|
50
|
+
productCode: string;
|
|
51
|
+
productName: string;
|
|
52
|
+
thumbnailUrl?: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const Booking: React.FC<BookingProps> = ({
|
|
56
|
+
productCode,
|
|
57
|
+
productName,
|
|
58
|
+
thumbnailUrl,
|
|
59
|
+
}) => {
|
|
60
|
+
const {
|
|
61
|
+
officeId,
|
|
62
|
+
entryStatus,
|
|
63
|
+
customEntryStatusId,
|
|
64
|
+
basePath,
|
|
65
|
+
options,
|
|
66
|
+
summary,
|
|
67
|
+
confirmation,
|
|
68
|
+
error,
|
|
69
|
+
showSidebarDeposit,
|
|
70
|
+
includeFlights,
|
|
71
|
+
loaderComponent,
|
|
72
|
+
skipPaymentWithAgent,
|
|
73
|
+
generatePaymentUrl,
|
|
74
|
+
tagIds,
|
|
75
|
+
agentAdressId,
|
|
76
|
+
} = useContext(SettingsContext);
|
|
77
|
+
|
|
78
|
+
const dispatch = useAppDispatch();
|
|
79
|
+
const location = useLocation();
|
|
80
|
+
|
|
81
|
+
const productAttributes = useSelector(selectProductAttributes);
|
|
82
|
+
const bookingAttributes = useSelector(selectBookingAttributes);
|
|
83
|
+
const rooms = useSelector(selectBookingRooms);
|
|
84
|
+
const bookingNumber = useSelector(selectBookingNumber);
|
|
85
|
+
const isRetry = useSelector(selectIsRetry);
|
|
86
|
+
const packageDetails = useSelector(selectPackageDetails);
|
|
87
|
+
const isUnvailable = useSelector(selectIsUnavailable);
|
|
88
|
+
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
dispatch(setSkipPayment(skipPaymentWithAgent ?? false));
|
|
91
|
+
dispatch(setGeneratePaymentUrl(generatePaymentUrl ?? false));
|
|
92
|
+
}, [skipPaymentWithAgent, generatePaymentUrl]);
|
|
93
|
+
|
|
94
|
+
useEffect(() => {
|
|
95
|
+
const params = new URLSearchParams(location.search);
|
|
96
|
+
const startDate = getDateFromParams(params, "startDate");
|
|
97
|
+
const endDate = getDateFromParams(params, "endDate");
|
|
98
|
+
const catalog = getNumberFromParams(params, "catalog");
|
|
99
|
+
const rooms = getRoomsFromParams(params, "rooms");
|
|
100
|
+
const allotmentName = getStringFromParams(params, "allotmentName");
|
|
101
|
+
const allotmentIds = getNumbersFromParams(params, "allotementId");
|
|
102
|
+
const tourCode = getStringFromParams(params, "tourCode");
|
|
103
|
+
const bookingNumber = params.get("bookingNr") ?? undefined;
|
|
104
|
+
|
|
105
|
+
if (!isNil(bookingNumber)) {
|
|
106
|
+
dispatch(setBookingNumber(bookingNumber));
|
|
107
|
+
navigate(
|
|
108
|
+
`${basePath}${confirmation.pathSuffix}?bookingNr=${bookingNumber}`
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (
|
|
113
|
+
!isNil(startDate) &&
|
|
114
|
+
!isNil(endDate) &&
|
|
115
|
+
!isNil(catalog) &&
|
|
116
|
+
!isNil(rooms)
|
|
117
|
+
) {
|
|
118
|
+
dispatch(
|
|
119
|
+
setBookingAttributes({
|
|
120
|
+
startDate,
|
|
121
|
+
endDate,
|
|
122
|
+
catalog,
|
|
123
|
+
rooms,
|
|
124
|
+
includeFlights,
|
|
125
|
+
allotmentName,
|
|
126
|
+
allotmentIds,
|
|
127
|
+
tourCode,
|
|
128
|
+
})
|
|
129
|
+
);
|
|
130
|
+
} else {
|
|
131
|
+
console.error(
|
|
132
|
+
"Failure when setting booking attributes",
|
|
133
|
+
startDate,
|
|
134
|
+
endDate,
|
|
135
|
+
catalog,
|
|
136
|
+
rooms
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
}, [location.search, setBookingAttributes, setBookingNumber, includeFlights]);
|
|
140
|
+
|
|
141
|
+
useEffect(() => {
|
|
142
|
+
if (
|
|
143
|
+
!productAttributes ||
|
|
144
|
+
!bookingAttributes ||
|
|
145
|
+
!isNil(bookingNumber) ||
|
|
146
|
+
!isRetry
|
|
147
|
+
) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Retried
|
|
152
|
+
dispatch(setIsRetry(false));
|
|
153
|
+
|
|
154
|
+
// Fetch data
|
|
155
|
+
const promise = dispatch(fetchPackage());
|
|
156
|
+
return () => {
|
|
157
|
+
promise.abort();
|
|
158
|
+
};
|
|
159
|
+
}, [isRetry]);
|
|
160
|
+
|
|
161
|
+
useEffect(() => {
|
|
162
|
+
if (!isNil(productCode) && !isNil(productName)) {
|
|
163
|
+
dispatch(
|
|
164
|
+
setProductAttributes({
|
|
165
|
+
productCode,
|
|
166
|
+
productName,
|
|
167
|
+
})
|
|
168
|
+
);
|
|
169
|
+
} else {
|
|
170
|
+
console.error(
|
|
171
|
+
"Failure when setting product attributes",
|
|
172
|
+
productCode,
|
|
173
|
+
productName
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
}, [productCode, productName, setProductAttributes]);
|
|
177
|
+
|
|
178
|
+
useEffect(() => {
|
|
179
|
+
dispatch(setOfficeId(officeId));
|
|
180
|
+
dispatch(setEntryStatus(entryStatus));
|
|
181
|
+
dispatch(setCustomEntryStatusId(customEntryStatusId ?? undefined));
|
|
182
|
+
dispatch(setCalculateDeposit(showSidebarDeposit));
|
|
183
|
+
dispatch(setTagIds(tagIds ?? undefined));
|
|
184
|
+
dispatch(setAgentAdressId(agentAdressId ?? undefined));
|
|
185
|
+
}, [
|
|
186
|
+
officeId,
|
|
187
|
+
entryStatus,
|
|
188
|
+
customEntryStatusId,
|
|
189
|
+
showSidebarDeposit,
|
|
190
|
+
setOfficeId,
|
|
191
|
+
setEntryStatus,
|
|
192
|
+
setCustomEntryStatusId,
|
|
193
|
+
setCalculateDeposit,
|
|
194
|
+
tagIds,
|
|
195
|
+
agentAdressId,
|
|
196
|
+
]);
|
|
197
|
+
|
|
198
|
+
useEffect(() => {
|
|
199
|
+
if (
|
|
200
|
+
!productAttributes ||
|
|
201
|
+
!bookingAttributes ||
|
|
202
|
+
!rooms?.length ||
|
|
203
|
+
!isNil(bookingNumber) ||
|
|
204
|
+
!isNil(packageDetails)
|
|
205
|
+
) {
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
// Fetch data
|
|
209
|
+
const promise = dispatch(fetchPackage());
|
|
210
|
+
return () => {
|
|
211
|
+
promise.abort();
|
|
212
|
+
};
|
|
213
|
+
}, [
|
|
214
|
+
productAttributes,
|
|
215
|
+
bookingAttributes,
|
|
216
|
+
rooms,
|
|
217
|
+
bookingNumber,
|
|
218
|
+
packageDetails,
|
|
219
|
+
]);
|
|
220
|
+
|
|
221
|
+
return (
|
|
222
|
+
<>
|
|
223
|
+
{((productAttributes && bookingAttributes && packageDetails) ||
|
|
224
|
+
bookingNumber) && (
|
|
225
|
+
<div className="booking">
|
|
226
|
+
<div className="booking__content">
|
|
227
|
+
<div className="booking__panel">
|
|
228
|
+
<Router basepath={basePath}>
|
|
229
|
+
<StepRoute
|
|
230
|
+
path="/"
|
|
231
|
+
number={1}
|
|
232
|
+
title={translations.STEPS.PERSONAL_DETAILS}
|
|
233
|
+
component={<TravelersForm />}
|
|
234
|
+
/>
|
|
235
|
+
<StepRoute
|
|
236
|
+
path={options.pathSuffix}
|
|
237
|
+
number={2}
|
|
238
|
+
title={translations.STEPS.TRAVEL_OPTIONS}
|
|
239
|
+
component={<OptionsForm />}
|
|
240
|
+
/>
|
|
241
|
+
<StepRoute
|
|
242
|
+
path={summary.pathSuffix}
|
|
243
|
+
number={3}
|
|
244
|
+
title={translations.STEPS.SUMMARY}
|
|
245
|
+
component={<Summary />}
|
|
246
|
+
/>
|
|
247
|
+
<StepRoute
|
|
248
|
+
path={confirmation.pathSuffix}
|
|
249
|
+
number={4}
|
|
250
|
+
title={translations.STEPS.CONFIRMATION}
|
|
251
|
+
component={<Confirmation />}
|
|
252
|
+
/>
|
|
253
|
+
<StepRoute
|
|
254
|
+
path={error.pathSuffix}
|
|
255
|
+
number={4}
|
|
256
|
+
title={translations.STEPS.ERROR}
|
|
257
|
+
component={<Error />}
|
|
258
|
+
/>
|
|
259
|
+
</Router>
|
|
260
|
+
</div>
|
|
261
|
+
<div className="backdrop" id="backdrop"></div>
|
|
262
|
+
{packageDetails && (
|
|
263
|
+
<Sidebar productName={productName} thumbnailUrl={thumbnailUrl} />
|
|
264
|
+
)}
|
|
265
|
+
</div>
|
|
266
|
+
</div>
|
|
267
|
+
)}
|
|
268
|
+
{!packageDetails && !bookingNumber && !isUnvailable && (
|
|
269
|
+
<div className="booking">
|
|
270
|
+
<div className="booking__loader">
|
|
271
|
+
{loaderComponent}
|
|
272
|
+
<p className="booking__loader-text">
|
|
273
|
+
{translations.MAIN.PREPARING_BOOKING}
|
|
274
|
+
</p>
|
|
275
|
+
</div>
|
|
276
|
+
</div>
|
|
277
|
+
)}
|
|
278
|
+
{isUnvailable && (
|
|
279
|
+
<div className="booking">
|
|
280
|
+
<div className="booking__loader">
|
|
281
|
+
<p className="booking__loader-text">
|
|
282
|
+
{translations.MAIN.PRODUCT_UNAVAILABLE}
|
|
283
|
+
</p>
|
|
284
|
+
</div>
|
|
285
|
+
</div>
|
|
286
|
+
)}
|
|
287
|
+
</>
|
|
288
|
+
);
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
export default Booking;
|