@wix/headless-bookings 0.0.57 → 0.0.59
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 +4 -5
- package/cjs/dist/__mocks__/booking.js +6 -3
- package/cjs/dist/react/booking/Booking.js +1 -1
- package/cjs/dist/react/core/booking/Booking.d.ts +3 -3
- package/cjs/dist/react/core/booking/Booking.js +2 -2
- package/cjs/dist/react/core/payment/Payment.d.ts +84 -5
- package/cjs/dist/react/core/payment/Payment.js +102 -4
- package/cjs/dist/react/core/staff-member/StaffMember.js +2 -1
- package/cjs/dist/react/payment/Payment.d.ts +64 -58
- package/cjs/dist/react/payment/Payment.js +66 -80
- package/cjs/dist/react/staff-member/StaffMemberList.js +1 -1
- package/cjs/dist/services/booking/booking.d.ts +15 -8
- package/cjs/dist/services/booking/booking.js +8 -16
- package/cjs/dist/services/index.d.ts +1 -1
- package/cjs/dist/services/payment/payment.d.ts +4 -4
- package/cjs/dist/services/payment/payment.def.d.ts +4 -4
- package/cjs/dist/services/payment/payment.js +26 -18
- package/cjs/dist/services/time-slot-list/time-slot-list.js +1 -1
- package/dist/__mocks__/booking.d.ts +4 -5
- package/dist/__mocks__/booking.js +6 -3
- package/dist/react/booking/Booking.js +1 -1
- package/dist/react/core/booking/Booking.d.ts +3 -3
- package/dist/react/core/booking/Booking.js +2 -2
- package/dist/react/core/payment/Payment.d.ts +84 -5
- package/dist/react/core/payment/Payment.js +102 -4
- package/dist/react/core/staff-member/StaffMember.js +2 -1
- package/dist/react/payment/Payment.d.ts +64 -58
- package/dist/react/payment/Payment.js +66 -80
- package/dist/react/staff-member/StaffMemberList.js +1 -1
- package/dist/services/booking/booking.d.ts +15 -8
- package/dist/services/booking/booking.js +8 -16
- package/dist/services/index.d.ts +1 -1
- package/dist/services/payment/payment.d.ts +4 -4
- package/dist/services/payment/payment.def.d.ts +4 -4
- package/dist/services/payment/payment.js +26 -18
- package/dist/services/time-slot-list/time-slot-list.js +1 -1
- package/package.json +2 -2
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { Resource } from '@wix/auto_sdk_bookings_availability-time-slots';
|
|
2
1
|
import type { FormValues } from '@wix/form-public';
|
|
3
|
-
import type { ServiceSelection, ServiceSelectionTimeSlot, BookingServiceConfig, BookingService } from '../services/booking/booking.js';
|
|
2
|
+
import type { ServiceSelection, ServiceSelectionTimeSlot, BookingServiceConfig, BookingService, ExtendedResource } from '../services/booking/booking.js';
|
|
4
3
|
import type { Signal } from '@wix/services-definitions/core-services/signals';
|
|
5
4
|
export declare function mockSignal<T>(initialValue: T): Signal<T>;
|
|
6
5
|
export declare function createMockSignalsService(): {
|
|
@@ -12,15 +11,15 @@ export declare function createMockBookingService(initialSelections?: ServiceSele
|
|
|
12
11
|
/**
|
|
13
12
|
* Mock resource (staff member)
|
|
14
13
|
*/
|
|
15
|
-
export declare const mockResource:
|
|
14
|
+
export declare const mockResource: ExtendedResource;
|
|
16
15
|
/**
|
|
17
16
|
* Mock resource (another staff member)
|
|
18
17
|
*/
|
|
19
|
-
export declare const mockResourceTwo:
|
|
18
|
+
export declare const mockResourceTwo: ExtendedResource;
|
|
20
19
|
/**
|
|
21
20
|
* Mock resource (room)
|
|
22
21
|
*/
|
|
23
|
-
export declare const mockResourceRoom:
|
|
22
|
+
export declare const mockResourceRoom: ExtendedResource;
|
|
24
23
|
/**
|
|
25
24
|
* Mock location
|
|
26
25
|
*/
|
|
@@ -35,9 +35,9 @@ export function createMockBookingService(initialSelections = []) {
|
|
|
35
35
|
addItem: vi.fn(),
|
|
36
36
|
removeItem: vi.fn(),
|
|
37
37
|
clearItems: vi.fn(),
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
setResource: vi.fn(),
|
|
39
|
+
getResourceByType: vi.fn(),
|
|
40
|
+
clearResourceByType: vi.fn(),
|
|
41
41
|
setLocation: vi.fn(),
|
|
42
42
|
clearLocation: vi.fn(),
|
|
43
43
|
setTimezone: vi.fn(),
|
|
@@ -56,6 +56,7 @@ export const mockResource = {
|
|
|
56
56
|
name: 'John Doe',
|
|
57
57
|
email: 'john.doe@example.com',
|
|
58
58
|
tag: 'STAFF',
|
|
59
|
+
type: 'staff',
|
|
59
60
|
};
|
|
60
61
|
/**
|
|
61
62
|
* Mock resource (another staff member)
|
|
@@ -65,6 +66,7 @@ export const mockResourceTwo = {
|
|
|
65
66
|
name: 'Jane Smith',
|
|
66
67
|
email: 'jane.smith@example.com',
|
|
67
68
|
tag: 'STAFF',
|
|
69
|
+
type: 'staff',
|
|
68
70
|
};
|
|
69
71
|
/**
|
|
70
72
|
* Mock resource (room)
|
|
@@ -73,6 +75,7 @@ export const mockResourceRoom = {
|
|
|
73
75
|
_id: 'resource-room-1',
|
|
74
76
|
name: 'Conference Room A',
|
|
75
77
|
tag: 'RESOURCE',
|
|
78
|
+
type: 'room',
|
|
76
79
|
};
|
|
77
80
|
/**
|
|
78
81
|
* Mock location
|
|
@@ -227,7 +227,7 @@ export function TimeSlot(props) {
|
|
|
227
227
|
*/
|
|
228
228
|
export function Payment(props) {
|
|
229
229
|
const { children } = props;
|
|
230
|
-
return (_jsx(CoreBooking.PaymentData, { children: ({
|
|
230
|
+
return (_jsx(CoreBooking.PaymentData, { children: ({ pricingServiceSelections }) => (_jsx(PaymentComponent.Root, { pricingServiceSelections: pricingServiceSelections, children: children })) }));
|
|
231
231
|
}
|
|
232
232
|
/**
|
|
233
233
|
* Wraps Location context with the location from the booking context.
|
|
@@ -7,7 +7,7 @@ import { type BookingServiceConfig, type ServiceSelection, type BookingServiceAc
|
|
|
7
7
|
import type { FormValues } from '@wix/form-public';
|
|
8
8
|
import type { TimeSlot, Resource } from '@wix/auto_sdk_bookings_availability-time-slots';
|
|
9
9
|
import type { Service, Location as ServiceLocationType } from '@wix/auto_sdk_bookings_services';
|
|
10
|
-
import type {
|
|
10
|
+
import type { PricingServiceSelection } from '../../../services/payment/payment.js';
|
|
11
11
|
/**
|
|
12
12
|
* Props for Booking.Root component
|
|
13
13
|
*/
|
|
@@ -167,8 +167,8 @@ export declare function ItemsData(props: ItemsDataProps): React.ReactNode;
|
|
|
167
167
|
* Data exposed by PaymentData render prop
|
|
168
168
|
*/
|
|
169
169
|
export interface PaymentDataRenderProps {
|
|
170
|
-
/**
|
|
171
|
-
|
|
170
|
+
/** Pricing service selections array for Payment.Root */
|
|
171
|
+
pricingServiceSelections: PricingServiceSelection[];
|
|
172
172
|
}
|
|
173
173
|
/**
|
|
174
174
|
* Props for PaymentData render prop component
|
|
@@ -267,9 +267,9 @@ export function PaymentData(props) {
|
|
|
267
267
|
const { children } = props;
|
|
268
268
|
const bookingService = useService(BookingServiceDefinition);
|
|
269
269
|
const serviceSelections = bookingService.serviceSelections.get();
|
|
270
|
-
const
|
|
270
|
+
const pricingServiceSelections = serviceSelections.map((selection) => ({
|
|
271
271
|
service: selection.service,
|
|
272
272
|
lineItemId: selection.instanceId,
|
|
273
273
|
}));
|
|
274
|
-
return children({
|
|
274
|
+
return children({ pricingServiceSelections });
|
|
275
275
|
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Note: Currently supports single service only
|
|
5
5
|
*/
|
|
6
6
|
import React from 'react';
|
|
7
|
-
import { type PaymentServiceConfig, type
|
|
7
|
+
import { type PaymentServiceConfig, type PricingServiceSelection } from '../../../services/payment/payment.js';
|
|
8
8
|
import type { MoneyData } from '@wix/headless-components/react';
|
|
9
9
|
/**
|
|
10
10
|
* Props for Payment.Root component
|
|
@@ -16,8 +16,8 @@ export interface RootProps {
|
|
|
16
16
|
}) => React.ReactNode);
|
|
17
17
|
/** Service config - SSR only (paymentDetails) */
|
|
18
18
|
paymentServiceConfig?: PaymentServiceConfig;
|
|
19
|
-
/**
|
|
20
|
-
|
|
19
|
+
/** Pricing service selections for lazy loading (triggers API call) */
|
|
20
|
+
pricingServiceSelections?: PricingServiceSelection[];
|
|
21
21
|
/** Number of participants for lazy loading */
|
|
22
22
|
numberOfParticipants?: number;
|
|
23
23
|
}
|
|
@@ -25,7 +25,7 @@ export interface RootProps {
|
|
|
25
25
|
* Root component that provides payment context.
|
|
26
26
|
* Supports 3 modes:
|
|
27
27
|
* 1. SSR: paymentServiceConfig.paymentDetails - pre-fetched data
|
|
28
|
-
* 2. Lazy loading:
|
|
28
|
+
* 2. Lazy loading: pricingServiceSelections + numberOfParticipants props - calls API on init
|
|
29
29
|
* 3. Reactive: no config/props - reads from BookingService signals
|
|
30
30
|
*
|
|
31
31
|
* @component
|
|
@@ -37,7 +37,7 @@ export interface RootProps {
|
|
|
37
37
|
* </Payment.Root>
|
|
38
38
|
*
|
|
39
39
|
* // Lazy loading mode
|
|
40
|
-
* <Payment.Root
|
|
40
|
+
* <Payment.Root pricingServiceSelections={[...]} numberOfParticipants={2}>
|
|
41
41
|
* {({ isLoading }) => isLoading ? <div>Loading...</div> : <Payment.Total />}
|
|
42
42
|
* </Payment.Root>
|
|
43
43
|
*
|
|
@@ -59,6 +59,12 @@ export interface DataProps {
|
|
|
59
59
|
discount: MoneyData | null;
|
|
60
60
|
payNow: MoneyData | null;
|
|
61
61
|
payLater: MoneyData | null;
|
|
62
|
+
priceText: string | null;
|
|
63
|
+
hasPriceText: boolean;
|
|
64
|
+
isFree: boolean;
|
|
65
|
+
hasTax: boolean;
|
|
66
|
+
hasDiscount: boolean;
|
|
67
|
+
isDeposit: boolean;
|
|
62
68
|
currency: string;
|
|
63
69
|
isLoading: boolean;
|
|
64
70
|
error: string | null;
|
|
@@ -123,3 +129,76 @@ export interface LineItemsProps {
|
|
|
123
129
|
* ```
|
|
124
130
|
*/
|
|
125
131
|
export declare function LineItems(props: LineItemsProps): React.ReactNode;
|
|
132
|
+
/**
|
|
133
|
+
* Context value for LineItem components
|
|
134
|
+
*/
|
|
135
|
+
export interface LineItemContextValue {
|
|
136
|
+
lineItem: LineItem;
|
|
137
|
+
currency: string;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Hook to access the current LineItem from context.
|
|
141
|
+
* Must be used within LineItemProvider.
|
|
142
|
+
*
|
|
143
|
+
* @throws Error if used outside of LineItemProvider context
|
|
144
|
+
*/
|
|
145
|
+
export declare function useLineItemContext(): LineItemContextValue;
|
|
146
|
+
/**
|
|
147
|
+
* Props for LineItemProvider
|
|
148
|
+
*/
|
|
149
|
+
export interface LineItemProviderProps {
|
|
150
|
+
children: React.ReactNode;
|
|
151
|
+
lineItem: LineItem;
|
|
152
|
+
currency: string;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Provider component used by repeaters to provide LineItem context.
|
|
156
|
+
* Can be used by core consumers to create their own repeater.
|
|
157
|
+
*
|
|
158
|
+
* @component
|
|
159
|
+
* @example
|
|
160
|
+
* ```tsx
|
|
161
|
+
* {lineItems.map((item) => (
|
|
162
|
+
* <LineItemProvider key={item.id} lineItem={item} currency={currency}>
|
|
163
|
+
* {children}
|
|
164
|
+
* </LineItemProvider>
|
|
165
|
+
* ))}
|
|
166
|
+
* ```
|
|
167
|
+
*/
|
|
168
|
+
export declare function LineItemProvider(props: LineItemProviderProps): React.ReactNode;
|
|
169
|
+
/**
|
|
170
|
+
* Props for LineItemInfo render prop component
|
|
171
|
+
*/
|
|
172
|
+
export interface LineItemInfoProps {
|
|
173
|
+
children: (data: {
|
|
174
|
+
lineItem: LineItem;
|
|
175
|
+
currency: string;
|
|
176
|
+
totalPrice: MoneyData | null;
|
|
177
|
+
subtotal: MoneyData | null;
|
|
178
|
+
tax: MoneyData | null;
|
|
179
|
+
discount: MoneyData | null;
|
|
180
|
+
deposit: MoneyData | null;
|
|
181
|
+
priceText: string | null;
|
|
182
|
+
hasPriceText: boolean;
|
|
183
|
+
isFree: boolean;
|
|
184
|
+
hasDiscount: boolean;
|
|
185
|
+
hasDeposit: boolean;
|
|
186
|
+
}) => React.ReactNode;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Core component that provides access to line item info via render props.
|
|
190
|
+
* Must be used within LineItemProvider.
|
|
191
|
+
*
|
|
192
|
+
* @component
|
|
193
|
+
* @example
|
|
194
|
+
* ```tsx
|
|
195
|
+
* <LineItemInfo>
|
|
196
|
+
* {({ totalPrice, priceText, lineItem }) => (
|
|
197
|
+
* <div>
|
|
198
|
+
* {priceText ? <span>{priceText}</span> : <Money money={totalPrice} />}
|
|
199
|
+
* </div>
|
|
200
|
+
* )}
|
|
201
|
+
* </LineItemInfo>
|
|
202
|
+
* ```
|
|
203
|
+
*/
|
|
204
|
+
export declare function LineItemInfo(props: LineItemInfoProps): React.ReactNode;
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Core Payment Components
|
|
4
|
+
* Provides low-level access to PaymentService via render props
|
|
5
|
+
* Note: Currently supports single service only
|
|
6
|
+
*/
|
|
7
|
+
import React from 'react';
|
|
2
8
|
import { WixServices, useService } from '@wix/services-manager-react';
|
|
3
9
|
import { createServicesMap } from '@wix/services-manager';
|
|
4
10
|
import { PaymentServiceDefinition, PaymentService, } from '../../../services/payment/payment.js';
|
|
@@ -20,7 +26,7 @@ function RootContent({ children, }) {
|
|
|
20
26
|
* Root component that provides payment context.
|
|
21
27
|
* Supports 3 modes:
|
|
22
28
|
* 1. SSR: paymentServiceConfig.paymentDetails - pre-fetched data
|
|
23
|
-
* 2. Lazy loading:
|
|
29
|
+
* 2. Lazy loading: pricingServiceSelections + numberOfParticipants props - calls API on init
|
|
24
30
|
* 3. Reactive: no config/props - reads from BookingService signals
|
|
25
31
|
*
|
|
26
32
|
* @component
|
|
@@ -32,7 +38,7 @@ function RootContent({ children, }) {
|
|
|
32
38
|
* </Payment.Root>
|
|
33
39
|
*
|
|
34
40
|
* // Lazy loading mode
|
|
35
|
-
* <Payment.Root
|
|
41
|
+
* <Payment.Root pricingServiceSelections={[...]} numberOfParticipants={2}>
|
|
36
42
|
* {({ isLoading }) => isLoading ? <div>Loading...</div> : <Payment.Total />}
|
|
37
43
|
* </Payment.Root>
|
|
38
44
|
*
|
|
@@ -43,11 +49,11 @@ function RootContent({ children, }) {
|
|
|
43
49
|
* ```
|
|
44
50
|
*/
|
|
45
51
|
export function Root(props) {
|
|
46
|
-
const { children, paymentServiceConfig = {},
|
|
52
|
+
const { children, paymentServiceConfig = {}, pricingServiceSelections, numberOfParticipants, } = props;
|
|
47
53
|
// Merge public config with lazy loading props into internal config
|
|
48
54
|
const internalConfig = {
|
|
49
55
|
...paymentServiceConfig,
|
|
50
|
-
|
|
56
|
+
pricingServiceSelections,
|
|
51
57
|
numberOfParticipants,
|
|
52
58
|
};
|
|
53
59
|
return (_jsx(WixServices, { servicesMap: createServicesMap().addService(PaymentServiceDefinition, PaymentService, internalConfig), children: _jsx(RootContent, { children: children }) }));
|
|
@@ -71,6 +77,16 @@ export function Data(props) {
|
|
|
71
77
|
const discount = convertMultiCurrencyPriceToMoneyData(priceSummary?.discount, currency);
|
|
72
78
|
const payNow = convertMultiCurrencyPriceToMoneyData(paymentDetails?.response?.payNow?.total, currency);
|
|
73
79
|
const payLater = convertMultiCurrencyPriceToMoneyData(paymentDetails?.response?.payLater?.total, currency);
|
|
80
|
+
// Get priceText from first line item (single service mode)
|
|
81
|
+
const additionalInfoList = paymentDetails?.additionalInfo?.lineItems || [];
|
|
82
|
+
const firstLineItemInfo = additionalInfoList[0];
|
|
83
|
+
const priceText = firstLineItemInfo?.priceText || null;
|
|
84
|
+
const hasPriceText = !!priceText;
|
|
85
|
+
const isFree = total !== null && total.amount === 0 && !hasPriceText;
|
|
86
|
+
// Computed flags
|
|
87
|
+
const hasTax = tax !== null && tax.amount > 0;
|
|
88
|
+
const hasDiscount = discount !== null && discount.amount > 0;
|
|
89
|
+
const isDeposit = payNow !== null && total !== null && payNow.amount < total.amount;
|
|
74
90
|
return props.children({
|
|
75
91
|
subtotal,
|
|
76
92
|
total,
|
|
@@ -78,6 +94,12 @@ export function Data(props) {
|
|
|
78
94
|
discount,
|
|
79
95
|
payNow,
|
|
80
96
|
payLater,
|
|
97
|
+
priceText,
|
|
98
|
+
hasPriceText,
|
|
99
|
+
isFree,
|
|
100
|
+
hasTax,
|
|
101
|
+
hasDiscount,
|
|
102
|
+
isDeposit,
|
|
81
103
|
currency,
|
|
82
104
|
isLoading,
|
|
83
105
|
error,
|
|
@@ -134,3 +156,79 @@ export function LineItems(props) {
|
|
|
134
156
|
error,
|
|
135
157
|
});
|
|
136
158
|
}
|
|
159
|
+
const LineItemContext = React.createContext(null);
|
|
160
|
+
/**
|
|
161
|
+
* Hook to access the current LineItem from context.
|
|
162
|
+
* Must be used within LineItemProvider.
|
|
163
|
+
*
|
|
164
|
+
* @throws Error if used outside of LineItemProvider context
|
|
165
|
+
*/
|
|
166
|
+
export function useLineItemContext() {
|
|
167
|
+
const context = React.useContext(LineItemContext);
|
|
168
|
+
if (!context) {
|
|
169
|
+
throw new Error('LineItem components must be used within LineItemProvider');
|
|
170
|
+
}
|
|
171
|
+
return context;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Provider component used by repeaters to provide LineItem context.
|
|
175
|
+
* Can be used by core consumers to create their own repeater.
|
|
176
|
+
*
|
|
177
|
+
* @component
|
|
178
|
+
* @example
|
|
179
|
+
* ```tsx
|
|
180
|
+
* {lineItems.map((item) => (
|
|
181
|
+
* <LineItemProvider key={item.id} lineItem={item} currency={currency}>
|
|
182
|
+
* {children}
|
|
183
|
+
* </LineItemProvider>
|
|
184
|
+
* ))}
|
|
185
|
+
* ```
|
|
186
|
+
*/
|
|
187
|
+
export function LineItemProvider(props) {
|
|
188
|
+
const { children, lineItem, currency } = props;
|
|
189
|
+
const contextValue = {
|
|
190
|
+
lineItem,
|
|
191
|
+
currency,
|
|
192
|
+
};
|
|
193
|
+
return (_jsx(LineItemContext.Provider, { value: contextValue, children: children }));
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Core component that provides access to line item info via render props.
|
|
197
|
+
* Must be used within LineItemProvider.
|
|
198
|
+
*
|
|
199
|
+
* @component
|
|
200
|
+
* @example
|
|
201
|
+
* ```tsx
|
|
202
|
+
* <LineItemInfo>
|
|
203
|
+
* {({ totalPrice, priceText, lineItem }) => (
|
|
204
|
+
* <div>
|
|
205
|
+
* {priceText ? <span>{priceText}</span> : <Money money={totalPrice} />}
|
|
206
|
+
* </div>
|
|
207
|
+
* )}
|
|
208
|
+
* </LineItemInfo>
|
|
209
|
+
* ```
|
|
210
|
+
*/
|
|
211
|
+
export function LineItemInfo(props) {
|
|
212
|
+
const { lineItem, currency } = useLineItemContext();
|
|
213
|
+
// Computed flags
|
|
214
|
+
const hasPriceText = !!lineItem.priceText;
|
|
215
|
+
const isFree = lineItem.totalPrice !== null &&
|
|
216
|
+
lineItem.totalPrice.amount === 0 &&
|
|
217
|
+
!hasPriceText;
|
|
218
|
+
const hasDiscount = lineItem.discount !== null && lineItem.discount.amount > 0;
|
|
219
|
+
const hasDeposit = lineItem.deposit !== null && lineItem.deposit.amount > 0;
|
|
220
|
+
return props.children({
|
|
221
|
+
lineItem,
|
|
222
|
+
currency,
|
|
223
|
+
totalPrice: lineItem.totalPrice,
|
|
224
|
+
subtotal: lineItem.subtotal,
|
|
225
|
+
tax: lineItem.tax,
|
|
226
|
+
discount: lineItem.discount,
|
|
227
|
+
deposit: lineItem.deposit,
|
|
228
|
+
priceText: lineItem.priceText,
|
|
229
|
+
hasPriceText,
|
|
230
|
+
isFree,
|
|
231
|
+
hasDiscount,
|
|
232
|
+
hasDeposit,
|
|
233
|
+
});
|
|
234
|
+
}
|
|
@@ -130,7 +130,8 @@ export function Actions(props) {
|
|
|
130
130
|
if (!rawStaffMember?.staffMemberId || !bookingService)
|
|
131
131
|
return;
|
|
132
132
|
// Use resource type ID as the lookup key, staff member ID as the actual resource ID
|
|
133
|
-
bookingService.actions.
|
|
133
|
+
bookingService.actions.setResource({
|
|
134
|
+
type: STAFF_MEMBER_RESOURCE_TYPE_ID,
|
|
134
135
|
_id: rawStaffMember.staffMemberId,
|
|
135
136
|
name: rawStaffMember.name,
|
|
136
137
|
});
|
|
@@ -5,8 +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 type { PaymentServiceConfig,
|
|
9
|
-
import type { LineItem as CoreLineItem } from '../core/payment/Payment.js';
|
|
8
|
+
import type { PaymentServiceConfig, PricingServiceSelection } from '../../services/payment/payment.js';
|
|
10
9
|
/**
|
|
11
10
|
* Props for Payment.Root component
|
|
12
11
|
*/
|
|
@@ -17,8 +16,8 @@ export interface RootProps {
|
|
|
17
16
|
}) => React.ReactNode);
|
|
18
17
|
/** Service config for SSR (pre-fetched paymentDetails) */
|
|
19
18
|
paymentServiceConfig?: PaymentServiceConfig;
|
|
20
|
-
/**
|
|
21
|
-
|
|
19
|
+
/** Pricing service selections for lazy loading (triggers API call) */
|
|
20
|
+
pricingServiceSelections?: PricingServiceSelection[];
|
|
22
21
|
/** Number of participants for lazy loading */
|
|
23
22
|
numberOfParticipants?: number;
|
|
24
23
|
asChild?: boolean;
|
|
@@ -28,7 +27,7 @@ export interface RootProps {
|
|
|
28
27
|
* Root component that provides payment context to the entire app.
|
|
29
28
|
* Supports 3 modes:
|
|
30
29
|
* 1. SSR: paymentServiceConfig.paymentDetails - pre-fetched data
|
|
31
|
-
* 2. Lazy loading:
|
|
30
|
+
* 2. Lazy loading: pricingServiceSelections + numberOfParticipants props - calls API via useEffect
|
|
32
31
|
* 3. Reactive: no config/props - reads from BookingService signals
|
|
33
32
|
*
|
|
34
33
|
* @order 1
|
|
@@ -64,17 +63,32 @@ export interface SubtotalProps {
|
|
|
64
63
|
asChild?: boolean;
|
|
65
64
|
children?: AsChildChildren<{
|
|
66
65
|
subtotal: MoneyData | null;
|
|
66
|
+
priceText: string | null;
|
|
67
|
+
hasPriceText: boolean;
|
|
68
|
+
isFree: boolean;
|
|
67
69
|
}>;
|
|
68
70
|
className?: string;
|
|
69
71
|
}
|
|
70
72
|
/**
|
|
71
73
|
* Displays the payment subtotal.
|
|
74
|
+
* Always displays the monetary value but exposes priceText, hasPriceText, and isFree for custom rendering.
|
|
72
75
|
*
|
|
73
76
|
* @component
|
|
74
77
|
* @example
|
|
75
78
|
* ```tsx
|
|
76
79
|
* <Payment.Subtotal className="text-lg" />
|
|
77
80
|
* ```
|
|
81
|
+
* @example
|
|
82
|
+
* ```tsx
|
|
83
|
+
* <Payment.Subtotal asChild>
|
|
84
|
+
* {({ subtotal, priceText, hasPriceText, isFree }) => (
|
|
85
|
+
* <div>
|
|
86
|
+
* <Money money={subtotal} />
|
|
87
|
+
* {hasPriceText && <span className="text-sm">({priceText})</span>}
|
|
88
|
+
* </div>
|
|
89
|
+
* )}
|
|
90
|
+
* </Payment.Subtotal>
|
|
91
|
+
* ```
|
|
78
92
|
*/
|
|
79
93
|
export declare const Subtotal: React.ForwardRefExoticComponent<SubtotalProps & React.RefAttributes<HTMLElement>>;
|
|
80
94
|
/**
|
|
@@ -126,17 +140,36 @@ export interface TotalProps {
|
|
|
126
140
|
asChild?: boolean;
|
|
127
141
|
children?: AsChildChildren<{
|
|
128
142
|
total: MoneyData | null;
|
|
143
|
+
priceText: string | null;
|
|
144
|
+
hasPriceText: boolean;
|
|
145
|
+
isFree: boolean;
|
|
129
146
|
}>;
|
|
130
147
|
className?: string;
|
|
131
148
|
}
|
|
132
149
|
/**
|
|
133
150
|
* Displays the payment total.
|
|
151
|
+
* Always displays the monetary value but exposes priceText, hasPriceText, and isFree for custom rendering.
|
|
134
152
|
*
|
|
135
153
|
* @component
|
|
136
154
|
* @example
|
|
137
155
|
* ```tsx
|
|
138
156
|
* <Payment.Total className="text-2xl font-bold" />
|
|
139
157
|
* ```
|
|
158
|
+
* @example
|
|
159
|
+
* ```tsx
|
|
160
|
+
* <Payment.Total asChild>
|
|
161
|
+
* {({ total, priceText, hasPriceText, isFree }) => (
|
|
162
|
+
* <div>
|
|
163
|
+
* {isFree ? (
|
|
164
|
+
* <span className="text-green-500">Free</span>
|
|
165
|
+
* ) : (
|
|
166
|
+
* <Money money={total} />
|
|
167
|
+
* )}
|
|
168
|
+
* {hasPriceText && <span className="text-sm">({priceText})</span>}
|
|
169
|
+
* </div>
|
|
170
|
+
* )}
|
|
171
|
+
* </Payment.Total>
|
|
172
|
+
* ```
|
|
140
173
|
*/
|
|
141
174
|
export declare const Total: React.ForwardRefExoticComponent<TotalProps & React.RefAttributes<HTMLElement>>;
|
|
142
175
|
/**
|
|
@@ -240,101 +273,74 @@ export interface LineItemsListProps {
|
|
|
240
273
|
* ```
|
|
241
274
|
*/
|
|
242
275
|
export declare const LineItemsList: React.ForwardRefExoticComponent<LineItemsListProps & React.RefAttributes<HTMLElement>>;
|
|
243
|
-
/**
|
|
244
|
-
* Render props for LineItemRepeater asChild pattern
|
|
245
|
-
*/
|
|
246
|
-
export interface LineItemRepeaterRenderProps {
|
|
247
|
-
items: CoreLineItem[];
|
|
248
|
-
itemWrapper: (props: {
|
|
249
|
-
item: CoreLineItem;
|
|
250
|
-
index: number;
|
|
251
|
-
children: React.ReactNode;
|
|
252
|
-
}) => React.ReactNode;
|
|
253
|
-
}
|
|
254
276
|
/**
|
|
255
277
|
* Props for Payment.LineItemRepeater component
|
|
256
278
|
*/
|
|
257
279
|
export interface LineItemRepeaterProps {
|
|
258
|
-
children
|
|
259
|
-
asChild?: boolean;
|
|
280
|
+
children: React.ReactNode;
|
|
260
281
|
}
|
|
261
282
|
/**
|
|
262
|
-
* Repeater component that
|
|
263
|
-
*
|
|
283
|
+
* Repeater component that maps over line items and provides context per item.
|
|
284
|
+
* Uses GenericList.Repeater internally with itemWrapper that provides LineItemContext.
|
|
264
285
|
*
|
|
265
286
|
* @component
|
|
266
287
|
* @example
|
|
267
288
|
* ```tsx
|
|
268
|
-
* // Standard usage
|
|
269
289
|
* <Payment.LineItemRepeater>
|
|
270
|
-
* <Payment.
|
|
271
|
-
*
|
|
272
|
-
*
|
|
273
|
-
* // AsChild usage with custom list
|
|
274
|
-
* <Payment.LineItemRepeater asChild>
|
|
275
|
-
* {({ items, itemWrapper }) => (
|
|
276
|
-
* <ol>
|
|
277
|
-
* {items.map((item, index) => (
|
|
278
|
-
* <li key={item.id}>
|
|
279
|
-
* {itemWrapper({ item, index, children: <Payment.LineItemPrice /> })}
|
|
280
|
-
* </li>
|
|
281
|
-
* ))}
|
|
282
|
-
* </ol>
|
|
283
|
-
* )}
|
|
290
|
+
* <Payment.LineItemTotal />
|
|
291
|
+
* <Payment.LineItemDiscount />
|
|
284
292
|
* </Payment.LineItemRepeater>
|
|
285
293
|
* ```
|
|
286
294
|
*/
|
|
287
295
|
export declare const LineItemRepeater: React.ForwardRefExoticComponent<LineItemRepeaterProps & React.RefAttributes<HTMLElement>>;
|
|
288
296
|
/**
|
|
289
|
-
* Props for Payment.
|
|
297
|
+
* Props for Payment.LineItemTotal component
|
|
290
298
|
*/
|
|
291
|
-
export interface
|
|
292
|
-
lineItem: CoreLineItem;
|
|
293
|
-
currency: string;
|
|
294
|
-
children?: React.ReactNode | AsChildChildren<{
|
|
295
|
-
lineItem: CoreLineItem;
|
|
296
|
-
currency: string;
|
|
297
|
-
}>;
|
|
299
|
+
export interface LineItemTotalProps {
|
|
298
300
|
asChild?: boolean;
|
|
301
|
+
children?: AsChildChildren<{
|
|
302
|
+
totalPrice: MoneyData | null;
|
|
303
|
+
priceText: string | null;
|
|
304
|
+
hasPriceText: boolean;
|
|
305
|
+
isFree: boolean;
|
|
306
|
+
}>;
|
|
299
307
|
className?: string;
|
|
300
|
-
'data-testid'?: string;
|
|
301
308
|
}
|
|
302
309
|
/**
|
|
303
|
-
*
|
|
304
|
-
*
|
|
310
|
+
* Displays the line item total (total price after tax).
|
|
311
|
+
* Shows priceText for CUSTOM rate type services, otherwise shows totalPrice.
|
|
305
312
|
*
|
|
306
313
|
* @component
|
|
307
314
|
* @example
|
|
308
315
|
* ```tsx
|
|
309
|
-
* <Payment.
|
|
310
|
-
* <Payment.LineItemPrice />
|
|
311
|
-
* <Payment.LineItemDiscount />
|
|
312
|
-
* </Payment.LineItemRoot>
|
|
316
|
+
* <Payment.LineItemTotal className="text-2xl font-bold" />
|
|
313
317
|
* ```
|
|
314
318
|
*/
|
|
315
|
-
export declare const
|
|
319
|
+
export declare const LineItemTotal: React.ForwardRefExoticComponent<LineItemTotalProps & React.RefAttributes<HTMLElement>>;
|
|
316
320
|
/**
|
|
317
|
-
* Props for Payment.
|
|
321
|
+
* Props for Payment.LineItemSubtotal component
|
|
318
322
|
*/
|
|
319
|
-
export interface
|
|
323
|
+
export interface LineItemSubtotalProps {
|
|
320
324
|
asChild?: boolean;
|
|
321
325
|
children?: AsChildChildren<{
|
|
322
|
-
|
|
326
|
+
subtotal: MoneyData | null;
|
|
323
327
|
priceText: string | null;
|
|
328
|
+
hasPriceText: boolean;
|
|
329
|
+
isFree: boolean;
|
|
324
330
|
}>;
|
|
325
331
|
className?: string;
|
|
326
332
|
}
|
|
327
333
|
/**
|
|
328
|
-
* Displays the line item price.
|
|
329
|
-
* Shows priceText for CUSTOM rate type services, otherwise shows
|
|
334
|
+
* Displays the line item subtotal (full price before discounts).
|
|
335
|
+
* Shows priceText for CUSTOM rate type services, otherwise shows subtotal.
|
|
330
336
|
*
|
|
331
337
|
* @component
|
|
332
338
|
* @example
|
|
333
339
|
* ```tsx
|
|
334
|
-
* <Payment.
|
|
340
|
+
* <Payment.LineItemSubtotal className="text-lg" />
|
|
335
341
|
* ```
|
|
336
342
|
*/
|
|
337
|
-
export declare const
|
|
343
|
+
export declare const LineItemSubtotal: React.ForwardRefExoticComponent<LineItemSubtotalProps & React.RefAttributes<HTMLElement>>;
|
|
338
344
|
/**
|
|
339
345
|
* Props for Payment.LineItemDiscount component
|
|
340
346
|
*/
|