@wix/headless-bookings 0.0.27 → 0.0.29
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 +82 -0
- package/cjs/dist/__mocks__/booking.js +163 -0
- package/cjs/dist/api/fetch-availability/index.d.ts +4 -4
- package/cjs/dist/api/fetch-availability/index.js +3 -47
- package/cjs/dist/react/core/time-slot-list/TimeSlot.d.ts +9 -143
- package/cjs/dist/react/core/time-slot-list/TimeSlot.js +32 -167
- package/cjs/dist/react/core/time-slot-list/TimeSlotList.d.ts +3 -2
- package/cjs/dist/react/core/time-slot-list/TimeSlotList.js +1 -1
- package/cjs/dist/react/time-slot-list/TimeSlot.d.ts +15 -113
- package/cjs/dist/react/time-slot-list/TimeSlot.js +26 -125
- package/cjs/dist/react/time-slot-list/TimeSlotList.d.ts +5 -34
- package/cjs/dist/react/time-slot-list/TimeSlotList.js +12 -5
- package/cjs/dist/services/index.d.ts +1 -1
- package/cjs/dist/services/time-slot-list/index.d.ts +1 -1
- package/cjs/dist/services/time-slot-list/time-slot-list.d.ts +4 -4
- package/cjs/dist/services/time-slot-list/time-slot-list.def.d.ts +5 -40
- package/cjs/dist/services/time-slot-list/time-slot-list.js +38 -167
- package/dist/__mocks__/booking.d.ts +82 -0
- package/dist/__mocks__/booking.js +163 -0
- package/dist/api/fetch-availability/index.d.ts +4 -4
- package/dist/api/fetch-availability/index.js +3 -47
- package/dist/react/core/time-slot-list/TimeSlot.d.ts +9 -143
- package/dist/react/core/time-slot-list/TimeSlot.js +32 -167
- package/dist/react/core/time-slot-list/TimeSlotList.d.ts +3 -2
- package/dist/react/core/time-slot-list/TimeSlotList.js +1 -1
- package/dist/react/time-slot-list/TimeSlot.d.ts +15 -113
- package/dist/react/time-slot-list/TimeSlot.js +26 -125
- package/dist/react/time-slot-list/TimeSlotList.d.ts +5 -34
- package/dist/react/time-slot-list/TimeSlotList.js +12 -5
- package/dist/services/index.d.ts +1 -1
- package/dist/services/time-slot-list/index.d.ts +1 -1
- package/dist/services/time-slot-list/time-slot-list.d.ts +4 -4
- package/dist/services/time-slot-list/time-slot-list.def.d.ts +5 -40
- package/dist/services/time-slot-list/time-slot-list.js +38 -167
- package/package.json +2 -2
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared mock data for booking service tests
|
|
3
|
+
*/
|
|
4
|
+
import type { Resource } from '@wix/auto_sdk_bookings_availability-time-slots';
|
|
5
|
+
import type { FormValues } from '@wix/form-public';
|
|
6
|
+
import type { ServiceSelection, ServiceSelectionTimeSlot, Location, BookingServiceConfig } from '../services/booking/booking.js';
|
|
7
|
+
/**
|
|
8
|
+
* Mock time slot data
|
|
9
|
+
*/
|
|
10
|
+
export declare const mockTimeSlot: ServiceSelectionTimeSlot;
|
|
11
|
+
/**
|
|
12
|
+
* Mock time slot for afternoon
|
|
13
|
+
*/
|
|
14
|
+
export declare const mockTimeSlotAfternoon: ServiceSelectionTimeSlot;
|
|
15
|
+
/**
|
|
16
|
+
* Mock resource (staff member)
|
|
17
|
+
*/
|
|
18
|
+
export declare const mockResource: Resource;
|
|
19
|
+
/**
|
|
20
|
+
* Mock resource (another staff member)
|
|
21
|
+
*/
|
|
22
|
+
export declare const mockResourceTwo: Resource;
|
|
23
|
+
/**
|
|
24
|
+
* Mock resource (room)
|
|
25
|
+
*/
|
|
26
|
+
export declare const mockResourceRoom: Resource;
|
|
27
|
+
/**
|
|
28
|
+
* Mock service selection with all data
|
|
29
|
+
*/
|
|
30
|
+
export declare const mockServiceSelection: ServiceSelection;
|
|
31
|
+
/**
|
|
32
|
+
* Mock service selection without time slot (incomplete)
|
|
33
|
+
*/
|
|
34
|
+
export declare const mockServiceSelectionWithoutTimeSlot: ServiceSelection;
|
|
35
|
+
/**
|
|
36
|
+
* Mock service selection for class
|
|
37
|
+
*/
|
|
38
|
+
export declare const mockServiceSelectionClass: ServiceSelection;
|
|
39
|
+
/**
|
|
40
|
+
* Mock location
|
|
41
|
+
*/
|
|
42
|
+
export declare const mockLocation: Location;
|
|
43
|
+
/**
|
|
44
|
+
* Mock location (second)
|
|
45
|
+
*/
|
|
46
|
+
export declare const mockLocationTwo: Location;
|
|
47
|
+
/**
|
|
48
|
+
* Mock form submission (contact info)
|
|
49
|
+
*/
|
|
50
|
+
export declare const mockFormSubmission: FormValues;
|
|
51
|
+
/**
|
|
52
|
+
* Mock form submission (minimal)
|
|
53
|
+
*/
|
|
54
|
+
export declare const mockFormSubmissionMinimal: FormValues;
|
|
55
|
+
/**
|
|
56
|
+
* Mock form submission with custom fields
|
|
57
|
+
*/
|
|
58
|
+
export declare const mockFormSubmissionWithCustomFields: FormValues;
|
|
59
|
+
/**
|
|
60
|
+
* Default timezone for tests
|
|
61
|
+
*/
|
|
62
|
+
export declare const mockTimezone = "America/New_York";
|
|
63
|
+
/**
|
|
64
|
+
* Mock booking service config (empty)
|
|
65
|
+
*/
|
|
66
|
+
export declare const mockEmptyBookingConfig: BookingServiceConfig;
|
|
67
|
+
/**
|
|
68
|
+
* Mock booking service config with initial data
|
|
69
|
+
*/
|
|
70
|
+
export declare const mockBookingConfigWithData: BookingServiceConfig;
|
|
71
|
+
/**
|
|
72
|
+
* Mock booking service config with multiple selections
|
|
73
|
+
*/
|
|
74
|
+
export declare const mockBookingConfigMultipleSelections: BookingServiceConfig;
|
|
75
|
+
/**
|
|
76
|
+
* Helper to create a service selection with custom instanceId
|
|
77
|
+
*/
|
|
78
|
+
export declare function createMockServiceSelection(overrides?: Partial<ServiceSelection>): Omit<ServiceSelection, 'instanceId'>;
|
|
79
|
+
/**
|
|
80
|
+
* Helper to create multiple service selections
|
|
81
|
+
*/
|
|
82
|
+
export declare function createMockServiceSelections(count: number): ServiceSelection[];
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared mock data for booking service tests
|
|
3
|
+
*/
|
|
4
|
+
import { mockService, mockServiceClass } from './services.js';
|
|
5
|
+
/**
|
|
6
|
+
* Mock time slot data
|
|
7
|
+
*/
|
|
8
|
+
export const mockTimeSlot = {
|
|
9
|
+
startDate: '2024-03-15T10:00:00Z',
|
|
10
|
+
endDate: '2024-03-15T11:00:00Z',
|
|
11
|
+
totalCapacity: 10,
|
|
12
|
+
remainingCapacity: 5,
|
|
13
|
+
scheduleId: 'schedule-123',
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Mock time slot for afternoon
|
|
17
|
+
*/
|
|
18
|
+
export const mockTimeSlotAfternoon = {
|
|
19
|
+
startDate: '2024-03-15T14:00:00Z',
|
|
20
|
+
endDate: '2024-03-15T15:00:00Z',
|
|
21
|
+
totalCapacity: 10,
|
|
22
|
+
remainingCapacity: 8,
|
|
23
|
+
scheduleId: 'schedule-456',
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Mock resource (staff member)
|
|
27
|
+
*/
|
|
28
|
+
export const mockResource = {
|
|
29
|
+
_id: 'resource-1',
|
|
30
|
+
name: 'John Doe',
|
|
31
|
+
email: 'john.doe@example.com',
|
|
32
|
+
tag: 'STAFF',
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Mock resource (another staff member)
|
|
36
|
+
*/
|
|
37
|
+
export const mockResourceTwo = {
|
|
38
|
+
_id: 'resource-2',
|
|
39
|
+
name: 'Jane Smith',
|
|
40
|
+
email: 'jane.smith@example.com',
|
|
41
|
+
tag: 'STAFF',
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Mock resource (room)
|
|
45
|
+
*/
|
|
46
|
+
export const mockResourceRoom = {
|
|
47
|
+
_id: 'resource-room-1',
|
|
48
|
+
name: 'Conference Room A',
|
|
49
|
+
tag: 'RESOURCE',
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Mock service selection with all data
|
|
53
|
+
*/
|
|
54
|
+
export const mockServiceSelection = {
|
|
55
|
+
instanceId: 'instance-1',
|
|
56
|
+
service: mockService,
|
|
57
|
+
resources: [mockResource],
|
|
58
|
+
timeSlot: mockTimeSlot,
|
|
59
|
+
totalParticipants: 1,
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Mock service selection without time slot (incomplete)
|
|
63
|
+
*/
|
|
64
|
+
export const mockServiceSelectionWithoutTimeSlot = {
|
|
65
|
+
instanceId: 'instance-2',
|
|
66
|
+
service: mockService,
|
|
67
|
+
resources: [],
|
|
68
|
+
totalParticipants: 1,
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Mock service selection for class
|
|
72
|
+
*/
|
|
73
|
+
export const mockServiceSelectionClass = {
|
|
74
|
+
instanceId: 'instance-3',
|
|
75
|
+
service: mockServiceClass,
|
|
76
|
+
resources: [mockResource],
|
|
77
|
+
timeSlot: mockTimeSlotAfternoon,
|
|
78
|
+
totalParticipants: 3,
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Mock location
|
|
82
|
+
*/
|
|
83
|
+
export const mockLocation = {
|
|
84
|
+
id: 'location-1',
|
|
85
|
+
name: 'Main Office',
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Mock location (second)
|
|
89
|
+
*/
|
|
90
|
+
export const mockLocationTwo = {
|
|
91
|
+
id: 'location-2',
|
|
92
|
+
name: 'Downtown Branch',
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Mock form submission (contact info)
|
|
96
|
+
*/
|
|
97
|
+
export const mockFormSubmission = {
|
|
98
|
+
firstName: 'John',
|
|
99
|
+
lastName: 'Doe',
|
|
100
|
+
email: 'john.doe@example.com',
|
|
101
|
+
phone: '+1234567890',
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Mock form submission (minimal)
|
|
105
|
+
*/
|
|
106
|
+
export const mockFormSubmissionMinimal = {
|
|
107
|
+
email: 'test@example.com',
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Mock form submission with custom fields
|
|
111
|
+
*/
|
|
112
|
+
export const mockFormSubmissionWithCustomFields = {
|
|
113
|
+
firstName: 'Jane',
|
|
114
|
+
lastName: 'Smith',
|
|
115
|
+
email: 'jane.smith@example.com',
|
|
116
|
+
notes: 'Please call before the appointment',
|
|
117
|
+
customField1: 'Custom value 1',
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* Default timezone for tests
|
|
121
|
+
*/
|
|
122
|
+
export const mockTimezone = 'America/New_York';
|
|
123
|
+
/**
|
|
124
|
+
* Mock booking service config (empty)
|
|
125
|
+
*/
|
|
126
|
+
export const mockEmptyBookingConfig = {};
|
|
127
|
+
/**
|
|
128
|
+
* Mock booking service config with initial data
|
|
129
|
+
*/
|
|
130
|
+
export const mockBookingConfigWithData = {
|
|
131
|
+
serviceSelections: [mockServiceSelection],
|
|
132
|
+
location: mockLocation,
|
|
133
|
+
timezone: mockTimezone,
|
|
134
|
+
formSubmission: mockFormSubmission,
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* Mock booking service config with multiple selections
|
|
138
|
+
*/
|
|
139
|
+
export const mockBookingConfigMultipleSelections = {
|
|
140
|
+
serviceSelections: [mockServiceSelection, mockServiceSelectionClass],
|
|
141
|
+
location: mockLocation,
|
|
142
|
+
timezone: mockTimezone,
|
|
143
|
+
formSubmission: mockFormSubmission,
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* Helper to create a service selection with custom instanceId
|
|
147
|
+
*/
|
|
148
|
+
export function createMockServiceSelection(overrides = {}) {
|
|
149
|
+
const { instanceId: _, ...base } = mockServiceSelection;
|
|
150
|
+
return {
|
|
151
|
+
...base,
|
|
152
|
+
...overrides,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Helper to create multiple service selections
|
|
157
|
+
*/
|
|
158
|
+
export function createMockServiceSelections(count) {
|
|
159
|
+
return Array.from({ length: count }, (_, i) => ({
|
|
160
|
+
...mockServiceSelection,
|
|
161
|
+
instanceId: `instance-${i + 1}`,
|
|
162
|
+
}));
|
|
163
|
+
}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* Time Slot List API
|
|
3
3
|
* Fetches available time slots for booking services from Wix Bookings
|
|
4
4
|
*/
|
|
5
|
-
import { type CursorPaging, type CursorPagingMetadata } from '@wix/auto_sdk_bookings_availability-time-slots';
|
|
5
|
+
import { type TimeSlot, type CursorPaging, type CursorPagingMetadata } from '@wix/auto_sdk_bookings_availability-time-slots';
|
|
6
6
|
import { type Service } from '@wix/auto_sdk_bookings_services';
|
|
7
|
-
import { ViewMode, type
|
|
7
|
+
import { ViewMode, type Location } from '../../services/time-slot-list/time-slot-list.def.js';
|
|
8
8
|
export interface FetchAvailabilityOptions {
|
|
9
9
|
services: Service[];
|
|
10
10
|
fromLocalDate?: string | null;
|
|
@@ -28,14 +28,14 @@ export interface FetchAvailabilityOptions {
|
|
|
28
28
|
* Response from fetchAvailability with grouped time slots
|
|
29
29
|
*/
|
|
30
30
|
export interface FetchAvailabilityResponse {
|
|
31
|
-
/**
|
|
31
|
+
/** time slots */
|
|
32
32
|
timeSlots: TimeSlot[];
|
|
33
33
|
/** Cursor pagination metadata for loading more results */
|
|
34
34
|
cursorPagingMetadata?: CursorPagingMetadata;
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
37
|
* Main entry point for fetching availability
|
|
38
|
-
* Detects flow type
|
|
38
|
+
* Detects flow type and calls appropriate API
|
|
39
39
|
*
|
|
40
40
|
* @param options - Fetch options including services, date range, timezone, and view mode
|
|
41
41
|
* @returns Promise with grouped time slots
|
|
@@ -29,50 +29,6 @@ function toLocalDateString(date) {
|
|
|
29
29
|
return format(date, pattern);
|
|
30
30
|
}
|
|
31
31
|
// ============================================================================
|
|
32
|
-
// Grouping Functions
|
|
33
|
-
// ============================================================================
|
|
34
|
-
/**
|
|
35
|
-
* Groups API time slots by their start time
|
|
36
|
-
* Multiple slots for the same time (different locations) are merged into one
|
|
37
|
-
*/
|
|
38
|
-
function groupTimeSlotsByTime(apiSlots) {
|
|
39
|
-
const groupedMap = new Map();
|
|
40
|
-
for (const apiSlot of apiSlots) {
|
|
41
|
-
const key = apiSlot.localStartDate;
|
|
42
|
-
if (!groupedMap.has(key)) {
|
|
43
|
-
// Create new grouped slot - omit location and availableResources
|
|
44
|
-
const { location: _location, availableResources: _availableResources, ...rest } = apiSlot;
|
|
45
|
-
groupedMap.set(key, {
|
|
46
|
-
...rest,
|
|
47
|
-
staffByLocation: [],
|
|
48
|
-
originalSlots: [],
|
|
49
|
-
id: apiSlot.localStartDate,
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
const groupedSlot = groupedMap.get(key);
|
|
53
|
-
// Extract staff members with IDs and names from availableResources
|
|
54
|
-
const staffMembers = (apiSlot.availableResources || [])
|
|
55
|
-
.flatMap((resourceGroup) => resourceGroup.resources || [])
|
|
56
|
-
.filter((resource) => resource._id && resource.name)
|
|
57
|
-
.map((resource) => ({
|
|
58
|
-
id: resource._id,
|
|
59
|
-
name: resource.name,
|
|
60
|
-
}));
|
|
61
|
-
// Add this slot's location/staff info
|
|
62
|
-
const staffByLocation = {
|
|
63
|
-
location: {
|
|
64
|
-
id: apiSlot.location?._id,
|
|
65
|
-
name: apiSlot.location?.name,
|
|
66
|
-
},
|
|
67
|
-
staffMembers,
|
|
68
|
-
};
|
|
69
|
-
groupedSlot.staffByLocation.push(staffByLocation);
|
|
70
|
-
// Store original slot for booking service
|
|
71
|
-
groupedSlot.originalSlots.push(apiSlot);
|
|
72
|
-
}
|
|
73
|
-
return Array.from(groupedMap.values());
|
|
74
|
-
}
|
|
75
|
-
// ============================================================================
|
|
76
32
|
// Internal Flow Detection
|
|
77
33
|
// ============================================================================
|
|
78
34
|
/**
|
|
@@ -98,7 +54,7 @@ function detectFlow(bookingServices, viewMode) {
|
|
|
98
54
|
}
|
|
99
55
|
/**
|
|
100
56
|
* Main entry point for fetching availability
|
|
101
|
-
* Detects flow type
|
|
57
|
+
* Detects flow type and calls appropriate API
|
|
102
58
|
*
|
|
103
59
|
* @param options - Fetch options including services, date range, timezone, and view mode
|
|
104
60
|
* @returns Promise with grouped time slots
|
|
@@ -158,7 +114,7 @@ export async function fetchAvailability({ services: selectedServices, viewMode =
|
|
|
158
114
|
timeSlotsPerDay,
|
|
159
115
|
});
|
|
160
116
|
return {
|
|
161
|
-
timeSlots:
|
|
117
|
+
timeSlots: response.timeSlots || [],
|
|
162
118
|
cursorPagingMetadata: response.cursorPagingMetadata,
|
|
163
119
|
};
|
|
164
120
|
}
|
|
@@ -188,7 +144,7 @@ export async function fetchAvailability({ services: selectedServices, viewMode =
|
|
|
188
144
|
maxSlotsPerDay: timeSlotsPerDay,
|
|
189
145
|
});
|
|
190
146
|
return {
|
|
191
|
-
timeSlots:
|
|
147
|
+
timeSlots: response.timeSlots || [],
|
|
192
148
|
cursorPagingMetadata: response.pagingMetadata,
|
|
193
149
|
};
|
|
194
150
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* which provides the TimeSlotProvider context.
|
|
7
7
|
*/
|
|
8
8
|
import React from 'react';
|
|
9
|
-
import {
|
|
9
|
+
import type { TimeSlot as TimeSlotType } from '@wix/auto_sdk_bookings_availability-time-slots';
|
|
10
10
|
/**
|
|
11
11
|
* Context value for TimeSlot components
|
|
12
12
|
*/
|
|
@@ -35,30 +35,6 @@ export interface TimeSlotProviderProps {
|
|
|
35
35
|
* Not used directly by consumers - only by TimeSlotList.TimeSlotRepeater.
|
|
36
36
|
*/
|
|
37
37
|
export declare function TimeSlotProvider(props: TimeSlotProviderProps): React.ReactNode;
|
|
38
|
-
/**
|
|
39
|
-
* Context value for Location components
|
|
40
|
-
*/
|
|
41
|
-
export interface LocationContextValue {
|
|
42
|
-
location: LocationData;
|
|
43
|
-
selectLocation: () => void;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Hook to access Location context
|
|
47
|
-
* @throws Error if used outside of LocationProvider
|
|
48
|
-
*/
|
|
49
|
-
export declare function useLocationContext(): LocationContextValue;
|
|
50
|
-
/**
|
|
51
|
-
* Props for LocationProvider
|
|
52
|
-
*/
|
|
53
|
-
export interface LocationProviderProps {
|
|
54
|
-
children: React.ReactNode;
|
|
55
|
-
location: LocationData;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Provider component used by LocationRepeater to provide context.
|
|
59
|
-
* Not used directly by consumers - only by TimeSlot.LocationRepeater.
|
|
60
|
-
*/
|
|
61
|
-
export declare function LocationProvider(props: LocationProviderProps): React.ReactNode;
|
|
62
38
|
/**
|
|
63
39
|
* Context value for StaffMember components
|
|
64
40
|
*/
|
|
@@ -94,6 +70,8 @@ export interface InfoProps {
|
|
|
94
70
|
endDate: Date;
|
|
95
71
|
/** Calculated duration in minutes */
|
|
96
72
|
durationInMinutes: number;
|
|
73
|
+
/** Location name */
|
|
74
|
+
locationName: string;
|
|
97
75
|
/** Whether the timeSlot is bookable */
|
|
98
76
|
bookable: boolean;
|
|
99
77
|
/** Whether this timeSlot is currently selected */
|
|
@@ -127,8 +105,8 @@ export interface ActionsProps {
|
|
|
127
105
|
children: (data: {
|
|
128
106
|
/** Action to select this timeSlot */
|
|
129
107
|
selectTimeSlot: () => void;
|
|
130
|
-
/** Action to clear
|
|
131
|
-
|
|
108
|
+
/** Action to clear staff selection */
|
|
109
|
+
clearStaffSelection?: () => void;
|
|
132
110
|
/** The raw timeSlot object */
|
|
133
111
|
timeSlot: TimeSlotType;
|
|
134
112
|
/** Whether the timeSlot is bookable */
|
|
@@ -158,112 +136,6 @@ export interface ActionsProps {
|
|
|
158
136
|
* ```
|
|
159
137
|
*/
|
|
160
138
|
export declare function Actions(props: ActionsProps): React.ReactNode;
|
|
161
|
-
/**
|
|
162
|
-
* Location data with selection state
|
|
163
|
-
*/
|
|
164
|
-
export interface LocationData {
|
|
165
|
-
/** Location ID */
|
|
166
|
-
id: string;
|
|
167
|
-
/** Location name */
|
|
168
|
-
name: string;
|
|
169
|
-
/** Whether this location is currently selected */
|
|
170
|
-
isSelected: boolean;
|
|
171
|
-
/** Whether this location is selectable (compatible with selected staff, or no staff selected) */
|
|
172
|
-
isSelectable: boolean;
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* Props for Locations render prop component
|
|
176
|
-
*/
|
|
177
|
-
export interface LocationsProps {
|
|
178
|
-
children: (data: {
|
|
179
|
-
/** Array of locations with selection state */
|
|
180
|
-
locations: LocationData[];
|
|
181
|
-
/** Action to select a location */
|
|
182
|
-
selectLocation: (locationId: string) => void;
|
|
183
|
-
}) => React.ReactNode;
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* Core component that provides access to time slot locations via render props.
|
|
187
|
-
* Extracts locations from slot.staffByLocation and enriches with name from originalSlots.
|
|
188
|
-
* Each location includes isSelected and isSelectable based on current selection state.
|
|
189
|
-
*
|
|
190
|
-
* Returns null if there's only 1 location (nothing to choose from).
|
|
191
|
-
*
|
|
192
|
-
* @component
|
|
193
|
-
* @example
|
|
194
|
-
* ```tsx
|
|
195
|
-
* <CoreTimeSlot.Locations>
|
|
196
|
-
* {({ locations, locationsCount, selectLocation }) => (
|
|
197
|
-
* <GenericList.Root items={locations}>
|
|
198
|
-
* {children}
|
|
199
|
-
* </GenericList.Root>
|
|
200
|
-
* )}
|
|
201
|
-
* </CoreTimeSlot.Locations>
|
|
202
|
-
* ```
|
|
203
|
-
*/
|
|
204
|
-
export declare function Locations(props: LocationsProps): React.ReactNode;
|
|
205
|
-
/**
|
|
206
|
-
* Props for LocationInfo render prop component
|
|
207
|
-
*/
|
|
208
|
-
export interface LocationInfoProps {
|
|
209
|
-
children: (data: {
|
|
210
|
-
/** Location name */
|
|
211
|
-
name: string;
|
|
212
|
-
/** Whether this location is currently selected */
|
|
213
|
-
isSelected: boolean;
|
|
214
|
-
/** Whether this location is selectable */
|
|
215
|
-
isSelectable: boolean;
|
|
216
|
-
/** The raw location object */
|
|
217
|
-
location: LocationData;
|
|
218
|
-
}) => React.ReactNode;
|
|
219
|
-
}
|
|
220
|
-
/**
|
|
221
|
-
* Core component that provides access to location info via render props.
|
|
222
|
-
* Must be used within LocationProvider.
|
|
223
|
-
*
|
|
224
|
-
* @component
|
|
225
|
-
* @example
|
|
226
|
-
* ```tsx
|
|
227
|
-
* <LocationInfo>
|
|
228
|
-
* {({ name, isSelected, isSelectable }) => (
|
|
229
|
-
* <span>{name}</span>
|
|
230
|
-
* )}
|
|
231
|
-
* </LocationInfo>
|
|
232
|
-
* ```
|
|
233
|
-
*/
|
|
234
|
-
export declare function LocationInfo(props: LocationInfoProps): React.ReactNode;
|
|
235
|
-
/**
|
|
236
|
-
* Props for LocationActions render prop component
|
|
237
|
-
*/
|
|
238
|
-
export interface LocationActionsProps {
|
|
239
|
-
children: (data: {
|
|
240
|
-
/** Action to select this location */
|
|
241
|
-
selectLocation: () => void;
|
|
242
|
-
/** Whether this location is currently selected */
|
|
243
|
-
isSelected: boolean;
|
|
244
|
-
/** Whether this location is selectable */
|
|
245
|
-
isSelectable: boolean;
|
|
246
|
-
/** The raw location object */
|
|
247
|
-
location: LocationData;
|
|
248
|
-
}) => React.ReactNode;
|
|
249
|
-
}
|
|
250
|
-
/**
|
|
251
|
-
* Core component that provides location actions via render props.
|
|
252
|
-
* Must be used within LocationProvider.
|
|
253
|
-
*
|
|
254
|
-
* @component
|
|
255
|
-
* @example
|
|
256
|
-
* ```tsx
|
|
257
|
-
* <LocationActions>
|
|
258
|
-
* {({ selectLocation, isSelected, isSelectable }) => (
|
|
259
|
-
* <button onClick={selectLocation} disabled={!isSelectable}>
|
|
260
|
-
* {isSelected ? 'Selected' : 'Select'}
|
|
261
|
-
* </button>
|
|
262
|
-
* )}
|
|
263
|
-
* </LocationActions>
|
|
264
|
-
* ```
|
|
265
|
-
*/
|
|
266
|
-
export declare function LocationActions(props: LocationActionsProps): React.ReactNode;
|
|
267
139
|
/**
|
|
268
140
|
* Staff member data with selection state
|
|
269
141
|
*/
|
|
@@ -274,8 +146,6 @@ export interface StaffMemberData {
|
|
|
274
146
|
name: string;
|
|
275
147
|
/** Whether this staff member is currently selected */
|
|
276
148
|
isSelected: boolean;
|
|
277
|
-
/** Whether this staff member is selectable (works at selected location, or no location selected) */
|
|
278
|
-
isSelectable: boolean;
|
|
279
149
|
}
|
|
280
150
|
/**
|
|
281
151
|
* Props for StaffMembers render prop component
|
|
@@ -291,7 +161,7 @@ export interface StaffMembersProps {
|
|
|
291
161
|
/**
|
|
292
162
|
* Core component that provides access to time slot staff members via render props.
|
|
293
163
|
* Extracts unique staff members from slot.staffByLocation (names already included).
|
|
294
|
-
* Each staff member includes isSelected
|
|
164
|
+
* Each staff member includes isSelected based on current selection state.
|
|
295
165
|
*
|
|
296
166
|
* Returns null if there's only 1 staff member (nothing to choose from).
|
|
297
167
|
*
|
|
@@ -317,8 +187,6 @@ export interface StaffMemberInfoProps {
|
|
|
317
187
|
name: string;
|
|
318
188
|
/** Whether this staff member is currently selected */
|
|
319
189
|
isSelected: boolean;
|
|
320
|
-
/** Whether this staff member is selectable */
|
|
321
|
-
isSelectable: boolean;
|
|
322
190
|
/** The raw staff member object */
|
|
323
191
|
staffMember: StaffMemberData;
|
|
324
192
|
}) => React.ReactNode;
|
|
@@ -331,7 +199,7 @@ export interface StaffMemberInfoProps {
|
|
|
331
199
|
* @example
|
|
332
200
|
* ```tsx
|
|
333
201
|
* <StaffMemberInfo>
|
|
334
|
-
* {({ name, isSelected
|
|
202
|
+
* {({ name, isSelected }) => (
|
|
335
203
|
* <span>{name}</span>
|
|
336
204
|
* )}
|
|
337
205
|
* </StaffMemberInfo>
|
|
@@ -347,8 +215,6 @@ export interface StaffMemberActionsProps {
|
|
|
347
215
|
selectStaffMember: () => void;
|
|
348
216
|
/** Whether this staff member is currently selected */
|
|
349
217
|
isSelected: boolean;
|
|
350
|
-
/** Whether this staff member is selectable */
|
|
351
|
-
isSelectable: boolean;
|
|
352
218
|
/** The raw staff member object */
|
|
353
219
|
staffMember: StaffMemberData;
|
|
354
220
|
}) => React.ReactNode;
|
|
@@ -361,8 +227,8 @@ export interface StaffMemberActionsProps {
|
|
|
361
227
|
* @example
|
|
362
228
|
* ```tsx
|
|
363
229
|
* <StaffMemberActions>
|
|
364
|
-
* {({ selectStaffMember, isSelected
|
|
365
|
-
* <button onClick={selectStaffMember}
|
|
230
|
+
* {({ selectStaffMember, isSelected }) => (
|
|
231
|
+
* <button onClick={selectStaffMember}>
|
|
366
232
|
* {isSelected ? 'Selected' : 'Select'}
|
|
367
233
|
* </button>
|
|
368
234
|
* )}
|