@wix/headless-bookings 0.0.11 → 0.0.13
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/api/index.d.ts +1 -0
- package/cjs/dist/api/index.js +1 -0
- package/cjs/dist/api/query-services/index.d.ts +6 -7
- package/cjs/dist/api/query-services/index.js +4 -4
- package/cjs/dist/api/time-slot-list/index.d.ts +53 -0
- package/cjs/dist/api/time-slot-list/index.js +133 -0
- package/cjs/dist/react/core/booking/Booking.d.ts +7 -7
- package/cjs/dist/react/core/booking/Booking.js +5 -5
- package/cjs/dist/react/core/location/Location.d.ts +3 -3
- package/cjs/dist/react/core/location/Location.js +2 -2
- package/cjs/dist/react/core/service/Service.d.ts +8 -8
- package/cjs/dist/react/core/service-list/ServiceList.d.ts +2 -2
- package/cjs/dist/react/location/Location.d.ts +3 -3
- package/cjs/dist/react/service/Service.d.ts +9 -9
- package/cjs/dist/react/service/Service.js +5 -5
- package/cjs/dist/react/service-list/ServiceList.d.ts +3 -3
- package/cjs/dist/services/booking/booking.d.ts +25 -16
- package/cjs/dist/services/booking/booking.js +50 -16
- package/cjs/dist/services/index.d.ts +2 -1
- package/cjs/dist/services/index.js +1 -0
- package/cjs/dist/services/service/service.d.ts +5 -5
- package/cjs/dist/services/service/service.js +20 -21
- package/cjs/dist/services/service-list/service-list.d.ts +3 -3
- package/cjs/dist/services/time-slot-list/index.d.ts +6 -0
- package/cjs/dist/services/time-slot-list/index.js +6 -0
- package/cjs/dist/services/time-slot-list/time-slot-list.d.ts +58 -0
- package/cjs/dist/services/time-slot-list/time-slot-list.def.d.ts +84 -0
- package/cjs/dist/services/time-slot-list/time-slot-list.def.js +17 -0
- package/cjs/dist/services/time-slot-list/time-slot-list.js +349 -0
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.js +1 -0
- package/dist/api/query-services/index.d.ts +6 -7
- package/dist/api/query-services/index.js +4 -4
- package/dist/api/time-slot-list/index.d.ts +53 -0
- package/dist/api/time-slot-list/index.js +133 -0
- package/dist/react/core/booking/Booking.d.ts +7 -7
- package/dist/react/core/booking/Booking.js +5 -5
- package/dist/react/core/location/Location.d.ts +3 -3
- package/dist/react/core/location/Location.js +2 -2
- package/dist/react/core/service/Service.d.ts +8 -8
- package/dist/react/core/service-list/ServiceList.d.ts +2 -2
- package/dist/react/location/Location.d.ts +3 -3
- package/dist/react/service/Service.d.ts +9 -9
- package/dist/react/service/Service.js +5 -5
- package/dist/react/service-list/ServiceList.d.ts +3 -3
- package/dist/services/booking/booking.d.ts +25 -16
- package/dist/services/booking/booking.js +50 -16
- package/dist/services/index.d.ts +2 -1
- package/dist/services/index.js +1 -0
- package/dist/services/service/service.d.ts +5 -5
- package/dist/services/service/service.js +20 -21
- package/dist/services/service-list/service-list.d.ts +3 -3
- package/dist/services/time-slot-list/index.d.ts +6 -0
- package/dist/services/time-slot-list/index.js +6 -0
- package/dist/services/time-slot-list/time-slot-list.d.ts +58 -0
- package/dist/services/time-slot-list/time-slot-list.def.d.ts +84 -0
- package/dist/services/time-slot-list/time-slot-list.def.js +17 -0
- package/dist/services/time-slot-list/time-slot-list.js +349 -0
- package/package.json +2 -2
package/cjs/dist/api/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* @module API
|
|
6
6
|
*/
|
|
7
7
|
export { getServiceById, getServiceBySlug, queryServices, type PagingMetadata, type ServiceListFilters, type QueryServicesRequest, } from './query-services/index.js';
|
|
8
|
+
export { fetchAvailability } from './time-slot-list/index.js';
|
|
8
9
|
/**
|
|
9
10
|
* PagingMetadata includes:
|
|
10
11
|
* - limit: Number of items per page
|
package/cjs/dist/api/index.js
CHANGED
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
* Query Services API
|
|
3
3
|
* Fetches single or multiple services with pagination and sorting
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
6
|
-
import type { services as servicesTypes } from '@wix/bookings';
|
|
5
|
+
import { type Service, type Paging, type Sorting } from '@wix/auto_sdk_bookings_services';
|
|
7
6
|
/**
|
|
8
7
|
* Paging metadata from query services response.
|
|
9
8
|
* Extends the SDK's Paging type with hasNext flag to indicate if more services are available.
|
|
10
9
|
*/
|
|
11
|
-
export type PagingMetadata =
|
|
10
|
+
export type PagingMetadata = Paging & {
|
|
12
11
|
/** Number of items returned in the current page */
|
|
13
12
|
count?: number;
|
|
14
13
|
/** Whether there are more services available to load */
|
|
@@ -31,7 +30,7 @@ export interface QueryServicesRequest {
|
|
|
31
30
|
appId: string;
|
|
32
31
|
filters?: ServiceListFilters;
|
|
33
32
|
pagingMetadata?: PagingMetadata;
|
|
34
|
-
sort?:
|
|
33
|
+
sort?: Sorting[];
|
|
35
34
|
}
|
|
36
35
|
/**
|
|
37
36
|
* Fetches a service by its ID
|
|
@@ -40,7 +39,7 @@ export interface QueryServicesRequest {
|
|
|
40
39
|
* @returns Object containing the service or null if not found
|
|
41
40
|
*/
|
|
42
41
|
export declare const getServiceById: (id: string, appId?: string) => Promise<{
|
|
43
|
-
service:
|
|
42
|
+
service: Service | null;
|
|
44
43
|
}>;
|
|
45
44
|
/**
|
|
46
45
|
* Fetches a service by its slug
|
|
@@ -49,7 +48,7 @@ export declare const getServiceById: (id: string, appId?: string) => Promise<{
|
|
|
49
48
|
* @returns Object containing the service or null if not found
|
|
50
49
|
*/
|
|
51
50
|
export declare const getServiceBySlug: (slug: string, appId?: string) => Promise<{
|
|
52
|
-
service:
|
|
51
|
+
service: Service | null;
|
|
53
52
|
}>;
|
|
54
53
|
/**
|
|
55
54
|
* Query services with pagination and sorting.
|
|
@@ -73,6 +72,6 @@ export declare const getServiceBySlug: (slug: string, appId?: string) => Promise
|
|
|
73
72
|
* ```
|
|
74
73
|
*/
|
|
75
74
|
export declare function queryServices({ appId, filters, pagingMetadata, sort, }: QueryServicesRequest): Promise<{
|
|
76
|
-
services:
|
|
75
|
+
services: Service[];
|
|
77
76
|
pagingMetadata: PagingMetadata;
|
|
78
77
|
}>;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Query Services API
|
|
3
3
|
* Fetches single or multiple services with pagination and sorting
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import { queryServices as queryServicesApi, } from '@wix/auto_sdk_bookings_services';
|
|
6
6
|
/**
|
|
7
7
|
* Booking app ID constant
|
|
8
8
|
*/
|
|
@@ -17,7 +17,7 @@ export const getServiceById = async (id, appId) => {
|
|
|
17
17
|
try {
|
|
18
18
|
const finalAppId = appId ?? BOOKING_APP_ID;
|
|
19
19
|
// Query services where _id equals the provided id and appId matches
|
|
20
|
-
const query =
|
|
20
|
+
const query = queryServicesApi({
|
|
21
21
|
conditionalFields: ['STAFF_MEMBER_DETAILS'],
|
|
22
22
|
});
|
|
23
23
|
const result = await query
|
|
@@ -44,7 +44,7 @@ export const getServiceBySlug = async (slug, appId) => {
|
|
|
44
44
|
try {
|
|
45
45
|
const finalAppId = appId ?? BOOKING_APP_ID;
|
|
46
46
|
// Query services where mainSlug.name equals the provided slug and appId matches
|
|
47
|
-
const query =
|
|
47
|
+
const query = queryServicesApi({
|
|
48
48
|
conditionalFields: ['STAFF_MEMBER_DETAILS'],
|
|
49
49
|
});
|
|
50
50
|
const result = await query
|
|
@@ -115,7 +115,7 @@ export async function queryServices({ appId, filters, pagingMetadata, sort, }) {
|
|
|
115
115
|
sort,
|
|
116
116
|
});
|
|
117
117
|
// Call queryServices with QueryServicesRequest and execute the query
|
|
118
|
-
const result = await
|
|
118
|
+
const result = await queryServicesApi(queryRequest).find();
|
|
119
119
|
// Construct PagingMetadata from result properties
|
|
120
120
|
// Includes count (number of items returned) and hasNext (whether more items are available)
|
|
121
121
|
const resultPagingMetadata = {
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Time Slot List API
|
|
3
|
+
* Fetches available time slots for booking services from Wix Bookings
|
|
4
|
+
*/
|
|
5
|
+
import { type Location, type CursorPaging, type CursorPagingMetadata } from '@wix/auto_sdk_bookings_availability-time-slots';
|
|
6
|
+
import { type Service } from '@wix/auto_sdk_bookings_services';
|
|
7
|
+
import { ViewMode, type TimeSlot } from '../../services/time-slot-list/time-slot-list.def.js';
|
|
8
|
+
export interface FetchAvailabilityOptions {
|
|
9
|
+
services: Service[];
|
|
10
|
+
fromLocalDate?: string | null;
|
|
11
|
+
toLocalDate?: string | null;
|
|
12
|
+
timeZone?: string | null;
|
|
13
|
+
locations?: Location[];
|
|
14
|
+
cursorPaging?: CursorPaging;
|
|
15
|
+
viewMode?: ViewMode;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Response from fetchAvailability with grouped time slots
|
|
19
|
+
*/
|
|
20
|
+
export interface FetchAvailabilityResponse {
|
|
21
|
+
/** Grouped time slots (one per unique time) */
|
|
22
|
+
timeSlots: TimeSlot[];
|
|
23
|
+
/** Cursor pagination metadata for loading more results */
|
|
24
|
+
cursorPagingMetadata?: CursorPagingMetadata;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Main entry point for fetching availability
|
|
28
|
+
* Detects flow type, calls appropriate API, and groups slots by time
|
|
29
|
+
*
|
|
30
|
+
* @param options - Fetch options including services, date range, timezone, and view mode
|
|
31
|
+
* @returns Promise with grouped time slots
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* const response = await fetchAvailability({
|
|
36
|
+
* services: [service],
|
|
37
|
+
* fromLocalDate: '2024-01-15T00:00:00',
|
|
38
|
+
* toLocalDate: '2024-01-22T00:00:00',
|
|
39
|
+
* timeZone: 'America/New_York',
|
|
40
|
+
* viewMode: ViewMode.CLASSIC,
|
|
41
|
+
* });
|
|
42
|
+
* // response.timeSlots are grouped by time
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare function fetchAvailability({ services: selectedServices, viewMode, fromLocalDate, toLocalDate, timeZone, locations, cursorPaging, }: {
|
|
46
|
+
services: Service[];
|
|
47
|
+
fromLocalDate: string;
|
|
48
|
+
toLocalDate: string;
|
|
49
|
+
timeZone?: string;
|
|
50
|
+
locations?: Location[];
|
|
51
|
+
cursorPaging?: CursorPaging;
|
|
52
|
+
viewMode?: ViewMode;
|
|
53
|
+
}): Promise<FetchAvailabilityResponse>;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Time Slot List API
|
|
3
|
+
* Fetches available time slots for booking services from Wix Bookings
|
|
4
|
+
*/
|
|
5
|
+
import { listAvailabilityTimeSlots, } from '@wix/auto_sdk_bookings_availability-time-slots';
|
|
6
|
+
import { ServiceType } from '@wix/auto_sdk_bookings_services';
|
|
7
|
+
import { ViewMode, } from '../../services/time-slot-list/time-slot-list.def.js';
|
|
8
|
+
// ============================================================================
|
|
9
|
+
// Internal Types
|
|
10
|
+
// ============================================================================
|
|
11
|
+
var FlowType;
|
|
12
|
+
(function (FlowType) {
|
|
13
|
+
FlowType["SINGLE_SERVICE"] = "single_service";
|
|
14
|
+
FlowType["MULTI_SERVICE"] = "multi_service";
|
|
15
|
+
FlowType["CLASS"] = "class";
|
|
16
|
+
})(FlowType || (FlowType = {}));
|
|
17
|
+
// ============================================================================
|
|
18
|
+
// Grouping Functions
|
|
19
|
+
// ============================================================================
|
|
20
|
+
/**
|
|
21
|
+
* Groups API time slots by their start time
|
|
22
|
+
* Multiple slots for the same time (different locations) are merged into one
|
|
23
|
+
*/
|
|
24
|
+
function groupTimeSlotsByTime(apiSlots) {
|
|
25
|
+
const groupedMap = new Map();
|
|
26
|
+
for (const apiSlot of apiSlots) {
|
|
27
|
+
const key = apiSlot.localStartDate;
|
|
28
|
+
if (!groupedMap.has(key)) {
|
|
29
|
+
// Create new grouped slot - omit location and availableResources
|
|
30
|
+
const { location: _location, availableResources: _availableResources, ...rest } = apiSlot;
|
|
31
|
+
groupedMap.set(key, {
|
|
32
|
+
...rest,
|
|
33
|
+
staffByLocation: [],
|
|
34
|
+
originalSlots: [],
|
|
35
|
+
id: apiSlot.localStartDate,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
const groupedSlot = groupedMap.get(key);
|
|
39
|
+
// Extract staff members with IDs and names from availableResources
|
|
40
|
+
const staffMembers = (apiSlot.availableResources || [])
|
|
41
|
+
.flatMap((resourceGroup) => resourceGroup.resources || [])
|
|
42
|
+
.filter((resource) => resource._id && resource.name)
|
|
43
|
+
.map((resource) => ({
|
|
44
|
+
id: resource._id,
|
|
45
|
+
name: resource.name,
|
|
46
|
+
}));
|
|
47
|
+
// Add this slot's location/staff info
|
|
48
|
+
const staffByLocation = {
|
|
49
|
+
location: {
|
|
50
|
+
id: apiSlot.location?._id,
|
|
51
|
+
name: apiSlot.location?.name,
|
|
52
|
+
},
|
|
53
|
+
staffMembers,
|
|
54
|
+
};
|
|
55
|
+
groupedSlot.staffByLocation.push(staffByLocation);
|
|
56
|
+
// Store original slot for booking service
|
|
57
|
+
groupedSlot.originalSlots.push(apiSlot);
|
|
58
|
+
}
|
|
59
|
+
return Array.from(groupedMap.values());
|
|
60
|
+
}
|
|
61
|
+
// ============================================================================
|
|
62
|
+
// Internal Flow Detection
|
|
63
|
+
// ============================================================================
|
|
64
|
+
/**
|
|
65
|
+
* Detects the booking flow type based on services and view mode
|
|
66
|
+
*/
|
|
67
|
+
function detectFlow(bookingServices, viewMode) {
|
|
68
|
+
if (bookingServices.length === 0) {
|
|
69
|
+
if (viewMode === ViewMode.AGENDA) {
|
|
70
|
+
return FlowType.CLASS; // AGENDA can fetch all classes without specifying services
|
|
71
|
+
}
|
|
72
|
+
throw new Error('Services required for classic view mode');
|
|
73
|
+
}
|
|
74
|
+
const allAppointments = bookingServices.every((s) => s.type === ServiceType.APPOINTMENT);
|
|
75
|
+
const allClasses = bookingServices.every((s) => s.type === ServiceType.CLASS);
|
|
76
|
+
if (!allAppointments && !allClasses) {
|
|
77
|
+
throw new Error('All services must be either appointments or classes');
|
|
78
|
+
}
|
|
79
|
+
if (allClasses)
|
|
80
|
+
return FlowType.CLASS;
|
|
81
|
+
if (bookingServices.length === 1)
|
|
82
|
+
return FlowType.SINGLE_SERVICE;
|
|
83
|
+
return FlowType.MULTI_SERVICE;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Main entry point for fetching availability
|
|
87
|
+
* Detects flow type, calls appropriate API, and groups slots by time
|
|
88
|
+
*
|
|
89
|
+
* @param options - Fetch options including services, date range, timezone, and view mode
|
|
90
|
+
* @returns Promise with grouped time slots
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```typescript
|
|
94
|
+
* const response = await fetchAvailability({
|
|
95
|
+
* services: [service],
|
|
96
|
+
* fromLocalDate: '2024-01-15T00:00:00',
|
|
97
|
+
* toLocalDate: '2024-01-22T00:00:00',
|
|
98
|
+
* timeZone: 'America/New_York',
|
|
99
|
+
* viewMode: ViewMode.CLASSIC,
|
|
100
|
+
* });
|
|
101
|
+
* // response.timeSlots are grouped by time
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
export async function fetchAvailability({ services: selectedServices, viewMode = ViewMode.CLASSIC, fromLocalDate, toLocalDate, timeZone, locations, cursorPaging, }) {
|
|
105
|
+
const flow = detectFlow(selectedServices, viewMode);
|
|
106
|
+
if (flow === FlowType.SINGLE_SERVICE) {
|
|
107
|
+
const serviceId = selectedServices[0]?._id;
|
|
108
|
+
if (!serviceId) {
|
|
109
|
+
throw new Error('Service ID is required');
|
|
110
|
+
}
|
|
111
|
+
const response = await listAvailabilityTimeSlots({
|
|
112
|
+
serviceId,
|
|
113
|
+
fromLocalDate,
|
|
114
|
+
toLocalDate,
|
|
115
|
+
timeZone,
|
|
116
|
+
locations,
|
|
117
|
+
cursorPaging,
|
|
118
|
+
});
|
|
119
|
+
return {
|
|
120
|
+
timeSlots: groupTimeSlotsByTime(response.timeSlots || []),
|
|
121
|
+
cursorPagingMetadata: response.cursorPagingMetadata,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
if (flow === FlowType.MULTI_SERVICE) {
|
|
125
|
+
// Phase 2: Multi-service support
|
|
126
|
+
throw new Error('Multi-service appointments not yet supported');
|
|
127
|
+
}
|
|
128
|
+
if (flow === FlowType.CLASS) {
|
|
129
|
+
// Phase 2: Class support
|
|
130
|
+
throw new Error('Class bookings not yet supported');
|
|
131
|
+
}
|
|
132
|
+
throw new Error(`Unknown flow type: ${flow}`);
|
|
133
|
+
}
|
|
@@ -3,8 +3,8 @@
|
|
|
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
|
|
7
|
-
import type {
|
|
6
|
+
import { type BookingServiceConfig, type BookingSelection } from '../../../services/booking/booking.js';
|
|
7
|
+
import type { TimeSlot } from '@wix/auto_sdk_bookings_availability-time-slots';
|
|
8
8
|
/**
|
|
9
9
|
* Props for Booking.Root component
|
|
10
10
|
*/
|
|
@@ -33,8 +33,8 @@ export declare function Root(props: RootProps): React.ReactNode;
|
|
|
33
33
|
*/
|
|
34
34
|
export interface DataProps {
|
|
35
35
|
children: (data: {
|
|
36
|
-
|
|
37
|
-
selectedTimeSlot:
|
|
36
|
+
bookingSelections: BookingSelection[];
|
|
37
|
+
selectedTimeSlot: TimeSlot | null;
|
|
38
38
|
}) => React.ReactNode;
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
@@ -45,9 +45,9 @@ export interface DataProps {
|
|
|
45
45
|
* @example
|
|
46
46
|
* ```tsx
|
|
47
47
|
* <Booking.Data>
|
|
48
|
-
* {({
|
|
49
|
-
*
|
|
50
|
-
* <div>{
|
|
48
|
+
* {({ bookingSelections }) => (
|
|
49
|
+
* bookingSelections.length > 0 ? (
|
|
50
|
+
* <div>{bookingSelections.map(s => s.service.name).join(', ')}</div>
|
|
51
51
|
* ) : (
|
|
52
52
|
* <div>No services selected</div>
|
|
53
53
|
* )
|
|
@@ -28,9 +28,9 @@ export function Root(props) {
|
|
|
28
28
|
* @example
|
|
29
29
|
* ```tsx
|
|
30
30
|
* <Booking.Data>
|
|
31
|
-
* {({
|
|
32
|
-
*
|
|
33
|
-
* <div>{
|
|
31
|
+
* {({ bookingSelections }) => (
|
|
32
|
+
* bookingSelections.length > 0 ? (
|
|
33
|
+
* <div>{bookingSelections.map(s => s.service.name).join(', ')}</div>
|
|
34
34
|
* ) : (
|
|
35
35
|
* <div>No services selected</div>
|
|
36
36
|
* )
|
|
@@ -41,10 +41,10 @@ export function Root(props) {
|
|
|
41
41
|
export function Data(props) {
|
|
42
42
|
const { children } = props;
|
|
43
43
|
const bookingService = useService(BookingServiceDefinition);
|
|
44
|
-
const
|
|
44
|
+
const bookingSelections = bookingService.bookingSelections.get();
|
|
45
45
|
const selectedTimeSlot = bookingService.timeSlot.get();
|
|
46
46
|
return children({
|
|
47
|
-
|
|
47
|
+
bookingSelections,
|
|
48
48
|
selectedTimeSlot,
|
|
49
49
|
});
|
|
50
50
|
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Converts location data to Address component format
|
|
5
5
|
*/
|
|
6
6
|
import React from 'react';
|
|
7
|
-
import {
|
|
7
|
+
import { LocationType, type Service } from '@wix/auto_sdk_bookings_services';
|
|
8
8
|
import type { AddressData as AddressDataType } from '@wix/headless-components/react';
|
|
9
9
|
/**
|
|
10
10
|
* Re-export AddressData type from Address component for convenience
|
|
@@ -14,14 +14,14 @@ export type AddressData = AddressDataType;
|
|
|
14
14
|
* Location render props passed to children
|
|
15
15
|
*/
|
|
16
16
|
export interface LocationRenderProps {
|
|
17
|
-
locationType:
|
|
17
|
+
locationType: LocationType;
|
|
18
18
|
address: AddressData | null;
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
21
|
* Props for the core Location component
|
|
22
22
|
*/
|
|
23
23
|
export interface LocationProps {
|
|
24
|
-
location: NonNullable<
|
|
24
|
+
location: NonNullable<Service['locations']>[number];
|
|
25
25
|
children: (props: LocationRenderProps) => React.ReactNode;
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
* Handles business, custom, and customer location types
|
|
4
4
|
* Converts location data to Address component format
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
6
|
+
import { LocationType } from '@wix/auto_sdk_bookings_services';
|
|
7
7
|
/**
|
|
8
8
|
* Parses location data into Address component format
|
|
9
9
|
*/
|
|
10
10
|
function parseLocationAddress(location, locationType) {
|
|
11
11
|
// Handle customer location specially
|
|
12
|
-
if (locationType ===
|
|
12
|
+
if (locationType === LocationType.CUSTOMER) {
|
|
13
13
|
// For customer location, return an AddressData object with Customer's Place
|
|
14
14
|
return {
|
|
15
15
|
address: {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import { type ServiceServiceConfig } from '../../../services/service/service.js';
|
|
7
|
-
import {
|
|
7
|
+
import type { Service, Payment, BookingPolicy, Schedule } from '@wix/auto_sdk_bookings_services';
|
|
8
8
|
import type { MoneyData } from '@wix/headless-components/react';
|
|
9
9
|
/**
|
|
10
10
|
* Props for Service.Root component
|
|
@@ -22,7 +22,7 @@ export declare function Root(props: RootProps): React.ReactNode;
|
|
|
22
22
|
*/
|
|
23
23
|
export interface ServiceProps {
|
|
24
24
|
children: (data: {
|
|
25
|
-
service:
|
|
25
|
+
service: Service;
|
|
26
26
|
isLoading: boolean;
|
|
27
27
|
error: string | null;
|
|
28
28
|
}) => React.ReactNode;
|
|
@@ -55,7 +55,7 @@ export interface InfoProps {
|
|
|
55
55
|
name?: string;
|
|
56
56
|
_id?: string;
|
|
57
57
|
};
|
|
58
|
-
locations?: Array<NonNullable<
|
|
58
|
+
locations?: Array<NonNullable<Service['locations']>[number]>;
|
|
59
59
|
staff?: Array<{
|
|
60
60
|
name?: string;
|
|
61
61
|
_id?: string;
|
|
@@ -110,8 +110,8 @@ export declare function Info(props: InfoProps): React.ReactNode;
|
|
|
110
110
|
*/
|
|
111
111
|
export interface PriceProps {
|
|
112
112
|
children: (data: {
|
|
113
|
-
servicePayment:
|
|
114
|
-
rateType:
|
|
113
|
+
servicePayment: Payment | undefined;
|
|
114
|
+
rateType: Payment['rateType'] | undefined;
|
|
115
115
|
money: MoneyData | null;
|
|
116
116
|
minPrice: MoneyData | null;
|
|
117
117
|
maxPrice: MoneyData | null;
|
|
@@ -151,7 +151,7 @@ export interface ActionsProps {
|
|
|
151
151
|
select: () => void;
|
|
152
152
|
add: () => void;
|
|
153
153
|
remove: () => void;
|
|
154
|
-
rawService:
|
|
154
|
+
rawService: Service;
|
|
155
155
|
bookable: boolean;
|
|
156
156
|
selected: boolean;
|
|
157
157
|
requiresAvailability: boolean;
|
|
@@ -180,7 +180,7 @@ export declare function Actions(props: ActionsProps): React.ReactNode;
|
|
|
180
180
|
*/
|
|
181
181
|
export interface PolicyProps {
|
|
182
182
|
children: (data: {
|
|
183
|
-
bookingPolicy:
|
|
183
|
+
bookingPolicy: BookingPolicy | null;
|
|
184
184
|
cancellationPolicyEnabled: boolean;
|
|
185
185
|
limitLatestCancellationEnabled: boolean;
|
|
186
186
|
latestCancellationInMinutes: number | undefined;
|
|
@@ -219,7 +219,7 @@ export declare function Policy(props: PolicyProps): React.ReactNode;
|
|
|
219
219
|
*/
|
|
220
220
|
export interface ScheduleProps {
|
|
221
221
|
children: (data: {
|
|
222
|
-
schedule:
|
|
222
|
+
schedule: Schedule | null;
|
|
223
223
|
isClassOrCourse: boolean;
|
|
224
224
|
}) => React.ReactNode;
|
|
225
225
|
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import { type ServiceListServiceConfig, type QueryOptions } from '../../../services/service-list/service-list.js';
|
|
7
|
-
import type {
|
|
7
|
+
import type { Service } from '@wix/auto_sdk_bookings_services';
|
|
8
8
|
import type { PagingMetadata } from '../../../api/query-services/index.js';
|
|
9
9
|
/**
|
|
10
10
|
* Props for ServiceList.Root component
|
|
@@ -37,7 +37,7 @@ export interface ServicesProps {
|
|
|
37
37
|
*/
|
|
38
38
|
export interface ServicesRenderProps {
|
|
39
39
|
/** Array of services */
|
|
40
|
-
services:
|
|
40
|
+
services: Service[];
|
|
41
41
|
/** Whether services are currently loading */
|
|
42
42
|
isLoading: boolean;
|
|
43
43
|
/** Error message, or null if no error */
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import * as CoreLocation from '../core/location/Location.js';
|
|
7
7
|
import { AsChildChildren } from '@wix/headless-utils/react';
|
|
8
|
-
import type
|
|
8
|
+
import { LocationType, type Service } from '@wix/auto_sdk_bookings_services';
|
|
9
9
|
/**
|
|
10
10
|
* Re-export AddressData type from core for convenience
|
|
11
11
|
*/
|
|
@@ -14,10 +14,10 @@ export type { AddressData } from '../core/location/Location.js';
|
|
|
14
14
|
* Props for Location.Root component
|
|
15
15
|
*/
|
|
16
16
|
export interface LocationRootProps {
|
|
17
|
-
location: NonNullable<
|
|
17
|
+
location: NonNullable<Service['locations']>[number];
|
|
18
18
|
asChild?: boolean;
|
|
19
19
|
children?: React.ReactNode | AsChildChildren<{
|
|
20
|
-
locationType:
|
|
20
|
+
locationType: LocationType;
|
|
21
21
|
address: CoreLocation.AddressData | null;
|
|
22
22
|
}>;
|
|
23
23
|
className?: string;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import { AsChildChildren } from '@wix/headless-utils/react';
|
|
7
7
|
import { MoneyData } from '@wix/headless-components/react';
|
|
8
|
-
import {
|
|
8
|
+
import { type Service, type Payment } from '@wix/auto_sdk_bookings_services';
|
|
9
9
|
/**
|
|
10
10
|
* Props for Service.Root component
|
|
11
11
|
*/
|
|
@@ -14,7 +14,7 @@ export interface ServiceRootProps {
|
|
|
14
14
|
selected: boolean;
|
|
15
15
|
bookable: boolean;
|
|
16
16
|
}>;
|
|
17
|
-
service:
|
|
17
|
+
service: Service;
|
|
18
18
|
appId?: string;
|
|
19
19
|
asChild?: boolean;
|
|
20
20
|
className?: string;
|
|
@@ -106,8 +106,8 @@ export declare const Description: React.ForwardRefExoticComponent<DescriptionPro
|
|
|
106
106
|
export interface PriceProps {
|
|
107
107
|
asChild?: boolean;
|
|
108
108
|
children?: AsChildChildren<{
|
|
109
|
-
servicePayment:
|
|
110
|
-
rateType:
|
|
109
|
+
servicePayment: Payment | undefined;
|
|
110
|
+
rateType: Payment['rateType'] | undefined;
|
|
111
111
|
money: MoneyData | null;
|
|
112
112
|
minPrice: MoneyData | null;
|
|
113
113
|
maxPrice: MoneyData | null;
|
|
@@ -327,7 +327,7 @@ export declare const Category: React.ForwardRefExoticComponent<CategoryProps & R
|
|
|
327
327
|
/**
|
|
328
328
|
* Type for location
|
|
329
329
|
*/
|
|
330
|
-
type LocationType = NonNullable<
|
|
330
|
+
type LocationType = NonNullable<Service['locations']>[number] & {
|
|
331
331
|
id: string;
|
|
332
332
|
};
|
|
333
333
|
/**
|
|
@@ -717,7 +717,7 @@ export declare const MediaItems: React.ForwardRefExoticComponent<MediaItemsProps
|
|
|
717
717
|
export interface RawProps {
|
|
718
718
|
asChild?: boolean;
|
|
719
719
|
children?: AsChildChildren<{
|
|
720
|
-
service:
|
|
720
|
+
service: Service;
|
|
721
721
|
isLoading: boolean;
|
|
722
722
|
error: string | null;
|
|
723
723
|
}>;
|
|
@@ -755,7 +755,7 @@ export declare namespace Actions {
|
|
|
755
755
|
selected: boolean;
|
|
756
756
|
requiresAvailability: boolean;
|
|
757
757
|
onClick: () => void;
|
|
758
|
-
service:
|
|
758
|
+
service: Service;
|
|
759
759
|
}) => React.ReactNode);
|
|
760
760
|
className?: string;
|
|
761
761
|
label?: string;
|
|
@@ -795,7 +795,7 @@ export declare namespace Actions {
|
|
|
795
795
|
selected: boolean;
|
|
796
796
|
requiresAvailability: boolean;
|
|
797
797
|
onClick: () => void;
|
|
798
|
-
service:
|
|
798
|
+
service: Service;
|
|
799
799
|
}) => React.ReactNode);
|
|
800
800
|
className?: string;
|
|
801
801
|
label?: string;
|
|
@@ -835,7 +835,7 @@ export declare namespace Actions {
|
|
|
835
835
|
selected: boolean;
|
|
836
836
|
requiresAvailability: boolean;
|
|
837
837
|
onClick: () => void;
|
|
838
|
-
service:
|
|
838
|
+
service: Service;
|
|
839
839
|
}) => React.ReactNode);
|
|
840
840
|
className?: string;
|
|
841
841
|
label?: string;
|
|
@@ -9,7 +9,7 @@ import { AsChildSlot } from '@wix/headless-utils/react';
|
|
|
9
9
|
import { Money, GenericList } from '@wix/headless-components/react';
|
|
10
10
|
import { WixMediaImage } from '@wix/headless-media/react';
|
|
11
11
|
import { MediaGallery } from '@wix/headless-media/react';
|
|
12
|
-
import {
|
|
12
|
+
import { RateType, } from '@wix/auto_sdk_bookings_services';
|
|
13
13
|
import * as Location from '../location/Location.js';
|
|
14
14
|
var TestIds;
|
|
15
15
|
(function (TestIds) {
|
|
@@ -160,17 +160,17 @@ export const Price = React.forwardRef((props, ref) => {
|
|
|
160
160
|
// Default rendering based on rate type
|
|
161
161
|
const renderDefaultPrice = () => {
|
|
162
162
|
switch (rateType) {
|
|
163
|
-
case
|
|
163
|
+
case RateType.FIXED:
|
|
164
164
|
return money ? (_jsx(Money, { money: money, className: className })) : null;
|
|
165
|
-
case
|
|
165
|
+
case RateType.VARIED:
|
|
166
166
|
if (minPrice && maxPrice) {
|
|
167
167
|
return (_jsxs("span", { className: className, "data-testid": TestIds.servicePrice, children: [_jsx(Money, { money: minPrice }), " - ", _jsx(Money, { money: maxPrice })] }));
|
|
168
168
|
}
|
|
169
169
|
// Fallback to defaultPrice if min/max not available
|
|
170
170
|
return money ? (_jsx(Money, { money: money, className: className })) : null;
|
|
171
|
-
case
|
|
171
|
+
case RateType.CUSTOM:
|
|
172
172
|
return priceDescription ? (_jsx("span", { className: className, "data-testid": TestIds.servicePrice, children: priceDescription })) : null;
|
|
173
|
-
case
|
|
173
|
+
case RateType.NO_FEE:
|
|
174
174
|
return money ? (_jsx(Money, { money: money, className: className })) : null;
|
|
175
175
|
default:
|
|
176
176
|
// UNKNOWN_RATE_TYPE or undefined
|
|
@@ -6,7 +6,7 @@ import React from 'react';
|
|
|
6
6
|
import { ListVariant, GenericListLoadMoreRenderProps } from '@wix/headless-components/react';
|
|
7
7
|
import { AsChildChildren } from '@wix/headless-utils/react';
|
|
8
8
|
import type { ServiceListServiceConfig } from '../../services/service-list/service-list.js';
|
|
9
|
-
import type {
|
|
9
|
+
import type { Service as ServiceType } from '@wix/auto_sdk_bookings_services';
|
|
10
10
|
/**
|
|
11
11
|
* Props for the ServiceList root component
|
|
12
12
|
*/
|
|
@@ -79,7 +79,7 @@ export type ServiceRootChildren = AsChildChildren<{
|
|
|
79
79
|
* Supports both ReactNode and function children that receive { selected, bookable }
|
|
80
80
|
*/
|
|
81
81
|
export interface ServiceItemWrapperProps {
|
|
82
|
-
item:
|
|
82
|
+
item: ServiceType;
|
|
83
83
|
index?: number;
|
|
84
84
|
/** Children can be ReactNode or a function that receives { selected, bookable } from Service.Root */
|
|
85
85
|
children: React.ReactNode | ServiceRootChildren;
|
|
@@ -89,7 +89,7 @@ export interface ServiceItemWrapperProps {
|
|
|
89
89
|
* Provides items array and itemWrapper function for custom rendering
|
|
90
90
|
*/
|
|
91
91
|
export interface ServiceRepeaterRenderProps {
|
|
92
|
-
items:
|
|
92
|
+
items: ServiceType[];
|
|
93
93
|
variant?: ListVariant;
|
|
94
94
|
/** Wraps each item in Service.Root - children can be ReactNode or function receiving { selected, bookable } */
|
|
95
95
|
itemWrapper: (props: ServiceItemWrapperProps) => React.ReactNode;
|