@wix/headless-restaurants-olo 0.0.14 → 0.0.15

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.
Files changed (65) hide show
  1. package/cjs/dist/mappers/operation-mapper.d.ts +3 -0
  2. package/cjs/dist/mappers/operation-mapper.js +95 -0
  3. package/cjs/dist/react/ItemDetails.d.ts +0 -31
  4. package/cjs/dist/react/ItemDetails.js +2 -23
  5. package/cjs/dist/react/OLO.d.ts +3 -2
  6. package/cjs/dist/react/OLOMenus.d.ts +20 -0
  7. package/cjs/dist/react/OLOMenus.js +22 -0
  8. package/cjs/dist/react/Settings.d.ts +160 -0
  9. package/cjs/dist/react/Settings.js +94 -0
  10. package/cjs/dist/react/core/ItemDetails.js +3 -1
  11. package/cjs/dist/react/core/OLO.js +16 -2
  12. package/cjs/dist/react/core/OLOMenus.d.ts +7 -0
  13. package/cjs/dist/react/core/OLOMenus.js +12 -0
  14. package/cjs/dist/react/core/Settings.d.ts +157 -0
  15. package/cjs/dist/react/core/Settings.js +192 -0
  16. package/cjs/dist/react/core/index.d.ts +1 -0
  17. package/cjs/dist/react/core/index.js +1 -0
  18. package/cjs/dist/react/index.d.ts +2 -0
  19. package/cjs/dist/react/index.js +2 -0
  20. package/cjs/dist/services/fulfillments-service.d.ts +13 -0
  21. package/cjs/dist/services/fulfillments-service.js +64 -0
  22. package/cjs/dist/services/index.d.ts +1 -0
  23. package/cjs/dist/services/index.js +1 -0
  24. package/cjs/dist/services/item-details-service.js +1 -1
  25. package/cjs/dist/services/olo-settings-service.d.ts +14 -8
  26. package/cjs/dist/services/olo-settings-service.js +24 -5
  27. package/cjs/dist/types/fulfillments-types.d.ts +33 -0
  28. package/cjs/dist/types/fulfillments-types.js +7 -0
  29. package/cjs/dist/types/operation.d.ts +57 -0
  30. package/cjs/dist/types/operation.js +1 -0
  31. package/cjs/dist/utils/fulfillments-utils.d.ts +23 -0
  32. package/cjs/dist/utils/fulfillments-utils.js +144 -0
  33. package/dist/mappers/operation-mapper.d.ts +3 -0
  34. package/dist/mappers/operation-mapper.js +95 -0
  35. package/dist/react/ItemDetails.d.ts +0 -31
  36. package/dist/react/ItemDetails.js +2 -23
  37. package/dist/react/OLO.d.ts +3 -2
  38. package/dist/react/OLOMenus.d.ts +20 -0
  39. package/dist/react/OLOMenus.js +22 -0
  40. package/dist/react/Settings.d.ts +160 -0
  41. package/dist/react/Settings.js +94 -0
  42. package/dist/react/core/ItemDetails.js +3 -1
  43. package/dist/react/core/OLO.js +16 -2
  44. package/dist/react/core/OLOMenus.d.ts +7 -0
  45. package/dist/react/core/OLOMenus.js +12 -0
  46. package/dist/react/core/Settings.d.ts +157 -0
  47. package/dist/react/core/Settings.js +192 -0
  48. package/dist/react/core/index.d.ts +1 -0
  49. package/dist/react/core/index.js +1 -0
  50. package/dist/react/index.d.ts +2 -0
  51. package/dist/react/index.js +2 -0
  52. package/dist/services/fulfillments-service.d.ts +13 -0
  53. package/dist/services/fulfillments-service.js +64 -0
  54. package/dist/services/index.d.ts +1 -0
  55. package/dist/services/index.js +1 -0
  56. package/dist/services/item-details-service.js +1 -1
  57. package/dist/services/olo-settings-service.d.ts +14 -8
  58. package/dist/services/olo-settings-service.js +24 -5
  59. package/dist/types/fulfillments-types.d.ts +33 -0
  60. package/dist/types/fulfillments-types.js +7 -0
  61. package/dist/types/operation.d.ts +57 -0
  62. package/dist/types/operation.js +1 -0
  63. package/dist/utils/fulfillments-utils.d.ts +23 -0
  64. package/dist/utils/fulfillments-utils.js +144 -0
  65. package/package.json +2 -2
@@ -0,0 +1,3 @@
1
+ import * as operationsSDK from '@wix/auto_sdk_restaurants_operations';
2
+ import { Operation } from '../types/operation.js';
3
+ export declare const OperationMapper: (operation: operationsSDK.Operation) => Operation;
@@ -0,0 +1,95 @@
1
+ import * as operationsSDK from '@wix/auto_sdk_restaurants_operations';
2
+ import { DispatchType } from '../types/fulfillments-types.js';
3
+ const TIME_UNIT_MULTIPLIER = {
4
+ MINUTES: 1,
5
+ UNKNOWN_TIME_UNIT: 0,
6
+ DAYS: 24 * 60,
7
+ HOURS: 60,
8
+ };
9
+ const getAsapOptionsFromOperation = (operation) => {
10
+ if (!operation.orderScheduling?.asapOptions) {
11
+ return;
12
+ }
13
+ const { timeRangeOptions, maxTimeOptions } = operation.orderScheduling.asapOptions.preparationTime || {};
14
+ if (maxTimeOptions &&
15
+ maxTimeOptions.duration !== null &&
16
+ maxTimeOptions.duration !== undefined &&
17
+ maxTimeOptions.timeUnit) {
18
+ return {
19
+ maxInMinutes: maxTimeOptions.duration * TIME_UNIT_MULTIPLIER[maxTimeOptions.timeUnit],
20
+ };
21
+ }
22
+ if (timeRangeOptions &&
23
+ timeRangeOptions.timeUnit &&
24
+ timeRangeOptions.maxDuration !== undefined &&
25
+ timeRangeOptions.maxDuration !== null &&
26
+ timeRangeOptions.minDuration !== undefined &&
27
+ timeRangeOptions.minDuration !== null) {
28
+ return {
29
+ rangeInMinutes: {
30
+ min: timeRangeOptions.minDuration *
31
+ TIME_UNIT_MULTIPLIER[timeRangeOptions.timeUnit],
32
+ max: timeRangeOptions.maxDuration *
33
+ TIME_UNIT_MULTIPLIER[timeRangeOptions.timeUnit],
34
+ },
35
+ };
36
+ }
37
+ };
38
+ function getPreOrderOptions(operation) {
39
+ if (!operation.orderScheduling?.preorderOptions) {
40
+ return;
41
+ }
42
+ const timeBoundedOptions = operation.orderScheduling?.preorderOptions?.method?.timeBoundedOptions;
43
+ if (!timeBoundedOptions) {
44
+ return;
45
+ }
46
+ const { maxTimeInAdvance, minTimeInAdvance } = timeBoundedOptions;
47
+ const max = TIME_UNIT_MULTIPLIER[maxTimeInAdvance?.timeUnit] *
48
+ maxTimeInAdvance?.duration;
49
+ const min = TIME_UNIT_MULTIPLIER[minTimeInAdvance?.timeUnit] *
50
+ minTimeInAdvance?.duration;
51
+ const timeWindowsOptions = operation.orderScheduling?.preorderOptions?.fulfillmentTimesDisplay
52
+ ?.timeWindowsOptions;
53
+ const timeWindowDuration = TIME_UNIT_MULTIPLIER[timeWindowsOptions.timeUnit] *
54
+ timeWindowsOptions.duration;
55
+ return {
56
+ timeInAdvance: { min, max },
57
+ timeWindowDuration,
58
+ };
59
+ }
60
+ function getOperationType(operation) {
61
+ switch (operation.orderScheduling?.type) {
62
+ case operationsSDK.SchedulingType.PREORDER:
63
+ return 'PRE_ORDER';
64
+ case operationsSDK.SchedulingType.ASAP:
65
+ default:
66
+ return 'ASAP';
67
+ }
68
+ }
69
+ export const OperationMapper = (operation) => {
70
+ const { asapFutureHandlingType, businessDaysAheadHandlingOptions } = operation.orderScheduling?.asapOptions || {};
71
+ const { daysCount } = businessDaysAheadHandlingOptions || {};
72
+ const allowAsapFutureHandling = asapFutureHandlingType ===
73
+ operationsSDK.AsapFutureHandlingType.BUSINESS_DAYS_AHEAD_HANDLING &&
74
+ Number(daysCount) >= 0;
75
+ return {
76
+ id: operation._id || '',
77
+ name: operation.name || '',
78
+ // @ts-expect-error - operation is not typed
79
+ enabled: !!operation.enabled,
80
+ fulfillmentIds: operation.fulfillmentIds || [],
81
+ asapOptions: getAsapOptionsFromOperation(operation),
82
+ preOrderOptions: getPreOrderOptions(operation),
83
+ operationType: getOperationType(operation),
84
+ allowAsapFutureHandling,
85
+ businessDaysAheadHandlingOptions: daysCount ?? undefined,
86
+ defaultDispatchType: operation.defaultFulfillmentType ===
87
+ operationsSDK.FulfillmentType.DELIVERY
88
+ ? DispatchType.DELIVERY
89
+ : DispatchType.PICKUP,
90
+ operationGroupId: operation.operationGroupId || '',
91
+ locationId: operation.businessLocationId || '',
92
+ // @ts-expect-error - operation is not typed
93
+ locationDetails: operation.businessLocationDetails,
94
+ };
95
+ };
@@ -1,6 +1,5 @@
1
1
  import React from 'react';
2
2
  import { Commerce } from '@wix/ecom/components';
3
- import { type LineItem } from '@wix/ecom/services';
4
3
  import { type AsChildChildren } from '@wix/headless-utils/react';
5
4
  import { ItemServiceConfig } from '../services/item-details-service.js';
6
5
  import { EnhancedModifier, EnhancedModifierGroup, EnhancedVariant } from '@wix/headless-restaurants-menus/services';
@@ -180,35 +179,6 @@ export interface ItemDetailsVariantsProps {
180
179
  variantPriceClassName?: string;
181
180
  }
182
181
  export declare const Variants: React.ForwardRefExoticComponent<ItemDetailsVariantsProps & React.RefAttributes<HTMLElement>>;
183
- export interface AddToCartActionProps {
184
- /** Whether to render as a child component */
185
- asChild?: boolean;
186
- /** Text label for the button */
187
- label: string;
188
- /** Custom render function when using asChild */
189
- lineItems: LineItem[];
190
- /** CSS classes to apply to the button */
191
- className?: string;
192
- /** Content to display when loading */
193
- loadingState?: string | React.ReactNode;
194
- children?: React.ReactNode;
195
- }
196
- /**
197
- * Add to Cart button for the menu item.
198
- * Triggers the action to add the selected item (and its modifiers/variants) to the cart.
199
- *
200
- * @component
201
- * @example
202
- * ```tsx
203
- * <ItemDetails>
204
- * <AddToCart
205
- * label="Add to Cart"
206
- * lineItems={[{ catalogReference: { ... }, quantity: 1 }]}
207
- * />
208
- * </ItemDetails>
209
- * ```
210
- */
211
- export declare const AddToCart: React.ForwardRefExoticComponent<AddToCartActionProps & React.RefAttributes<HTMLButtonElement>>;
212
182
  /**
213
183
  * Multi-line text input component for special requests or instructions.
214
184
  * Provides a textarea for customers to add custom notes or modifications.
@@ -256,7 +226,6 @@ export interface AddToCartButtonProps extends Omit<React.ComponentPropsWithoutRe
256
226
  children?: React.ReactNode;
257
227
  className?: string;
258
228
  label?: string;
259
- onClick?: () => void;
260
229
  }
261
230
  export interface ItemDetailsQuantityProps {
262
231
  children: React.ReactNode;
@@ -89,29 +89,8 @@ export const Variants = React.forwardRef(({ children, className, asChild, varian
89
89
  } }));
90
90
  });
91
91
  Variants.displayName = 'ItemDetails.Variants';
92
- /**
93
- * Add to Cart button for the menu item.
94
- * Triggers the action to add the selected item (and its modifiers/variants) to the cart.
95
- *
96
- * @component
97
- * @example
98
- * ```tsx
99
- * <ItemDetails>
100
- * <AddToCart
101
- * label="Add to Cart"
102
- * lineItems={[{ catalogReference: { ... }, quantity: 1 }]}
103
- * />
104
- * </ItemDetails>
105
- * ```
106
- */
107
- export const AddToCart = React.forwardRef(({ lineItems, className, label, ...props }, ref) => {
108
- return (_jsx(Commerce.Actions.AddToCart, { ref: ref, asChild: false, label: label, className: className, lineItems: lineItems, children: props.children }));
109
- });
110
- AddToCart.displayName = 'AddToCart';
111
- export const AddToCartButton = ({ asChild = false, children, className, onClick, label = 'Add to cart', ...props }) => {
112
- return (_jsx(CoreItemDetails.LineItemComponent, { children: ({ lineItem }) => (_jsx(AsChildSlot, { asChild: asChild, className: className, customElement: children, customElementProps: {
113
- onClick,
114
- }, children: _jsx(Commerce.Actions.AddToCart, { asChild: false, label: label, className: className, lineItems: [lineItem], ...props, children: children }) })) }));
92
+ export const AddToCartButton = ({ asChild, children, className, label = 'Add to cart', ...props }) => {
93
+ return (_jsx(CoreItemDetails.LineItemComponent, { children: ({ lineItem }) => (_jsx(Commerce.Actions.AddToCart, { asChild: asChild, label: label, className: className, lineItems: [lineItem], ...props, children: children })) }));
115
94
  };
116
95
  export const Quantity = ({ children }) => {
117
96
  return (_jsx(CoreItemDetails.QuantityComponent, { children: ({ quantity, onValueChange, }) => (_jsx(QuantityComponent.Root, { onValueChange: onValueChange, initialValue: quantity, children: children })) }));
@@ -1,12 +1,13 @@
1
1
  import React from 'react';
2
2
  import { ItemServiceConfig } from '../services/item-details-service.js';
3
+ import { OLOSettingsServiceConfig } from '../services/olo-settings-service.js';
3
4
  interface OLORootProps {
4
5
  /** The ID of the item to load */
5
6
  itemId?: string;
6
7
  /** Pre-loaded item service config (optional) */
7
- itemServiceConfig?: any;
8
+ itemServiceConfig?: ItemServiceConfig;
8
9
  /** Pre-loaded OLO settings service config (optional) */
9
- oloSettingsServiceConfig?: any;
10
+ oloSettingsServiceConfig?: OLOSettingsServiceConfig;
10
11
  /** Children render prop that receives the service state */
11
12
  children: React.ReactNode;
12
13
  }
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+ import { type MenusServiceConfig } from '@wix/headless-restaurants-menus/services';
3
+ declare enum TestIds {
4
+ menusRoot = "menus-root"
5
+ }
6
+ /**
7
+ * Menus.Root
8
+ * Container for the menus context and data loading.
9
+ * Does not render if there are no menus.
10
+ */
11
+ export interface MenusRootProps {
12
+ children: React.ReactNode;
13
+ config: MenusServiceConfig;
14
+ }
15
+ export declare const Root: React.ForwardRefExoticComponent<MenusRootProps & React.RefAttributes<HTMLElement>>;
16
+ export declare const OLOMenus: {
17
+ Root: React.ForwardRefExoticComponent<MenusRootProps & React.RefAttributes<HTMLElement>>;
18
+ TestIds: typeof TestIds;
19
+ };
20
+ export {};
@@ -0,0 +1,22 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import React from 'react';
3
+ import { Menus } from '@wix/headless-restaurants-menus/react';
4
+ import * as CoreOLOMenus from './core/OLOMenus.js';
5
+ // =======================
6
+ // TestIds Enum
7
+ // =======================
8
+ var TestIds;
9
+ (function (TestIds) {
10
+ // Container Level
11
+ TestIds["menusRoot"] = "menus-root";
12
+ })(TestIds || (TestIds = {}));
13
+ export const Root = React.forwardRef((props) => {
14
+ const { children, config } = props;
15
+ return (_jsx(CoreOLOMenus.Root, { "data-testid": TestIds.menusRoot, config: config, children: (updatedConfig) => (_jsx(Menus.Root, { "data-testid": TestIds.menusRoot, config: updatedConfig, children: children })) }));
16
+ });
17
+ Root.displayName = 'Menus.Root';
18
+ // Compose Menus namespace
19
+ export const OLOMenus = {
20
+ Root,
21
+ TestIds,
22
+ };
@@ -0,0 +1,160 @@
1
+ import React from 'react';
2
+ import { AsChildChildren } from '@wix/headless-utils/react';
3
+ /**
4
+ * Root headless component for OLO Settings
5
+ * Provides access to current details, fulfillment options, location, and extra data
6
+ *
7
+ * @example
8
+ * ```tsx
9
+ * <Settings.Root>
10
+ * {({ currentDetails, currentFulfillment, currentLocation, extraData, isLoading, error }) => (
11
+ * isLoading ? (
12
+ * <div>Loading settings...</div>
13
+ * ) : error ? (
14
+ * <div>Error: {error}</div>
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
+ * )}
26
+ * </Settings.Root>
27
+ * ```
28
+ */
29
+ interface CurrentTimeSlotProps {
30
+ /** Children render prop that receives the current details */
31
+ children?: AsChildChildren<{
32
+ timeSlot: string;
33
+ }>;
34
+ /** CSS classes to apply to the default element */
35
+ className?: string;
36
+ /** Whether to render as a child component */
37
+ asChild?: boolean;
38
+ }
39
+ /**
40
+ * Headless component for current store details
41
+ * Provides access to store name, address, contact info, and hours
42
+ *
43
+ * @example
44
+ * ```tsx
45
+ * <Settings.CurrentTimeSlot>
46
+ * {({ details, hasDetails }) => (
47
+ * hasDetails ? (
48
+ * <div>
49
+ * <h3>{details.name}</h3>
50
+ * <p>{details.address}</p>
51
+ * <p>{details.phone}</p>
52
+ * <p>{details.email}</p>
53
+ * </div>
54
+ * ) : (
55
+ * <div>No store details available</div>
56
+ * )
57
+ * )}
58
+ * </Settings.CurrentTimeSlot>
59
+ * ```
60
+ */
61
+ export declare const CurrentTimeSlot: React.ForwardRefExoticComponent<CurrentTimeSlotProps & React.RefAttributes<HTMLElement>>;
62
+ /**
63
+ * Headless component for current fulfillment options
64
+ * Provides access to pickup, delivery, and dine-in options
65
+ *
66
+ * @example
67
+ * ```tsx
68
+ * <Settings.CurrentFulfillment>
69
+ * {({ fulfillment, availableOptions }) => (
70
+ * <div>
71
+ * <h3>Available Options:</h3>
72
+ * {availableOptions.map(option => (
73
+ * <div key={option}>
74
+ * {option}: {fulfillment[option]?.enabled ? 'Available' : 'Unavailable'}
75
+ * {fulfillment[option]?.estimatedTime && (
76
+ * <span> - {fulfillment[option].estimatedTime} mins</span>
77
+ * )}
78
+ * </div>
79
+ * ))}
80
+ * </div>
81
+ * )}
82
+ * </Settings.CurrentFulfillment>
83
+ * ```
84
+ */
85
+ interface CurrentLocationProps {
86
+ /** Whether to render as a child component */
87
+ asChild?: boolean;
88
+ /** CSS classes to apply to the default element */
89
+ className?: string;
90
+ /** Children render prop that receives the location data */
91
+ children?: AsChildChildren<{
92
+ currentLocation: {
93
+ name: string;
94
+ };
95
+ hasLocation: boolean;
96
+ }>;
97
+ }
98
+ /**
99
+ * Headless component for current location data
100
+ * Provides access to store location and coordinates
101
+ *
102
+ * @example
103
+ * ```tsx
104
+ * <Settings.CurrentLocation>
105
+ * {({ location, hasLocation }) => (
106
+ * <div>
107
+ * <p>{currentLocation.name}</p>
108
+ * {hasLocation && (
109
+ * <p>Coordinates: {location.latitude}, {location.longitude}</p>
110
+ * )}
111
+ * </div>
112
+ * )}
113
+ * </Settings.CurrentLocation>
114
+ * ```
115
+ */
116
+ export declare const CurrentLocation: React.FC<CurrentLocationProps>;
117
+ interface ExtraDataProps {
118
+ /** Children render prop that receives the extra settings data */
119
+ children: (props: {
120
+ extraData: {
121
+ acceptingOrders: boolean;
122
+ deliveryFee?: number;
123
+ minOrderAmount?: number;
124
+ freeDeliveryThreshold?: number;
125
+ taxRate?: number;
126
+ serviceCharge?: number;
127
+ isOnline?: boolean;
128
+ orderingDisabledReason?: string;
129
+ };
130
+ hasExtraData: boolean;
131
+ }) => React.ReactNode;
132
+ }
133
+ /**
134
+ * Headless component for extra settings data
135
+ * Provides access to ordering status, fees, and thresholds
136
+ *
137
+ * @example
138
+ * ```tsx
139
+ * <Settings.ExtraData>
140
+ * {({ extraData, hasExtraData }) => (
141
+ * hasExtraData ? (
142
+ * <div>
143
+ * <p>Status: {extraData.acceptingOrders ? 'Open' : 'Closed'}</p>
144
+ * {extraData.orderingDisabledReason && (
145
+ * <p>Reason: {extraData.orderingDisabledReason}</p>
146
+ * )}
147
+ * <p>Delivery Fee: ${extraData.deliveryFee}</p>
148
+ * <p>Min Order: ${extraData.minOrderAmount}</p>
149
+ * <p>Free Delivery: ${extraData.freeDeliveryThreshold}</p>
150
+ * <p>Tax Rate: {extraData.taxRate}%</p>
151
+ * </div>
152
+ * ) : (
153
+ * <div>No additional settings available</div>
154
+ * )
155
+ * )}
156
+ * </Settings.ExtraData>
157
+ * ```
158
+ */
159
+ export declare const ExtraData: React.FC<ExtraDataProps>;
160
+ export {};
@@ -0,0 +1,94 @@
1
+ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
+ import React from 'react';
3
+ import { CoreSettings } from './core/index.js';
4
+ // import { OLOSettingsServiceConfig } from '../services/olo-settings-service.js';
5
+ import { AsChildSlot } from '@wix/headless-utils/react';
6
+ /**
7
+ * Headless component for current store details
8
+ * Provides access to store name, address, contact info, and hours
9
+ *
10
+ * @example
11
+ * ```tsx
12
+ * <Settings.CurrentTimeSlot>
13
+ * {({ details, hasDetails }) => (
14
+ * hasDetails ? (
15
+ * <div>
16
+ * <h3>{details.name}</h3>
17
+ * <p>{details.address}</p>
18
+ * <p>{details.phone}</p>
19
+ * <p>{details.email}</p>
20
+ * </div>
21
+ * ) : (
22
+ * <div>No store details available</div>
23
+ * )
24
+ * )}
25
+ * </Settings.CurrentTimeSlot>
26
+ * ```
27
+ */
28
+ // export const CurrentTimeSlot2: React.FC<CurrentTimeSlotProps> = ({ children }) => {
29
+ // return <CoreSettings.CurrentTimeSlot>{children}</CoreSettings.CurrentTimeSlot>;
30
+ // };
31
+ export const CurrentTimeSlot = React.forwardRef(({ asChild, children, className, ...rest }, ref) => {
32
+ return (_jsx(CoreSettings.CurrentTimeSlot, { children: ({ timeSlot, hasDetails }) => (_jsxs(AsChildSlot, { ref: ref, asChild: asChild,
33
+ // testId={TestIds.currentTimeSlot}
34
+ className: className, customElement: children, customElementProps: { timeSlot, hasDetails }, content: timeSlot, ...rest, children: [timeSlot?.dispatchType, timeSlot?.startTime.toLocaleString() +
35
+ ' - ' +
36
+ timeSlot?.endTime.toLocaleString()] })) }));
37
+ });
38
+ CurrentTimeSlot.displayName = 'Settings.CurrentTimeSlot';
39
+ /**
40
+ * Headless component for current location data
41
+ * Provides access to store location and coordinates
42
+ *
43
+ * @example
44
+ * ```tsx
45
+ * <Settings.CurrentLocation>
46
+ * {({ location, hasLocation }) => (
47
+ * <div>
48
+ * <p>{currentLocation.name}</p>
49
+ * {hasLocation && (
50
+ * <p>Coordinates: {location.latitude}, {location.longitude}</p>
51
+ * )}
52
+ * </div>
53
+ * )}
54
+ * </Settings.CurrentLocation>
55
+ * ```
56
+ */
57
+ export const CurrentLocation = ({ children, className, asChild, }) => {
58
+ return (_jsx(CoreSettings.CurrentLocation, { children: ({ location, hasLocation }) => (_jsx(AsChildSlot
59
+ // ref={ref}
60
+ , {
61
+ // ref={ref}
62
+ asChild: asChild,
63
+ // testId={TestIds.currentLocation}
64
+ className: className, customElement: children, customElementProps: { location, hasLocation }, content: location.name, children: location.name })) }));
65
+ };
66
+ /**
67
+ * Headless component for extra settings data
68
+ * Provides access to ordering status, fees, and thresholds
69
+ *
70
+ * @example
71
+ * ```tsx
72
+ * <Settings.ExtraData>
73
+ * {({ extraData, hasExtraData }) => (
74
+ * hasExtraData ? (
75
+ * <div>
76
+ * <p>Status: {extraData.acceptingOrders ? 'Open' : 'Closed'}</p>
77
+ * {extraData.orderingDisabledReason && (
78
+ * <p>Reason: {extraData.orderingDisabledReason}</p>
79
+ * )}
80
+ * <p>Delivery Fee: ${extraData.deliveryFee}</p>
81
+ * <p>Min Order: ${extraData.minOrderAmount}</p>
82
+ * <p>Free Delivery: ${extraData.freeDeliveryThreshold}</p>
83
+ * <p>Tax Rate: {extraData.taxRate}%</p>
84
+ * </div>
85
+ * ) : (
86
+ * <div>No additional settings available</div>
87
+ * )
88
+ * )}
89
+ * </Settings.ExtraData>
90
+ * ```
91
+ */
92
+ export const ExtraData = ({ children }) => {
93
+ return _jsx(CoreSettings.ExtraData, { children: children });
94
+ };
@@ -10,11 +10,13 @@ import { convertModifierToFormModifier } from '../../services/utils.js';
10
10
  export const Root = ({ children, itemDetailsServiceConfig, }) => {
11
11
  const service = useService(OLOSettingsServiceDefinition);
12
12
  const selectedItem = service.selectedItem?.get();
13
+ console.log('selectedItem', selectedItem, itemDetailsServiceConfig);
13
14
  let config = itemDetailsServiceConfig;
14
15
  if (!config) {
15
16
  config = loadItemServiceConfig({
16
17
  item: selectedItem,
17
- operationId: service.operation?.get()?._id ?? '',
18
+ // @ts-expect-error - operation is not typed
19
+ operationId: service.operation?.get()?.id ?? '',
18
20
  });
19
21
  }
20
22
  if (config.item) {
@@ -1,9 +1,10 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useEffect } from 'react';
2
+ import { useEffect, useState } from 'react';
3
3
  import { createServicesMap } from '@wix/services-manager';
4
4
  import { WixServices } from '@wix/services-manager-react';
5
5
  // import { ItemService, ItemServiceDefinition, loadItemServiceConfig } from '@/components/restaurants-olo/services/itemDetailsService';
6
6
  import { OLOSettingsService, OLOSettingsServiceDefinition, } from '@wix/headless-restaurants-olo/services';
7
+ import { FulfillmentsService, FulfillmentsServiceDefinition, loadFulfillmentsServiceConfig, } from '../../services/fulfillments-service.js';
7
8
  /**
8
9
  * Core OLO Root component that sets up service management
9
10
  * Provides ItemService and CurrentCartService to child components
@@ -24,6 +25,9 @@ import { OLOSettingsService, OLOSettingsServiceDefinition, } from '@wix/headless
24
25
  * ```
25
26
  */
26
27
  export const Root = ({ itemId, itemServiceConfig, cartServiceConfig, oloSettingsServiceConfig, children, }) => {
28
+ const [fulfillmentsServiceConfig, setFulfillmentsServiceConfig] = useState({
29
+ operation: oloSettingsServiceConfig?.operation ?? undefined,
30
+ });
27
31
  // const [servicesManager, setServicesManager] = useState<ServicesManager | null>(null);
28
32
  // const [isLoading, setIsLoading] = useState(true);
29
33
  // const [error, setError] = useState<string | undefined>();
@@ -86,7 +90,17 @@ export const Root = ({ itemId, itemServiceConfig, cartServiceConfig, oloSettings
86
90
  // hasServices
87
91
  // });
88
92
  console.log('oloSettingsServiceConfig', oloSettingsServiceConfig);
89
- return (_jsx(WixServices, { servicesMap: createServicesMap().addService(OLOSettingsServiceDefinition, OLOSettingsService, oloSettingsServiceConfig), children: children }));
93
+ useEffect(() => {
94
+ if (oloSettingsServiceConfig?.operation?._id) {
95
+ loadFulfillmentsServiceConfig(oloSettingsServiceConfig.operation).then((config) => {
96
+ console.log('config', config);
97
+ setFulfillmentsServiceConfig(config);
98
+ });
99
+ }
100
+ }, [oloSettingsServiceConfig?.operation?._id]);
101
+ return (_jsx(WixServices, { servicesMap: createServicesMap()
102
+ .addService(OLOSettingsServiceDefinition, OLOSettingsService, oloSettingsServiceConfig)
103
+ .addService(FulfillmentsServiceDefinition, FulfillmentsService, fulfillmentsServiceConfig), children: children }));
90
104
  };
91
105
  /**
92
106
  * Convenience wrapper that combines Root with ServicesManagerProvider
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import { MenusServiceConfig } from '@wix/headless-restaurants-menus/services';
3
+ export interface OLOMenusRootProps {
4
+ config: MenusServiceConfig;
5
+ children: (updatedConfig: MenusServiceConfig) => React.ReactNode;
6
+ }
7
+ export declare const Root: React.ForwardRefExoticComponent<OLOMenusRootProps & React.RefAttributes<HTMLElement>>;
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import { OLOSettingsServiceDefinition } from '../../services/olo-settings-service.js';
3
+ import { useService } from '@wix/services-manager-react';
4
+ export const Root = React.forwardRef(function OLOMenusRoot({ config, children }) {
5
+ const service = useService(OLOSettingsServiceDefinition);
6
+ const filteredMenus = service.filterMenus(config.menus);
7
+ const hasMenus = Array.isArray(filteredMenus) && filteredMenus.length > 0;
8
+ if (!hasMenus)
9
+ return null;
10
+ config.menus = filteredMenus;
11
+ return children(config);
12
+ });