@wix/headless-restaurants-olo 0.0.43 → 0.0.44

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.
@@ -58,8 +58,14 @@ export interface ItemDetailsVariantsProps {
58
58
  radioGroupClassName?: string;
59
59
  /** CSS classes to apply to each RadioGroup.Item (variant radio button) */
60
60
  variantRadioItemClassName?: string;
61
+ /** CSS classes to apply to the RadioGroup.Indicator (radio button circle) */
62
+ variantRadioIndicatorClassName?: string;
63
+ /** CSS classes to apply to the radio button wrapper (outer circle with border) */
64
+ variantRadioButtonWrapperClassName?: string;
61
65
  /** CSS classes to apply to each variant item container */
62
66
  variantItemClassName?: string;
67
+ /** CSS classes to apply to the variant name and price container */
68
+ variantContentClassName?: string;
63
69
  /** Optional content to display when no variants are available */
64
70
  emptyState?: React.ReactNode;
65
71
  }
@@ -78,7 +78,7 @@ Root.displayName = 'ItemDetails.Root';
78
78
  * </ItemDetails.Variants>
79
79
  * ```
80
80
  */
81
- export const Variants = React.forwardRef(({ children, className, asChild, variantNameClassName, variantPriceClassName, radioGroupClassName, variantRadioItemClassName, variantItemClassName, emptyState, }, ref) => {
81
+ export const Variants = React.forwardRef(({ children, className, asChild, variantNameClassName, variantPriceClassName, radioGroupClassName, variantRadioItemClassName, variantRadioIndicatorClassName, variantRadioButtonWrapperClassName, variantItemClassName, variantContentClassName, emptyState, }, ref) => {
82
82
  return (_jsx(CoreItemDetails.VariantsComponent, { children: ({ variants, hasVariants, selectedVariantId, onVariantChange }) => {
83
83
  if (!hasVariants) {
84
84
  return emptyState || null;
@@ -88,9 +88,9 @@ export const Variants = React.forwardRef(({ children, className, asChild, varian
88
88
  hasVariants,
89
89
  selectedVariantId,
90
90
  onVariantChange,
91
- }, children: _jsx(RadioGroupPrimitive.Root, { className: radioGroupClassName, value: selectedVariantId, onValueChange: onVariantChange, children: variants.map((variant) => (_jsx(RadioGroupPrimitive.Item, { value: variant._id ?? '', className: variantRadioItemClassName, children: _jsxs("div", { className: variantItemClassName, children: [_jsx("div", { className: variantNameClassName, children: variant.name }), _jsx("div", { className: variantPriceClassName, children: variant.priceInfo?.formattedPrice ||
92
- variant.priceInfo?.price ||
93
- '' })] }) }, variant._id))) }) }));
91
+ }, children: _jsx(RadioGroupPrimitive.Root, { className: radioGroupClassName, value: selectedVariantId, onValueChange: onVariantChange, children: variants.map((variant) => (_jsx(RadioGroupPrimitive.Item, { value: variant._id ?? '', className: variantRadioItemClassName, children: _jsxs("div", { className: variantItemClassName, children: [_jsx("div", { className: variantRadioButtonWrapperClassName, children: _jsx(RadioGroupPrimitive.Indicator, { className: variantRadioIndicatorClassName }) }), _jsxs("div", { className: variantContentClassName, children: [_jsx("div", { className: variantNameClassName, children: variant.name }), _jsx("div", { className: variantPriceClassName, children: variant.priceInfo?.formattedPrice ||
92
+ variant.priceInfo?.price ||
93
+ '' })] })] }) }, variant._id))) }) }));
94
94
  } }));
95
95
  });
96
96
  Variants.displayName = 'ItemDetails.Variants';
@@ -1,5 +1,5 @@
1
- import * as operationsSDK from '@wix/auto_sdk_restaurants_operations';
2
1
  import { FulfillmentsServiceAPI, FulfillmentsServiceConfig } from '../types/fulfillments-types.js';
2
+ import { Operation } from '../types/operation.js';
3
3
  export declare const FulfillmentsServiceDefinition: string & {
4
4
  __api: FulfillmentsServiceAPI;
5
5
  __config: {};
@@ -10,4 +10,4 @@ export declare const FulfillmentsService: import("@wix/services-definitions").Se
10
10
  __config: {};
11
11
  isServiceDefinition?: boolean;
12
12
  } & FulfillmentsServiceAPI, FulfillmentsServiceConfig>;
13
- export declare const loadFulfillmentsServiceConfig: (operation?: operationsSDK.Operation) => Promise<FulfillmentsServiceConfig>;
13
+ export declare const loadFulfillmentsServiceConfig: (operation: Operation) => Promise<FulfillmentsServiceConfig>;
@@ -140,19 +140,15 @@ export const FulfillmentsService = implementService.withConfig()(FulfillmentsSer
140
140
  });
141
141
  export const loadFulfillmentsServiceConfig = async (operation) => {
142
142
  const [timeSlots, fulfillments] = await Promise.all([
143
- operationsSDK.calculateFirstAvailableTimeSlotsPerOperation([
144
- // @ts-expect-error - operation is not typed
145
- operation.id,
146
- ]),
143
+ operationsSDK.calculateFirstAvailableTimeSlotsPerOperation([operation.id]),
147
144
  fulfillemtMethodsSDK
148
145
  .queryFulfillmentMethods()
149
146
  .in('_id', operation?.fulfillmentIds)
150
147
  .find(),
151
148
  ]);
152
- console.log('operation', operation);
153
149
  return {
154
150
  firstAvailableTimeSlots: timeSlots.timeSlotsPerOperation,
155
- operation: operation,
151
+ operation,
156
152
  fulfillments: fulfillments.items.filter((f) => f.enabled),
157
153
  };
158
154
  };
@@ -1,21 +1,20 @@
1
1
  import { operations as operationsSDK, operationGroups as operationGroupsSDK } from '@wix/restaurants';
2
2
  import { type Signal } from '@wix/services-definitions/core-services/signals';
3
3
  import { MenusServiceConfig } from '@wix/headless-restaurants-menus/services';
4
+ import { Operation } from '../types/operation.js';
4
5
  export interface OLOSettingsServiceAPI {
5
6
  operationGroup: Signal<operationGroupsSDK.OperationGroup | undefined>;
6
7
  operation: Signal<operationsSDK.Operation | undefined>;
7
8
  isLoading: Signal<boolean>;
8
9
  error: Signal<string | null>;
9
10
  availabilityDispatchAction?: Signal<(() => void) | undefined>;
10
- currentFulfillment: Signal<string>;
11
- currentTimeSlot: Signal<string>;
12
11
  filterMenus: (menus: MenusServiceConfig['menus']) => MenusServiceConfig['menus'];
13
12
  canAcceptOrders: boolean;
14
13
  formatCurrency: (price?: number) => string;
15
14
  }
16
15
  export interface OLOSettingsServiceConfig {
17
16
  operationGroup?: operationGroupsSDK.OperationGroup;
18
- operation?: operationsSDK.Operation;
17
+ operation?: Operation;
19
18
  availabilityDispatchAction?: () => void;
20
19
  menuIdsByOperation?: string[];
21
20
  canAcceptOrders?: boolean;
@@ -32,8 +31,8 @@ export declare const OLOSettingsService: import("@wix/services-definitions").Ser
32
31
  isServiceDefinition?: boolean;
33
32
  } & OLOSettingsServiceAPI, OLOSettingsServiceConfig>;
34
33
  export declare function loadOLOSettingsServiceConfig(): Promise<{
35
- operationGroup: operationGroupsSDK.OperationGroup | undefined;
36
- operation: import("../types/operation.js").Operation;
34
+ operationGroup: operationGroupsSDK.OperationGroup;
35
+ operation: Operation;
37
36
  menuIdsByOperation: (string | null | undefined)[];
38
37
  isLoading?: undefined;
39
38
  error?: undefined;
@@ -12,9 +12,6 @@ export const OLOSettingsService = implementService.withConfig()(OLOSettingsServi
12
12
  ((price) => price?.toFixed(2)?.toString() ?? '');
13
13
  const isLoading = signalsService.signal(true);
14
14
  const error = signalsService.signal(null);
15
- const currentFulfillment = signalsService.signal('Pickup');
16
- const currentTimeSlot = signalsService.signal('10-14');
17
- // const isAsap = operation.get()?.orderSchedulingType === OrderSchedulingType.ASAP;
18
15
  const filterMenus = (menus) => {
19
16
  return menus?.filter((menu) => menu.visible && config.menuIdsByOperation?.includes(menu._id || ''));
20
17
  };
@@ -24,8 +21,6 @@ export const OLOSettingsService = implementService.withConfig()(OLOSettingsServi
24
21
  isLoading,
25
22
  error,
26
23
  availabilityDispatchAction,
27
- currentFulfillment,
28
- currentTimeSlot,
29
24
  filterMenus,
30
25
  canAcceptOrders: config.canAcceptOrders ?? true,
31
26
  formatCurrency,
@@ -38,19 +33,25 @@ export async function loadOLOSettingsServiceConfig() {
38
33
  operationGroupsSDK.queryOperationGroups().find(),
39
34
  operationsSDK.queryOperation().find(),
40
35
  ]);
36
+ //TODO: Handle multiple pages
37
+ const [operationGroup] = operationGroupsResponse.items;
38
+ if (!operationGroup) {
39
+ throw new Error('Operation group not found');
40
+ }
41
+ // TODO: Handle multiple locations
41
42
  const [currentOperation] = operationsResponse.items;
42
43
  if (!currentOperation) {
43
44
  throw new Error('Operation not found');
44
45
  }
45
46
  const operation = OperationMapper(currentOperation);
46
- const menuIdsByOperation = await menuOrderingSettingsSDK
47
+ const menuIdsByOperation = (await menuOrderingSettingsSDK
47
48
  .queryMenuOrderingSettings()
48
- .in('operationId', operationsResponse.items[0]?._id)
49
- .find();
49
+ .in('operationId', currentOperation._id)
50
+ .find()).items.map((menu) => menu.menuId);
50
51
  return {
51
- operationGroup: operationGroupsResponse.items[0] || undefined,
52
+ operationGroup,
52
53
  operation,
53
- menuIdsByOperation: menuIdsByOperation.items.map((menu) => menu.menuId),
54
+ menuIdsByOperation,
54
55
  };
55
56
  }
56
57
  catch (error) {
@@ -58,8 +58,14 @@ export interface ItemDetailsVariantsProps {
58
58
  radioGroupClassName?: string;
59
59
  /** CSS classes to apply to each RadioGroup.Item (variant radio button) */
60
60
  variantRadioItemClassName?: string;
61
+ /** CSS classes to apply to the RadioGroup.Indicator (radio button circle) */
62
+ variantRadioIndicatorClassName?: string;
63
+ /** CSS classes to apply to the radio button wrapper (outer circle with border) */
64
+ variantRadioButtonWrapperClassName?: string;
61
65
  /** CSS classes to apply to each variant item container */
62
66
  variantItemClassName?: string;
67
+ /** CSS classes to apply to the variant name and price container */
68
+ variantContentClassName?: string;
63
69
  /** Optional content to display when no variants are available */
64
70
  emptyState?: React.ReactNode;
65
71
  }
@@ -78,7 +78,7 @@ Root.displayName = 'ItemDetails.Root';
78
78
  * </ItemDetails.Variants>
79
79
  * ```
80
80
  */
81
- export const Variants = React.forwardRef(({ children, className, asChild, variantNameClassName, variantPriceClassName, radioGroupClassName, variantRadioItemClassName, variantItemClassName, emptyState, }, ref) => {
81
+ export const Variants = React.forwardRef(({ children, className, asChild, variantNameClassName, variantPriceClassName, radioGroupClassName, variantRadioItemClassName, variantRadioIndicatorClassName, variantRadioButtonWrapperClassName, variantItemClassName, variantContentClassName, emptyState, }, ref) => {
82
82
  return (_jsx(CoreItemDetails.VariantsComponent, { children: ({ variants, hasVariants, selectedVariantId, onVariantChange }) => {
83
83
  if (!hasVariants) {
84
84
  return emptyState || null;
@@ -88,9 +88,9 @@ export const Variants = React.forwardRef(({ children, className, asChild, varian
88
88
  hasVariants,
89
89
  selectedVariantId,
90
90
  onVariantChange,
91
- }, children: _jsx(RadioGroupPrimitive.Root, { className: radioGroupClassName, value: selectedVariantId, onValueChange: onVariantChange, children: variants.map((variant) => (_jsx(RadioGroupPrimitive.Item, { value: variant._id ?? '', className: variantRadioItemClassName, children: _jsxs("div", { className: variantItemClassName, children: [_jsx("div", { className: variantNameClassName, children: variant.name }), _jsx("div", { className: variantPriceClassName, children: variant.priceInfo?.formattedPrice ||
92
- variant.priceInfo?.price ||
93
- '' })] }) }, variant._id))) }) }));
91
+ }, children: _jsx(RadioGroupPrimitive.Root, { className: radioGroupClassName, value: selectedVariantId, onValueChange: onVariantChange, children: variants.map((variant) => (_jsx(RadioGroupPrimitive.Item, { value: variant._id ?? '', className: variantRadioItemClassName, children: _jsxs("div", { className: variantItemClassName, children: [_jsx("div", { className: variantRadioButtonWrapperClassName, children: _jsx(RadioGroupPrimitive.Indicator, { className: variantRadioIndicatorClassName }) }), _jsxs("div", { className: variantContentClassName, children: [_jsx("div", { className: variantNameClassName, children: variant.name }), _jsx("div", { className: variantPriceClassName, children: variant.priceInfo?.formattedPrice ||
92
+ variant.priceInfo?.price ||
93
+ '' })] })] }) }, variant._id))) }) }));
94
94
  } }));
95
95
  });
96
96
  Variants.displayName = 'ItemDetails.Variants';
@@ -1,5 +1,5 @@
1
- import * as operationsSDK from '@wix/auto_sdk_restaurants_operations';
2
1
  import { FulfillmentsServiceAPI, FulfillmentsServiceConfig } from '../types/fulfillments-types.js';
2
+ import { Operation } from '../types/operation.js';
3
3
  export declare const FulfillmentsServiceDefinition: string & {
4
4
  __api: FulfillmentsServiceAPI;
5
5
  __config: {};
@@ -10,4 +10,4 @@ export declare const FulfillmentsService: import("@wix/services-definitions").Se
10
10
  __config: {};
11
11
  isServiceDefinition?: boolean;
12
12
  } & FulfillmentsServiceAPI, FulfillmentsServiceConfig>;
13
- export declare const loadFulfillmentsServiceConfig: (operation?: operationsSDK.Operation) => Promise<FulfillmentsServiceConfig>;
13
+ export declare const loadFulfillmentsServiceConfig: (operation: Operation) => Promise<FulfillmentsServiceConfig>;
@@ -140,19 +140,15 @@ export const FulfillmentsService = implementService.withConfig()(FulfillmentsSer
140
140
  });
141
141
  export const loadFulfillmentsServiceConfig = async (operation) => {
142
142
  const [timeSlots, fulfillments] = await Promise.all([
143
- operationsSDK.calculateFirstAvailableTimeSlotsPerOperation([
144
- // @ts-expect-error - operation is not typed
145
- operation.id,
146
- ]),
143
+ operationsSDK.calculateFirstAvailableTimeSlotsPerOperation([operation.id]),
147
144
  fulfillemtMethodsSDK
148
145
  .queryFulfillmentMethods()
149
146
  .in('_id', operation?.fulfillmentIds)
150
147
  .find(),
151
148
  ]);
152
- console.log('operation', operation);
153
149
  return {
154
150
  firstAvailableTimeSlots: timeSlots.timeSlotsPerOperation,
155
- operation: operation,
151
+ operation,
156
152
  fulfillments: fulfillments.items.filter((f) => f.enabled),
157
153
  };
158
154
  };
@@ -1,21 +1,20 @@
1
1
  import { operations as operationsSDK, operationGroups as operationGroupsSDK } from '@wix/restaurants';
2
2
  import { type Signal } from '@wix/services-definitions/core-services/signals';
3
3
  import { MenusServiceConfig } from '@wix/headless-restaurants-menus/services';
4
+ import { Operation } from '../types/operation.js';
4
5
  export interface OLOSettingsServiceAPI {
5
6
  operationGroup: Signal<operationGroupsSDK.OperationGroup | undefined>;
6
7
  operation: Signal<operationsSDK.Operation | undefined>;
7
8
  isLoading: Signal<boolean>;
8
9
  error: Signal<string | null>;
9
10
  availabilityDispatchAction?: Signal<(() => void) | undefined>;
10
- currentFulfillment: Signal<string>;
11
- currentTimeSlot: Signal<string>;
12
11
  filterMenus: (menus: MenusServiceConfig['menus']) => MenusServiceConfig['menus'];
13
12
  canAcceptOrders: boolean;
14
13
  formatCurrency: (price?: number) => string;
15
14
  }
16
15
  export interface OLOSettingsServiceConfig {
17
16
  operationGroup?: operationGroupsSDK.OperationGroup;
18
- operation?: operationsSDK.Operation;
17
+ operation?: Operation;
19
18
  availabilityDispatchAction?: () => void;
20
19
  menuIdsByOperation?: string[];
21
20
  canAcceptOrders?: boolean;
@@ -32,8 +31,8 @@ export declare const OLOSettingsService: import("@wix/services-definitions").Ser
32
31
  isServiceDefinition?: boolean;
33
32
  } & OLOSettingsServiceAPI, OLOSettingsServiceConfig>;
34
33
  export declare function loadOLOSettingsServiceConfig(): Promise<{
35
- operationGroup: operationGroupsSDK.OperationGroup | undefined;
36
- operation: import("../types/operation.js").Operation;
34
+ operationGroup: operationGroupsSDK.OperationGroup;
35
+ operation: Operation;
37
36
  menuIdsByOperation: (string | null | undefined)[];
38
37
  isLoading?: undefined;
39
38
  error?: undefined;
@@ -12,9 +12,6 @@ export const OLOSettingsService = implementService.withConfig()(OLOSettingsServi
12
12
  ((price) => price?.toFixed(2)?.toString() ?? '');
13
13
  const isLoading = signalsService.signal(true);
14
14
  const error = signalsService.signal(null);
15
- const currentFulfillment = signalsService.signal('Pickup');
16
- const currentTimeSlot = signalsService.signal('10-14');
17
- // const isAsap = operation.get()?.orderSchedulingType === OrderSchedulingType.ASAP;
18
15
  const filterMenus = (menus) => {
19
16
  return menus?.filter((menu) => menu.visible && config.menuIdsByOperation?.includes(menu._id || ''));
20
17
  };
@@ -24,8 +21,6 @@ export const OLOSettingsService = implementService.withConfig()(OLOSettingsServi
24
21
  isLoading,
25
22
  error,
26
23
  availabilityDispatchAction,
27
- currentFulfillment,
28
- currentTimeSlot,
29
24
  filterMenus,
30
25
  canAcceptOrders: config.canAcceptOrders ?? true,
31
26
  formatCurrency,
@@ -38,19 +33,25 @@ export async function loadOLOSettingsServiceConfig() {
38
33
  operationGroupsSDK.queryOperationGroups().find(),
39
34
  operationsSDK.queryOperation().find(),
40
35
  ]);
36
+ //TODO: Handle multiple pages
37
+ const [operationGroup] = operationGroupsResponse.items;
38
+ if (!operationGroup) {
39
+ throw new Error('Operation group not found');
40
+ }
41
+ // TODO: Handle multiple locations
41
42
  const [currentOperation] = operationsResponse.items;
42
43
  if (!currentOperation) {
43
44
  throw new Error('Operation not found');
44
45
  }
45
46
  const operation = OperationMapper(currentOperation);
46
- const menuIdsByOperation = await menuOrderingSettingsSDK
47
+ const menuIdsByOperation = (await menuOrderingSettingsSDK
47
48
  .queryMenuOrderingSettings()
48
- .in('operationId', operationsResponse.items[0]?._id)
49
- .find();
49
+ .in('operationId', currentOperation._id)
50
+ .find()).items.map((menu) => menu.menuId);
50
51
  return {
51
- operationGroup: operationGroupsResponse.items[0] || undefined,
52
+ operationGroup,
52
53
  operation,
53
- menuIdsByOperation: menuIdsByOperation.items.map((menu) => menu.menuId),
54
+ menuIdsByOperation,
54
55
  };
55
56
  }
56
57
  catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/headless-restaurants-olo",
3
- "version": "0.0.43",
3
+ "version": "0.0.44",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -78,5 +78,5 @@
78
78
  "groupId": "com.wixpress.headless-components"
79
79
  }
80
80
  },
81
- "falconPackageHash": "25e56de1c5e1be8c65b00bd03ae07fb32f297114f752d75297741b66"
81
+ "falconPackageHash": "8b0e8f84677d9e75b1242a120c014e61d8e0279095afd8bf291e54aa"
82
82
  }