@wix/headless-bookings 0.0.92 → 0.0.94
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__/services.d.ts +0 -4
- package/cjs/dist/__mocks__/services.js +1 -4
- package/cjs/dist/api/fetch-availability/index.js +3 -3
- package/cjs/dist/api/query-services/index.js +1 -4
- package/cjs/dist/react/booking/Book.d.ts +4 -1
- package/cjs/dist/react/booking/Book.js +12 -10
- package/cjs/dist/react/booking/Booking.d.ts +10 -0
- package/cjs/dist/react/booking/Booking.js +10 -11
- package/cjs/dist/react/booking/BookingItem.d.ts +6 -2
- package/cjs/dist/react/booking/BookingItem.js +7 -8
- package/cjs/dist/react/booking-form/BookingForm.d.ts +5 -0
- package/cjs/dist/react/booking-form/BookingForm.js +8 -9
- package/cjs/dist/react/core/staff-member/StaffMember.js +1 -2
- package/cjs/dist/react/core/staff-member-list/StaffMemberList.d.ts +2 -0
- package/cjs/dist/react/core/staff-member-list/StaffMemberList.js +11 -0
- package/cjs/dist/react/location/Location.d.ts +12 -4
- package/cjs/dist/react/location/Location.js +24 -25
- package/cjs/dist/react/location/LocationList.d.ts +8 -2
- package/cjs/dist/react/location/LocationList.js +12 -12
- package/cjs/dist/react/payment/Payment.d.ts +22 -16
- package/cjs/dist/react/payment/Payment.js +28 -29
- package/cjs/dist/react/service/Service.d.ts +41 -16
- package/cjs/dist/react/service/Service.js +62 -63
- package/cjs/dist/react/service/ServiceMedia.d.ts +4 -0
- package/cjs/dist/react/service/ServiceMedia.js +4 -5
- package/cjs/dist/react/service-list/ServiceList.d.ts +7 -0
- package/cjs/dist/react/service-list/ServiceList.js +7 -8
- package/cjs/dist/react/staff-member/StaffMember.d.ts +7 -8
- package/cjs/dist/react/staff-member/StaffMember.js +11 -12
- package/cjs/dist/react/staff-member/StaffMemberList.d.ts +9 -8
- package/cjs/dist/react/staff-member/StaffMemberList.js +14 -24
- package/cjs/dist/react/time-slot-list/TimeSlot.d.ts +16 -20
- package/cjs/dist/react/time-slot-list/TimeSlot.js +31 -32
- package/cjs/dist/react/time-slot-list/TimeSlotList.d.ts +10 -12
- package/cjs/dist/react/time-slot-list/TimeSlotList.js +18 -18
- package/cjs/dist/services/booking/book-action/buildBookingRequest.js +1 -2
- package/cjs/dist/services/booking/book-action/buildCheckoutRequest.js +2 -2
- package/cjs/dist/services/constants.d.ts +9 -0
- package/cjs/dist/services/constants.js +9 -0
- package/cjs/dist/services/payment/payment.js +2 -5
- package/cjs/dist/services/service/service.js +1 -1
- package/cjs/dist/services/service-list/service-list.js +1 -4
- package/dist/__mocks__/services.d.ts +0 -4
- package/dist/__mocks__/services.js +1 -4
- package/dist/api/fetch-availability/index.js +3 -3
- package/dist/api/query-services/index.js +1 -4
- package/dist/react/booking/Book.d.ts +4 -1
- package/dist/react/booking/Book.js +12 -10
- package/dist/react/booking/Booking.d.ts +10 -0
- package/dist/react/booking/Booking.js +10 -11
- package/dist/react/booking/BookingItem.d.ts +6 -2
- package/dist/react/booking/BookingItem.js +7 -8
- package/dist/react/booking-form/BookingForm.d.ts +5 -0
- package/dist/react/booking-form/BookingForm.js +8 -9
- package/dist/react/core/staff-member/StaffMember.js +1 -2
- package/dist/react/core/staff-member-list/StaffMemberList.d.ts +2 -0
- package/dist/react/core/staff-member-list/StaffMemberList.js +11 -0
- package/dist/react/location/Location.d.ts +12 -4
- package/dist/react/location/Location.js +24 -25
- package/dist/react/location/LocationList.d.ts +8 -2
- package/dist/react/location/LocationList.js +12 -12
- package/dist/react/payment/Payment.d.ts +22 -16
- package/dist/react/payment/Payment.js +28 -29
- package/dist/react/service/Service.d.ts +41 -16
- package/dist/react/service/Service.js +62 -63
- package/dist/react/service/ServiceMedia.d.ts +4 -0
- package/dist/react/service/ServiceMedia.js +4 -5
- package/dist/react/service-list/ServiceList.d.ts +7 -0
- package/dist/react/service-list/ServiceList.js +7 -8
- package/dist/react/staff-member/StaffMember.d.ts +7 -8
- package/dist/react/staff-member/StaffMember.js +11 -12
- package/dist/react/staff-member/StaffMemberList.d.ts +9 -8
- package/dist/react/staff-member/StaffMemberList.js +14 -24
- package/dist/react/time-slot-list/TimeSlot.d.ts +16 -20
- package/dist/react/time-slot-list/TimeSlot.js +31 -32
- package/dist/react/time-slot-list/TimeSlotList.d.ts +10 -12
- package/dist/react/time-slot-list/TimeSlotList.js +18 -18
- package/dist/services/booking/book-action/buildBookingRequest.js +1 -2
- package/dist/services/booking/book-action/buildCheckoutRequest.js +2 -2
- package/dist/services/constants.d.ts +9 -0
- package/dist/services/constants.js +9 -0
- package/dist/services/payment/payment.js +2 -5
- package/dist/services/service/service.js +1 -1
- package/dist/services/service-list/service-list.js +1 -4
- package/package.json +2 -2
|
@@ -24,28 +24,27 @@ import * as CoreTimeSlot from '../core/time-slot-list/TimeSlot.js';
|
|
|
24
24
|
* ```
|
|
25
25
|
*/
|
|
26
26
|
export const Root = React.forwardRef((props, ref) => {
|
|
27
|
-
const { children, timeSlot, asChild, className
|
|
28
|
-
return (_jsx(CoreTimeSlot.Root, { config: { timeSlot }, children: _jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, customElement: children,
|
|
27
|
+
const { children, timeSlot, asChild, className } = props;
|
|
28
|
+
return (_jsx(CoreTimeSlot.Root, { config: { timeSlot }, children: _jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, customElement: children, children: children }) }));
|
|
29
29
|
});
|
|
30
30
|
Root.displayName = 'TimeSlot.Root';
|
|
31
31
|
// ============================================================================
|
|
32
32
|
// TestIds
|
|
33
33
|
// ============================================================================
|
|
34
|
-
export
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
TestIds["timeSlotActionClearStaffSelection"] = "time-slot-action-clear-staff-selection";
|
|
34
|
+
export const TestIds = {
|
|
35
|
+
timeSlotStartDate: 'time-slot-start-date',
|
|
36
|
+
timeSlotEndDate: 'time-slot-end-date',
|
|
37
|
+
timeSlotDuration: 'time-slot-duration',
|
|
38
|
+
timeSlotActionSelect: 'time-slot-action-select',
|
|
39
|
+
timeSlotActionClearStaffSelection: 'time-slot-action-clear-staff-selection',
|
|
41
40
|
// Location component
|
|
42
|
-
|
|
41
|
+
timeSlotLocationName: 'time-slot-location-name',
|
|
43
42
|
// StaffMember components
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
43
|
+
timeSlotStaffMembers: 'time-slot-staff-members',
|
|
44
|
+
timeSlotStaffMember: 'time-slot-staff-member',
|
|
45
|
+
timeSlotStaffMemberName: 'time-slot-staff-member-name',
|
|
46
|
+
timeSlotStaffMemberActionSelect: 'time-slot-staff-member-action-select',
|
|
47
|
+
};
|
|
49
48
|
/**
|
|
50
49
|
* Displays the time slot start time.
|
|
51
50
|
* Default formatting shows time as "10:00 AM" (hour:minute with AM/PM).
|
|
@@ -137,8 +136,8 @@ EndDate.displayName = 'TimeSlot.EndDate';
|
|
|
137
136
|
* ```
|
|
138
137
|
*/
|
|
139
138
|
export const Duration = React.forwardRef((props, ref) => {
|
|
140
|
-
const { asChild, children,
|
|
141
|
-
return (_jsx(CoreTimeSlot.Info, { children: ({ durationInMinutes }) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild,
|
|
139
|
+
const { asChild, children, ...rest } = props;
|
|
140
|
+
return (_jsx(CoreTimeSlot.Info, { children: ({ durationInMinutes }) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild, ...rest, "data-testid": TestIds.timeSlotDuration, customElement: children, customElementProps: { durationInMinutes }, children: _jsx("span", { children: durationInMinutes }) })) }));
|
|
142
141
|
});
|
|
143
142
|
Duration.displayName = 'TimeSlot.Duration';
|
|
144
143
|
/**
|
|
@@ -175,19 +174,19 @@ Duration.displayName = 'TimeSlot.Duration';
|
|
|
175
174
|
* ```
|
|
176
175
|
*/
|
|
177
176
|
export const Select = React.forwardRef((props, ref) => {
|
|
178
|
-
const { asChild, children, className, label, onClick, ...
|
|
177
|
+
const { asChild, children, className, label, onClick, ...rest } = props;
|
|
179
178
|
return (_jsx(CoreTimeSlot.Actions, { children: ({ selectTimeSlot, timeSlot, isSelected, bookable }) => {
|
|
180
179
|
const handleClick = () => {
|
|
181
180
|
selectTimeSlot();
|
|
182
181
|
onClick?.(timeSlot);
|
|
183
182
|
};
|
|
184
|
-
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.timeSlotActionSelect, "data-selected": isSelected, "data-bookable": bookable, customElement: children, customElementProps: {
|
|
183
|
+
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, ...rest, className: className, disabled: !bookable, "data-testid": TestIds.timeSlotActionSelect, "data-selected": isSelected, "data-bookable": bookable, customElement: children, customElementProps: {
|
|
185
184
|
onClick: handleClick,
|
|
186
185
|
disabled: !bookable,
|
|
187
186
|
isSelected,
|
|
188
187
|
bookable,
|
|
189
188
|
timeSlot,
|
|
190
|
-
}, children: _jsx("button", {
|
|
189
|
+
}, children: _jsx("button", { onClick: handleClick, children: children || label }) }));
|
|
191
190
|
} }));
|
|
192
191
|
});
|
|
193
192
|
Select.displayName = 'TimeSlot.Actions.Select';
|
|
@@ -222,7 +221,7 @@ Select.displayName = 'TimeSlot.Actions.Select';
|
|
|
222
221
|
* ```
|
|
223
222
|
*/
|
|
224
223
|
export const ClearStaffSelection = React.forwardRef((props, ref) => {
|
|
225
|
-
const { asChild, children, className, label, onClick, ...
|
|
224
|
+
const { asChild, children, className, label, onClick, ...rest } = props;
|
|
226
225
|
return (_jsx(CoreTimeSlot.Actions, { children: ({ clearStaffSelection, timeSlot }) => {
|
|
227
226
|
if (!clearStaffSelection) {
|
|
228
227
|
return null;
|
|
@@ -231,9 +230,9 @@ export const ClearStaffSelection = React.forwardRef((props, ref) => {
|
|
|
231
230
|
clearStaffSelection();
|
|
232
231
|
onClick?.(timeSlot);
|
|
233
232
|
};
|
|
234
|
-
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.timeSlotActionClearStaffSelection, customElement: children, customElementProps: {
|
|
233
|
+
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, ...rest, className: className, "data-testid": TestIds.timeSlotActionClearStaffSelection, customElement: children, customElementProps: {
|
|
235
234
|
onClick: handleClick,
|
|
236
|
-
}, children: _jsx("button", {
|
|
235
|
+
}, children: _jsx("button", { onClick: handleClick, children: children || label }) }));
|
|
237
236
|
} }));
|
|
238
237
|
});
|
|
239
238
|
ClearStaffSelection.displayName = 'TimeSlot.Actions.ClearStaffSelection';
|
|
@@ -262,9 +261,9 @@ export const Actions = {
|
|
|
262
261
|
* ```
|
|
263
262
|
*/
|
|
264
263
|
export const LocationName = React.forwardRef((props, ref) => {
|
|
265
|
-
const { asChild, children,
|
|
264
|
+
const { asChild, children, ...rest } = props;
|
|
266
265
|
return (_jsx(CoreTimeSlot.Info, { children: ({ locationName }) => {
|
|
267
|
-
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild,
|
|
266
|
+
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, ...rest, "data-testid": TestIds.timeSlotLocationName, customElement: children, customElementProps: { name: locationName }, children: _jsx("span", { children: locationName }) }));
|
|
268
267
|
} }));
|
|
269
268
|
});
|
|
270
269
|
LocationName.displayName = 'TimeSlot.Location.Name';
|
|
@@ -290,9 +289,9 @@ export const Location = {
|
|
|
290
289
|
* ```
|
|
291
290
|
*/
|
|
292
291
|
export const StaffMembers = React.forwardRef((props, ref) => {
|
|
293
|
-
const { children,
|
|
292
|
+
const { children, ...attrs } = props;
|
|
294
293
|
return (_jsx(CoreTimeSlot.StaffMembers, { children: ({ staffMembers }) => {
|
|
295
|
-
return (_jsx(GenericList.Root, { items: staffMembers, children: _jsx("div", { ref: ref,
|
|
294
|
+
return (_jsx(GenericList.Root, { items: staffMembers, children: _jsx("div", { ref: ref, ...attrs, "data-testid": TestIds.timeSlotStaffMembers, children: children }) }));
|
|
296
295
|
} }));
|
|
297
296
|
});
|
|
298
297
|
StaffMembers.displayName = 'TimeSlot.StaffMembers';
|
|
@@ -341,8 +340,8 @@ StaffMemberRepeater.displayName = 'TimeSlot.StaffMemberRepeater';
|
|
|
341
340
|
* ```
|
|
342
341
|
*/
|
|
343
342
|
export const StaffMemberName = React.forwardRef((props, ref) => {
|
|
344
|
-
const { asChild, children,
|
|
345
|
-
return (_jsx(CoreTimeSlot.StaffMemberInfo, { children: ({ name }) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild,
|
|
343
|
+
const { asChild, children, ...rest } = props;
|
|
344
|
+
return (_jsx(CoreTimeSlot.StaffMemberInfo, { children: ({ name }) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild, ...rest, "data-testid": TestIds.timeSlotStaffMemberName, customElement: children, customElementProps: { name }, children: _jsx("span", { children: name }) })) }));
|
|
346
345
|
});
|
|
347
346
|
StaffMemberName.displayName = 'TimeSlot.StaffMember.Name';
|
|
348
347
|
/**
|
|
@@ -379,17 +378,17 @@ StaffMemberName.displayName = 'TimeSlot.StaffMember.Name';
|
|
|
379
378
|
* ```
|
|
380
379
|
*/
|
|
381
380
|
export const SelectStaffMember = React.forwardRef((props, ref) => {
|
|
382
|
-
const { asChild, children, className, label, onClick, ...
|
|
381
|
+
const { asChild, children, className, label, onClick, ...rest } = props;
|
|
383
382
|
return (_jsx(CoreTimeSlot.StaffMemberActions, { children: ({ selectStaffMember, isSelected, staffMember }) => {
|
|
384
383
|
const handleClick = () => {
|
|
385
384
|
selectStaffMember();
|
|
386
385
|
onClick?.(staffMember);
|
|
387
386
|
};
|
|
388
|
-
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.timeSlotStaffMemberActionSelect, "data-selected": isSelected, customElement: children, customElementProps: {
|
|
387
|
+
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, ...rest, className: className, "data-testid": TestIds.timeSlotStaffMemberActionSelect, "data-selected": isSelected, customElement: children, customElementProps: {
|
|
389
388
|
onClick: handleClick,
|
|
390
389
|
isSelected,
|
|
391
390
|
staffMember,
|
|
392
|
-
}, children: _jsx("button", {
|
|
391
|
+
}, children: _jsx("button", { onClick: handleClick, children: children || label }) }));
|
|
393
392
|
} }));
|
|
394
393
|
});
|
|
395
394
|
SelectStaffMember.displayName = 'TimeSlot.StaffMember.Actions.Select';
|
|
@@ -10,15 +10,15 @@ export type { StartDateProps as TimeSlotStartDateProps, EndDateProps as TimeSlot
|
|
|
10
10
|
/**
|
|
11
11
|
* TimeSlot with required id field for GenericList
|
|
12
12
|
*/
|
|
13
|
-
export declare
|
|
14
|
-
timeSlotListRoot
|
|
15
|
-
timeSlotListTimeSlots
|
|
16
|
-
timeSlotListTimeSlot
|
|
17
|
-
timeSlotListTimezone
|
|
18
|
-
timeSlotListLoadMore
|
|
19
|
-
timeSlotListContinue
|
|
20
|
-
timeSlotListDateRangeInput
|
|
21
|
-
}
|
|
13
|
+
export declare const TestIds: {
|
|
14
|
+
readonly timeSlotListRoot: "time-slot-list-root";
|
|
15
|
+
readonly timeSlotListTimeSlots: "time-slot-list-time-slots";
|
|
16
|
+
readonly timeSlotListTimeSlot: "time-slot-list-time-slot";
|
|
17
|
+
readonly timeSlotListTimezone: "time-slot-list-timezone";
|
|
18
|
+
readonly timeSlotListLoadMore: "time-slot-list-load-more";
|
|
19
|
+
readonly timeSlotListContinue: "time-slot-list-continue";
|
|
20
|
+
readonly timeSlotListDateRangeInput: "time-slot-list-date-range-input";
|
|
21
|
+
};
|
|
22
22
|
/**
|
|
23
23
|
* Render props for TimeSlotList.Timezone component
|
|
24
24
|
*/
|
|
@@ -163,7 +163,7 @@ export declare const Actions: {
|
|
|
163
163
|
/**
|
|
164
164
|
* Props for DateRange.Input component
|
|
165
165
|
*/
|
|
166
|
-
export interface DateRangeInputProps {
|
|
166
|
+
export interface DateRangeInputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'children' | 'type' | 'value' | 'defaultValue'> {
|
|
167
167
|
/** Whether to render as a child component */
|
|
168
168
|
asChild?: boolean;
|
|
169
169
|
/** Children for custom rendering */
|
|
@@ -174,8 +174,6 @@ export interface DateRangeInputProps {
|
|
|
174
174
|
/** IANA timezone string for the time slots (e.g., "America/New_York") */
|
|
175
175
|
timezone: string | undefined;
|
|
176
176
|
}>;
|
|
177
|
-
/** CSS classes to apply to the container */
|
|
178
|
-
className?: string;
|
|
179
177
|
}
|
|
180
178
|
/**
|
|
181
179
|
* DateRange namespace for TimeSlotList date range filter
|
|
@@ -32,16 +32,15 @@ function toISODateString(date, timezone) {
|
|
|
32
32
|
/**
|
|
33
33
|
* TimeSlot with required id field for GenericList
|
|
34
34
|
*/
|
|
35
|
-
export
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
})(TestIds || (TestIds = {}));
|
|
35
|
+
export const TestIds = {
|
|
36
|
+
timeSlotListRoot: 'time-slot-list-root',
|
|
37
|
+
timeSlotListTimeSlots: 'time-slot-list-time-slots',
|
|
38
|
+
timeSlotListTimeSlot: 'time-slot-list-time-slot',
|
|
39
|
+
timeSlotListTimezone: 'time-slot-list-timezone',
|
|
40
|
+
timeSlotListLoadMore: 'time-slot-list-load-more',
|
|
41
|
+
timeSlotListContinue: 'time-slot-list-continue',
|
|
42
|
+
timeSlotListDateRangeInput: 'time-slot-list-date-range-input',
|
|
43
|
+
};
|
|
45
44
|
/**
|
|
46
45
|
* Displays the current timezone with customizable rendering.
|
|
47
46
|
*
|
|
@@ -182,7 +181,7 @@ export const Actions = {
|
|
|
182
181
|
* Uses the core DateRange component to access service data.
|
|
183
182
|
* Both dates are set together and trigger a single fetch.
|
|
184
183
|
*
|
|
185
|
-
* Default rendering provides
|
|
184
|
+
* Default rendering provides a native date input.
|
|
186
185
|
*
|
|
187
186
|
* @component
|
|
188
187
|
* @example
|
|
@@ -203,18 +202,19 @@ export const Actions = {
|
|
|
203
202
|
* ```
|
|
204
203
|
*/
|
|
205
204
|
const DateRangeInput = React.forwardRef((props, ref) => {
|
|
206
|
-
const { asChild, children, className, ...
|
|
205
|
+
const { asChild, children, className, onChange, ...rest } = props;
|
|
207
206
|
return (_jsx(CoreTimeSlotList.DateRange, { children: ({ startDate, endDate, setDateRange, timezone }) => {
|
|
208
|
-
const
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
207
|
+
const handleChange = (e) => {
|
|
208
|
+
const date = parse(e.target.value, 'yyyy-MM-dd', new Date());
|
|
209
|
+
setDateRange(startOfDay(date), endOfDay(date));
|
|
210
|
+
onChange?.(e);
|
|
211
|
+
};
|
|
212
|
+
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, ...rest, className: className, onChange: handleChange, "data-testid": TestIds.timeSlotListDateRangeInput, customElement: children, customElementProps: {
|
|
213
213
|
startDate,
|
|
214
214
|
endDate,
|
|
215
215
|
onChange: setDateRange,
|
|
216
216
|
timezone,
|
|
217
|
-
},
|
|
217
|
+
}, children: _jsx("input", { ref: ref, type: "date", value: toISODateString(startDate, timezone) }) }));
|
|
218
218
|
} }));
|
|
219
219
|
});
|
|
220
220
|
DateRangeInput.displayName = 'TimeSlotList.DateRange.Input';
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { LocationType as TimeSlotLocationType } from '@wix/auto_sdk_bookings_availability-time-slots';
|
|
5
5
|
import { LocationType as BookingLocationType, SelectionMethod, } from '@wix/auto_sdk_bookings_bookings';
|
|
6
|
-
|
|
7
|
-
const STAFF_MEMBER_RESOURCE_TYPE_ID = '1cd44cf8-756f-41c3-bd90-3e2ffcaf1155';
|
|
6
|
+
import { STAFF_MEMBER_RESOURCE_TYPE_ID } from '../../constants.js';
|
|
8
7
|
/**
|
|
9
8
|
* Derives the selected payment option from service payment settings.
|
|
10
9
|
* Maps service.payment.options to booking API's selectedPaymentOption.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Builds the createCheckout request
|
|
3
3
|
*/
|
|
4
4
|
import { ChannelType, } from '../../../api/create-checkout/index.js';
|
|
5
|
-
|
|
5
|
+
import { BOOKING_APP_ID } from '../../constants.js';
|
|
6
6
|
/**
|
|
7
7
|
* Builds a checkout request from the booking ID and contact details
|
|
8
8
|
*
|
|
@@ -53,7 +53,7 @@ export function buildCheckoutRequest(params) {
|
|
|
53
53
|
quantity: 1,
|
|
54
54
|
catalogReference: {
|
|
55
55
|
catalogItemId: bookingId,
|
|
56
|
-
appId:
|
|
56
|
+
appId: BOOKING_APP_ID,
|
|
57
57
|
},
|
|
58
58
|
},
|
|
59
59
|
],
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared constants for bookings services
|
|
3
|
+
*
|
|
4
|
+
* @module Services/Constants
|
|
5
|
+
*/
|
|
6
|
+
/** Booking app definition ID */
|
|
7
|
+
export declare const BOOKING_APP_ID = "13d21c63-b5ec-5912-8397-c3a5ddb27a97";
|
|
8
|
+
/** Resource type ID for staff members */
|
|
9
|
+
export declare const STAFF_MEMBER_RESOURCE_TYPE_ID = "1cd44cf8-756f-41c3-bd90-3e2ffcaf1155";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared constants for bookings services
|
|
3
|
+
*
|
|
4
|
+
* @module Services/Constants
|
|
5
|
+
*/
|
|
6
|
+
/** Booking app definition ID */
|
|
7
|
+
export const BOOKING_APP_ID = '13d21c63-b5ec-5912-8397-c3a5ddb27a97';
|
|
8
|
+
/** Resource type ID for staff members */
|
|
9
|
+
export const STAFF_MEMBER_RESOURCE_TYPE_ID = '1cd44cf8-756f-41c3-bd90-3e2ffcaf1155';
|
|
@@ -11,10 +11,7 @@ import { RateType } from '@wix/auto_sdk_bookings_services';
|
|
|
11
11
|
import { PaymentServiceDefinition, } from './payment.def.js';
|
|
12
12
|
import { generateLineItemId } from '../../utils/guid.js';
|
|
13
13
|
export { PaymentServiceDefinition, } from './payment.def.js';
|
|
14
|
-
|
|
15
|
-
// Constants
|
|
16
|
-
// ============================================================================
|
|
17
|
-
const BOOKINGS_APP_DEF_ID = '13d21c63-b5ec-5912-8397-c3a5ddb27a97';
|
|
14
|
+
import { BOOKING_APP_ID } from '../constants.js';
|
|
18
15
|
// ============================================================================
|
|
19
16
|
// Helper Functions
|
|
20
17
|
// ============================================================================
|
|
@@ -52,7 +49,7 @@ function buildLineItem(service, totalParticipants, lineItemId) {
|
|
|
52
49
|
_id: lineItemId,
|
|
53
50
|
catalogReference: {
|
|
54
51
|
catalogItemId: service._id || '',
|
|
55
|
-
appId:
|
|
52
|
+
appId: BOOKING_APP_ID,
|
|
56
53
|
},
|
|
57
54
|
price: String(price),
|
|
58
55
|
...(deposit ? { depositAmount: String(deposit) } : {}),
|
|
@@ -11,7 +11,7 @@ import { convertToMoneyData } from '../../utils/money.js';
|
|
|
11
11
|
/**
|
|
12
12
|
* Booking app ID constant
|
|
13
13
|
*/
|
|
14
|
-
|
|
14
|
+
import { BOOKING_APP_ID } from '../constants.js';
|
|
15
15
|
/**
|
|
16
16
|
* Service definition for the Service service.
|
|
17
17
|
* This defines the contract that the ServiceService must implement.
|
|
@@ -7,10 +7,7 @@ import { SignalsServiceDefinition, } from '@wix/services-definitions/core-servic
|
|
|
7
7
|
import { queryServices } from '../../api/query-services/index.js';
|
|
8
8
|
import { queryCategories, } from '../../api/query-categories/index.js';
|
|
9
9
|
import { BookingServiceDefinition } from '../booking/booking.js';
|
|
10
|
-
|
|
11
|
-
* Booking app ID constant
|
|
12
|
-
*/
|
|
13
|
-
const BOOKING_APP_ID = '13d21c63-b5ec-5912-8397-c3a5ddb27a97';
|
|
10
|
+
import { BOOKING_APP_ID } from '../constants.js';
|
|
14
11
|
/**
|
|
15
12
|
* Default query limit
|
|
16
13
|
*/
|
|
@@ -7,10 +7,6 @@ import type { ServiceListServiceConfig } from '../services/service-list/service-
|
|
|
7
7
|
import type { StaffMemberListServiceConfig } from '../services/staff-member-list/staff-member-list.js';
|
|
8
8
|
import type { PagingMetadata } from '../api/query-services/index.js';
|
|
9
9
|
import type { Category } from '../api/query-categories/index.js';
|
|
10
|
-
/**
|
|
11
|
-
* Booking app ID constant
|
|
12
|
-
*/
|
|
13
|
-
export declare const BOOKING_APP_ID = "13d21c63-b5ec-5912-8397-c3a5ddb27a97";
|
|
14
10
|
/**
|
|
15
11
|
* Base mock service with all fields populated (APPOINTMENT type, FIXED pricing)
|
|
16
12
|
*/
|
|
@@ -2,10 +2,7 @@
|
|
|
2
2
|
* Shared mock data for booking service tests
|
|
3
3
|
*/
|
|
4
4
|
import { RateType, ServiceType } from '@wix/auto_sdk_bookings_services';
|
|
5
|
-
|
|
6
|
-
* Booking app ID constant
|
|
7
|
-
*/
|
|
8
|
-
export const BOOKING_APP_ID = '13d21c63-b5ec-5912-8397-c3a5ddb27a97';
|
|
5
|
+
import { BOOKING_APP_ID } from '../services/constants.js';
|
|
9
6
|
/**
|
|
10
7
|
* Base mock service with all fields populated (APPOINTMENT type, FIXED pricing)
|
|
11
8
|
*/
|
|
@@ -7,6 +7,7 @@ import { listEventTimeSlots } from '@wix/auto_sdk_bookings_event-time-slots';
|
|
|
7
7
|
import { ServiceType } from '@wix/auto_sdk_bookings_services';
|
|
8
8
|
import { format } from 'date-fns';
|
|
9
9
|
import { ViewMode, } from '../../services/time-slot-list/time-slot-list.def.js';
|
|
10
|
+
import { STAFF_MEMBER_RESOURCE_TYPE_ID } from '../../services/constants.js';
|
|
10
11
|
// ============================================================================
|
|
11
12
|
// Internal Types
|
|
12
13
|
// ============================================================================
|
|
@@ -16,7 +17,6 @@ var FlowType;
|
|
|
16
17
|
FlowType["MULTI_SERVICE"] = "multi_service";
|
|
17
18
|
FlowType["CLASS"] = "class";
|
|
18
19
|
})(FlowType || (FlowType = {}));
|
|
19
|
-
const STAFF_RESOURCE_TYPE_ID = '1cd44cf8-756f-41c3-bd90-3e2ffcaf1155';
|
|
20
20
|
// ============================================================================
|
|
21
21
|
// Helpers
|
|
22
22
|
// ============================================================================
|
|
@@ -87,14 +87,14 @@ export async function fetchAvailability({ services: selectedServices, viewMode =
|
|
|
87
87
|
const resourceTypes = staffMemberIds?.length
|
|
88
88
|
? [
|
|
89
89
|
{
|
|
90
|
-
resourceTypeId:
|
|
90
|
+
resourceTypeId: STAFF_MEMBER_RESOURCE_TYPE_ID,
|
|
91
91
|
resourceIds: staffMemberIds,
|
|
92
92
|
},
|
|
93
93
|
]
|
|
94
94
|
: undefined;
|
|
95
95
|
const includeResourceTypeIds = isFetchAvailabileDays
|
|
96
96
|
? undefined
|
|
97
|
-
: [
|
|
97
|
+
: [STAFF_MEMBER_RESOURCE_TYPE_ID];
|
|
98
98
|
const locations = location
|
|
99
99
|
? [{ _id: location.id, locationType: location.locationType }]
|
|
100
100
|
: undefined;
|
|
@@ -3,10 +3,7 @@
|
|
|
3
3
|
* Fetches single or multiple services with pagination and sorting
|
|
4
4
|
*/
|
|
5
5
|
import { queryServices as queryServicesApi, LocationType, } from '@wix/auto_sdk_bookings_services';
|
|
6
|
-
|
|
7
|
-
* Booking app ID constant
|
|
8
|
-
*/
|
|
9
|
-
const BOOKING_APP_ID = '13d21c63-b5ec-5912-8397-c3a5ddb27a97';
|
|
6
|
+
import { BOOKING_APP_ID } from '../../services/constants.js';
|
|
10
7
|
/**
|
|
11
8
|
* Synthetic location ID constants for non-business locations
|
|
12
9
|
*/
|
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import type { BookChildProps, BookingError } from '../../services/booking/book-action/types.js';
|
|
7
|
+
export declare const TestIds: {
|
|
8
|
+
readonly bookingActionBook: "booking-action-book";
|
|
9
|
+
};
|
|
7
10
|
/**
|
|
8
11
|
* Props for the high-level Book component
|
|
9
12
|
*/
|
|
@@ -11,7 +14,7 @@ export interface BookProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonEle
|
|
|
11
14
|
asChild?: boolean;
|
|
12
15
|
children?: React.ReactNode | ((props: BookChildProps) => React.ReactNode);
|
|
13
16
|
label?: string;
|
|
14
|
-
loadingState?:
|
|
17
|
+
loadingState?: React.ReactNode;
|
|
15
18
|
disabled?: boolean;
|
|
16
19
|
/**
|
|
17
20
|
* Called when checkout is required for payment.
|
|
@@ -7,10 +7,9 @@ import React from 'react';
|
|
|
7
7
|
import { AsChildSlot } from '@wix/headless-utils/react';
|
|
8
8
|
import * as CoreBook from '../core/booking/Book.js';
|
|
9
9
|
import { navigateToCheckout as navigateToCheckoutUtil } from '../../utils/navigation.js';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
})(TestIds || (TestIds = {}));
|
|
10
|
+
export const TestIds = {
|
|
11
|
+
bookingActionBook: 'booking-action-book',
|
|
12
|
+
};
|
|
14
13
|
/**
|
|
15
14
|
* Book action button component with AsChildSlot pattern.
|
|
16
15
|
*
|
|
@@ -57,7 +56,7 @@ var TestIds;
|
|
|
57
56
|
* ```
|
|
58
57
|
*/
|
|
59
58
|
export const Book = React.forwardRef((props, ref) => {
|
|
60
|
-
const { asChild, children,
|
|
59
|
+
const { asChild, children, label, loadingState, disabled, onCheckout, onComplete, onError, onClick, ...rest } = props;
|
|
61
60
|
return (_jsx(CoreBook.Book, { onCheckout: (result) => {
|
|
62
61
|
// Create navigateToCheckout with checkoutId captured
|
|
63
62
|
const navigateToCheckout = (options) => navigateToCheckoutUtil({
|
|
@@ -68,12 +67,15 @@ export const Book = React.forwardRef((props, ref) => {
|
|
|
68
67
|
return onCheckout?.(navigateToCheckout);
|
|
69
68
|
}, onComplete: (result) => {
|
|
70
69
|
return onComplete?.({ orderId: result.orderId });
|
|
71
|
-
}, onError: onError, disabled: disabled, children: (
|
|
72
|
-
const handleClick = () => {
|
|
73
|
-
|
|
74
|
-
onClick?.(
|
|
70
|
+
}, onError: onError, disabled: disabled, children: (coreBookProps) => {
|
|
71
|
+
const handleClick = async () => {
|
|
72
|
+
await coreBookProps.onClick();
|
|
73
|
+
onClick?.(coreBookProps);
|
|
75
74
|
};
|
|
76
|
-
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild,
|
|
75
|
+
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, ...rest, disabled: coreBookProps.disabled, "data-testid": TestIds.bookingActionBook, "data-in-progress": coreBookProps.isLoading, "data-can-book": coreBookProps.canBook, customElement: children, customElementProps: {
|
|
76
|
+
...coreBookProps,
|
|
77
|
+
onClick: handleClick,
|
|
78
|
+
}, children: _jsx("button", { onClick: handleClick, children: coreBookProps.isLoading
|
|
77
79
|
? loadingState
|
|
78
80
|
: children || label }) }));
|
|
79
81
|
} }));
|
|
@@ -6,6 +6,16 @@ import React from 'react';
|
|
|
6
6
|
import * as CoreBooking from '../core/booking/Booking.js';
|
|
7
7
|
import type { BookingServiceConfig } from '../../services/booking/booking.js';
|
|
8
8
|
export type { BookingData, DataProps, BookingItem, } from '../core/booking/Booking.js';
|
|
9
|
+
export declare const TestIds: {
|
|
10
|
+
readonly bookingItemsRoot: "booking-items-root";
|
|
11
|
+
readonly bookingItems: "booking-items";
|
|
12
|
+
readonly bookingItem: "booking-item";
|
|
13
|
+
readonly bookingItemService: "booking-item-service";
|
|
14
|
+
readonly bookingItemTimeSlot: "booking-item-time-slot";
|
|
15
|
+
readonly bookingItemPayment: "booking-item-payment";
|
|
16
|
+
readonly bookingLocation: "booking-location";
|
|
17
|
+
readonly bookingStaffName: "booking-staff-name";
|
|
18
|
+
};
|
|
9
19
|
/**
|
|
10
20
|
* Props for Booking.Root component
|
|
11
21
|
*/
|
|
@@ -12,17 +12,16 @@ import { GenericList } from '@wix/headless-components/react';
|
|
|
12
12
|
// ============================================================================
|
|
13
13
|
// TestIds
|
|
14
14
|
// ============================================================================
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
})(TestIds || (TestIds = {}));
|
|
15
|
+
export const TestIds = {
|
|
16
|
+
bookingItemsRoot: 'booking-items-root',
|
|
17
|
+
bookingItems: 'booking-items',
|
|
18
|
+
bookingItem: 'booking-item',
|
|
19
|
+
bookingItemService: 'booking-item-service',
|
|
20
|
+
bookingItemTimeSlot: 'booking-item-time-slot',
|
|
21
|
+
bookingItemPayment: 'booking-item-payment',
|
|
22
|
+
bookingLocation: 'booking-location',
|
|
23
|
+
bookingStaffName: 'booking-staff-name',
|
|
24
|
+
};
|
|
26
25
|
/**
|
|
27
26
|
* Root component that provides booking context to the entire app.
|
|
28
27
|
*
|
|
@@ -4,6 +4,11 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import { type AsChildChildren } from '@wix/headless-utils/react';
|
|
7
|
+
export declare const TestIds: {
|
|
8
|
+
readonly bookingItemService: "booking-item-service";
|
|
9
|
+
readonly bookingItemTimeSlot: "booking-item-time-slot";
|
|
10
|
+
readonly bookingItemStaffName: "booking-item-staff-name";
|
|
11
|
+
};
|
|
7
12
|
export interface ServiceProps {
|
|
8
13
|
children: React.ReactNode;
|
|
9
14
|
}
|
|
@@ -44,12 +49,11 @@ export declare function TimeSlot(props: TimeSlotProps): React.ReactNode;
|
|
|
44
49
|
export declare namespace TimeSlot {
|
|
45
50
|
var displayName: string;
|
|
46
51
|
}
|
|
47
|
-
export interface StaffNameProps {
|
|
52
|
+
export interface StaffNameProps extends Omit<React.HTMLAttributes<HTMLElement>, 'children'> {
|
|
48
53
|
asChild?: boolean;
|
|
49
54
|
children?: AsChildChildren<{
|
|
50
55
|
name: string;
|
|
51
56
|
}>;
|
|
52
|
-
className?: string;
|
|
53
57
|
}
|
|
54
58
|
/**
|
|
55
59
|
* Displays the staff member's name from the current booking item.
|
|
@@ -8,12 +8,11 @@ import * as CoreBooking from '../core/booking/Booking.js';
|
|
|
8
8
|
import { AsChildSlot } from '@wix/headless-utils/react';
|
|
9
9
|
import * as ServiceComponent from '../service/Service.js';
|
|
10
10
|
import * as TimeSlotComponent from '../time-slot-list/TimeSlot.js';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
})(TestIds || (TestIds = {}));
|
|
11
|
+
export const TestIds = {
|
|
12
|
+
bookingItemService: 'booking-item-service',
|
|
13
|
+
bookingItemTimeSlot: 'booking-item-time-slot',
|
|
14
|
+
bookingItemStaffName: 'booking-item-staff-name',
|
|
15
|
+
};
|
|
17
16
|
/**
|
|
18
17
|
* Wraps Service.Root with the service from the current booking item context.
|
|
19
18
|
* Must be used within Booking.BookingItemRepeater.
|
|
@@ -61,11 +60,11 @@ TimeSlot.displayName = 'BookingItem.TimeSlot';
|
|
|
61
60
|
* ```
|
|
62
61
|
*/
|
|
63
62
|
export const StaffName = React.forwardRef((props, ref) => {
|
|
64
|
-
const { asChild, children,
|
|
63
|
+
const { asChild, children, ...rest } = props;
|
|
65
64
|
return (_jsx(CoreBooking.BookingItemInfo, { children: ({ staffName }) => {
|
|
66
65
|
if (!staffName)
|
|
67
66
|
return null;
|
|
68
|
-
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild,
|
|
67
|
+
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, ...rest, "data-testid": TestIds.bookingItemStaffName, customElement: children, customElementProps: { name: staffName }, children: _jsx("span", { children: staffName }) }));
|
|
69
68
|
} }));
|
|
70
69
|
});
|
|
71
70
|
StaffName.displayName = 'BookingItem.StaffName';
|
|
@@ -6,6 +6,11 @@ import React from 'react';
|
|
|
6
6
|
import { Form } from '@wix/headless-forms/react';
|
|
7
7
|
import * as CoreBookingForm from '../core/booking-form/BookingForm.js';
|
|
8
8
|
type FieldMap = Parameters<typeof Form.Fields>[0]['fieldMap'];
|
|
9
|
+
export declare const TestIds: {
|
|
10
|
+
readonly bookingFormRoot: "booking-form-root";
|
|
11
|
+
readonly bookingFormFields: "booking-form-fields";
|
|
12
|
+
readonly bookingFormActionValidateFormSubmission: "booking-form-action-validate-form-submission";
|
|
13
|
+
};
|
|
9
14
|
/**
|
|
10
15
|
* Props for BookingForm.Root component
|
|
11
16
|
*/
|