@wix/headless-bookings 0.0.41 → 0.0.42

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.
@@ -58,6 +58,7 @@ export interface ListDataRenderProps {
58
58
  isLoading: boolean;
59
59
  error: string | null;
60
60
  loadMore: () => Promise<void>;
61
+ isSelectionComplete: boolean;
61
62
  }
62
63
  /**
63
64
  * Props for ListData render prop component
@@ -73,7 +74,7 @@ export interface ListDataProps {
73
74
  * @example
74
75
  * ```tsx
75
76
  * <ListData>
76
- * {({ timeSlots, hasMore, isLoading, loadMore }) => (
77
+ * {({ timeSlots, hasMore, isLoading, loadMore, isSelectionComplete }) => (
77
78
  * <GenericList.Root items={timeSlots} hasMore={hasMore} isLoading={isLoading} loadMore={loadMore}>
78
79
  * {children}
79
80
  * </GenericList.Root>
@@ -68,7 +68,7 @@ export function Timezone(props) {
68
68
  * @example
69
69
  * ```tsx
70
70
  * <ListData>
71
- * {({ timeSlots, hasMore, isLoading, loadMore }) => (
71
+ * {({ timeSlots, hasMore, isLoading, loadMore, isSelectionComplete }) => (
72
72
  * <GenericList.Root items={timeSlots} hasMore={hasMore} isLoading={isLoading} loadMore={loadMore}>
73
73
  * {children}
74
74
  * </GenericList.Root>
@@ -78,12 +78,18 @@ export function Timezone(props) {
78
78
  */
79
79
  export function ListData(props) {
80
80
  const service = useService(TimeSlotListServiceDefinition);
81
+ const bookingService = useService(BookingServiceDefinition);
82
+ const selectedTimeSlot = bookingService.serviceSelections.get()[0]?.timeSlot;
83
+ const hasTimeSlot = !!selectedTimeSlot;
84
+ const hasSelectedStaffMember = (selectedTimeSlot?.resources?.length ?? 0) === 1;
85
+ const isSelectionComplete = hasTimeSlot && hasSelectedStaffMember;
81
86
  return props.children({
82
87
  timeSlots: service.timeSlots.get(),
83
88
  hasMore: service.hasMore.get(),
84
89
  isLoading: service.isLoading.get(),
85
90
  error: service.error.get(),
86
91
  loadMore: service.actions.loadMore,
92
+ isSelectionComplete,
87
93
  });
88
94
  }
89
95
  /**
@@ -86,13 +86,10 @@ Root.displayName = 'TimeSlotList.Root';
86
86
  */
87
87
  const RootContent = React.forwardRef((props, ref) => {
88
88
  const { children, className, variant } = props;
89
- return (_jsx(CoreTimeSlotList.ListData, { children: ({ timeSlots, hasMore, isLoading, error, loadMore }) => (
90
- // Add stable `id` for GenericList at the headless boundary only.
91
- // The underlying service slots remain raw (no grouping / no extra fields).
92
- _jsx(GenericList.Root, { items: timeSlots.map((slot) => ({
89
+ return (_jsx(CoreTimeSlotList.ListData, { children: ({ timeSlots, hasMore, isLoading, error, loadMore, isSelectionComplete, }) => (_jsx(GenericList.Root, { items: timeSlots.map((slot) => ({
93
90
  ...slot,
94
91
  id: generateSlotKey(slot),
95
- })), loadMore: loadMore, hasMore: hasMore, isLoading: isLoading, error: error, className: className, ref: ref, "data-testid": TestIds.timeSlotListRoot, variant: variant, children: children })) }));
92
+ })), loadMore: loadMore, hasMore: hasMore, isLoading: isLoading, error: error, className: className, ref: ref, "data-testid": TestIds.timeSlotListRoot, "data-selection-complete": isSelectionComplete, variant: variant, children: children })) }));
96
93
  });
97
94
  RootContent.displayName = 'TimeSlotList.RootContent';
98
95
  /**
@@ -58,6 +58,7 @@ export interface ListDataRenderProps {
58
58
  isLoading: boolean;
59
59
  error: string | null;
60
60
  loadMore: () => Promise<void>;
61
+ isSelectionComplete: boolean;
61
62
  }
62
63
  /**
63
64
  * Props for ListData render prop component
@@ -73,7 +74,7 @@ export interface ListDataProps {
73
74
  * @example
74
75
  * ```tsx
75
76
  * <ListData>
76
- * {({ timeSlots, hasMore, isLoading, loadMore }) => (
77
+ * {({ timeSlots, hasMore, isLoading, loadMore, isSelectionComplete }) => (
77
78
  * <GenericList.Root items={timeSlots} hasMore={hasMore} isLoading={isLoading} loadMore={loadMore}>
78
79
  * {children}
79
80
  * </GenericList.Root>
@@ -68,7 +68,7 @@ export function Timezone(props) {
68
68
  * @example
69
69
  * ```tsx
70
70
  * <ListData>
71
- * {({ timeSlots, hasMore, isLoading, loadMore }) => (
71
+ * {({ timeSlots, hasMore, isLoading, loadMore, isSelectionComplete }) => (
72
72
  * <GenericList.Root items={timeSlots} hasMore={hasMore} isLoading={isLoading} loadMore={loadMore}>
73
73
  * {children}
74
74
  * </GenericList.Root>
@@ -78,12 +78,18 @@ export function Timezone(props) {
78
78
  */
79
79
  export function ListData(props) {
80
80
  const service = useService(TimeSlotListServiceDefinition);
81
+ const bookingService = useService(BookingServiceDefinition);
82
+ const selectedTimeSlot = bookingService.serviceSelections.get()[0]?.timeSlot;
83
+ const hasTimeSlot = !!selectedTimeSlot;
84
+ const hasSelectedStaffMember = (selectedTimeSlot?.resources?.length ?? 0) === 1;
85
+ const isSelectionComplete = hasTimeSlot && hasSelectedStaffMember;
81
86
  return props.children({
82
87
  timeSlots: service.timeSlots.get(),
83
88
  hasMore: service.hasMore.get(),
84
89
  isLoading: service.isLoading.get(),
85
90
  error: service.error.get(),
86
91
  loadMore: service.actions.loadMore,
92
+ isSelectionComplete,
87
93
  });
88
94
  }
89
95
  /**
@@ -86,13 +86,10 @@ Root.displayName = 'TimeSlotList.Root';
86
86
  */
87
87
  const RootContent = React.forwardRef((props, ref) => {
88
88
  const { children, className, variant } = props;
89
- return (_jsx(CoreTimeSlotList.ListData, { children: ({ timeSlots, hasMore, isLoading, error, loadMore }) => (
90
- // Add stable `id` for GenericList at the headless boundary only.
91
- // The underlying service slots remain raw (no grouping / no extra fields).
92
- _jsx(GenericList.Root, { items: timeSlots.map((slot) => ({
89
+ return (_jsx(CoreTimeSlotList.ListData, { children: ({ timeSlots, hasMore, isLoading, error, loadMore, isSelectionComplete, }) => (_jsx(GenericList.Root, { items: timeSlots.map((slot) => ({
93
90
  ...slot,
94
91
  id: generateSlotKey(slot),
95
- })), loadMore: loadMore, hasMore: hasMore, isLoading: isLoading, error: error, className: className, ref: ref, "data-testid": TestIds.timeSlotListRoot, variant: variant, children: children })) }));
92
+ })), loadMore: loadMore, hasMore: hasMore, isLoading: isLoading, error: error, className: className, ref: ref, "data-testid": TestIds.timeSlotListRoot, "data-selection-complete": isSelectionComplete, variant: variant, children: children })) }));
96
93
  });
97
94
  RootContent.displayName = 'TimeSlotList.RootContent';
98
95
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/headless-bookings",
3
- "version": "0.0.41",
3
+ "version": "0.0.42",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -72,5 +72,5 @@
72
72
  "groupId": "com.wixpress.headless-components"
73
73
  }
74
74
  },
75
- "falconPackageHash": "5847d0ce3b07a2485f7d9b707eee272b9f100b3d13614c2d92018112"
75
+ "falconPackageHash": "5dc20d0dd95441ac614497962bdf5803fa6e5e53d5887826fc888ea6"
76
76
  }