@wix/headless-restaurants-olo 0.0.24 → 0.0.26
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/ItemDetails.d.ts +2 -2
- package/cjs/dist/react/ItemDetails.js +1 -9
- package/cjs/dist/react/OLO.d.ts +0 -2
- package/cjs/dist/react/OLO.js +6 -6
- package/cjs/dist/react/Settings.d.ts +24 -21
- package/cjs/dist/react/Settings.js +34 -4
- package/cjs/dist/react/core/OLO.d.ts +0 -1
- package/cjs/dist/react/core/OLO.js +2 -79
- package/cjs/dist/react/core/Settings.d.ts +41 -65
- package/cjs/dist/react/core/Settings.js +83 -113
- package/cjs/dist/services/fulfillments-service.js +22 -18
- package/cjs/dist/types/fulfillments-types.d.ts +7 -4
- package/dist/react/ItemDetails.d.ts +2 -2
- package/dist/react/ItemDetails.js +1 -9
- package/dist/react/OLO.d.ts +0 -2
- package/dist/react/OLO.js +6 -6
- package/dist/react/Settings.d.ts +24 -21
- package/dist/react/Settings.js +34 -4
- package/dist/react/core/OLO.d.ts +0 -1
- package/dist/react/core/OLO.js +2 -79
- package/dist/react/core/Settings.d.ts +41 -65
- package/dist/react/core/Settings.js +83 -113
- package/dist/services/fulfillments-service.js +22 -18
- package/dist/types/fulfillments-types.d.ts +7 -4
- package/package.json +2 -2
|
@@ -1,109 +1,63 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
|
+
import { WixServices, useService } from '@wix/services-manager-react';
|
|
3
4
|
import { OLOSettingsServiceDefinition } from '../../services/olo-settings-service.js';
|
|
4
|
-
import { FulfillmentsServiceDefinition } from '../../services/fulfillments-service.js';
|
|
5
|
+
import { FulfillmentsService, FulfillmentsServiceDefinition, loadFulfillmentsServiceConfig, } from '../../services/fulfillments-service.js';
|
|
6
|
+
import { createServicesMap } from '@wix/services-manager';
|
|
5
7
|
/**
|
|
6
|
-
* Core Settings component that provides
|
|
7
|
-
*
|
|
8
|
+
* Core Settings Root component that provides service context
|
|
9
|
+
* Wraps children with both OLOSettingsService and FulfillmentsService providers
|
|
8
10
|
*
|
|
9
11
|
* @example
|
|
10
12
|
* ```tsx
|
|
11
|
-
* <CoreSettings.Root>
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* <div>
|
|
15
|
-
* )
|
|
16
|
-
*
|
|
17
|
-
* ) : (
|
|
18
|
-
* <div>
|
|
19
|
-
* <h2>{currentDetails.name}</h2>
|
|
20
|
-
* <p>Accepting Orders: {extraData.acceptingOrders ? 'Yes' : 'No'}</p>
|
|
21
|
-
* <p>Delivery Fee: ${extraData.deliveryFee}</p>
|
|
22
|
-
* </div>
|
|
23
|
-
* )
|
|
24
|
-
* )}
|
|
13
|
+
* <CoreSettings.Root fulfillmentsServiceConfig={config}>
|
|
14
|
+
* <CoreSettings.CurrentTimeSlot>
|
|
15
|
+
* {({ timeSlot, hasDetails }) => (
|
|
16
|
+
* <div>{timeSlot?.dispatchType}</div>
|
|
17
|
+
* )}
|
|
18
|
+
* </CoreSettings.CurrentTimeSlot>
|
|
25
19
|
* </CoreSettings.Root>
|
|
26
20
|
* ```
|
|
27
21
|
*/
|
|
28
|
-
export const Root = ({ children }) => {
|
|
22
|
+
export const Root = ({ children, fulfillmentsServiceConfig, }) => {
|
|
29
23
|
const service = useService(OLOSettingsServiceDefinition);
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const currentFulfillment = {
|
|
44
|
-
current: fulfillmentsService.selectedFulfillment?.get() ?? undefined,
|
|
45
|
-
};
|
|
46
|
-
// Extract location data from operation group
|
|
47
|
-
// Note: Using safe property access since the exact API structure may vary
|
|
48
|
-
const currentLocation = {
|
|
49
|
-
name: operation.locationDetails?.name,
|
|
50
|
-
};
|
|
51
|
-
// Extract extra data from operation
|
|
52
|
-
// Note: Using safe property access since the exact API structure may vary
|
|
53
|
-
const extraData = {
|
|
54
|
-
acceptingOrders: operation?.status === 'ACTIVE' && !operation?.paused,
|
|
55
|
-
deliveryFee: operation?.fulfillment?.delivery?.fee?.amount ||
|
|
56
|
-
operation?.deliveryFee,
|
|
57
|
-
minOrderAmount: operation?.orderingRules?.minimumOrderValue?.amount ||
|
|
58
|
-
operation?.minOrderAmount,
|
|
59
|
-
freeDeliveryThreshold: operation?.fulfillment?.delivery?.freeDeliveryThreshold
|
|
60
|
-
?.amount || operation?.freeDeliveryThreshold,
|
|
61
|
-
taxRate: operation?.pricing?.taxRate || operation?.taxRate,
|
|
62
|
-
serviceCharge: operation?.pricing?.serviceCharge?.amount ||
|
|
63
|
-
operation?.serviceCharge,
|
|
64
|
-
isOnline: operation?.status === 'ACTIVE',
|
|
65
|
-
orderingDisabledReason: operation?.paused
|
|
66
|
-
? operation?.pauseReason
|
|
67
|
-
: undefined,
|
|
68
|
-
};
|
|
69
|
-
return children({
|
|
70
|
-
currentTime,
|
|
71
|
-
currentFulfillment,
|
|
72
|
-
selectedFulfillment,
|
|
73
|
-
currentLocation,
|
|
74
|
-
extraData,
|
|
75
|
-
isLoading,
|
|
76
|
-
error,
|
|
77
|
-
});
|
|
24
|
+
const [config, setConfig] = useState(fulfillmentsServiceConfig);
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
if (!fulfillmentsServiceConfig) {
|
|
27
|
+
loadFulfillmentsServiceConfig(service.operation?.get()).then((loadedConfig) => {
|
|
28
|
+
setConfig(loadedConfig);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}, [fulfillmentsServiceConfig]);
|
|
32
|
+
service.isLoading.set(!config);
|
|
33
|
+
if (!config) {
|
|
34
|
+
return children({ isLoading: !config });
|
|
35
|
+
}
|
|
36
|
+
return (_jsx(WixServices, { servicesMap: createServicesMap().addService(FulfillmentsServiceDefinition, FulfillmentsService, config), children: children({ isLoading: !config }) }));
|
|
78
37
|
};
|
|
79
38
|
/**
|
|
80
|
-
* Component that provides access to current
|
|
39
|
+
* Component that provides access to current time slot
|
|
81
40
|
*
|
|
82
41
|
* @example
|
|
83
42
|
* ```tsx
|
|
84
43
|
* <CoreSettings.CurrentTimeSlot>
|
|
85
|
-
* {({
|
|
44
|
+
* {({ timeSlot, hasDetails }) => (
|
|
86
45
|
* hasDetails ? (
|
|
87
46
|
* <div>
|
|
88
|
-
* <h3>{
|
|
47
|
+
* <h3>{timeSlot.dispatchType}</h3>
|
|
89
48
|
* </div>
|
|
90
49
|
* ) : (
|
|
91
|
-
* <div>No
|
|
50
|
+
* <div>No time slot selected</div>
|
|
92
51
|
* )
|
|
93
52
|
* )}
|
|
94
53
|
* </CoreSettings.CurrentTimeSlot>
|
|
95
54
|
* ```
|
|
96
55
|
*/
|
|
97
56
|
export const CurrentTimeSlot = ({ children, }) => {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
return children({
|
|
103
|
-
timeSlot: selectedFulfillment,
|
|
104
|
-
hasDetails,
|
|
105
|
-
});
|
|
106
|
-
} }));
|
|
57
|
+
const fulfillmentsService = useService(FulfillmentsServiceDefinition);
|
|
58
|
+
const selectedTimeSlot = fulfillmentsService.selectedTimeSlot?.get() ?? {};
|
|
59
|
+
const hasDetails = Boolean(fulfillmentsService.selectedTimeSlot?.get());
|
|
60
|
+
return children({ timeSlot: selectedTimeSlot, hasDetails });
|
|
107
61
|
};
|
|
108
62
|
/**
|
|
109
63
|
* Component that provides access to current fulfillment options
|
|
@@ -123,17 +77,18 @@ export const CurrentTimeSlot = ({ children, }) => {
|
|
|
123
77
|
* ```
|
|
124
78
|
*/
|
|
125
79
|
export const CurrentFulfillment = ({ children, }) => {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
80
|
+
const fulfillmentsService = useService(FulfillmentsServiceDefinition);
|
|
81
|
+
const currentFulfillment = {
|
|
82
|
+
current: fulfillmentsService.selectedTimeSlot?.get() ?? undefined,
|
|
83
|
+
};
|
|
84
|
+
const availableOptions = [];
|
|
85
|
+
// TODO: Add logic to determine available options from fulfillments
|
|
86
|
+
const hasFulfillment = availableOptions.length > 0;
|
|
87
|
+
return children({
|
|
88
|
+
fulfillment: currentFulfillment,
|
|
89
|
+
hasFulfillment,
|
|
90
|
+
availableOptions,
|
|
91
|
+
});
|
|
137
92
|
};
|
|
138
93
|
/**
|
|
139
94
|
* Component that provides access to current location data
|
|
@@ -141,26 +96,22 @@ export const CurrentFulfillment = ({ children, }) => {
|
|
|
141
96
|
* @example
|
|
142
97
|
* ```tsx
|
|
143
98
|
* <CoreSettings.CurrentLocation>
|
|
144
|
-
* {({ location,
|
|
99
|
+
* {({ location, hasLocation }) => (
|
|
145
100
|
* <div>
|
|
146
|
-
* <p>{location.
|
|
147
|
-
* {hasCoordinates && (
|
|
148
|
-
* <p>Coordinates: {location.latitude}, {location.longitude}</p>
|
|
149
|
-
* )}
|
|
101
|
+
* <p>{location.name}</p>
|
|
150
102
|
* </div>
|
|
151
103
|
* )}
|
|
152
104
|
* </CoreSettings.CurrentLocation>
|
|
153
105
|
* ```
|
|
154
106
|
*/
|
|
155
107
|
export const CurrentLocation = ({ children, }) => {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
} }));
|
|
108
|
+
const service = useService(OLOSettingsServiceDefinition);
|
|
109
|
+
const operation = service.operation?.get();
|
|
110
|
+
const currentLocation = {
|
|
111
|
+
name: operation?.locationDetails?.name || '',
|
|
112
|
+
};
|
|
113
|
+
const hasLocation = Boolean(currentLocation.name);
|
|
114
|
+
return children({ location: currentLocation, hasLocation });
|
|
164
115
|
};
|
|
165
116
|
/**
|
|
166
117
|
* Component that provides access to extra settings data
|
|
@@ -180,13 +131,32 @@ export const CurrentLocation = ({ children, }) => {
|
|
|
180
131
|
* ```
|
|
181
132
|
*/
|
|
182
133
|
export const ExtraData = ({ children }) => {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
134
|
+
const service = useService(OLOSettingsServiceDefinition);
|
|
135
|
+
const fulfillmentsService = useService(FulfillmentsServiceDefinition);
|
|
136
|
+
const operation = service.operation?.get();
|
|
137
|
+
const fulfillments = fulfillmentsService.fulfillments?.get();
|
|
138
|
+
const minOrderPrice = fulfillments && fulfillments.length > 0
|
|
139
|
+
? Math.min(...fulfillments
|
|
140
|
+
.map((f) => Number(f.minOrderPrice ?? 0))
|
|
141
|
+
.filter((x) => x !== undefined))
|
|
142
|
+
: undefined;
|
|
143
|
+
const extraData = {
|
|
144
|
+
acceptingOrders: operation?.status === 'ACTIVE' && !operation?.paused,
|
|
145
|
+
deliveryFee: operation?.fulfillment?.delivery?.fee?.amount ||
|
|
146
|
+
operation?.deliveryFee,
|
|
147
|
+
minOrderAmount: minOrderPrice,
|
|
148
|
+
freeDeliveryThreshold: operation?.fulfillment?.delivery?.freeDeliveryThreshold
|
|
149
|
+
?.amount || operation?.freeDeliveryThreshold,
|
|
150
|
+
taxRate: operation?.pricing?.taxRate || operation?.taxRate,
|
|
151
|
+
serviceCharge: operation?.pricing?.serviceCharge?.amount ||
|
|
152
|
+
operation?.serviceCharge,
|
|
153
|
+
isOnline: operation?.status === 'ACTIVE',
|
|
154
|
+
orderingDisabledReason: operation?.paused
|
|
155
|
+
? operation?.pauseReason
|
|
156
|
+
: undefined,
|
|
157
|
+
};
|
|
158
|
+
const hasExtraData = Boolean(extraData.deliveryFee !== undefined ||
|
|
159
|
+
extraData.minOrderAmount !== undefined ||
|
|
160
|
+
extraData.freeDeliveryThreshold !== undefined);
|
|
161
|
+
return children({ extraData, hasExtraData });
|
|
192
162
|
};
|
|
@@ -10,35 +10,38 @@ export const FulfillmentsService = implementService.withConfig()(FulfillmentsSer
|
|
|
10
10
|
throw new Error('Operation ID is required');
|
|
11
11
|
}
|
|
12
12
|
const signalsService = getService(SignalsServiceDefinition);
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
const
|
|
13
|
+
const timeSlotsMap = new Map(config.timeSlots?.map(processFulfillmentTimeSlotByOperationList) ?? []);
|
|
14
|
+
const fulfillments = signalsService.signal(config.fulfillments ?? []);
|
|
15
|
+
const timeSlots = signalsService.signal(
|
|
16
16
|
// @ts-expect-error - operation is not typed
|
|
17
|
-
|
|
17
|
+
timeSlotsMap.get(config.operation?.id ?? '') ?? []);
|
|
18
18
|
const isLoading = signalsService.signal(false);
|
|
19
19
|
const error = signalsService.signal(null);
|
|
20
|
-
const initialSelected =
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
|
|
20
|
+
const initialSelected = timeSlots.get()?.[0] ?? null;
|
|
21
|
+
const selectedTimeSlot = signalsService.signal(initialSelected);
|
|
22
|
+
selectedTimeSlot.set(initialSelected);
|
|
23
|
+
const setSelectedTimeSlot = (timeSlot) => {
|
|
24
|
+
selectedTimeSlot.set(timeSlot);
|
|
25
25
|
};
|
|
26
|
-
if (!config.
|
|
26
|
+
if (!config.timeSlots && config.operation) {
|
|
27
27
|
loadFulfillmentsServiceConfig(config.operation).then((config) => {
|
|
28
|
-
const
|
|
29
|
-
|
|
28
|
+
const timeSlotsMap = new Map(config.timeSlots?.map(processFulfillmentTimeSlotByOperationList) ??
|
|
29
|
+
[]);
|
|
30
|
+
timeSlots.set(
|
|
30
31
|
// @ts-expect-error - operation is not typed
|
|
31
|
-
|
|
32
|
-
const initialSelected =
|
|
33
|
-
|
|
32
|
+
timeSlotsMap.get(config.operation?.id ?? '') ?? []);
|
|
33
|
+
const initialSelected = timeSlots.get()?.[0] ?? null;
|
|
34
|
+
selectedTimeSlot.set(initialSelected);
|
|
35
|
+
fulfillments.set(config.fulfillments ?? []);
|
|
34
36
|
});
|
|
35
37
|
}
|
|
36
38
|
return {
|
|
39
|
+
timeSlots,
|
|
37
40
|
fulfillments,
|
|
38
|
-
|
|
41
|
+
selectedTimeSlot,
|
|
39
42
|
isLoading,
|
|
40
43
|
error,
|
|
41
|
-
|
|
44
|
+
setSelectedTimeSlot,
|
|
42
45
|
};
|
|
43
46
|
});
|
|
44
47
|
export const loadFulfillmentsServiceConfig = async (operation) => {
|
|
@@ -58,7 +61,8 @@ export const loadFulfillmentsServiceConfig = async (operation) => {
|
|
|
58
61
|
console.log('fulfillments', fulfillments.items);
|
|
59
62
|
// const fulfillmentsMap = new Map(fulfillments.timeSlotsPerOperation?.map(processFulfillmentTimeSlotByOperationList));
|
|
60
63
|
return {
|
|
61
|
-
|
|
64
|
+
timeSlots: timeSlots.timeSlotsPerOperation, //fulfillmentsMap.get(operationId) ?? [],
|
|
62
65
|
operation: operation,
|
|
66
|
+
fulfillments: fulfillments.items.filter((f) => f.enabled),
|
|
63
67
|
};
|
|
64
68
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as operationsSDK from '@wix/auto_sdk_restaurants_operations';
|
|
2
2
|
import { Signal } from '@wix/services-definitions/core-services/signals';
|
|
3
|
+
import * as fulfillemtMethodsSDK from '@wix/auto_sdk_restaurants_fulfillment-methods';
|
|
3
4
|
export declare enum DispatchType {
|
|
4
5
|
/** Pickup fulfillment */
|
|
5
6
|
PICKUP = "PICKUP",
|
|
@@ -21,13 +22,15 @@ export interface Fulfillment {
|
|
|
21
22
|
isAvailable: boolean;
|
|
22
23
|
}
|
|
23
24
|
export interface FulfillmentsServiceAPI {
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
timeSlots: Signal<TimeSlot[]>;
|
|
26
|
+
fulfillments: Signal<fulfillemtMethodsSDK.FulfillmentMethod[]>;
|
|
27
|
+
selectedTimeSlot: Signal<TimeSlot | null>;
|
|
26
28
|
isLoading: Signal<boolean>;
|
|
27
29
|
error: Signal<string | null>;
|
|
28
|
-
|
|
30
|
+
setSelectedTimeSlot: (timeSlot: TimeSlot) => void;
|
|
29
31
|
}
|
|
30
32
|
export interface FulfillmentsServiceConfig {
|
|
31
|
-
|
|
33
|
+
timeSlots?: operationsSDK.TimeSlotForOperation[];
|
|
32
34
|
operation?: operationsSDK.Operation;
|
|
35
|
+
fulfillments?: fulfillemtMethodsSDK.FulfillmentMethod[];
|
|
33
36
|
}
|
|
@@ -99,7 +99,7 @@ export interface AddToCartButtonProps {
|
|
|
99
99
|
asChild?: boolean;
|
|
100
100
|
className?: string;
|
|
101
101
|
addToCartLabelMap: Record<AddToCartButtonState, string>;
|
|
102
|
-
children
|
|
102
|
+
children?: AsChildChildren<{
|
|
103
103
|
lineItem: LineItem;
|
|
104
104
|
buttonState: AddToCartButtonState;
|
|
105
105
|
addToCartButtonDisabled?: boolean;
|
|
@@ -109,7 +109,7 @@ export interface AddToCartButtonProps {
|
|
|
109
109
|
label: React.ReactNode;
|
|
110
110
|
formattedPrice: string;
|
|
111
111
|
modifierGroupHasError: boolean;
|
|
112
|
-
}
|
|
112
|
+
}>;
|
|
113
113
|
}
|
|
114
114
|
export declare const AddToCartButton: React.ForwardRefExoticComponent<AddToCartButtonProps & React.RefAttributes<HTMLElement>>;
|
|
115
115
|
export interface ItemDetailsQuantityProps {
|
|
@@ -50,15 +50,7 @@ export const AddToCartButton = React.forwardRef(({ asChild, children, className,
|
|
|
50
50
|
label,
|
|
51
51
|
formattedPrice,
|
|
52
52
|
modifierGroupHasError,
|
|
53
|
-
}, ref: ref, ...props, children: _jsx(Commerce.Actions.AddToCart, { asChild: false, label: label, className: className, lineItems: [lineItem], ...props
|
|
54
|
-
lineItem,
|
|
55
|
-
buttonState,
|
|
56
|
-
addToCartButtonDisabled,
|
|
57
|
-
loadingState,
|
|
58
|
-
label,
|
|
59
|
-
formattedPrice,
|
|
60
|
-
modifierGroupHasError,
|
|
61
|
-
}) }) }));
|
|
53
|
+
}, ref: ref, ...props, children: _jsx(Commerce.Actions.AddToCart, { asChild: false, label: label, className: className, lineItems: [lineItem], ...props }) }));
|
|
62
54
|
} }));
|
|
63
55
|
});
|
|
64
56
|
AddToCartButton.displayName = 'AddToCartButton';
|
package/dist/react/OLO.d.ts
CHANGED
|
@@ -2,8 +2,6 @@ import React from 'react';
|
|
|
2
2
|
import { ItemServiceConfig } from '../services/item-details-service.js';
|
|
3
3
|
import { OLOSettingsServiceConfig } from '../services/olo-settings-service.js';
|
|
4
4
|
interface OLORootProps {
|
|
5
|
-
/** The ID of the item to load */
|
|
6
|
-
itemId?: string;
|
|
7
5
|
/** Pre-loaded item service config (optional) */
|
|
8
6
|
itemServiceConfig?: ItemServiceConfig;
|
|
9
7
|
/** Pre-loaded OLO settings service config (optional) */
|
package/dist/react/OLO.js
CHANGED
|
@@ -20,12 +20,12 @@ import { CoreOLO } from './core/index.js';
|
|
|
20
20
|
* </OLO.Root>
|
|
21
21
|
* ```
|
|
22
22
|
*/
|
|
23
|
-
export const Root = ({
|
|
23
|
+
export const Root = ({ oloSettingsServiceConfig, children, }) => {
|
|
24
24
|
const [retryKey] = React.useState(0);
|
|
25
25
|
// const retry = React.useCallback(() => {
|
|
26
26
|
// setRetryKey(prev => prev + 1);
|
|
27
27
|
// }, []);
|
|
28
|
-
return (_jsx(CoreOLO.Root, {
|
|
28
|
+
return (_jsx(CoreOLO.Root, { oloSettingsServiceConfig: oloSettingsServiceConfig, children: children }, retryKey));
|
|
29
29
|
};
|
|
30
30
|
/**
|
|
31
31
|
* Convenience provider that handles loading and error states automatically
|
|
@@ -41,7 +41,7 @@ export const Root = ({ itemId, oloSettingsServiceConfig, children, }) => {
|
|
|
41
41
|
* </OLO.Provider>
|
|
42
42
|
* ```
|
|
43
43
|
*/
|
|
44
|
-
export const Provider = ({
|
|
44
|
+
export const Provider = ({ configs,
|
|
45
45
|
// loading = (
|
|
46
46
|
// <div className="flex items-center justify-center p-8">
|
|
47
47
|
// <div className="text-secondary-foreground">Loading services...</div>
|
|
@@ -59,7 +59,7 @@ export const Provider = ({ itemId, configs,
|
|
|
59
59
|
// </div>
|
|
60
60
|
// ),
|
|
61
61
|
children, }) => {
|
|
62
|
-
return
|
|
62
|
+
return _jsx(Root, { itemServiceConfig: configs?.itemServiceConfig, children: children });
|
|
63
63
|
};
|
|
64
64
|
/**
|
|
65
65
|
* Specialized headless component for item details
|
|
@@ -120,8 +120,8 @@ export const Cart = ({ loading, error, children }) => {
|
|
|
120
120
|
* </OLO.ServicesStatus>
|
|
121
121
|
* ```
|
|
122
122
|
*/
|
|
123
|
-
export const ServicesStatus = ({
|
|
124
|
-
return (_jsx(Root, {
|
|
123
|
+
export const ServicesStatus = ({ children, }) => {
|
|
124
|
+
return (_jsx(Root, { children: children }));
|
|
125
125
|
};
|
|
126
126
|
export const Menus = ({
|
|
127
127
|
// menuServiceConfig,
|
package/dist/react/Settings.d.ts
CHANGED
|
@@ -1,31 +1,33 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { FulfillmentsServiceConfig } from '../types/fulfillments-types.js';
|
|
2
3
|
import { AsChildChildren } from '@wix/headless-utils/react';
|
|
4
|
+
/**
|
|
5
|
+
* Props for the Settings Root component
|
|
6
|
+
*/
|
|
7
|
+
export interface RootProps {
|
|
8
|
+
/** Child components that will have access to the settings context */
|
|
9
|
+
children: (props: {
|
|
10
|
+
isLoading: boolean;
|
|
11
|
+
}) => React.ReactNode;
|
|
12
|
+
/** Optional pre-loaded fulfillments service configuration */
|
|
13
|
+
fulfillmentsServiceConfig?: FulfillmentsServiceConfig;
|
|
14
|
+
}
|
|
3
15
|
/**
|
|
4
16
|
* Root headless component for OLO Settings
|
|
5
|
-
* Provides
|
|
17
|
+
* Provides service context for settings components
|
|
6
18
|
*
|
|
7
19
|
* @example
|
|
8
20
|
* ```tsx
|
|
9
|
-
* <Settings.Root>
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* <div>
|
|
13
|
-
* )
|
|
14
|
-
*
|
|
15
|
-
* ) : (
|
|
16
|
-
* <div>
|
|
17
|
-
* <h2>{currentDetails.name}</h2>
|
|
18
|
-
* <p>{currentDetails.address}</p>
|
|
19
|
-
* <p>Accepting Orders: {extraData.acceptingOrders ? 'Yes' : 'No'}</p>
|
|
20
|
-
* <p>Delivery Fee: ${extraData.deliveryFee}</p>
|
|
21
|
-
* <p>Min Order: ${extraData.minOrderAmount}</p>
|
|
22
|
-
* <p>Free Delivery: ${extraData.freeDeliveryThreshold}</p>
|
|
23
|
-
* </div>
|
|
24
|
-
* )
|
|
25
|
-
* )}
|
|
21
|
+
* <Settings.Root fulfillmentsServiceConfig={config}>
|
|
22
|
+
* <Settings.CurrentTimeSlot>
|
|
23
|
+
* {({ timeSlot, hasDetails }) => (
|
|
24
|
+
* <div>{timeSlot?.dispatchType}</div>
|
|
25
|
+
* )}
|
|
26
|
+
* </Settings.CurrentTimeSlot>
|
|
26
27
|
* </Settings.Root>
|
|
27
28
|
* ```
|
|
28
29
|
*/
|
|
30
|
+
export declare const Root: React.FC<RootProps>;
|
|
29
31
|
interface CurrentTimeSlotProps {
|
|
30
32
|
/** Children render prop that receives the current details */
|
|
31
33
|
children?: AsChildChildren<{
|
|
@@ -114,9 +116,10 @@ interface CurrentLocationProps {
|
|
|
114
116
|
* ```
|
|
115
117
|
*/
|
|
116
118
|
export declare const CurrentLocation: React.FC<CurrentLocationProps>;
|
|
117
|
-
interface ExtraDataProps {
|
|
119
|
+
interface ExtraDataProps extends Omit<React.ComponentPropsWithoutRef<'div'>, 'children'> {
|
|
120
|
+
asChild?: boolean;
|
|
118
121
|
/** Children render prop that receives the extra settings data */
|
|
119
|
-
children
|
|
122
|
+
children?: AsChildChildren<{
|
|
120
123
|
extraData: {
|
|
121
124
|
acceptingOrders: boolean;
|
|
122
125
|
deliveryFee?: number;
|
|
@@ -128,7 +131,7 @@ interface ExtraDataProps {
|
|
|
128
131
|
orderingDisabledReason?: string;
|
|
129
132
|
};
|
|
130
133
|
hasExtraData: boolean;
|
|
131
|
-
}
|
|
134
|
+
}> | React.ReactNode;
|
|
132
135
|
}
|
|
133
136
|
/**
|
|
134
137
|
* Headless component for extra settings data
|
package/dist/react/Settings.js
CHANGED
|
@@ -1,8 +1,38 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { CoreSettings } from './core/index.js';
|
|
4
|
-
// import { OLOSettingsServiceConfig } from '../services/olo-settings-service.js';
|
|
5
4
|
import { AsChildSlot } from '@wix/headless-utils/react';
|
|
5
|
+
// ========================================
|
|
6
|
+
// OLO SETTINGS HEADLESS COMPONENTS
|
|
7
|
+
// ========================================
|
|
8
|
+
// Headless components that wrap CoreSettings and provide convenient service management
|
|
9
|
+
// These components handle service initialization and provide render props for UI
|
|
10
|
+
// ========================================
|
|
11
|
+
// ROOT COMPONENT
|
|
12
|
+
// ========================================
|
|
13
|
+
var TestIds;
|
|
14
|
+
(function (TestIds) {
|
|
15
|
+
TestIds["settingsRoot"] = "settings-root";
|
|
16
|
+
})(TestIds || (TestIds = {}));
|
|
17
|
+
/**
|
|
18
|
+
* Root headless component for OLO Settings
|
|
19
|
+
* Provides service context for settings components
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```tsx
|
|
23
|
+
* <Settings.Root fulfillmentsServiceConfig={config}>
|
|
24
|
+
* <Settings.CurrentTimeSlot>
|
|
25
|
+
* {({ timeSlot, hasDetails }) => (
|
|
26
|
+
* <div>{timeSlot?.dispatchType}</div>
|
|
27
|
+
* )}
|
|
28
|
+
* </Settings.CurrentTimeSlot>
|
|
29
|
+
* </Settings.Root>
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export const Root = ({ children, fulfillmentsServiceConfig, }) => {
|
|
33
|
+
return (_jsx(CoreSettings.Root, { fulfillmentsServiceConfig: fulfillmentsServiceConfig, "data-testid": TestIds.settingsRoot, children: ({ isLoading }) => children({ isLoading }) }));
|
|
34
|
+
};
|
|
35
|
+
Root.displayName = 'Settings.Root';
|
|
6
36
|
/**
|
|
7
37
|
* Headless component for current store details
|
|
8
38
|
* Provides access to store name, address, contact info, and hours
|
|
@@ -89,6 +119,6 @@ export const CurrentLocation = ({ children, className, asChild, }) => {
|
|
|
89
119
|
* </Settings.ExtraData>
|
|
90
120
|
* ```
|
|
91
121
|
*/
|
|
92
|
-
export const ExtraData = ({ children }) => {
|
|
93
|
-
return _jsx(CoreSettings.ExtraData, { children: children });
|
|
122
|
+
export const ExtraData = ({ children, asChild, className, ...rest }) => {
|
|
123
|
+
return (_jsx(CoreSettings.ExtraData, { children: ({ extraData, hasExtraData }) => (_jsx(AsChildSlot, { asChild: asChild, className: className, customElement: children, customElementProps: { extraData, hasExtraData }, content: hasExtraData ? (_jsx("div", { children: extraData.acceptingOrders ? 'Accepting Orders' : 'Closed' })) : null, ...rest, children: hasExtraData ? (_jsx("div", { children: extraData.acceptingOrders ? 'Accepting Orders' : 'Closed' })) : null })) }));
|
|
94
124
|
};
|
package/dist/react/core/OLO.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import React from 'react';
|
|
|
2
2
|
import { OLOSettingsServiceConfig } from '../../services/olo-settings-service.js';
|
|
3
3
|
import { ItemServiceConfig } from '../../services/item-details-service.js';
|
|
4
4
|
interface CoreOLORootProps {
|
|
5
|
-
/** The ID of the item to load */
|
|
6
5
|
itemId?: string;
|
|
7
6
|
/** Pre-loaded item service config (optional) */
|
|
8
7
|
itemServiceConfig?: ItemServiceConfig;
|