@wix/headless-bookings 0.0.40 → 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.
- package/cjs/dist/react/core/payment/Payment.js +18 -2
- package/cjs/dist/react/core/time-slot-list/TimeSlotList.d.ts +2 -1
- package/cjs/dist/react/core/time-slot-list/TimeSlotList.js +7 -1
- package/cjs/dist/react/payment/Payment.js +1 -1
- package/cjs/dist/react/time-slot-list/TimeSlotList.js +2 -5
- package/dist/react/core/payment/Payment.js +18 -2
- package/dist/react/core/time-slot-list/TimeSlotList.d.ts +2 -1
- package/dist/react/core/time-slot-list/TimeSlotList.js +7 -1
- package/dist/react/payment/Payment.js +1 -1
- package/dist/react/time-slot-list/TimeSlotList.js +2 -5
- package/package.json +2 -2
|
@@ -71,7 +71,17 @@ export function Data(props) {
|
|
|
71
71
|
const discount = convertMultiCurrencyPriceToMoneyData(priceSummary?.discount, currency);
|
|
72
72
|
const payNow = convertMultiCurrencyPriceToMoneyData(paymentDetails?.response?.payNow?.total, currency);
|
|
73
73
|
const payLater = convertMultiCurrencyPriceToMoneyData(paymentDetails?.response?.payLater?.total, currency);
|
|
74
|
-
return props.children({
|
|
74
|
+
return props.children({
|
|
75
|
+
subtotal,
|
|
76
|
+
total,
|
|
77
|
+
tax,
|
|
78
|
+
discount,
|
|
79
|
+
payNow,
|
|
80
|
+
payLater,
|
|
81
|
+
currency,
|
|
82
|
+
isLoading,
|
|
83
|
+
error,
|
|
84
|
+
});
|
|
75
85
|
}
|
|
76
86
|
/**
|
|
77
87
|
* Core component that provides access to calculated line items via render props.
|
|
@@ -116,5 +126,11 @@ export function LineItems(props) {
|
|
|
116
126
|
};
|
|
117
127
|
});
|
|
118
128
|
const hasLineItems = lineItems.length > 0;
|
|
119
|
-
return props.children({
|
|
129
|
+
return props.children({
|
|
130
|
+
lineItems,
|
|
131
|
+
hasLineItems,
|
|
132
|
+
currency,
|
|
133
|
+
isLoading,
|
|
134
|
+
error,
|
|
135
|
+
});
|
|
120
136
|
}
|
|
@@ -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
|
/**
|
|
@@ -294,7 +294,7 @@ export const LineItemPrice = React.forwardRef((props, ref) => {
|
|
|
294
294
|
const { asChild, children, className } = props;
|
|
295
295
|
const { lineItem } = useLineItemContext();
|
|
296
296
|
const { totalPrice, priceText } = lineItem;
|
|
297
|
-
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.paymentLineItemPrice, "data-has-price-text": !!priceText, customElement: children, customElementProps: { totalPrice, priceText }, children: priceText ? _jsx("span", { children: priceText }) : totalPrice ? _jsx(Money, { money: totalPrice }) : null }));
|
|
297
|
+
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.paymentLineItemPrice, "data-has-price-text": !!priceText, customElement: children, customElementProps: { totalPrice, priceText }, children: priceText ? (_jsx("span", { children: priceText })) : totalPrice ? (_jsx(Money, { money: totalPrice })) : null }));
|
|
298
298
|
});
|
|
299
299
|
LineItemPrice.displayName = 'Payment.LineItemPrice';
|
|
300
300
|
/**
|
|
@@ -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
|
/**
|
|
@@ -71,7 +71,17 @@ export function Data(props) {
|
|
|
71
71
|
const discount = convertMultiCurrencyPriceToMoneyData(priceSummary?.discount, currency);
|
|
72
72
|
const payNow = convertMultiCurrencyPriceToMoneyData(paymentDetails?.response?.payNow?.total, currency);
|
|
73
73
|
const payLater = convertMultiCurrencyPriceToMoneyData(paymentDetails?.response?.payLater?.total, currency);
|
|
74
|
-
return props.children({
|
|
74
|
+
return props.children({
|
|
75
|
+
subtotal,
|
|
76
|
+
total,
|
|
77
|
+
tax,
|
|
78
|
+
discount,
|
|
79
|
+
payNow,
|
|
80
|
+
payLater,
|
|
81
|
+
currency,
|
|
82
|
+
isLoading,
|
|
83
|
+
error,
|
|
84
|
+
});
|
|
75
85
|
}
|
|
76
86
|
/**
|
|
77
87
|
* Core component that provides access to calculated line items via render props.
|
|
@@ -116,5 +126,11 @@ export function LineItems(props) {
|
|
|
116
126
|
};
|
|
117
127
|
});
|
|
118
128
|
const hasLineItems = lineItems.length > 0;
|
|
119
|
-
return props.children({
|
|
129
|
+
return props.children({
|
|
130
|
+
lineItems,
|
|
131
|
+
hasLineItems,
|
|
132
|
+
currency,
|
|
133
|
+
isLoading,
|
|
134
|
+
error,
|
|
135
|
+
});
|
|
120
136
|
}
|
|
@@ -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
|
/**
|
|
@@ -294,7 +294,7 @@ export const LineItemPrice = React.forwardRef((props, ref) => {
|
|
|
294
294
|
const { asChild, children, className } = props;
|
|
295
295
|
const { lineItem } = useLineItemContext();
|
|
296
296
|
const { totalPrice, priceText } = lineItem;
|
|
297
|
-
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.paymentLineItemPrice, "data-has-price-text": !!priceText, customElement: children, customElementProps: { totalPrice, priceText }, children: priceText ? _jsx("span", { children: priceText }) : totalPrice ? _jsx(Money, { money: totalPrice }) : null }));
|
|
297
|
+
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.paymentLineItemPrice, "data-has-price-text": !!priceText, customElement: children, customElementProps: { totalPrice, priceText }, children: priceText ? (_jsx("span", { children: priceText })) : totalPrice ? (_jsx(Money, { money: totalPrice })) : null }));
|
|
298
298
|
});
|
|
299
299
|
LineItemPrice.displayName = 'Payment.LineItemPrice';
|
|
300
300
|
/**
|
|
@@ -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.
|
|
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": "
|
|
75
|
+
"falconPackageHash": "5dc20d0dd95441ac614497962bdf5803fa6e5e53d5887826fc888ea6"
|
|
76
76
|
}
|