@wix/headless-bookings 0.0.33 → 0.0.35
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.d.ts +9 -3
- package/cjs/dist/__mocks__/booking.js +2 -2
- package/cjs/dist/react/core/booking/Booking.d.ts +3 -2
- package/cjs/dist/react/core/time-slot-list/TimeSlot.js +3 -4
- package/cjs/dist/react/payment/Payment.js +1 -5
- package/cjs/dist/react/service/Service.d.ts +39 -0
- package/cjs/dist/react/service/Service.js +58 -40
- package/cjs/dist/services/booking/book-action/bookAction.js +1 -1
- package/cjs/dist/services/booking/book-action/buildBookingRequest.js +1 -1
- package/cjs/dist/services/booking/book-action/types.d.ts +3 -2
- package/cjs/dist/services/booking/booking.d.ts +6 -10
- package/cjs/dist/services/index.d.ts +1 -1
- package/cjs/dist/services/time-slot-list/time-slot-list.js +76 -90
- package/dist/__mocks__/booking.d.ts +9 -3
- package/dist/__mocks__/booking.js +2 -2
- package/dist/react/core/booking/Booking.d.ts +3 -2
- package/dist/react/core/time-slot-list/TimeSlot.js +3 -4
- package/dist/react/payment/Payment.js +1 -5
- package/dist/react/service/Service.d.ts +39 -0
- package/dist/react/service/Service.js +58 -40
- package/dist/services/booking/book-action/bookAction.js +1 -1
- package/dist/services/booking/book-action/buildBookingRequest.js +1 -1
- package/dist/services/booking/book-action/types.d.ts +3 -2
- package/dist/services/booking/booking.d.ts +6 -10
- package/dist/services/index.d.ts +1 -1
- package/dist/services/time-slot-list/time-slot-list.js +76 -90
- package/package.json +2 -2
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { Resource } from '@wix/auto_sdk_bookings_availability-time-slots';
|
|
5
5
|
import type { FormValues } from '@wix/form-public';
|
|
6
|
-
import type { ServiceSelection, ServiceSelectionTimeSlot,
|
|
6
|
+
import type { ServiceSelection, ServiceSelectionTimeSlot, BookingServiceConfig } from '../services/booking/booking.js';
|
|
7
7
|
/**
|
|
8
8
|
* Mock resource (staff member)
|
|
9
9
|
*/
|
|
@@ -19,11 +19,17 @@ export declare const mockResourceRoom: Resource;
|
|
|
19
19
|
/**
|
|
20
20
|
* Mock location
|
|
21
21
|
*/
|
|
22
|
-
export declare const mockLocation:
|
|
22
|
+
export declare const mockLocation: {
|
|
23
|
+
_id: string;
|
|
24
|
+
name: string;
|
|
25
|
+
};
|
|
23
26
|
/**
|
|
24
27
|
* Mock location (second)
|
|
25
28
|
*/
|
|
26
|
-
export declare const mockLocationTwo:
|
|
29
|
+
export declare const mockLocationTwo: {
|
|
30
|
+
_id: string;
|
|
31
|
+
name: string;
|
|
32
|
+
};
|
|
27
33
|
/**
|
|
28
34
|
* Mock time slot data
|
|
29
35
|
*/
|
|
@@ -32,14 +32,14 @@ export const mockResourceRoom = {
|
|
|
32
32
|
* Mock location
|
|
33
33
|
*/
|
|
34
34
|
export const mockLocation = {
|
|
35
|
-
|
|
35
|
+
_id: 'location-1',
|
|
36
36
|
name: 'Main Office',
|
|
37
37
|
};
|
|
38
38
|
/**
|
|
39
39
|
* Mock location (second)
|
|
40
40
|
*/
|
|
41
41
|
export const mockLocationTwo = {
|
|
42
|
-
|
|
42
|
+
_id: 'location-2',
|
|
43
43
|
name: 'Downtown Branch',
|
|
44
44
|
};
|
|
45
45
|
/**
|
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
* Provides low-level access to BookingService via render props and service setup
|
|
4
4
|
*/
|
|
5
5
|
import React from 'react';
|
|
6
|
-
import { type BookingServiceConfig, type ServiceSelection, type
|
|
6
|
+
import { type BookingServiceConfig, type ServiceSelection, type BookingServiceActions } from '../../../services/booking/booking.js';
|
|
7
7
|
import type { FormValues } from '@wix/form-public';
|
|
8
|
+
import type { Location as TimeSlotLocationType } from '@wix/auto_sdk_bookings_availability-time-slots';
|
|
8
9
|
/**
|
|
9
10
|
* Props for Booking.Root component
|
|
10
11
|
*/
|
|
@@ -34,7 +35,7 @@ export declare function Root(props: RootProps): React.ReactNode;
|
|
|
34
35
|
*/
|
|
35
36
|
export interface BookingData {
|
|
36
37
|
serviceSelections: ServiceSelection[];
|
|
37
|
-
location:
|
|
38
|
+
location: TimeSlotLocationType | null;
|
|
38
39
|
timezone: string | undefined;
|
|
39
40
|
formSubmission: FormValues | null;
|
|
40
41
|
actions: BookingServiceActions;
|
|
@@ -31,9 +31,8 @@ export function TimeSlotProvider(props) {
|
|
|
31
31
|
const service = useService(TimeSlotListServiceDefinition);
|
|
32
32
|
const bookingService = useService(BookingServiceDefinition);
|
|
33
33
|
const selectedTimeSlot = bookingService.serviceSelections.get()[0]?.timeSlot;
|
|
34
|
-
const selectedLocationId = bookingService.location.get()?.id;
|
|
35
34
|
const isSelected = selectedTimeSlot?.startDate === timeSlot.localStartDate &&
|
|
36
|
-
|
|
35
|
+
selectedTimeSlot?.location?._id === timeSlot.location?._id;
|
|
37
36
|
const selectTimeSlot = () => {
|
|
38
37
|
service.actions.selectSlot(timeSlot);
|
|
39
38
|
};
|
|
@@ -132,7 +131,7 @@ export function Actions(props) {
|
|
|
132
131
|
const service = useService(TimeSlotListServiceDefinition);
|
|
133
132
|
const bookingService = useService(BookingServiceDefinition);
|
|
134
133
|
const bookable = timeSlot.bookable ?? false;
|
|
135
|
-
const selectedStaffMemberId = bookingService.serviceSelections.get()[0]?.resources?.[0]?._id;
|
|
134
|
+
const selectedStaffMemberId = bookingService.serviceSelections.get()[0]?.timeSlot?.resources?.[0]?._id;
|
|
136
135
|
const staffFromSlot = timeSlot.availableResources[0].resources.map((r) => r._id);
|
|
137
136
|
const shouldShowClearStaffSelection = !!selectedStaffMemberId && staffFromSlot.length > 1;
|
|
138
137
|
const clearStaffSelection = shouldShowClearStaffSelection
|
|
@@ -169,7 +168,7 @@ export function StaffMembers(props) {
|
|
|
169
168
|
const { timeSlot } = useTimeSlotContext();
|
|
170
169
|
const service = useService(TimeSlotListServiceDefinition);
|
|
171
170
|
const bookingService = useService(BookingServiceDefinition);
|
|
172
|
-
const selectedStaffMemberId = bookingService.serviceSelections.get()[0]?.resources?.[0]?._id;
|
|
171
|
+
const selectedStaffMemberId = bookingService.serviceSelections.get()[0]?.timeSlot?.resources?.[0]?._id;
|
|
173
172
|
const staffMembers = timeSlot.availableResources[0].resources;
|
|
174
173
|
// Return null if only 1 staff member - nothing to choose from
|
|
175
174
|
if (staffMembers.length <= 1) {
|
|
@@ -57,11 +57,7 @@ var TestIds;
|
|
|
57
57
|
export const Root = React.forwardRef((props, ref) => {
|
|
58
58
|
const { children, paymentServiceConfig, slotServices, numberOfParticipants, asChild, className, ...attrs } = props;
|
|
59
59
|
return (_jsx(CorePayment.Root, { paymentServiceConfig: paymentServiceConfig, slotServices: slotServices, numberOfParticipants: numberOfParticipants, children: ({ isLoading, hasError }) => {
|
|
60
|
-
|
|
61
|
-
const resolvedChildren = typeof children === 'function'
|
|
62
|
-
? children({ isLoading, hasError })
|
|
63
|
-
: children;
|
|
64
|
-
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.paymentRoot, "data-loading": isLoading, "data-has-error": hasError, customElement: resolvedChildren, customElementProps: { isLoading, hasError }, ...attrs, children: _jsx("div", { children: React.isValidElement(resolvedChildren) ? resolvedChildren : null }) }));
|
|
60
|
+
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.paymentRoot, "data-loading": isLoading, "data-has-error": hasError, customElement: children, customElementProps: { isLoading, hasError }, ...attrs, children: children }));
|
|
65
61
|
} }));
|
|
66
62
|
});
|
|
67
63
|
Root.displayName = 'Payment.Root';
|
|
@@ -577,6 +577,7 @@ export interface RawProps {
|
|
|
577
577
|
* @component
|
|
578
578
|
* @example
|
|
579
579
|
* ```tsx
|
|
580
|
+
* // Using render prop pattern to access raw service data
|
|
580
581
|
* <Service.Raw>
|
|
581
582
|
* {({ service, isLoading, error }) => (
|
|
582
583
|
* <div>
|
|
@@ -586,6 +587,11 @@ export interface RawProps {
|
|
|
586
587
|
* </div>
|
|
587
588
|
* )}
|
|
588
589
|
* </Service.Raw>
|
|
590
|
+
*
|
|
591
|
+
* // With asChild pattern
|
|
592
|
+
* <Service.Raw asChild>
|
|
593
|
+
* <CustomServiceDisplay />
|
|
594
|
+
* </Service.Raw>
|
|
589
595
|
* ```
|
|
590
596
|
*/
|
|
591
597
|
export declare const Raw: React.ForwardRefExoticComponent<RawProps & React.RefAttributes<HTMLElement>>;
|
|
@@ -607,6 +613,7 @@ export declare namespace Actions {
|
|
|
607
613
|
}) => React.ReactNode);
|
|
608
614
|
className?: string;
|
|
609
615
|
label?: string;
|
|
616
|
+
onClicked?: (service: Service) => void;
|
|
610
617
|
}
|
|
611
618
|
/**
|
|
612
619
|
* Select action component - replaces selection with only this service.
|
|
@@ -622,6 +629,16 @@ export declare namespace Actions {
|
|
|
622
629
|
* <Button variant="primary">Select Service</Button>
|
|
623
630
|
* </Service.Actions.Select>
|
|
624
631
|
*
|
|
632
|
+
* // With onClicked callback for navigation
|
|
633
|
+
* <Service.Actions.Select
|
|
634
|
+
* asChild
|
|
635
|
+
* onClicked={(service) => {
|
|
636
|
+
* router.push(`/booking/time-slots/${service._id}`);
|
|
637
|
+
* }}
|
|
638
|
+
* >
|
|
639
|
+
* <Button variant="primary">Select Service</Button>
|
|
640
|
+
* </Service.Actions.Select>
|
|
641
|
+
*
|
|
625
642
|
* // Using render prop pattern to access bookable state
|
|
626
643
|
* <Service.Actions.Select>
|
|
627
644
|
* {({ bookable, selected, onClick }) => (
|
|
@@ -647,6 +664,7 @@ export declare namespace Actions {
|
|
|
647
664
|
}) => React.ReactNode);
|
|
648
665
|
className?: string;
|
|
649
666
|
label?: string;
|
|
667
|
+
onClicked?: (service: Service) => void;
|
|
650
668
|
}
|
|
651
669
|
/**
|
|
652
670
|
* Add action component - adds service to selection array.
|
|
@@ -662,6 +680,16 @@ export declare namespace Actions {
|
|
|
662
680
|
* <Button variant="secondary">Add Service</Button>
|
|
663
681
|
* </Service.Actions.Add>
|
|
664
682
|
*
|
|
683
|
+
* // With onClicked callback for custom behavior after adding
|
|
684
|
+
* <Service.Actions.Add
|
|
685
|
+
* asChild
|
|
686
|
+
* onClicked={(service) => {
|
|
687
|
+
* console.log(`Added service: ${service.name}`);
|
|
688
|
+
* }}
|
|
689
|
+
* >
|
|
690
|
+
* <Button variant="secondary">Add Service</Button>
|
|
691
|
+
* </Service.Actions.Add>
|
|
692
|
+
*
|
|
665
693
|
* // Using render prop pattern to access bookable state
|
|
666
694
|
* <Service.Actions.Add>
|
|
667
695
|
* {({ bookable, selected, onClick }) => (
|
|
@@ -687,6 +715,7 @@ export declare namespace Actions {
|
|
|
687
715
|
}) => React.ReactNode);
|
|
688
716
|
className?: string;
|
|
689
717
|
label?: string;
|
|
718
|
+
onClicked?: (service: Service) => void;
|
|
690
719
|
}
|
|
691
720
|
/**
|
|
692
721
|
* Remove action component - removes service from selection array.
|
|
@@ -702,6 +731,16 @@ export declare namespace Actions {
|
|
|
702
731
|
* <Button variant="destructive">Remove Service</Button>
|
|
703
732
|
* </Service.Actions.Remove>
|
|
704
733
|
*
|
|
734
|
+
* // With onClicked callback for custom behavior after removing
|
|
735
|
+
* <Service.Actions.Remove
|
|
736
|
+
* asChild
|
|
737
|
+
* onClicked={(service) => {
|
|
738
|
+
* console.log(`Removed service: ${service.name}`);
|
|
739
|
+
* }}
|
|
740
|
+
* >
|
|
741
|
+
* <Button variant="destructive">Remove Service</Button>
|
|
742
|
+
* </Service.Actions.Remove>
|
|
743
|
+
*
|
|
705
744
|
* // Using render prop pattern to access bookable state
|
|
706
745
|
* <Service.Actions.Remove>
|
|
707
746
|
* {({ bookable, selected, onClick }) => (
|
|
@@ -539,6 +539,7 @@ StaffMemberRepeater.displayName = 'Service.StaffMembers.StaffMemberRepeater';
|
|
|
539
539
|
* @component
|
|
540
540
|
* @example
|
|
541
541
|
* ```tsx
|
|
542
|
+
* // Using render prop pattern to access raw service data
|
|
542
543
|
* <Service.Raw>
|
|
543
544
|
* {({ service, isLoading, error }) => (
|
|
544
545
|
* <div>
|
|
@@ -548,11 +549,16 @@ StaffMemberRepeater.displayName = 'Service.StaffMembers.StaffMemberRepeater';
|
|
|
548
549
|
* </div>
|
|
549
550
|
* )}
|
|
550
551
|
* </Service.Raw>
|
|
552
|
+
*
|
|
553
|
+
* // With asChild pattern
|
|
554
|
+
* <Service.Raw asChild>
|
|
555
|
+
* <CustomServiceDisplay />
|
|
556
|
+
* </Service.Raw>
|
|
551
557
|
* ```
|
|
552
558
|
*/
|
|
553
559
|
export const Raw = React.forwardRef((props, ref) => {
|
|
554
560
|
const { asChild, children, className } = props;
|
|
555
|
-
return (_jsx(CoreService.Service, { children: ({ service, isLoading, error }) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.serviceRaw, customElement: children, customElementProps: { service, isLoading, error }, children:
|
|
561
|
+
return (_jsx(CoreService.Service, { children: ({ service, isLoading, error }) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.serviceRaw, customElement: children, customElementProps: { service, isLoading, error }, children: children })) }));
|
|
556
562
|
});
|
|
557
563
|
Raw.displayName = 'Service.Raw';
|
|
558
564
|
/**
|
|
@@ -574,6 +580,16 @@ export var Actions;
|
|
|
574
580
|
* <Button variant="primary">Select Service</Button>
|
|
575
581
|
* </Service.Actions.Select>
|
|
576
582
|
*
|
|
583
|
+
* // With onClicked callback for navigation
|
|
584
|
+
* <Service.Actions.Select
|
|
585
|
+
* asChild
|
|
586
|
+
* onClicked={(service) => {
|
|
587
|
+
* router.push(`/booking/time-slots/${service._id}`);
|
|
588
|
+
* }}
|
|
589
|
+
* >
|
|
590
|
+
* <Button variant="primary">Select Service</Button>
|
|
591
|
+
* </Service.Actions.Select>
|
|
592
|
+
*
|
|
577
593
|
* // Using render prop pattern to access bookable state
|
|
578
594
|
* <Service.Actions.Select>
|
|
579
595
|
* {({ bookable, selected, onClick }) => (
|
|
@@ -585,25 +601,19 @@ export var Actions;
|
|
|
585
601
|
* ```
|
|
586
602
|
*/
|
|
587
603
|
Actions.Select = React.forwardRef((props, ref) => {
|
|
588
|
-
const { asChild, children, className, label = 'Select Service' } = props;
|
|
604
|
+
const { asChild, children, className, label = 'Select Service', onClicked, } = props;
|
|
589
605
|
return (_jsx(CoreService.Actions, { children: ({ select, rawService, bookable, selected, requiresAvailability, }) => {
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
selected,
|
|
595
|
-
requiresAvailability,
|
|
596
|
-
onClick: select,
|
|
597
|
-
service: rawService,
|
|
598
|
-
});
|
|
599
|
-
}
|
|
606
|
+
const handleClick = () => {
|
|
607
|
+
select();
|
|
608
|
+
onClicked?.(rawService);
|
|
609
|
+
};
|
|
600
610
|
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.serviceActionSelect, "data-selected": selected, "data-bookable": bookable, "data-requires-availability": requiresAvailability, customElement: children, customElementProps: {
|
|
601
|
-
onClick:
|
|
611
|
+
onClick: handleClick,
|
|
602
612
|
disabled: !bookable,
|
|
603
613
|
selected,
|
|
604
614
|
bookable,
|
|
605
615
|
requiresAvailability,
|
|
606
|
-
}, children: _jsx("button", { onClick:
|
|
616
|
+
}, children: _jsx("button", { onClick: handleClick, disabled: !bookable, "data-selected": selected, "data-bookable": bookable, "data-requires-availability": requiresAvailability, children: label }) }));
|
|
607
617
|
} }));
|
|
608
618
|
});
|
|
609
619
|
Actions.Select.displayName = 'Service.Actions.Select';
|
|
@@ -621,6 +631,16 @@ export var Actions;
|
|
|
621
631
|
* <Button variant="secondary">Add Service</Button>
|
|
622
632
|
* </Service.Actions.Add>
|
|
623
633
|
*
|
|
634
|
+
* // With onClicked callback for custom behavior after adding
|
|
635
|
+
* <Service.Actions.Add
|
|
636
|
+
* asChild
|
|
637
|
+
* onClicked={(service) => {
|
|
638
|
+
* console.log(`Added service: ${service.name}`);
|
|
639
|
+
* }}
|
|
640
|
+
* >
|
|
641
|
+
* <Button variant="secondary">Add Service</Button>
|
|
642
|
+
* </Service.Actions.Add>
|
|
643
|
+
*
|
|
624
644
|
* // Using render prop pattern to access bookable state
|
|
625
645
|
* <Service.Actions.Add>
|
|
626
646
|
* {({ bookable, selected, onClick }) => (
|
|
@@ -632,27 +652,21 @@ export var Actions;
|
|
|
632
652
|
* ```
|
|
633
653
|
*/
|
|
634
654
|
Actions.Add = React.forwardRef((props, ref) => {
|
|
635
|
-
const { asChild, children, className, label = 'Add Service' } = props;
|
|
655
|
+
const { asChild, children, className, label = 'Add Service', onClicked, } = props;
|
|
636
656
|
return (_jsx(CoreService.Actions, { children: ({ add, rawService, bookable, selected, requiresAvailability }) => {
|
|
637
|
-
// If children is a function, call it with bookable, selected, requiresAvailability and other props
|
|
638
|
-
if (typeof children === 'function') {
|
|
639
|
-
return children({
|
|
640
|
-
bookable,
|
|
641
|
-
selected,
|
|
642
|
-
requiresAvailability,
|
|
643
|
-
onClick: add,
|
|
644
|
-
service: rawService,
|
|
645
|
-
});
|
|
646
|
-
}
|
|
647
657
|
// Disabled when already selected (can't add again) or not bookable
|
|
648
658
|
const isDisabled = selected || !bookable;
|
|
659
|
+
const handleClick = () => {
|
|
660
|
+
add();
|
|
661
|
+
onClicked?.(rawService);
|
|
662
|
+
};
|
|
649
663
|
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.serviceActionAdd, "data-selected": selected, "data-bookable": bookable, "data-requires-availability": requiresAvailability, customElement: children, customElementProps: {
|
|
650
|
-
onClick:
|
|
664
|
+
onClick: handleClick,
|
|
651
665
|
disabled: isDisabled,
|
|
652
666
|
selected,
|
|
653
667
|
bookable,
|
|
654
668
|
requiresAvailability,
|
|
655
|
-
}, children: _jsx("button", { onClick:
|
|
669
|
+
}, children: _jsx("button", { onClick: handleClick, disabled: isDisabled, "data-selected": selected, "data-bookable": bookable, "data-requires-availability": requiresAvailability, children: label }) }));
|
|
656
670
|
} }));
|
|
657
671
|
});
|
|
658
672
|
Actions.Add.displayName = 'Service.Actions.Add';
|
|
@@ -670,6 +684,16 @@ export var Actions;
|
|
|
670
684
|
* <Button variant="destructive">Remove Service</Button>
|
|
671
685
|
* </Service.Actions.Remove>
|
|
672
686
|
*
|
|
687
|
+
* // With onClicked callback for custom behavior after removing
|
|
688
|
+
* <Service.Actions.Remove
|
|
689
|
+
* asChild
|
|
690
|
+
* onClicked={(service) => {
|
|
691
|
+
* console.log(`Removed service: ${service.name}`);
|
|
692
|
+
* }}
|
|
693
|
+
* >
|
|
694
|
+
* <Button variant="destructive">Remove Service</Button>
|
|
695
|
+
* </Service.Actions.Remove>
|
|
696
|
+
*
|
|
673
697
|
* // Using render prop pattern to access bookable state
|
|
674
698
|
* <Service.Actions.Remove>
|
|
675
699
|
* {({ bookable, selected, onClick }) => (
|
|
@@ -681,27 +705,21 @@ export var Actions;
|
|
|
681
705
|
* ```
|
|
682
706
|
*/
|
|
683
707
|
Actions.Remove = React.forwardRef((props, ref) => {
|
|
684
|
-
const { asChild, children, className, label = 'Remove Service' } = props;
|
|
708
|
+
const { asChild, children, className, label = 'Remove Service', onClicked, } = props;
|
|
685
709
|
return (_jsx(CoreService.Actions, { children: ({ remove, rawService, bookable, selected, requiresAvailability, }) => {
|
|
686
|
-
// If children is a function, call it with bookable, selected, requiresAvailability and other props
|
|
687
|
-
if (typeof children === 'function') {
|
|
688
|
-
return children({
|
|
689
|
-
bookable,
|
|
690
|
-
selected,
|
|
691
|
-
requiresAvailability,
|
|
692
|
-
onClick: remove,
|
|
693
|
-
service: rawService,
|
|
694
|
-
});
|
|
695
|
-
}
|
|
696
710
|
// Disabled when not selected (nothing to remove) or not bookable
|
|
697
711
|
const isDisabled = !selected || !bookable;
|
|
712
|
+
const handleClick = () => {
|
|
713
|
+
remove();
|
|
714
|
+
onClicked?.(rawService);
|
|
715
|
+
};
|
|
698
716
|
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.serviceActionRemove, "data-selected": selected, "data-bookable": bookable, "data-requires-availability": requiresAvailability, customElement: children, customElementProps: {
|
|
699
|
-
onClick:
|
|
717
|
+
onClick: handleClick,
|
|
700
718
|
disabled: isDisabled,
|
|
701
719
|
selected,
|
|
702
720
|
bookable,
|
|
703
721
|
requiresAvailability,
|
|
704
|
-
}, children: _jsx("button", { onClick:
|
|
722
|
+
}, children: _jsx("button", { onClick: handleClick, disabled: isDisabled, "data-selected": selected, "data-bookable": bookable, "data-requires-availability": requiresAvailability, children: label }) }));
|
|
705
723
|
} }));
|
|
706
724
|
});
|
|
707
725
|
Actions.Remove.displayName = 'Service.Actions.Remove';
|
|
@@ -45,7 +45,7 @@ export async function executeBookAction(params) {
|
|
|
45
45
|
// Step 2: Create checkout
|
|
46
46
|
// businessLocationId: prefer timeSlot.location, fallback to global location
|
|
47
47
|
const firstSelection = params.serviceSelections[0];
|
|
48
|
-
const businessLocationId = firstSelection?.timeSlot?.location?.
|
|
48
|
+
const businessLocationId = firstSelection?.timeSlot?.location?._id ?? undefined;
|
|
49
49
|
const checkoutRequest = buildCheckoutRequest({
|
|
50
50
|
bookingId,
|
|
51
51
|
contactDetails,
|
|
@@ -69,7 +69,7 @@ export function buildBookingRequest(params) {
|
|
|
69
69
|
? { _id: resource._id, name: resource.name }
|
|
70
70
|
: undefined,
|
|
71
71
|
location: slotLocation
|
|
72
|
-
? { _id: slotLocation.
|
|
72
|
+
? { _id: slotLocation._id, name: slotLocation.name }
|
|
73
73
|
: undefined,
|
|
74
74
|
},
|
|
75
75
|
},
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Types for the Book action
|
|
3
3
|
*/
|
|
4
|
-
import type { ServiceSelection
|
|
4
|
+
import type { ServiceSelection } from '../booking.js';
|
|
5
5
|
import type { FormValues } from '@wix/form-public';
|
|
6
|
+
import type { Location as TimeSlotLocationType } from '@wix/auto_sdk_bookings_availability-time-slots';
|
|
6
7
|
/**
|
|
7
8
|
* Result returned from the book action
|
|
8
9
|
*/
|
|
@@ -21,7 +22,7 @@ export interface BookingError {
|
|
|
21
22
|
*/
|
|
22
23
|
export interface BookActionParams {
|
|
23
24
|
serviceSelections: ServiceSelection[];
|
|
24
|
-
location:
|
|
25
|
+
location: TimeSlotLocationType | null;
|
|
25
26
|
formSubmission: FormValues | null;
|
|
26
27
|
timezone?: string;
|
|
27
28
|
}
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* Persists across page navigation in SPA until page refresh
|
|
5
5
|
*/
|
|
6
6
|
import { type Signal } from '@wix/services-definitions/core-services/signals';
|
|
7
|
-
import type { Service } from '@wix/auto_sdk_bookings_services';
|
|
8
|
-
import type { Resource, EventInfo } from '@wix/auto_sdk_bookings_availability-time-slots';
|
|
7
|
+
import type { Service, Location as ServiceLocationType } from '@wix/auto_sdk_bookings_services';
|
|
8
|
+
import type { Resource, EventInfo, Location as TimeSlotLocationType } from '@wix/auto_sdk_bookings_availability-time-slots';
|
|
9
9
|
import type { FormValues } from '@wix/form-public';
|
|
10
10
|
import type { BookResult } from './book-action/types.js';
|
|
11
11
|
export declare const ANY_STAFF_MEMBER_ID = "__any_staff_member__";
|
|
@@ -22,7 +22,7 @@ export interface ServiceSelectionTimeSlot {
|
|
|
22
22
|
/** Resources available in this time slot (populated when slot is selected) */
|
|
23
23
|
resources?: Resource[];
|
|
24
24
|
/** Location of this time slot (populated when slot is selected) */
|
|
25
|
-
location?:
|
|
25
|
+
location?: TimeSlotLocationType;
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
28
|
* ServiceSelection contains the service AND its related selections
|
|
@@ -39,10 +39,6 @@ export interface ServiceSelection {
|
|
|
39
39
|
/** Number of participants for this service selection */
|
|
40
40
|
totalParticipants?: number;
|
|
41
41
|
}
|
|
42
|
-
export interface Location {
|
|
43
|
-
id: string;
|
|
44
|
-
name?: string;
|
|
45
|
-
}
|
|
46
42
|
/**
|
|
47
43
|
* BookingService actions - setters only, no API calls
|
|
48
44
|
*/
|
|
@@ -61,7 +57,7 @@ export interface BookingServiceActions {
|
|
|
61
57
|
setResourceById(resourceId: string, resource: Resource, instanceId?: string): void;
|
|
62
58
|
/** Gets a resource by ID from a service selection. If no instanceId provided, uses the first item. */
|
|
63
59
|
getResourceById(resourceId: string, instanceId?: string): Resource | undefined;
|
|
64
|
-
setLocation(location:
|
|
60
|
+
setLocation(location: ServiceLocationType | null): void;
|
|
65
61
|
clearLocation(): void;
|
|
66
62
|
setTimezone(timezone: string): void;
|
|
67
63
|
setFormSubmission(values: FormValues | null): void;
|
|
@@ -77,7 +73,7 @@ export interface BookingService {
|
|
|
77
73
|
/** Signal containing the service selections (services with their related data) */
|
|
78
74
|
serviceSelections: Signal<ServiceSelection[]>;
|
|
79
75
|
/** Signal containing the selected location */
|
|
80
|
-
location: Signal<
|
|
76
|
+
location: Signal<ServiceLocationType | null>;
|
|
81
77
|
/** Signal containing the selected timezone */
|
|
82
78
|
timezone: Signal<string | undefined>;
|
|
83
79
|
/** Signal containing the form submission */
|
|
@@ -101,7 +97,7 @@ export interface BookingServiceConfig {
|
|
|
101
97
|
/** Optional initial service selections to pre-populate */
|
|
102
98
|
serviceSelections?: ServiceSelection[];
|
|
103
99
|
/** Optional initial location */
|
|
104
|
-
location?:
|
|
100
|
+
location?: ServiceLocationType | null;
|
|
105
101
|
/** Optional initial timezone */
|
|
106
102
|
timezone?: string;
|
|
107
103
|
/** Optional initial form submission */
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Main export file for all service definitions and implementations
|
|
4
4
|
*/
|
|
5
5
|
export { ServiceService, ServiceServiceDefinition, type ServiceServiceAPI, type ServiceServiceConfig, type ServiceActions, type ServicePaymentData, loadServiceServiceInitialData, type SuccessServiceServiceConfigResult, type NotFoundServiceServiceConfigResult, } from './service/service.js';
|
|
6
|
-
export { BookingService, BookingServiceDefinition, type BookingServiceConfig, type
|
|
6
|
+
export { BookingService, BookingServiceDefinition, type BookingServiceConfig, type BookingServiceActions, type ServiceSelection, type ServiceSelectionTimeSlot, } from './booking/booking.js';
|
|
7
7
|
export { TimeSlotListService, TimeSlotListServiceDefinition, ViewMode, loadTimeSlotListConfig, type TimeSlotListServiceAPI, type TimeSlotListServiceActions, type TimeSlotListServiceConfig, type LoadTimeSlotListConfigOptions, type LoadTimeSlotListConfigResult, } from './time-slot-list/index.js';
|
|
8
8
|
export { ServiceListService, ServiceListServiceDefinition, type ServiceListServiceAPI, type ServiceListServiceConfig, type ServiceListFilters, type ServiceListActions, type QueryOptions, loadServiceListServiceInitialData, type SuccessServiceListServiceConfigResult, type ErrorServiceListServiceConfigResult, } from './service-list/service-list.js';
|
|
9
9
|
export { executeBookAction, canBook, buildBookingRequest, buildCheckoutRequest, type CanBookParams, type BookResult, type BookingError, type BookActionParams, type BookChildProps, type BookProps, type BuildCheckoutParams, } from './booking/book-action/index.js';
|