@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,249 +1,258 @@
|
|
|
1
|
-
import JsonURL from "@jsonurl/jsonurl";
|
|
2
|
-
import { Gender } from "@qite/tide-client";
|
|
3
|
-
import {
|
|
4
|
-
BookingPackageAddress,
|
|
5
|
-
BookingPackageBookRequest,
|
|
6
|
-
BookingPackagePax,
|
|
7
|
-
BookingPackageRequest,
|
|
8
|
-
} from "@qite/tide-client/build/types/offer";
|
|
9
|
-
import { createSelector } from "@reduxjs/toolkit";
|
|
10
|
-
import { format, parseISO } from "date-fns";
|
|
11
|
-
import { omit } from "lodash";
|
|
12
|
-
import { RootState } from "../../store";
|
|
13
|
-
import { Room, Traveler } from "../../types";
|
|
14
|
-
import { selectNotifications } from "../price-details/price-details-slice";
|
|
15
|
-
import {
|
|
16
|
-
selectAgentId,
|
|
17
|
-
selectTravelersFormValues,
|
|
18
|
-
} from "../travelers-form/travelers-form-slice";
|
|
19
|
-
|
|
20
|
-
export const selectGeneratePaymentUrl = (state: RootState) =>
|
|
21
|
-
state.booking.generatePaymentUrl;
|
|
22
|
-
|
|
23
|
-
export const selectSkipPaymentWithAgent = (state: RootState) =>
|
|
24
|
-
state.booking.skipPaymentWithAgent;
|
|
25
|
-
|
|
26
|
-
export const selectIsFetchingProductOptions = (state: RootState) =>
|
|
27
|
-
state.booking.isBusy;
|
|
28
|
-
|
|
29
|
-
export const selectDepartureFlight = (state: RootState) =>
|
|
30
|
-
state.booking.package?.outwardFlights?.find((x) => x.isSelected);
|
|
31
|
-
|
|
32
|
-
export const selectReturnFlight = (state: RootState) =>
|
|
33
|
-
state.booking.package?.returnFlights?.find((x) => x.isSelected);
|
|
34
|
-
|
|
35
|
-
export const selectPackageRooms = (state: RootState) =>
|
|
36
|
-
state.booking.package?.options.find((x) => x.isSelected)?.rooms;
|
|
37
|
-
|
|
38
|
-
export const selectPackageOptionUnits = (state: RootState) =>
|
|
39
|
-
state.booking.package?.options.find((x) => x.isSelected)?.optionUnits;
|
|
40
|
-
|
|
41
|
-
export const selectPackageOptionPax = (state: RootState) =>
|
|
42
|
-
state.booking.package?.options.find((x) => x.isSelected)?.optionPax;
|
|
43
|
-
|
|
44
|
-
export const selectPackageGroups = (state: RootState) =>
|
|
45
|
-
state.booking.package?.options.find((x) => x.isSelected)?.groups;
|
|
46
|
-
|
|
47
|
-
export const selectPackageDetails = (state: RootState) => state.booking.package;
|
|
48
|
-
|
|
49
|
-
export const selectActiveOption = (state: RootState) =>
|
|
50
|
-
state.booking.package?.options.find((x) => x.isSelected);
|
|
51
|
-
|
|
52
|
-
export const selectIsUnavailable = (state: RootState) =>
|
|
53
|
-
state.booking.isUnavailable;
|
|
54
|
-
|
|
55
|
-
export const selectRequestRooms = (state: RootState) =>
|
|
56
|
-
state.booking.package?.options.find((x) => x.isSelected)?.requestRooms;
|
|
57
|
-
|
|
58
|
-
export const selectOfficeId = (state: RootState) => state.booking.officeId;
|
|
59
|
-
|
|
60
|
-
export const selectEntryStatus = (state: RootState) =>
|
|
61
|
-
state.booking.entryStatus;
|
|
62
|
-
|
|
63
|
-
export const selectCustomEntryStatusId = (state: RootState) =>
|
|
64
|
-
state.booking.customEntryStatusId;
|
|
65
|
-
|
|
66
|
-
export const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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
|
-
pax.push(
|
|
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
|
-
return
|
|
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
|
-
|
|
1
|
+
import JsonURL from "@jsonurl/jsonurl";
|
|
2
|
+
import { Gender } from "@qite/tide-client";
|
|
3
|
+
import {
|
|
4
|
+
BookingPackageAddress,
|
|
5
|
+
BookingPackageBookRequest,
|
|
6
|
+
BookingPackagePax,
|
|
7
|
+
BookingPackageRequest,
|
|
8
|
+
} from "@qite/tide-client/build/types/offer";
|
|
9
|
+
import { createSelector } from "@reduxjs/toolkit";
|
|
10
|
+
import { format, parseISO } from "date-fns";
|
|
11
|
+
import { omit } from "lodash";
|
|
12
|
+
import { RootState } from "../../store";
|
|
13
|
+
import { Room, Traveler } from "../../types";
|
|
14
|
+
import { selectNotifications } from "../price-details/price-details-slice";
|
|
15
|
+
import {
|
|
16
|
+
selectAgentId,
|
|
17
|
+
selectTravelersFormValues,
|
|
18
|
+
} from "../travelers-form/travelers-form-slice";
|
|
19
|
+
|
|
20
|
+
export const selectGeneratePaymentUrl = (state: RootState) =>
|
|
21
|
+
state.booking.generatePaymentUrl;
|
|
22
|
+
|
|
23
|
+
export const selectSkipPaymentWithAgent = (state: RootState) =>
|
|
24
|
+
state.booking.skipPaymentWithAgent;
|
|
25
|
+
|
|
26
|
+
export const selectIsFetchingProductOptions = (state: RootState) =>
|
|
27
|
+
state.booking.isBusy;
|
|
28
|
+
|
|
29
|
+
export const selectDepartureFlight = (state: RootState) =>
|
|
30
|
+
state.booking.package?.outwardFlights?.find((x) => x.isSelected);
|
|
31
|
+
|
|
32
|
+
export const selectReturnFlight = (state: RootState) =>
|
|
33
|
+
state.booking.package?.returnFlights?.find((x) => x.isSelected);
|
|
34
|
+
|
|
35
|
+
export const selectPackageRooms = (state: RootState) =>
|
|
36
|
+
state.booking.package?.options.find((x) => x.isSelected)?.rooms;
|
|
37
|
+
|
|
38
|
+
export const selectPackageOptionUnits = (state: RootState) =>
|
|
39
|
+
state.booking.package?.options.find((x) => x.isSelected)?.optionUnits;
|
|
40
|
+
|
|
41
|
+
export const selectPackageOptionPax = (state: RootState) =>
|
|
42
|
+
state.booking.package?.options.find((x) => x.isSelected)?.optionPax;
|
|
43
|
+
|
|
44
|
+
export const selectPackageGroups = (state: RootState) =>
|
|
45
|
+
state.booking.package?.options.find((x) => x.isSelected)?.groups;
|
|
46
|
+
|
|
47
|
+
export const selectPackageDetails = (state: RootState) => state.booking.package;
|
|
48
|
+
|
|
49
|
+
export const selectActiveOption = (state: RootState) =>
|
|
50
|
+
state.booking.package?.options.find((x) => x.isSelected);
|
|
51
|
+
|
|
52
|
+
export const selectIsUnavailable = (state: RootState) =>
|
|
53
|
+
state.booking.isUnavailable;
|
|
54
|
+
|
|
55
|
+
export const selectRequestRooms = (state: RootState) =>
|
|
56
|
+
state.booking.package?.options.find((x) => x.isSelected)?.requestRooms;
|
|
57
|
+
|
|
58
|
+
export const selectOfficeId = (state: RootState) => state.booking.officeId;
|
|
59
|
+
|
|
60
|
+
export const selectEntryStatus = (state: RootState) =>
|
|
61
|
+
state.booking.entryStatus;
|
|
62
|
+
|
|
63
|
+
export const selectCustomEntryStatusId = (state: RootState) =>
|
|
64
|
+
state.booking.customEntryStatusId;
|
|
65
|
+
|
|
66
|
+
export const selectTagIds = (state: RootState) => state.booking.tagIds;
|
|
67
|
+
export const selectAgentAdressId = (state: RootState) =>
|
|
68
|
+
state.booking.agentAdressId;
|
|
69
|
+
|
|
70
|
+
export const selectProductAttributes = (state: RootState) =>
|
|
71
|
+
state.booking.productAttributes;
|
|
72
|
+
|
|
73
|
+
export const selectBookingAttributes = (state: RootState) =>
|
|
74
|
+
state.booking.bookingAttributes;
|
|
75
|
+
|
|
76
|
+
export const selectBookingNumber = (state: RootState) =>
|
|
77
|
+
state.booking.bookingNumber;
|
|
78
|
+
|
|
79
|
+
export const selectBookingRooms = (state: RootState) =>
|
|
80
|
+
state.booking.bookingAttributes?.rooms;
|
|
81
|
+
|
|
82
|
+
export const selectCalculateDeposit = (state: RootState) =>
|
|
83
|
+
state.booking.calculateDeposit;
|
|
84
|
+
|
|
85
|
+
export const selectIsRetry = (state: RootState) => state.booking.isRetry;
|
|
86
|
+
|
|
87
|
+
export const selectStartDate = (state: RootState) =>
|
|
88
|
+
state.booking.package?.options.find((x) => x.isSelected)?.fromDate;
|
|
89
|
+
|
|
90
|
+
export const selectAgents = (state: RootState) => state.booking.agents;
|
|
91
|
+
|
|
92
|
+
export const selectBookingQuery = (state: RootState) => {
|
|
93
|
+
const bookingAttributes = state.booking.bookingAttributes;
|
|
94
|
+
|
|
95
|
+
if (!bookingAttributes) {
|
|
96
|
+
return undefined;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const params: Record<string, string> = {};
|
|
100
|
+
Object.entries(bookingAttributes).forEach(([key, value]) => {
|
|
101
|
+
if (key === "startDate" || key === "endDate") {
|
|
102
|
+
value = format(parseISO(value), "yyyy-MM-dd");
|
|
103
|
+
}
|
|
104
|
+
if (key === "rooms") {
|
|
105
|
+
value = JsonURL.stringify(
|
|
106
|
+
(value as Room[]).map((room) => omit(room, ["children"])),
|
|
107
|
+
{
|
|
108
|
+
AQF: true,
|
|
109
|
+
}
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
params[key] = value;
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
return params;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export const selectBookingQueryString = createSelector(
|
|
119
|
+
selectBookingQuery,
|
|
120
|
+
(params) => {
|
|
121
|
+
if (!params) {
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return Object.keys(params)
|
|
126
|
+
.filter((key) => typeof params[key] !== "undefined")
|
|
127
|
+
.map((key) => `${key}=${params[key]}`)
|
|
128
|
+
.join("&");
|
|
129
|
+
}
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
export const selectMainBookerId = createSelector(
|
|
133
|
+
selectTravelersFormValues,
|
|
134
|
+
(formValues) => formValues?.mainBookerId
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
export const selectBookingPackagePax = createSelector(
|
|
138
|
+
selectTravelersFormValues,
|
|
139
|
+
(formValues) => {
|
|
140
|
+
var pax: BookingPackagePax[] = [];
|
|
141
|
+
|
|
142
|
+
formValues?.adults.forEach((x) => {
|
|
143
|
+
const adultPax = buildPax(x, formValues?.mainBookerId);
|
|
144
|
+
|
|
145
|
+
if (adultPax.isMainBooker) {
|
|
146
|
+
adultPax.mobilePhone = formValues?.phone;
|
|
147
|
+
adultPax.email = formValues?.email;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
pax.push(adultPax);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
formValues?.children.forEach((x) => {
|
|
154
|
+
pax.push(buildPax(x));
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
return pax;
|
|
158
|
+
}
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
export const selectBookingAddress = createSelector(
|
|
162
|
+
selectTravelersFormValues,
|
|
163
|
+
selectBookingPackagePax,
|
|
164
|
+
(formValues, pax) => {
|
|
165
|
+
const mainBooker = pax.find((x) => x.isMainBooker);
|
|
166
|
+
if (!mainBooker) return undefined;
|
|
167
|
+
|
|
168
|
+
return {
|
|
169
|
+
name: `${mainBooker.firstName} ${mainBooker.lastName}`,
|
|
170
|
+
street: formValues?.street,
|
|
171
|
+
number: formValues?.houseNumber,
|
|
172
|
+
box: formValues?.box,
|
|
173
|
+
postalCode: formValues?.zipCode,
|
|
174
|
+
location: formValues?.place,
|
|
175
|
+
country: formValues?.country,
|
|
176
|
+
mobilePhone: formValues?.phone,
|
|
177
|
+
email: formValues?.email,
|
|
178
|
+
} as BookingPackageAddress;
|
|
179
|
+
}
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
export const selectBookingPackageBookRequest = createSelector(
|
|
183
|
+
selectOfficeId,
|
|
184
|
+
selectEntryStatus,
|
|
185
|
+
selectCustomEntryStatusId,
|
|
186
|
+
selectBookingPackagePax,
|
|
187
|
+
selectBookingAddress,
|
|
188
|
+
selectPackageDetails,
|
|
189
|
+
selectCalculateDeposit,
|
|
190
|
+
selectAgentId,
|
|
191
|
+
selectGeneratePaymentUrl,
|
|
192
|
+
selectSkipPaymentWithAgent,
|
|
193
|
+
selectNotifications,
|
|
194
|
+
selectTagIds,
|
|
195
|
+
selectAgentAdressId,
|
|
196
|
+
(
|
|
197
|
+
officeId,
|
|
198
|
+
entryStatus,
|
|
199
|
+
customEntryStatusId,
|
|
200
|
+
pax,
|
|
201
|
+
address,
|
|
202
|
+
packageDetails,
|
|
203
|
+
calculateDeposit,
|
|
204
|
+
agentId,
|
|
205
|
+
generatePaymentUrl,
|
|
206
|
+
skipPaymentWithAgent,
|
|
207
|
+
notifications,
|
|
208
|
+
tagIds,
|
|
209
|
+
agentAdressId
|
|
210
|
+
) => {
|
|
211
|
+
if (!packageDetails || pax?.length == 0) return null;
|
|
212
|
+
|
|
213
|
+
let returnPaymentUrl = false;
|
|
214
|
+
|
|
215
|
+
if (generatePaymentUrl && (!skipPaymentWithAgent || (agentId ?? 0) == 0)) {
|
|
216
|
+
returnPaymentUrl = true;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
return {
|
|
220
|
+
officeId: officeId,
|
|
221
|
+
agentId: (agentId ?? 0) > 0 ? agentId : null,
|
|
222
|
+
payload: {
|
|
223
|
+
package: packageDetails,
|
|
224
|
+
status: entryStatus,
|
|
225
|
+
customStatusId: customEntryStatusId,
|
|
226
|
+
address: address,
|
|
227
|
+
pax: pax,
|
|
228
|
+
calculateDeposit: calculateDeposit,
|
|
229
|
+
returnPaymentUrl: returnPaymentUrl,
|
|
230
|
+
notifications: notifications,
|
|
231
|
+
tagIds: tagIds,
|
|
232
|
+
},
|
|
233
|
+
} as BookingPackageRequest<BookingPackageBookRequest>;
|
|
234
|
+
}
|
|
235
|
+
);
|
|
236
|
+
|
|
237
|
+
const buildPax = (traveler: Traveler, mainBookerId?: number) => {
|
|
238
|
+
return {
|
|
239
|
+
id: traveler.id,
|
|
240
|
+
gender: parseGender(traveler.gender),
|
|
241
|
+
firstName: traveler.firstName,
|
|
242
|
+
lastName: traveler.lastName,
|
|
243
|
+
dateOfBirth: traveler.birthDate,
|
|
244
|
+
isMainBooker: traveler.id == mainBookerId,
|
|
245
|
+
} as BookingPackagePax;
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
const parseGender = (gender: string): number => {
|
|
249
|
+
switch (gender) {
|
|
250
|
+
case "m":
|
|
251
|
+
return Gender.male;
|
|
252
|
+
case "f":
|
|
253
|
+
return Gender.female;
|
|
254
|
+
case "x":
|
|
255
|
+
default:
|
|
256
|
+
return Gender.other;
|
|
257
|
+
}
|
|
258
|
+
};
|