@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,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
+ });
@@ -0,0 +1,157 @@
1
+ import React from 'react';
2
+ import * as operationsSDK from '@wix/auto_sdk_restaurants_operations';
3
+ import { TimeSlot } from '../../types/fulfillments-types.js';
4
+ interface CurrentTime {
5
+ timeSlot: string;
6
+ }
7
+ interface CurrentFulfillment {
8
+ current?: operationsSDK.TimeSlot;
9
+ }
10
+ interface CurrentLocation {
11
+ name: string;
12
+ }
13
+ interface ExtraData {
14
+ acceptingOrders: boolean;
15
+ deliveryFee?: number;
16
+ minOrderAmount?: number;
17
+ freeDeliveryThreshold?: number;
18
+ taxRate?: number;
19
+ serviceCharge?: number;
20
+ isOnline?: boolean;
21
+ orderingDisabledReason?: string;
22
+ }
23
+ interface SettingsData {
24
+ currentTime: CurrentTime;
25
+ currentFulfillment: CurrentFulfillment;
26
+ currentLocation: CurrentLocation;
27
+ selectedFulfillment: any;
28
+ extraData: ExtraData;
29
+ isLoading: boolean;
30
+ error?: string | null;
31
+ }
32
+ interface SettingsRootProps {
33
+ children: (props: SettingsData) => React.ReactNode;
34
+ }
35
+ /**
36
+ * Core Settings component that provides access to OLO settings data
37
+ * Integrates with OLOSettingsService to expose operation and operation group data
38
+ *
39
+ * @example
40
+ * ```tsx
41
+ * <CoreSettings.Root>
42
+ * {({ currentDetails, currentFulfillment, currentLocation, extraData, isLoading, error }) => (
43
+ * isLoading ? (
44
+ * <div>Loading settings...</div>
45
+ * ) : error ? (
46
+ * <div>Error: {error}</div>
47
+ * ) : (
48
+ * <div>
49
+ * <h2>{currentDetails.name}</h2>
50
+ * <p>Accepting Orders: {extraData.acceptingOrders ? 'Yes' : 'No'}</p>
51
+ * <p>Delivery Fee: ${extraData.deliveryFee}</p>
52
+ * </div>
53
+ * )
54
+ * )}
55
+ * </CoreSettings.Root>
56
+ * ```
57
+ */
58
+ export declare const Root: React.FC<SettingsRootProps>;
59
+ interface CurrentTimeSlotProps {
60
+ children: (props: {
61
+ timeSlot: TimeSlot;
62
+ hasDetails: boolean;
63
+ }) => React.ReactNode;
64
+ }
65
+ /**
66
+ * Component that provides access to current store details
67
+ *
68
+ * @example
69
+ * ```tsx
70
+ * <CoreSettings.CurrentTimeSlot>
71
+ * {({ details, hasDetails }) => (
72
+ * hasDetails ? (
73
+ * <div>
74
+ * <h3>{details.timeSlot}</h3>
75
+ * </div>
76
+ * ) : (
77
+ * <div>No store details available</div>
78
+ * )
79
+ * )}
80
+ * </CoreSettings.CurrentTimeSlot>
81
+ * ```
82
+ */
83
+ export declare const CurrentTimeSlot: React.FC<CurrentTimeSlotProps>;
84
+ interface CurrentFulfillmentProps {
85
+ children: (props: {
86
+ fulfillment: CurrentFulfillment;
87
+ hasFulfillment: boolean;
88
+ availableOptions: string[];
89
+ }) => React.ReactNode;
90
+ }
91
+ /**
92
+ * Component that provides access to current fulfillment options
93
+ *
94
+ * @example
95
+ * ```tsx
96
+ * <CoreSettings.CurrentFulfillment>
97
+ * {({ fulfillment, availableOptions }) => (
98
+ * <div>
99
+ * <h3>Available Options:</h3>
100
+ * {availableOptions.map(option => (
101
+ * <div key={option}>{option}: Available</div>
102
+ * ))}
103
+ * </div>
104
+ * )}
105
+ * </CoreSettings.CurrentFulfillment>
106
+ * ```
107
+ */
108
+ export declare const CurrentFulfillment: React.FC<CurrentFulfillmentProps>;
109
+ interface CurrentLocationProps {
110
+ children: (props: {
111
+ location: CurrentLocation;
112
+ hasLocation: boolean;
113
+ }) => React.ReactNode;
114
+ }
115
+ /**
116
+ * Component that provides access to current location data
117
+ *
118
+ * @example
119
+ * ```tsx
120
+ * <CoreSettings.CurrentLocation>
121
+ * {({ location, hasCoordinates }) => (
122
+ * <div>
123
+ * <p>{location.address}</p>
124
+ * {hasCoordinates && (
125
+ * <p>Coordinates: {location.latitude}, {location.longitude}</p>
126
+ * )}
127
+ * </div>
128
+ * )}
129
+ * </CoreSettings.CurrentLocation>
130
+ * ```
131
+ */
132
+ export declare const CurrentLocation: React.FC<CurrentLocationProps>;
133
+ interface ExtraDataProps {
134
+ children: (props: {
135
+ extraData: ExtraData;
136
+ hasExtraData: boolean;
137
+ }) => React.ReactNode;
138
+ }
139
+ /**
140
+ * Component that provides access to extra settings data
141
+ *
142
+ * @example
143
+ * ```tsx
144
+ * <CoreSettings.ExtraData>
145
+ * {({ extraData }) => (
146
+ * <div>
147
+ * <p>Accepting Orders: {extraData.acceptingOrders ? 'Yes' : 'No'}</p>
148
+ * <p>Delivery Fee: ${extraData.deliveryFee}</p>
149
+ * <p>Min Order: ${extraData.minOrderAmount}</p>
150
+ * <p>Free Delivery: ${extraData.freeDeliveryThreshold}</p>
151
+ * </div>
152
+ * )}
153
+ * </CoreSettings.ExtraData>
154
+ * ```
155
+ */
156
+ export declare const ExtraData: React.FC<ExtraDataProps>;
157
+ export {};
@@ -0,0 +1,192 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useService } from '@wix/services-manager-react';
3
+ import { OLOSettingsServiceDefinition } from '../../services/olo-settings-service.js';
4
+ import { FulfillmentsServiceDefinition } from '../../services/fulfillments-service.js';
5
+ /**
6
+ * Core Settings component that provides access to OLO settings data
7
+ * Integrates with OLOSettingsService to expose operation and operation group data
8
+ *
9
+ * @example
10
+ * ```tsx
11
+ * <CoreSettings.Root>
12
+ * {({ currentDetails, currentFulfillment, currentLocation, extraData, isLoading, error }) => (
13
+ * isLoading ? (
14
+ * <div>Loading settings...</div>
15
+ * ) : error ? (
16
+ * <div>Error: {error}</div>
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
+ * )}
25
+ * </CoreSettings.Root>
26
+ * ```
27
+ */
28
+ export const Root = ({ children }) => {
29
+ const service = useService(OLOSettingsServiceDefinition);
30
+ const fulfillmentsService = useService(FulfillmentsServiceDefinition);
31
+ const operation = service.operation?.get();
32
+ const selectedFulfillment = fulfillmentsService.selectedFulfillment?.get();
33
+ console.log('selectedFulfillment', selectedFulfillment);
34
+ const isLoading = service.isLoading?.get() ?? false;
35
+ const error = service.error?.get();
36
+ // Extract current details from operation group
37
+ // Note: Using safe property access since the exact API structure may vary
38
+ const currentTime = {
39
+ timeSlot: 'TODO', // service.currentTimeSlot?.get(),
40
+ };
41
+ // Extract fulfillment options from operation
42
+ // Note: Using safe property access since the exact API structure may vary
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
+ });
78
+ };
79
+ /**
80
+ * Component that provides access to current store details
81
+ *
82
+ * @example
83
+ * ```tsx
84
+ * <CoreSettings.CurrentTimeSlot>
85
+ * {({ details, hasDetails }) => (
86
+ * hasDetails ? (
87
+ * <div>
88
+ * <h3>{details.timeSlot}</h3>
89
+ * </div>
90
+ * ) : (
91
+ * <div>No store details available</div>
92
+ * )
93
+ * )}
94
+ * </CoreSettings.CurrentTimeSlot>
95
+ * ```
96
+ */
97
+ export const CurrentTimeSlot = ({ children, }) => {
98
+ return (_jsx(Root, { children: ({ selectedFulfillment }) => {
99
+ const hasDetails = Boolean(selectedFulfillment);
100
+ console.log('selectedFulfillment', selectedFulfillment);
101
+ console.log('timeSlot', selectedFulfillment?.startTime.toLocaleString());
102
+ return children({
103
+ timeSlot: selectedFulfillment,
104
+ hasDetails,
105
+ });
106
+ } }));
107
+ };
108
+ /**
109
+ * Component that provides access to current fulfillment options
110
+ *
111
+ * @example
112
+ * ```tsx
113
+ * <CoreSettings.CurrentFulfillment>
114
+ * {({ fulfillment, availableOptions }) => (
115
+ * <div>
116
+ * <h3>Available Options:</h3>
117
+ * {availableOptions.map(option => (
118
+ * <div key={option}>{option}: Available</div>
119
+ * ))}
120
+ * </div>
121
+ * )}
122
+ * </CoreSettings.CurrentFulfillment>
123
+ * ```
124
+ */
125
+ export const CurrentFulfillment = ({ children, }) => {
126
+ return (_jsx(Root, { children: ({ currentFulfillment }) => {
127
+ const availableOptions = [];
128
+ // if (currentFulfillment.pickup?.enabled) availableOptions.push('pickup');
129
+ // if (currentFulfillment.delivery?.enabled) availableOptions.push('delivery');
130
+ const hasFulfillment = availableOptions.length > 0;
131
+ return children({
132
+ fulfillment: currentFulfillment,
133
+ hasFulfillment,
134
+ availableOptions,
135
+ });
136
+ } }));
137
+ };
138
+ /**
139
+ * Component that provides access to current location data
140
+ *
141
+ * @example
142
+ * ```tsx
143
+ * <CoreSettings.CurrentLocation>
144
+ * {({ location, hasCoordinates }) => (
145
+ * <div>
146
+ * <p>{location.address}</p>
147
+ * {hasCoordinates && (
148
+ * <p>Coordinates: {location.latitude}, {location.longitude}</p>
149
+ * )}
150
+ * </div>
151
+ * )}
152
+ * </CoreSettings.CurrentLocation>
153
+ * ```
154
+ */
155
+ export const CurrentLocation = ({ children, }) => {
156
+ return (_jsx(Root, { children: ({ currentLocation }) => {
157
+ console.log('currentLocation', currentLocation);
158
+ const hasLocation = Boolean(currentLocation.name);
159
+ return children({
160
+ location: currentLocation,
161
+ hasLocation,
162
+ });
163
+ } }));
164
+ };
165
+ /**
166
+ * Component that provides access to extra settings data
167
+ *
168
+ * @example
169
+ * ```tsx
170
+ * <CoreSettings.ExtraData>
171
+ * {({ extraData }) => (
172
+ * <div>
173
+ * <p>Accepting Orders: {extraData.acceptingOrders ? 'Yes' : 'No'}</p>
174
+ * <p>Delivery Fee: ${extraData.deliveryFee}</p>
175
+ * <p>Min Order: ${extraData.minOrderAmount}</p>
176
+ * <p>Free Delivery: ${extraData.freeDeliveryThreshold}</p>
177
+ * </div>
178
+ * )}
179
+ * </CoreSettings.ExtraData>
180
+ * ```
181
+ */
182
+ export const ExtraData = ({ children }) => {
183
+ return (_jsx(Root, { children: ({ extraData }) => {
184
+ const hasExtraData = Boolean(extraData.deliveryFee !== undefined ||
185
+ extraData.minOrderAmount !== undefined ||
186
+ extraData.freeDeliveryThreshold !== undefined);
187
+ return children({
188
+ extraData,
189
+ hasExtraData,
190
+ });
191
+ } }));
192
+ };
@@ -1,3 +1,4 @@
1
1
  export * as CoreItemDetails from './ItemDetails.js';
2
2
  export { CoreClickableItem } from './ClickableItem.js';
3
3
  export * as CoreOLO from './OLO.js';
4
+ export * as CoreSettings from './Settings.js';
@@ -1,3 +1,4 @@
1
1
  export * as CoreItemDetails from './ItemDetails.js';
2
2
  export { CoreClickableItem } from './ClickableItem.js';
3
3
  export * as CoreOLO from './OLO.js';
4
+ export * as CoreSettings from './Settings.js';
@@ -1,3 +1,5 @@
1
1
  export * as ItemDetails from './ItemDetails.js';
2
2
  export * as ClickableItem from './ClickableItem.js';
3
3
  export * as OLO from './OLO.js';
4
+ export * as Settings from './Settings.js';
5
+ export * as OLOMenus from './OLOMenus.js';
@@ -1,3 +1,5 @@
1
1
  export * as ItemDetails from './ItemDetails.js';
2
2
  export * as ClickableItem from './ClickableItem.js';
3
3
  export * as OLO from './OLO.js';
4
+ export * as Settings from './Settings.js';
5
+ export * as OLOMenus from './OLOMenus.js';
@@ -0,0 +1,13 @@
1
+ import * as operationsSDK from '@wix/auto_sdk_restaurants_operations';
2
+ import { FulfillmentsServiceAPI, FulfillmentsServiceConfig } from '../types/fulfillments-types.js';
3
+ export declare const FulfillmentsServiceDefinition: string & {
4
+ __api: FulfillmentsServiceAPI;
5
+ __config: {};
6
+ isServiceDefinition?: boolean;
7
+ } & FulfillmentsServiceAPI;
8
+ export declare const FulfillmentsService: import("@wix/services-definitions").ServiceFactory<string & {
9
+ __api: FulfillmentsServiceAPI;
10
+ __config: {};
11
+ isServiceDefinition?: boolean;
12
+ } & FulfillmentsServiceAPI, FulfillmentsServiceConfig>;
13
+ export declare const loadFulfillmentsServiceConfig: (operation?: operationsSDK.Operation) => Promise<FulfillmentsServiceConfig>;
@@ -0,0 +1,64 @@
1
+ import { defineService, implementService } from '@wix/services-definitions';
2
+ import { SignalsServiceDefinition } from '@wix/services-definitions/core-services/signals';
3
+ import * as operationsSDK from '@wix/auto_sdk_restaurants_operations';
4
+ import * as fulfillemtMethodsSDK from '@wix/auto_sdk_restaurants_fulfillment-methods';
5
+ import { processFulfillmentTimeSlotByOperationList } from '../utils/fulfillments-utils.js';
6
+ export const FulfillmentsServiceDefinition = defineService('fulfillments');
7
+ export const FulfillmentsService = implementService.withConfig()(FulfillmentsServiceDefinition, ({ getService, config }) => {
8
+ console.log('config', config);
9
+ if (!config.operation) {
10
+ throw new Error('Operation ID is required');
11
+ }
12
+ const signalsService = getService(SignalsServiceDefinition);
13
+ const fulfillmentsMap = new Map(config.fulfillments?.map(processFulfillmentTimeSlotByOperationList) ??
14
+ []);
15
+ const fulfillments = signalsService.signal(
16
+ // @ts-expect-error - operation is not typed
17
+ fulfillmentsMap.get(config.operation?.id ?? '') ?? []);
18
+ const isLoading = signalsService.signal(false);
19
+ const error = signalsService.signal(null);
20
+ const initialSelected = fulfillments.get()?.[0] ?? null;
21
+ const selectedFulfillment = signalsService.signal(initialSelected);
22
+ selectedFulfillment.set(initialSelected);
23
+ const setSelectedFulfillment = (fulfillment) => {
24
+ selectedFulfillment.set(fulfillment);
25
+ };
26
+ if (!config.fulfillments && config.operation) {
27
+ loadFulfillmentsServiceConfig(config.operation).then((config) => {
28
+ const fulfillmentsMap = new Map(config.fulfillments?.map(processFulfillmentTimeSlotByOperationList) ?? []);
29
+ fulfillments.set(
30
+ // @ts-expect-error - operation is not typed
31
+ fulfillmentsMap.get(config.operation?.id ?? '') ?? []);
32
+ const initialSelected = fulfillments.get()?.[0] ?? null;
33
+ selectedFulfillment.set(initialSelected);
34
+ });
35
+ }
36
+ return {
37
+ fulfillments,
38
+ selectedFulfillment,
39
+ isLoading,
40
+ error,
41
+ setSelectedFulfillment,
42
+ };
43
+ });
44
+ export const loadFulfillmentsServiceConfig = async (operation) => {
45
+ const [timeSlots, fulfillments] = await Promise.all([
46
+ operationsSDK.calculateFirstAvailableTimeSlotsPerOperation([
47
+ // @ts-expect-error - operation is not typed
48
+ operation.id,
49
+ ]),
50
+ fulfillemtMethodsSDK
51
+ .queryFulfillmentMethods()
52
+ .in('_id', operation?.fulfillmentIds)
53
+ .find(),
54
+ ]);
55
+ // const fulfillments = await operationsSDK.calculateFirstAvailableTimeSlotsPerOperation([
56
+ // operationId,
57
+ // ]);
58
+ console.log('fulfillments', fulfillments.items);
59
+ // const fulfillmentsMap = new Map(fulfillments.timeSlotsPerOperation?.map(processFulfillmentTimeSlotByOperationList));
60
+ return {
61
+ fulfillments: timeSlots.timeSlotsPerOperation, //fulfillmentsMap.get(operationId) ?? [],
62
+ operation: operation,
63
+ };
64
+ };
@@ -1,3 +1,4 @@
1
1
  export { ItemService, ItemServiceDefinition, loadItemServiceConfig, ItemServiceConfig, } from './item-details-service.js';
2
2
  export { OLOSettingsService, OLOSettingsServiceDefinition, loadOLOSettingsServiceConfig, type OLOSettingsServiceConfig, type OLOSettingsServiceAPI, } from './olo-settings-service.js';
3
3
  export { AvailabilityStatus, AvailabilityStatusMap } from './common-types.js';
4
+ export { FulfillmentsService, FulfillmentsServiceDefinition, loadFulfillmentsServiceConfig, } from './fulfillments-service.js';
@@ -1,3 +1,4 @@
1
1
  export { ItemService, ItemServiceDefinition, loadItemServiceConfig, } from './item-details-service.js';
2
2
  export { OLOSettingsService, OLOSettingsServiceDefinition, loadOLOSettingsServiceConfig, } from './olo-settings-service.js';
3
3
  export { AvailabilityStatus } from './common-types.js';
4
+ export { FulfillmentsService, FulfillmentsServiceDefinition, loadFulfillmentsServiceConfig, } from './fulfillments-service.js';
@@ -58,8 +58,8 @@ export const ItemService = implementService.withConfig()(ItemServiceDefinition,
58
58
  const modifierGroups = config.item?.modifierGroups || [];
59
59
  const initialSelectedModifiers = getModifiersInitState(modifierGroups);
60
60
  const selectedModifiers = signalsService.signal(initialSelectedModifiers);
61
+ console.log('config.item', config.item);
61
62
  if (config.item) {
62
- console.log('config.item', config.item);
63
63
  lineItem.set({
64
64
  quantity: quantity.get(),
65
65
  catalogReference: {