@wix/headless-bookings 0.0.104 → 0.0.106
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/cjs/dist/__mocks__/booking/booking-client-service.js +25 -20
- package/cjs/dist/__mocks__/booking/booking-mocks.js +28 -20
- package/cjs/dist/__mocks__/payment/payment-mocks.js +6 -3
- package/cjs/dist/__mocks__/services/services-mocks.js +79 -74
- package/cjs/dist/__mocks__/time-slots/time-slots-client-service.js +39 -33
- package/cjs/dist/__mocks__/time-slots/time-slots-core.js +43 -33
- package/cjs/dist/__mocks__/time-slots/time-slots-mocks.js +18 -13
- package/cjs/dist/api/create-booking/index.js +6 -3
- package/cjs/dist/api/create-checkout/index.js +9 -4
- package/cjs/dist/api/create-order/index.js +6 -3
- package/cjs/dist/api/fetch-availability/index.js +18 -15
- package/cjs/dist/api/index.js +24 -7
- package/cjs/dist/api/query-categories/index.js +6 -3
- package/cjs/dist/api/query-locations/index.js +9 -5
- package/cjs/dist/api/query-services/index.js +24 -17
- package/cjs/dist/react/booking/Book.js +51 -12
- package/cjs/dist/react/booking/Booking.js +68 -26
- package/cjs/dist/react/booking/BookingItem.d.ts +2 -0
- package/cjs/dist/react/booking/BookingItem.js +57 -16
- package/cjs/dist/react/booking-form/BookingForm.js +63 -21
- package/cjs/dist/react/core/booking/Book.js +14 -11
- package/cjs/dist/react/core/booking/Booking.d.ts +3 -1
- package/cjs/dist/react/core/booking/Booking.js +38 -25
- package/cjs/dist/react/core/booking-form/BookingForm.js +63 -26
- package/cjs/dist/react/core/location/Location.js +60 -21
- package/cjs/dist/react/core/location-list/LocationList.js +15 -10
- package/cjs/dist/react/core/payment/Payment.js +41 -30
- package/cjs/dist/react/core/service/Service.js +28 -19
- package/cjs/dist/react/core/service/ServiceMediaCover.js +7 -4
- package/cjs/dist/react/core/service/ServiceMediaGallery.js +7 -4
- package/cjs/dist/react/core/service/ServiceMediaMain.js +7 -4
- package/cjs/dist/react/core/service-list/ServiceList.js +12 -8
- package/cjs/dist/react/core/service-list/ServiceListFilter.js +9 -6
- package/cjs/dist/react/core/staff-member/StaffMember.js +20 -14
- package/cjs/dist/react/core/staff-member-list/StaffMemberList.js +19 -14
- package/cjs/dist/react/core/time-slot-list/TimeSlot.js +41 -28
- package/cjs/dist/react/core/time-slot-list/TimeSlotList.js +21 -15
- package/cjs/dist/react/index.js +49 -13
- package/cjs/dist/react/location/Location.js +76 -36
- package/cjs/dist/react/location/LocationList.js +70 -31
- package/cjs/dist/react/payment/Payment.js +87 -48
- package/cjs/dist/react/service/Service.js +197 -158
- package/cjs/dist/react/service/ServiceMedia.js +56 -17
- package/cjs/dist/react/service-list/ServiceList.js +71 -32
- package/cjs/dist/react/staff-member/StaffMember.js +61 -20
- package/cjs/dist/react/staff-member/StaffMemberList.js +68 -29
- package/cjs/dist/react/time-slot-list/TimeSlot.js +95 -56
- package/cjs/dist/react/time-slot-list/TimeSlotList.js +87 -48
- package/cjs/dist/services/booking/book-action/bookAction.js +21 -18
- package/cjs/dist/services/booking/book-action/buildBookingRequest.js +18 -15
- package/cjs/dist/services/booking/book-action/buildCheckoutRequest.js +8 -5
- package/cjs/dist/services/booking/book-action/canBook.js +4 -1
- package/cjs/dist/services/booking/book-action/index.js +15 -6
- package/cjs/dist/services/booking/book-action/isCheckoutRequired.js +4 -1
- package/cjs/dist/services/booking/book-action/types.js +5 -2
- package/cjs/dist/services/booking/booking.js +11 -8
- package/cjs/dist/services/booking-form/booking-form.js +26 -18
- package/cjs/dist/services/booking-form/utils.js +10 -4
- package/cjs/dist/services/constants.js +6 -3
- package/cjs/dist/services/index.js +48 -10
- package/cjs/dist/services/location-list/location-list.def.js +7 -5
- package/cjs/dist/services/location-list/location-list.js +31 -23
- package/cjs/dist/services/payment/payment.def.js +5 -2
- package/cjs/dist/services/payment/payment.js +22 -17
- package/cjs/dist/services/service/service.js +33 -29
- package/cjs/dist/services/service-list/service-list.js +22 -18
- package/cjs/dist/services/staff-member-list/staff-member-list.def.js +5 -2
- package/cjs/dist/services/staff-member-list/staff-member-list.js +16 -10
- package/cjs/dist/services/time-slot-list/index.js +12 -3
- package/cjs/dist/services/time-slot-list/time-slot-list.def.js +8 -5
- package/cjs/dist/services/time-slot-list/time-slot-list.js +24 -19
- package/cjs/dist/services/time-slot-list/time-slot.js +9 -6
- package/cjs/dist/utils/dateAndTime.js +7 -2
- package/cjs/dist/utils/guid.js +4 -1
- package/cjs/dist/utils/index.js +5 -1
- package/cjs/dist/utils/money.js +6 -2
- package/cjs/dist/utils/navigation.js +6 -3
- package/dist/react/booking/BookingItem.d.ts +2 -0
- package/dist/react/booking/BookingItem.js +2 -2
- package/dist/react/core/booking/Booking.d.ts +3 -1
- package/dist/react/core/booking/Booking.js +3 -2
- package/package.json +3 -3
|
@@ -1,4 +1,43 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.StaffMember = exports.SelectStaffMember = exports.StaffMemberName = exports.StaffMemberRepeater = exports.StaffMembers = exports.Location = exports.LocationName = exports.Actions = exports.ClearStaffSelection = exports.Select = exports.Duration = exports.EndDate = exports.StartDate = exports.TestIds = exports.Root = void 0;
|
|
40
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
2
41
|
/**
|
|
3
42
|
* TimeSlot - Headless components for displaying time slot information within TimeSlotList
|
|
4
43
|
* Provides components for displaying start/end times, duration, and selection actions
|
|
@@ -6,10 +45,10 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
6
45
|
* Note: These components must be used within TimeSlotList.TimeSlotRepeater which provides
|
|
7
46
|
* the necessary context. There is no public TimeSlot.Root - context is managed internally.
|
|
8
47
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
48
|
+
const react_1 = __importDefault(require("react"));
|
|
49
|
+
const react_2 = require("@wix/headless-components/react");
|
|
50
|
+
const react_3 = require("@wix/headless-utils/react");
|
|
51
|
+
const CoreTimeSlot = __importStar(require("../core/time-slot-list/TimeSlot.js"));
|
|
13
52
|
/**
|
|
14
53
|
* Root component that provides time slot context.
|
|
15
54
|
*
|
|
@@ -23,15 +62,15 @@ import * as CoreTimeSlot from '../core/time-slot-list/TimeSlot.js';
|
|
|
23
62
|
* </TimeSlot.Root>
|
|
24
63
|
* ```
|
|
25
64
|
*/
|
|
26
|
-
|
|
65
|
+
exports.Root = react_1.default.forwardRef((props, ref) => {
|
|
27
66
|
const { children, timeSlot, asChild, className } = props;
|
|
28
|
-
return (
|
|
67
|
+
return ((0, jsx_runtime_1.jsx)(CoreTimeSlot.Root, { config: { timeSlot }, children: (0, jsx_runtime_1.jsx)(react_3.AsChildSlot, { ref: ref, asChild: asChild, className: className, customElement: children, children: children }) }));
|
|
29
68
|
});
|
|
30
|
-
Root.displayName = 'TimeSlot.Root';
|
|
69
|
+
exports.Root.displayName = 'TimeSlot.Root';
|
|
31
70
|
// ============================================================================
|
|
32
71
|
// TestIds
|
|
33
72
|
// ============================================================================
|
|
34
|
-
|
|
73
|
+
exports.TestIds = {
|
|
35
74
|
timeSlotStartDate: 'time-slot-start-date',
|
|
36
75
|
timeSlotEndDate: 'time-slot-end-date',
|
|
37
76
|
timeSlotDuration: 'time-slot-duration',
|
|
@@ -69,9 +108,9 @@ export const TestIds = {
|
|
|
69
108
|
* </TimeSlot.StartDate>
|
|
70
109
|
* ```
|
|
71
110
|
*/
|
|
72
|
-
|
|
111
|
+
exports.StartDate = react_1.default.forwardRef((props, ref) => {
|
|
73
112
|
const { asChild, children, className, dateTimeFormatOptions, locale } = props;
|
|
74
|
-
return (
|
|
113
|
+
return ((0, jsx_runtime_1.jsx)(CoreTimeSlot.Info, { children: ({ startDate }) => ((0, jsx_runtime_1.jsx)(react_3.AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": exports.TestIds.timeSlotStartDate, customElement: children, customElementProps: { startDate }, children: (0, jsx_runtime_1.jsx)(react_2.Date, { date: {
|
|
75
114
|
date: startDate,
|
|
76
115
|
locale,
|
|
77
116
|
dateTimeFormatOptions: dateTimeFormatOptions ?? {
|
|
@@ -80,7 +119,7 @@ export const StartDate = React.forwardRef((props, ref) => {
|
|
|
80
119
|
},
|
|
81
120
|
} }) })) }));
|
|
82
121
|
});
|
|
83
|
-
StartDate.displayName = 'TimeSlot.StartDate';
|
|
122
|
+
exports.StartDate.displayName = 'TimeSlot.StartDate';
|
|
84
123
|
/**
|
|
85
124
|
* Displays the time slot end time.
|
|
86
125
|
* Default formatting shows time as "11:00 AM" (hour:minute with AM/PM).
|
|
@@ -105,9 +144,9 @@ StartDate.displayName = 'TimeSlot.StartDate';
|
|
|
105
144
|
* </TimeSlot.EndDate>
|
|
106
145
|
* ```
|
|
107
146
|
*/
|
|
108
|
-
|
|
147
|
+
exports.EndDate = react_1.default.forwardRef((props, ref) => {
|
|
109
148
|
const { asChild, children, className, dateTimeFormatOptions, locale } = props;
|
|
110
|
-
return (
|
|
149
|
+
return ((0, jsx_runtime_1.jsx)(CoreTimeSlot.Info, { children: ({ endDate }) => ((0, jsx_runtime_1.jsx)(react_3.AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": exports.TestIds.timeSlotEndDate, customElement: children, customElementProps: { endDate }, children: (0, jsx_runtime_1.jsx)(react_2.Date, { date: {
|
|
111
150
|
date: endDate,
|
|
112
151
|
locale,
|
|
113
152
|
dateTimeFormatOptions: dateTimeFormatOptions ?? {
|
|
@@ -116,7 +155,7 @@ export const EndDate = React.forwardRef((props, ref) => {
|
|
|
116
155
|
},
|
|
117
156
|
} }) })) }));
|
|
118
157
|
});
|
|
119
|
-
EndDate.displayName = 'TimeSlot.EndDate';
|
|
158
|
+
exports.EndDate.displayName = 'TimeSlot.EndDate';
|
|
120
159
|
/**
|
|
121
160
|
* Calculates and displays the duration between start and end times in minutes.
|
|
122
161
|
* Returns null if start/end dates are not available.
|
|
@@ -135,11 +174,11 @@ EndDate.displayName = 'TimeSlot.EndDate';
|
|
|
135
174
|
* </TimeSlot.Duration>
|
|
136
175
|
* ```
|
|
137
176
|
*/
|
|
138
|
-
|
|
177
|
+
exports.Duration = react_1.default.forwardRef((props, ref) => {
|
|
139
178
|
const { asChild, children, ...rest } = props;
|
|
140
|
-
return (
|
|
179
|
+
return ((0, jsx_runtime_1.jsx)(CoreTimeSlot.Info, { children: ({ durationInMinutes }) => ((0, jsx_runtime_1.jsx)(react_3.AsChildSlot, { ref: ref, asChild: asChild, ...rest, "data-testid": exports.TestIds.timeSlotDuration, customElement: children, customElementProps: { durationInMinutes }, children: (0, jsx_runtime_1.jsx)("span", { children: durationInMinutes }) })) }));
|
|
141
180
|
});
|
|
142
|
-
Duration.displayName = 'TimeSlot.Duration';
|
|
181
|
+
exports.Duration.displayName = 'TimeSlot.Duration';
|
|
143
182
|
/**
|
|
144
183
|
* Button to select this time slot.
|
|
145
184
|
* Default label is "Select".
|
|
@@ -173,23 +212,23 @@ Duration.displayName = 'TimeSlot.Duration';
|
|
|
173
212
|
* </TimeSlot.Actions.Select>
|
|
174
213
|
* ```
|
|
175
214
|
*/
|
|
176
|
-
|
|
215
|
+
exports.Select = react_1.default.forwardRef((props, ref) => {
|
|
177
216
|
const { asChild, children, className, label, onClick, ...rest } = props;
|
|
178
|
-
return (
|
|
217
|
+
return ((0, jsx_runtime_1.jsx)(CoreTimeSlot.Actions, { children: ({ selectTimeSlot, timeSlot, isSelected, bookable }) => {
|
|
179
218
|
const handleClick = () => {
|
|
180
219
|
selectTimeSlot();
|
|
181
220
|
onClick?.(timeSlot);
|
|
182
221
|
};
|
|
183
|
-
return (
|
|
222
|
+
return ((0, jsx_runtime_1.jsx)(react_3.AsChildSlot, { ref: ref, asChild: asChild, ...rest, className: className, disabled: !bookable, "data-testid": exports.TestIds.timeSlotActionSelect, "data-selected": isSelected, "data-bookable": bookable, customElement: children, customElementProps: {
|
|
184
223
|
onClick: handleClick,
|
|
185
224
|
disabled: !bookable,
|
|
186
225
|
isSelected,
|
|
187
226
|
bookable,
|
|
188
227
|
timeSlot,
|
|
189
|
-
}, children:
|
|
228
|
+
}, children: (0, jsx_runtime_1.jsx)("button", { onClick: handleClick, children: children || label }) }));
|
|
190
229
|
} }));
|
|
191
230
|
});
|
|
192
|
-
Select.displayName = 'TimeSlot.Actions.Select';
|
|
231
|
+
exports.Select.displayName = 'TimeSlot.Actions.Select';
|
|
193
232
|
/**
|
|
194
233
|
* Button to clear staff selection while keeping the slot selected.
|
|
195
234
|
* Only renders when a staff member is selected and there are multiple staff options.
|
|
@@ -220,9 +259,9 @@ Select.displayName = 'TimeSlot.Actions.Select';
|
|
|
220
259
|
* </TimeSlot.Actions.ClearStaffSelection>
|
|
221
260
|
* ```
|
|
222
261
|
*/
|
|
223
|
-
|
|
262
|
+
exports.ClearStaffSelection = react_1.default.forwardRef((props, ref) => {
|
|
224
263
|
const { asChild, children, className, label, onClick, ...rest } = props;
|
|
225
|
-
return (
|
|
264
|
+
return ((0, jsx_runtime_1.jsx)(CoreTimeSlot.Actions, { children: ({ clearStaffSelection, timeSlot }) => {
|
|
226
265
|
if (!clearStaffSelection) {
|
|
227
266
|
return null;
|
|
228
267
|
}
|
|
@@ -230,18 +269,18 @@ export const ClearStaffSelection = React.forwardRef((props, ref) => {
|
|
|
230
269
|
clearStaffSelection();
|
|
231
270
|
onClick?.(timeSlot);
|
|
232
271
|
};
|
|
233
|
-
return (
|
|
272
|
+
return ((0, jsx_runtime_1.jsx)(react_3.AsChildSlot, { ref: ref, asChild: asChild, ...rest, className: className, "data-testid": exports.TestIds.timeSlotActionClearStaffSelection, customElement: children, customElementProps: {
|
|
234
273
|
onClick: handleClick,
|
|
235
|
-
}, children:
|
|
274
|
+
}, children: (0, jsx_runtime_1.jsx)("button", { onClick: handleClick, children: children || label }) }));
|
|
236
275
|
} }));
|
|
237
276
|
});
|
|
238
|
-
ClearStaffSelection.displayName = 'TimeSlot.Actions.ClearStaffSelection';
|
|
277
|
+
exports.ClearStaffSelection.displayName = 'TimeSlot.Actions.ClearStaffSelection';
|
|
239
278
|
/**
|
|
240
279
|
* Actions namespace for TimeSlot
|
|
241
280
|
*/
|
|
242
|
-
|
|
243
|
-
Select,
|
|
244
|
-
ClearStaffSelection,
|
|
281
|
+
exports.Actions = {
|
|
282
|
+
Select: exports.Select,
|
|
283
|
+
ClearStaffSelection: exports.ClearStaffSelection,
|
|
245
284
|
};
|
|
246
285
|
/**
|
|
247
286
|
* Displays the location name.
|
|
@@ -260,18 +299,18 @@ export const Actions = {
|
|
|
260
299
|
* </TimeSlot.Location.Name>
|
|
261
300
|
* ```
|
|
262
301
|
*/
|
|
263
|
-
|
|
302
|
+
exports.LocationName = react_1.default.forwardRef((props, ref) => {
|
|
264
303
|
const { asChild, children, ...rest } = props;
|
|
265
|
-
return (
|
|
266
|
-
return (
|
|
304
|
+
return ((0, jsx_runtime_1.jsx)(CoreTimeSlot.Info, { children: ({ locationName }) => {
|
|
305
|
+
return ((0, jsx_runtime_1.jsx)(react_3.AsChildSlot, { ref: ref, asChild: asChild, ...rest, "data-testid": exports.TestIds.timeSlotLocationName, customElement: children, customElementProps: { name: locationName }, children: (0, jsx_runtime_1.jsx)("span", { children: locationName }) }));
|
|
267
306
|
} }));
|
|
268
307
|
});
|
|
269
|
-
LocationName.displayName = 'TimeSlot.Location.Name';
|
|
308
|
+
exports.LocationName.displayName = 'TimeSlot.Location.Name';
|
|
270
309
|
/**
|
|
271
310
|
* Location namespace containing components for displaying individual location data.
|
|
272
311
|
*/
|
|
273
|
-
|
|
274
|
-
Name: LocationName,
|
|
312
|
+
exports.Location = {
|
|
313
|
+
Name: exports.LocationName,
|
|
275
314
|
};
|
|
276
315
|
/**
|
|
277
316
|
* Container for the staff members list within a time slot.
|
|
@@ -288,18 +327,18 @@ export const Location = {
|
|
|
288
327
|
* </TimeSlot.StaffMembers>
|
|
289
328
|
* ```
|
|
290
329
|
*/
|
|
291
|
-
|
|
330
|
+
exports.StaffMembers = react_1.default.forwardRef((props, ref) => {
|
|
292
331
|
const { children, ...attrs } = props;
|
|
293
|
-
return (
|
|
294
|
-
return (
|
|
332
|
+
return ((0, jsx_runtime_1.jsx)(CoreTimeSlot.StaffMembers, { children: ({ staffMembers }) => {
|
|
333
|
+
return ((0, jsx_runtime_1.jsx)(react_2.GenericList.Root, { items: staffMembers, children: (0, jsx_runtime_1.jsx)("div", { ref: ref, ...attrs, "data-testid": exports.TestIds.timeSlotStaffMembers, children: children }) }));
|
|
295
334
|
} }));
|
|
296
335
|
});
|
|
297
|
-
StaffMembers.displayName = 'TimeSlot.StaffMembers';
|
|
336
|
+
exports.StaffMembers.displayName = 'TimeSlot.StaffMembers';
|
|
298
337
|
/**
|
|
299
338
|
* Internal component that wraps each staff member item with context provider.
|
|
300
339
|
*/
|
|
301
340
|
const StaffMemberItemWrapper = ({ staffMember, children, }) => {
|
|
302
|
-
return (
|
|
341
|
+
return ((0, jsx_runtime_1.jsx)(CoreTimeSlot.StaffMemberProvider, { staffMember: staffMember, children: (0, jsx_runtime_1.jsx)("div", { "data-testid": exports.TestIds.timeSlotStaffMember, "data-staff-member-id": staffMember.id, "data-selected": staffMember.isSelected, children: children }) }));
|
|
303
342
|
};
|
|
304
343
|
/**
|
|
305
344
|
* Repeater component that renders each staff member.
|
|
@@ -317,11 +356,11 @@ const StaffMemberItemWrapper = ({ staffMember, children, }) => {
|
|
|
317
356
|
* </TimeSlot.StaffMemberRepeater>
|
|
318
357
|
* ```
|
|
319
358
|
*/
|
|
320
|
-
|
|
359
|
+
exports.StaffMemberRepeater = react_1.default.forwardRef((props, ref) => {
|
|
321
360
|
const { children } = props;
|
|
322
|
-
return (
|
|
361
|
+
return ((0, jsx_runtime_1.jsx)(react_2.GenericList.Repeater, { ref: ref, itemWrapper: ({ item: staffMember, children: itemChildren }) => ((0, jsx_runtime_1.jsx)(StaffMemberItemWrapper, { staffMember: staffMember, children: itemChildren }, staffMember.id)), children: children }));
|
|
323
362
|
});
|
|
324
|
-
StaffMemberRepeater.displayName = 'TimeSlot.StaffMemberRepeater';
|
|
363
|
+
exports.StaffMemberRepeater.displayName = 'TimeSlot.StaffMemberRepeater';
|
|
325
364
|
/**
|
|
326
365
|
* Displays the staff member name.
|
|
327
366
|
*
|
|
@@ -339,11 +378,11 @@ StaffMemberRepeater.displayName = 'TimeSlot.StaffMemberRepeater';
|
|
|
339
378
|
* </TimeSlot.StaffMember.Name>
|
|
340
379
|
* ```
|
|
341
380
|
*/
|
|
342
|
-
|
|
381
|
+
exports.StaffMemberName = react_1.default.forwardRef((props, ref) => {
|
|
343
382
|
const { asChild, children, ...rest } = props;
|
|
344
|
-
return (
|
|
383
|
+
return ((0, jsx_runtime_1.jsx)(CoreTimeSlot.StaffMemberInfo, { children: ({ name }) => ((0, jsx_runtime_1.jsx)(react_3.AsChildSlot, { ref: ref, asChild: asChild, ...rest, "data-testid": exports.TestIds.timeSlotStaffMemberName, customElement: children, customElementProps: { name }, children: (0, jsx_runtime_1.jsx)("span", { children: name }) })) }));
|
|
345
384
|
});
|
|
346
|
-
StaffMemberName.displayName = 'TimeSlot.StaffMember.Name';
|
|
385
|
+
exports.StaffMemberName.displayName = 'TimeSlot.StaffMember.Name';
|
|
347
386
|
/**
|
|
348
387
|
* Button to select this staff member.
|
|
349
388
|
* Default label is "Select".
|
|
@@ -377,21 +416,21 @@ StaffMemberName.displayName = 'TimeSlot.StaffMember.Name';
|
|
|
377
416
|
* </TimeSlot.StaffMember.Actions.Select>
|
|
378
417
|
* ```
|
|
379
418
|
*/
|
|
380
|
-
|
|
419
|
+
exports.SelectStaffMember = react_1.default.forwardRef((props, ref) => {
|
|
381
420
|
const { asChild, children, className, label, onClick, ...rest } = props;
|
|
382
|
-
return (
|
|
421
|
+
return ((0, jsx_runtime_1.jsx)(CoreTimeSlot.StaffMemberActions, { children: ({ selectStaffMember, isSelected, staffMember }) => {
|
|
383
422
|
const handleClick = () => {
|
|
384
423
|
selectStaffMember();
|
|
385
424
|
onClick?.(staffMember);
|
|
386
425
|
};
|
|
387
|
-
return (
|
|
426
|
+
return ((0, jsx_runtime_1.jsx)(react_3.AsChildSlot, { ref: ref, asChild: asChild, ...rest, className: className, "data-testid": exports.TestIds.timeSlotStaffMemberActionSelect, "data-selected": isSelected, customElement: children, customElementProps: {
|
|
388
427
|
onClick: handleClick,
|
|
389
428
|
isSelected,
|
|
390
429
|
staffMember,
|
|
391
|
-
}, children:
|
|
430
|
+
}, children: (0, jsx_runtime_1.jsx)("button", { onClick: handleClick, children: children || label }) }));
|
|
392
431
|
} }));
|
|
393
432
|
});
|
|
394
|
-
SelectStaffMember.displayName = 'TimeSlot.StaffMember.Actions.Select';
|
|
433
|
+
exports.SelectStaffMember.displayName = 'TimeSlot.StaffMember.Actions.Select';
|
|
395
434
|
/**
|
|
396
435
|
* StaffMember namespace containing components for displaying individual staff member data.
|
|
397
436
|
* These components must be used within TimeSlot.StaffMemberRepeater.
|
|
@@ -404,9 +443,9 @@ SelectStaffMember.displayName = 'TimeSlot.StaffMember.Actions.Select';
|
|
|
404
443
|
* </TimeSlot.StaffMemberRepeater>
|
|
405
444
|
* ```
|
|
406
445
|
*/
|
|
407
|
-
|
|
408
|
-
Name: StaffMemberName,
|
|
446
|
+
exports.StaffMember = {
|
|
447
|
+
Name: exports.StaffMemberName,
|
|
409
448
|
Actions: {
|
|
410
|
-
Select: SelectStaffMember,
|
|
449
|
+
Select: exports.SelectStaffMember,
|
|
411
450
|
},
|
|
412
451
|
};
|
|
@@ -1,15 +1,54 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.TimeSlot = exports.DateRange = exports.Actions = exports.LoadMore = exports.TimeSlotRepeater = exports.TimeSlots = exports.Root = exports.Timezone = exports.TestIds = void 0;
|
|
40
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
2
41
|
/**
|
|
3
42
|
* TimeSlotList - High-level component for displaying time slot list information
|
|
4
43
|
* Provides components for displaying timezone and time slot data
|
|
5
44
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
45
|
+
const react_1 = __importDefault(require("react"));
|
|
46
|
+
const react_2 = require("@wix/headless-components/react");
|
|
47
|
+
const react_3 = require("@wix/headless-utils/react");
|
|
48
|
+
const date_fns_1 = require("date-fns");
|
|
49
|
+
const CoreTimeSlotList = __importStar(require("../core/time-slot-list/TimeSlotList.js"));
|
|
50
|
+
const CoreTimeSlot = __importStar(require("../core/time-slot-list/TimeSlot.js"));
|
|
51
|
+
const TimeSlot_js_1 = require("./TimeSlot.js");
|
|
13
52
|
// ============================================================================
|
|
14
53
|
// Utilities
|
|
15
54
|
// ============================================================================
|
|
@@ -27,12 +66,12 @@ function toISODateString(date, timezone) {
|
|
|
27
66
|
});
|
|
28
67
|
return formatter.format(date);
|
|
29
68
|
}
|
|
30
|
-
return format(date, 'yyyy-MM-dd');
|
|
69
|
+
return (0, date_fns_1.format)(date, 'yyyy-MM-dd');
|
|
31
70
|
}
|
|
32
71
|
/**
|
|
33
72
|
* TimeSlot with required id field for GenericList
|
|
34
73
|
*/
|
|
35
|
-
|
|
74
|
+
exports.TestIds = {
|
|
36
75
|
timeSlotListRoot: 'time-slot-list-root',
|
|
37
76
|
timeSlotListTimeSlots: 'time-slot-list-time-slots',
|
|
38
77
|
timeSlotListTimeSlot: 'time-slot-list-time-slot',
|
|
@@ -60,11 +99,11 @@ export const TestIds = {
|
|
|
60
99
|
* </TimeSlotList.Timezone>
|
|
61
100
|
* ```
|
|
62
101
|
*/
|
|
63
|
-
|
|
102
|
+
exports.Timezone = react_1.default.forwardRef((props, ref) => {
|
|
64
103
|
const { asChild, children, className } = props;
|
|
65
|
-
return (
|
|
104
|
+
return ((0, jsx_runtime_1.jsx)(CoreTimeSlotList.Timezone, { children: ({ timezone, displayName }) => ((0, jsx_runtime_1.jsx)(react_3.AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": exports.TestIds.timeSlotListTimezone, customElement: children, customElementProps: { timezone, displayName }, children: (0, jsx_runtime_1.jsx)("span", { children: displayName }) })) }));
|
|
66
105
|
});
|
|
67
|
-
Timezone.displayName = 'TimeSlotList.Timezone';
|
|
106
|
+
exports.Timezone.displayName = 'TimeSlotList.Timezone';
|
|
68
107
|
/**
|
|
69
108
|
* Root component that provides the TimeSlotList service context.
|
|
70
109
|
*
|
|
@@ -87,20 +126,20 @@ Timezone.displayName = 'TimeSlotList.Timezone';
|
|
|
87
126
|
* }
|
|
88
127
|
* ```
|
|
89
128
|
*/
|
|
90
|
-
|
|
129
|
+
exports.Root = react_1.default.forwardRef((props, ref) => {
|
|
91
130
|
const { children, config, className, variant } = props;
|
|
92
|
-
return (
|
|
131
|
+
return ((0, jsx_runtime_1.jsx)(CoreTimeSlotList.Root, { config: config, children: (0, jsx_runtime_1.jsx)(RootContent, { className: className, ref: ref, variant: variant, children: children }) }));
|
|
93
132
|
});
|
|
94
|
-
Root.displayName = 'TimeSlotList.Root';
|
|
133
|
+
exports.Root.displayName = 'TimeSlotList.Root';
|
|
95
134
|
/**
|
|
96
135
|
* Internal component to handle the Root content with core layer access
|
|
97
136
|
*/
|
|
98
|
-
const RootContent =
|
|
137
|
+
const RootContent = react_1.default.forwardRef((props, ref) => {
|
|
99
138
|
const { children, className, variant } = props;
|
|
100
|
-
return (
|
|
139
|
+
return ((0, jsx_runtime_1.jsx)(CoreTimeSlotList.ListData, { children: ({ timeSlots, hasMore, isLoading, error, loadMore, hasSelectedTimeSlot, }) => ((0, jsx_runtime_1.jsx)(react_2.GenericList.Root, { items: timeSlots.map((slot) => ({
|
|
101
140
|
...slot,
|
|
102
141
|
id: generateSlotKey(slot),
|
|
103
|
-
})), loadMore: loadMore, hasMore: hasMore, isLoading: isLoading, error: error, className: className, ref: ref, "data-testid": TestIds.timeSlotListRoot, "data-has-selected-time-slot": hasSelectedTimeSlot, variant: variant, children: children })) }));
|
|
142
|
+
})), loadMore: loadMore, hasMore: hasMore, isLoading: isLoading, error: error, className: className, ref: ref, "data-testid": exports.TestIds.timeSlotListRoot, "data-has-selected-time-slot": hasSelectedTimeSlot, variant: variant, children: children })) }));
|
|
104
143
|
});
|
|
105
144
|
RootContent.displayName = 'TimeSlotList.RootContent';
|
|
106
145
|
/**
|
|
@@ -120,16 +159,16 @@ RootContent.displayName = 'TimeSlotList.RootContent';
|
|
|
120
159
|
* </TimeSlotList.TimeSlots>
|
|
121
160
|
* ```
|
|
122
161
|
*/
|
|
123
|
-
|
|
162
|
+
exports.TimeSlots = react_1.default.forwardRef((props, ref) => {
|
|
124
163
|
const { children, ...otherProps } = props;
|
|
125
|
-
return (
|
|
164
|
+
return ((0, jsx_runtime_1.jsx)(react_2.GenericList.Items, { ref: ref, "data-testid": exports.TestIds.timeSlotListTimeSlots, ...otherProps, children: children }));
|
|
126
165
|
});
|
|
127
|
-
TimeSlots.displayName = 'TimeSlotList.TimeSlots';
|
|
166
|
+
exports.TimeSlots.displayName = 'TimeSlotList.TimeSlots';
|
|
128
167
|
/**
|
|
129
168
|
* Internal component that wraps each time slot item with context provider.
|
|
130
169
|
*/
|
|
131
170
|
const TimeSlotItemWrapper = ({ timeSlot, children, }) => {
|
|
132
|
-
return (
|
|
171
|
+
return ((0, jsx_runtime_1.jsx)(TimeSlot_js_1.Root, { timeSlot: timeSlot, children: (0, jsx_runtime_1.jsx)(CoreTimeSlot.Info, { children: (props) => ((0, jsx_runtime_1.jsx)("div", { "data-testid": exports.TestIds.timeSlotListTimeSlot, "data-bookable": props.bookable, "data-selected": props.isSelected, children: children })) }) }));
|
|
133
172
|
};
|
|
134
173
|
/**
|
|
135
174
|
* Repeater component that renders TimeSlot.Root for each time slot.
|
|
@@ -148,11 +187,11 @@ const TimeSlotItemWrapper = ({ timeSlot, children, }) => {
|
|
|
148
187
|
const generateSlotKey = (timeSlot) => {
|
|
149
188
|
return `${timeSlot.localStartDate}-${timeSlot.location?._id}`;
|
|
150
189
|
};
|
|
151
|
-
|
|
190
|
+
exports.TimeSlotRepeater = react_1.default.forwardRef((props, ref) => {
|
|
152
191
|
const { children } = props;
|
|
153
|
-
return (
|
|
192
|
+
return ((0, jsx_runtime_1.jsx)(react_2.GenericList.Repeater, { ref: ref, itemWrapper: ({ item: timeSlot, children: itemChildren }) => ((0, jsx_runtime_1.jsx)(TimeSlotItemWrapper, { timeSlot: timeSlot, children: itemChildren }, generateSlotKey(timeSlot))), children: children }));
|
|
154
193
|
});
|
|
155
|
-
TimeSlotRepeater.displayName = 'TimeSlotList.TimeSlotRepeater';
|
|
194
|
+
exports.TimeSlotRepeater.displayName = 'TimeSlotList.TimeSlotRepeater';
|
|
156
195
|
/**
|
|
157
196
|
* Displays a button to load more time slots. Not rendered if no more slots are left to load.
|
|
158
197
|
* Follows the architecture rules - does not support asChild as it's a simple trigger component.
|
|
@@ -165,16 +204,16 @@ TimeSlotRepeater.displayName = 'TimeSlotList.TimeSlotRepeater';
|
|
|
165
204
|
* </TimeSlotList.Actions.LoadMore>
|
|
166
205
|
* ```
|
|
167
206
|
*/
|
|
168
|
-
|
|
169
|
-
const { children =
|
|
170
|
-
return (
|
|
207
|
+
exports.LoadMore = react_1.default.forwardRef((props, ref) => {
|
|
208
|
+
const { children = (0, jsx_runtime_1.jsx)("button", {}), ...otherProps } = props;
|
|
209
|
+
return ((0, jsx_runtime_1.jsx)(react_2.GenericList.Actions.LoadMore, { ref: ref, "data-testid": exports.TestIds.timeSlotListLoadMore, ...otherProps, children: children }));
|
|
171
210
|
});
|
|
172
|
-
LoadMore.displayName = 'TimeSlotList.Actions.LoadMore';
|
|
211
|
+
exports.LoadMore.displayName = 'TimeSlotList.Actions.LoadMore';
|
|
173
212
|
/**
|
|
174
213
|
* Actions namespace for TimeSlotList
|
|
175
214
|
*/
|
|
176
|
-
|
|
177
|
-
LoadMore,
|
|
215
|
+
exports.Actions = {
|
|
216
|
+
LoadMore: exports.LoadMore,
|
|
178
217
|
};
|
|
179
218
|
/**
|
|
180
219
|
* Date range input for setting the start and end date filter.
|
|
@@ -201,27 +240,27 @@ export const Actions = {
|
|
|
201
240
|
* </TimeSlotList.DateRange.Input>
|
|
202
241
|
* ```
|
|
203
242
|
*/
|
|
204
|
-
const DateRangeInput =
|
|
243
|
+
const DateRangeInput = react_1.default.forwardRef((props, ref) => {
|
|
205
244
|
const { asChild, children, className, onChange, ...rest } = props;
|
|
206
|
-
return (
|
|
245
|
+
return ((0, jsx_runtime_1.jsx)(CoreTimeSlotList.DateRange, { children: ({ startDate, endDate, setDateRange, timezone }) => {
|
|
207
246
|
const handleChange = (e) => {
|
|
208
|
-
const date = parse(e.target.value, 'yyyy-MM-dd', new Date());
|
|
209
|
-
setDateRange(startOfDay(date), endOfDay(date));
|
|
247
|
+
const date = (0, date_fns_1.parse)(e.target.value, 'yyyy-MM-dd', new Date());
|
|
248
|
+
setDateRange((0, date_fns_1.startOfDay)(date), (0, date_fns_1.endOfDay)(date));
|
|
210
249
|
onChange?.(e);
|
|
211
250
|
};
|
|
212
|
-
return (
|
|
251
|
+
return ((0, jsx_runtime_1.jsx)(react_3.AsChildSlot, { ref: ref, asChild: asChild, ...rest, className: className, onChange: handleChange, "data-testid": exports.TestIds.timeSlotListDateRangeInput, customElement: children, customElementProps: {
|
|
213
252
|
startDate,
|
|
214
253
|
endDate,
|
|
215
254
|
onChange: setDateRange,
|
|
216
255
|
timezone,
|
|
217
|
-
}, children:
|
|
256
|
+
}, children: (0, jsx_runtime_1.jsx)("input", { ref: ref, type: "date", value: toISODateString(startDate, timezone) }) }));
|
|
218
257
|
} }));
|
|
219
258
|
});
|
|
220
259
|
DateRangeInput.displayName = 'TimeSlotList.DateRange.Input';
|
|
221
260
|
/**
|
|
222
261
|
* DateRange namespace for TimeSlotList date range filter
|
|
223
262
|
*/
|
|
224
|
-
|
|
263
|
+
exports.DateRange = {
|
|
225
264
|
Input: DateRangeInput,
|
|
226
265
|
};
|
|
227
266
|
// ============================================================================
|
|
@@ -256,13 +295,13 @@ export const DateRange = {
|
|
|
256
295
|
* </TimeSlotList.TimeSlotRepeater>
|
|
257
296
|
* ```
|
|
258
297
|
*/
|
|
259
|
-
|
|
260
|
-
StartDate:
|
|
261
|
-
EndDate:
|
|
262
|
-
Duration,
|
|
263
|
-
Actions:
|
|
264
|
-
Location,
|
|
265
|
-
StaffMembers,
|
|
266
|
-
StaffMemberRepeater,
|
|
267
|
-
StaffMember,
|
|
298
|
+
exports.TimeSlot = {
|
|
299
|
+
StartDate: TimeSlot_js_1.StartDate,
|
|
300
|
+
EndDate: TimeSlot_js_1.EndDate,
|
|
301
|
+
Duration: TimeSlot_js_1.Duration,
|
|
302
|
+
Actions: TimeSlot_js_1.Actions,
|
|
303
|
+
Location: TimeSlot_js_1.Location,
|
|
304
|
+
StaffMembers: TimeSlot_js_1.StaffMembers,
|
|
305
|
+
StaffMemberRepeater: TimeSlot_js_1.StaffMemberRepeater,
|
|
306
|
+
StaffMember: TimeSlot_js_1.StaffMember,
|
|
268
307
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* Book Action - Orchestrates the booking flow
|
|
3
4
|
*
|
|
@@ -7,14 +8,16 @@
|
|
|
7
8
|
* 4. Determines if checkout is required or can be skipped
|
|
8
9
|
* 5. Returns appropriate result for navigation
|
|
9
10
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.executeBookAction = executeBookAction;
|
|
13
|
+
const index_js_1 = require("../../../api/create-booking/index.js");
|
|
14
|
+
const index_js_2 = require("../../../api/create-checkout/index.js");
|
|
15
|
+
const index_js_3 = require("../../../api/create-order/index.js");
|
|
16
|
+
const buildBookingRequest_js_1 = require("./buildBookingRequest.js");
|
|
17
|
+
const buildCheckoutRequest_js_1 = require("./buildCheckoutRequest.js");
|
|
18
|
+
const canBook_js_1 = require("./canBook.js");
|
|
19
|
+
const isCheckoutRequired_js_1 = require("./isCheckoutRequired.js");
|
|
20
|
+
const types_js_1 = require("./types.js");
|
|
18
21
|
/**
|
|
19
22
|
* Executes the complete booking flow:
|
|
20
23
|
* 1. Validates that all required data is present
|
|
@@ -28,17 +31,17 @@ import { BookResultType, } from './types.js';
|
|
|
28
31
|
* @returns BookResult with either checkoutId or orderId
|
|
29
32
|
* @throws Error if validation fails, or booking/checkout/order creation fails
|
|
30
33
|
*/
|
|
31
|
-
|
|
34
|
+
async function executeBookAction(params) {
|
|
32
35
|
// Step 0: Validate
|
|
33
|
-
if (!canBook({
|
|
36
|
+
if (!(0, canBook_js_1.canBook)({
|
|
34
37
|
serviceSelections: params.serviceSelections,
|
|
35
38
|
formSubmission: params.formSubmission,
|
|
36
39
|
})) {
|
|
37
40
|
throw new Error('Cannot book: missing required data');
|
|
38
41
|
}
|
|
39
42
|
// Step 1: Create booking
|
|
40
|
-
const createBookingRequest = buildBookingRequest(params);
|
|
41
|
-
const bookingResponse = await createBooking(createBookingRequest.booking, {
|
|
43
|
+
const createBookingRequest = (0, buildBookingRequest_js_1.buildBookingRequest)(params);
|
|
44
|
+
const bookingResponse = await (0, index_js_1.createBooking)(createBookingRequest.booking, {
|
|
42
45
|
participantNotification: createBookingRequest.participantNotification,
|
|
43
46
|
sendSmsReminder: createBookingRequest.sendSmsReminder ?? undefined,
|
|
44
47
|
formSubmission: createBookingRequest.formSubmission ?? undefined,
|
|
@@ -55,26 +58,26 @@ export async function executeBookAction(params) {
|
|
|
55
58
|
throw new Error('No service selection found');
|
|
56
59
|
}
|
|
57
60
|
const businessLocationId = firstSelection.timeSlot?.location?._id ?? undefined;
|
|
58
|
-
const checkoutRequest = buildCheckoutRequest({
|
|
61
|
+
const checkoutRequest = (0, buildCheckoutRequest_js_1.buildCheckoutRequest)({
|
|
59
62
|
bookingId,
|
|
60
63
|
contactDetails,
|
|
61
64
|
businessLocationId,
|
|
62
65
|
});
|
|
63
|
-
const checkoutResponse = await createCheckout(checkoutRequest);
|
|
66
|
+
const checkoutResponse = await (0, index_js_2.createCheckout)(checkoutRequest);
|
|
64
67
|
const checkout = checkoutResponse.checkout;
|
|
65
68
|
if (!checkout?._id) {
|
|
66
69
|
throw new Error('Failed to create checkout');
|
|
67
70
|
}
|
|
68
71
|
// Step 3: Determine if checkout is required or can be skipped
|
|
69
72
|
const service = firstSelection.service;
|
|
70
|
-
if (isCheckoutRequired(checkout, service)) {
|
|
71
|
-
return { type: BookResultType.CheckoutRequired, checkoutId: checkout._id };
|
|
73
|
+
if ((0, isCheckoutRequired_js_1.isCheckoutRequired)(checkout, service)) {
|
|
74
|
+
return { type: types_js_1.BookResultType.CheckoutRequired, checkoutId: checkout._id };
|
|
72
75
|
}
|
|
73
76
|
// Step 4: Skip checkout - create order directly
|
|
74
|
-
const orderResponse = await createOrder(checkout._id);
|
|
77
|
+
const orderResponse = await (0, index_js_3.createOrder)(checkout._id);
|
|
75
78
|
const orderId = orderResponse.orderId;
|
|
76
79
|
if (!orderId) {
|
|
77
80
|
throw new Error('Failed to create order');
|
|
78
81
|
}
|
|
79
|
-
return { type: BookResultType.CheckoutSkipped, orderId };
|
|
82
|
+
return { type: types_js_1.BookResultType.CheckoutSkipped, orderId };
|
|
80
83
|
}
|