@wix/headless-restaurants-olo 0.0.14 → 0.0.16

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 (85) 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 +4 -162
  4. package/cjs/dist/react/ItemDetails.js +6 -78
  5. package/cjs/dist/react/ModifierGroup.d.ts +57 -0
  6. package/cjs/dist/react/ModifierGroup.js +61 -0
  7. package/cjs/dist/react/OLO.d.ts +3 -2
  8. package/cjs/dist/react/OLOMenus.d.ts +20 -0
  9. package/cjs/dist/react/OLOMenus.js +22 -0
  10. package/cjs/dist/react/Settings.d.ts +160 -0
  11. package/cjs/dist/react/Settings.js +94 -0
  12. package/cjs/dist/react/core/ItemDetails.d.ts +1 -11
  13. package/cjs/dist/react/core/ItemDetails.js +4 -21
  14. package/cjs/dist/react/core/ModifierGroup.d.ts +42 -0
  15. package/cjs/dist/react/core/ModifierGroup.js +67 -0
  16. package/cjs/dist/react/core/OLO.js +16 -2
  17. package/cjs/dist/react/core/OLOMenus.d.ts +7 -0
  18. package/cjs/dist/react/core/OLOMenus.js +12 -0
  19. package/cjs/dist/react/core/Settings.d.ts +157 -0
  20. package/cjs/dist/react/core/Settings.js +192 -0
  21. package/cjs/dist/react/core/index.d.ts +1 -0
  22. package/cjs/dist/react/core/index.js +1 -0
  23. package/cjs/dist/react/index.d.ts +3 -0
  24. package/cjs/dist/react/index.js +3 -0
  25. package/cjs/dist/services/common-types.d.ts +18 -0
  26. package/cjs/dist/services/common-types.js +10 -0
  27. package/cjs/dist/services/fulfillments-service.d.ts +13 -0
  28. package/cjs/dist/services/fulfillments-service.js +64 -0
  29. package/cjs/dist/services/index.d.ts +1 -0
  30. package/cjs/dist/services/index.js +1 -0
  31. package/cjs/dist/services/item-details-service.d.ts +2 -0
  32. package/cjs/dist/services/item-details-service.js +8 -1
  33. package/cjs/dist/services/olo-settings-service.d.ts +14 -8
  34. package/cjs/dist/services/olo-settings-service.js +24 -5
  35. package/cjs/dist/services/utils.d.ts +17 -0
  36. package/cjs/dist/services/utils.js +104 -0
  37. package/cjs/dist/types/fulfillments-types.d.ts +33 -0
  38. package/cjs/dist/types/fulfillments-types.js +7 -0
  39. package/cjs/dist/types/operation.d.ts +57 -0
  40. package/cjs/dist/types/operation.js +1 -0
  41. package/cjs/dist/utils/fulfillments-utils.d.ts +23 -0
  42. package/cjs/dist/utils/fulfillments-utils.js +144 -0
  43. package/dist/mappers/operation-mapper.d.ts +3 -0
  44. package/dist/mappers/operation-mapper.js +95 -0
  45. package/dist/react/ItemDetails.d.ts +4 -162
  46. package/dist/react/ItemDetails.js +6 -78
  47. package/dist/react/ModifierGroup.d.ts +57 -0
  48. package/dist/react/ModifierGroup.js +61 -0
  49. package/dist/react/OLO.d.ts +3 -2
  50. package/dist/react/OLOMenus.d.ts +20 -0
  51. package/dist/react/OLOMenus.js +22 -0
  52. package/dist/react/Settings.d.ts +160 -0
  53. package/dist/react/Settings.js +94 -0
  54. package/dist/react/core/ItemDetails.d.ts +1 -11
  55. package/dist/react/core/ItemDetails.js +4 -21
  56. package/dist/react/core/ModifierGroup.d.ts +42 -0
  57. package/dist/react/core/ModifierGroup.js +67 -0
  58. package/dist/react/core/OLO.js +16 -2
  59. package/dist/react/core/OLOMenus.d.ts +7 -0
  60. package/dist/react/core/OLOMenus.js +12 -0
  61. package/dist/react/core/Settings.d.ts +157 -0
  62. package/dist/react/core/Settings.js +192 -0
  63. package/dist/react/core/index.d.ts +1 -0
  64. package/dist/react/core/index.js +1 -0
  65. package/dist/react/index.d.ts +3 -0
  66. package/dist/react/index.js +3 -0
  67. package/dist/services/common-types.d.ts +18 -0
  68. package/dist/services/common-types.js +10 -0
  69. package/dist/services/fulfillments-service.d.ts +13 -0
  70. package/dist/services/fulfillments-service.js +64 -0
  71. package/dist/services/index.d.ts +1 -0
  72. package/dist/services/index.js +1 -0
  73. package/dist/services/item-details-service.d.ts +2 -0
  74. package/dist/services/item-details-service.js +8 -1
  75. package/dist/services/olo-settings-service.d.ts +14 -8
  76. package/dist/services/olo-settings-service.js +24 -5
  77. package/dist/services/utils.d.ts +17 -0
  78. package/dist/services/utils.js +104 -0
  79. package/dist/types/fulfillments-types.d.ts +33 -0
  80. package/dist/types/fulfillments-types.js +7 -0
  81. package/dist/types/operation.d.ts +57 -0
  82. package/dist/types/operation.js +1 -0
  83. package/dist/utils/fulfillments-utils.d.ts +23 -0
  84. package/dist/utils/fulfillments-utils.js +144 -0
  85. package/package.json +5 -6
@@ -1,4 +1,10 @@
1
1
  import type { EnhancedModifier, EnhancedModifierGroup } from '@wix/headless-restaurants-menus/services';
2
+ import { RuleType, RuleTypeMap } from './common-types.js';
3
+ interface ruleUtilsArgs {
4
+ required: boolean;
5
+ minSelections: number;
6
+ maxSelections?: number | null;
7
+ }
2
8
  export declare const getModifiersInitState: (modifierGroups: EnhancedModifierGroup[]) => Record<string, string[]>;
3
9
  export declare const isSingleSelectRule: (rule: NonNullable<EnhancedModifierGroup["rule"]>) => boolean | null | undefined;
4
10
  export declare const getFirstPreSelectedModifier: (modifiers: EnhancedModifier[]) => string | null | undefined;
@@ -18,3 +24,14 @@ export declare const convertModifierToFormModifier: (modifier: EnhancedModifier,
18
24
  };
19
25
  preSelected?: boolean;
20
26
  };
27
+ export declare const getModifierGroupRuleType: (modifierGroupRule: EnhancedModifierGroup["rule"]) => RuleType;
28
+ export declare const hasNoLimit: ({ required, minSelections, maxSelections, }: ruleUtilsArgs) => boolean;
29
+ export declare const canChooseOne: ({ required, minSelections, maxSelections, }: ruleUtilsArgs) => boolean;
30
+ export declare const hasToChooseOne: ({ required, minSelections, maxSelections, }: ruleUtilsArgs) => boolean;
31
+ export declare const hasToChooseX: ({ required, minSelections, maxSelections, }: ruleUtilsArgs) => boolean | 0 | null | undefined;
32
+ export declare const hasToChooseAtLeastOne: ({ required, minSelections, maxSelections, }: ruleUtilsArgs) => boolean;
33
+ export declare const hasToChooseAtLeastX: ({ required, minSelections, maxSelections, }: ruleUtilsArgs) => boolean;
34
+ export declare const chooseUpToX: ({ required, minSelections, maxSelections, }: ruleUtilsArgs) => boolean;
35
+ export declare const hasToChooseBetweenXAndY: ({ required, minSelections, maxSelections, }: ruleUtilsArgs) => boolean;
36
+ export declare const getRuleTypeMapValue: (ruleTypeMap: RuleTypeMap, ruleType: RuleType, modifierGroupName: string, rule: EnhancedModifierGroup["rule"]) => string | undefined;
37
+ export {};
@@ -1,3 +1,4 @@
1
+ import { RuleType } from './common-types.js';
1
2
  export const getModifiersInitState = (modifierGroups) => {
2
3
  const initialSelectedModifiers = {};
3
4
  modifierGroups.forEach((group) => {
@@ -32,3 +33,106 @@ export const convertModifierToFormModifier = (modifier, index) => {
32
33
  _id: `${modifier._id}~${index}`,
33
34
  };
34
35
  };
36
+ export const getModifierGroupRuleType = (modifierGroupRule) => {
37
+ const required = modifierGroupRule?.required ?? false;
38
+ const minSelections = modifierGroupRule?.minSelections ?? 0;
39
+ const maxSelections = modifierGroupRule?.maxSelections;
40
+ const ruleFields = { required, minSelections, maxSelections };
41
+ if (hasNoLimit(ruleFields)) {
42
+ return RuleType.NO_LIMIT;
43
+ }
44
+ if (hasToChooseOne(ruleFields) || canChooseOne(ruleFields)) {
45
+ return RuleType.CHOOSE_ONE;
46
+ }
47
+ if (hasToChooseX(ruleFields)) {
48
+ return RuleType.CHOOSE_X;
49
+ }
50
+ if (hasToChooseAtLeastOne(ruleFields)) {
51
+ return RuleType.CHOOSE_AT_LEAST_ONE;
52
+ }
53
+ if (hasToChooseAtLeastX(ruleFields)) {
54
+ return RuleType.CHOOSE_AT_LEAST_X;
55
+ }
56
+ if (chooseUpToX(ruleFields)) {
57
+ return RuleType.CHOOSE_UP_TO_X;
58
+ }
59
+ if (hasToChooseBetweenXAndY(ruleFields)) {
60
+ return RuleType.CHOOSE_BETWEEN_X_AND_Y;
61
+ }
62
+ return RuleType.NO_LIMIT;
63
+ };
64
+ const hasNoValue = (variable) => variable === null || variable === undefined;
65
+ export const hasNoLimit = ({ required, minSelections, maxSelections, }) => !required && minSelections < 1 && (maxSelections ? maxSelections < 1 : true);
66
+ export const canChooseOne = ({ required, minSelections, maxSelections, }) => !required &&
67
+ minSelections === 0 &&
68
+ (maxSelections ? maxSelections === 1 : false);
69
+ export const hasToChooseOne = ({ required, minSelections, maxSelections, }) => required &&
70
+ minSelections === 1 &&
71
+ (maxSelections ? maxSelections === 1 : false);
72
+ export const hasToChooseX = ({ required, minSelections, maxSelections, }) => required ? maxSelections && minSelections === maxSelections : false;
73
+ export const hasToChooseAtLeastOne = ({ required, minSelections, maxSelections, }) => required ? minSelections === 1 && hasNoValue(maxSelections) : false;
74
+ export const hasToChooseAtLeastX = ({ required, minSelections, maxSelections, }) => required ? minSelections > 1 && hasNoValue(maxSelections) : false;
75
+ export const chooseUpToX = ({ required, minSelections, maxSelections, }) => !required &&
76
+ minSelections === 0 &&
77
+ (maxSelections ? maxSelections > 1 : false);
78
+ export const hasToChooseBetweenXAndY = ({ required, minSelections, maxSelections, }) => required
79
+ ? maxSelections
80
+ ? minSelections > 0 && maxSelections > minSelections
81
+ : false
82
+ : false;
83
+ export const getRuleTypeMapValue = (ruleTypeMap, ruleType, modifierGroupName, rule) => {
84
+ const minSelections = rule?.minSelections ?? 0;
85
+ const maxSelections = rule?.maxSelections;
86
+ switch (ruleType) {
87
+ case RuleType.NO_LIMIT: {
88
+ const callback = ruleTypeMap[RuleType.NO_LIMIT];
89
+ if (callback) {
90
+ return callback(modifierGroupName);
91
+ }
92
+ break;
93
+ }
94
+ case RuleType.CHOOSE_ONE: {
95
+ const callback = ruleTypeMap[RuleType.CHOOSE_ONE];
96
+ if (callback) {
97
+ return callback(modifierGroupName);
98
+ }
99
+ break;
100
+ }
101
+ case RuleType.CHOOSE_X: {
102
+ const callback = ruleTypeMap[RuleType.CHOOSE_X];
103
+ if (callback) {
104
+ return callback(modifierGroupName, minSelections);
105
+ }
106
+ break;
107
+ }
108
+ case RuleType.CHOOSE_AT_LEAST_ONE: {
109
+ const callback = ruleTypeMap[RuleType.CHOOSE_AT_LEAST_ONE];
110
+ if (callback) {
111
+ return callback(modifierGroupName);
112
+ }
113
+ break;
114
+ }
115
+ case RuleType.CHOOSE_AT_LEAST_X: {
116
+ const callback = ruleTypeMap[RuleType.CHOOSE_AT_LEAST_X];
117
+ if (callback) {
118
+ return callback(modifierGroupName, minSelections);
119
+ }
120
+ break;
121
+ }
122
+ case RuleType.CHOOSE_UP_TO_X: {
123
+ const callback = ruleTypeMap[RuleType.CHOOSE_UP_TO_X];
124
+ if (callback && maxSelections) {
125
+ return callback(modifierGroupName, maxSelections);
126
+ }
127
+ break;
128
+ }
129
+ case RuleType.CHOOSE_BETWEEN_X_AND_Y: {
130
+ const callback = ruleTypeMap[RuleType.CHOOSE_BETWEEN_X_AND_Y];
131
+ if (callback && maxSelections) {
132
+ return callback(modifierGroupName, minSelections, maxSelections);
133
+ }
134
+ break;
135
+ }
136
+ }
137
+ return undefined;
138
+ };
@@ -0,0 +1,33 @@
1
+ import * as operationsSDK from '@wix/auto_sdk_restaurants_operations';
2
+ import { Signal } from '@wix/services-definitions/core-services/signals';
3
+ export declare enum DispatchType {
4
+ /** Pickup fulfillment */
5
+ PICKUP = "PICKUP",
6
+ /** Delivery fulfillment */
7
+ DELIVERY = "DELIVERY"
8
+ }
9
+ export type TimeSlot = {
10
+ id: string;
11
+ startTime: Date;
12
+ endTime: Date;
13
+ dispatchType: DispatchType;
14
+ startsNow?: boolean;
15
+ fulfillmentDetails: operationsSDK.FulfillmentDetails;
16
+ };
17
+ export interface Fulfillment {
18
+ id: string;
19
+ name: string;
20
+ type: string;
21
+ isAvailable: boolean;
22
+ }
23
+ export interface FulfillmentsServiceAPI {
24
+ fulfillments: Signal<TimeSlot[]>;
25
+ selectedFulfillment: Signal<TimeSlot | null>;
26
+ isLoading: Signal<boolean>;
27
+ error: Signal<string | null>;
28
+ setSelectedFulfillment: (fulfillment: TimeSlot) => void;
29
+ }
30
+ export interface FulfillmentsServiceConfig {
31
+ fulfillments?: operationsSDK.TimeSlotForOperation[];
32
+ operation?: operationsSDK.Operation;
33
+ }
@@ -0,0 +1,7 @@
1
+ export var DispatchType;
2
+ (function (DispatchType) {
3
+ /** Pickup fulfillment */
4
+ DispatchType["PICKUP"] = "PICKUP";
5
+ /** Delivery fulfillment */
6
+ DispatchType["DELIVERY"] = "DELIVERY";
7
+ })(DispatchType || (DispatchType = {}));
@@ -0,0 +1,57 @@
1
+ import { DispatchType } from './fulfillments-types.js';
2
+ export type MinMaxRange = {
3
+ min: number;
4
+ max: number;
5
+ };
6
+ export type AsapScheduling = {
7
+ maxInMinutes?: number;
8
+ rangeInMinutes?: MinMaxRange;
9
+ };
10
+ export type PreorderScheduling = {
11
+ timeWindowDuration: number;
12
+ timeInAdvance: MinMaxRange;
13
+ };
14
+ export type OperationType = 'PRE_ORDER' | 'ASAP';
15
+ type BaseOperation = {
16
+ id: string;
17
+ name: string;
18
+ };
19
+ export interface StreetAddress {
20
+ apt?: String;
21
+ formattedAddressLine?: String;
22
+ name?: String;
23
+ number?: String;
24
+ }
25
+ export interface Address {
26
+ addressLine?: String;
27
+ addressLine2?: String;
28
+ city?: String;
29
+ country?: String;
30
+ countryFullname?: String;
31
+ formattedAddress?: String;
32
+ hint?: String;
33
+ postalCode?: String;
34
+ streetAddress?: StreetAddress;
35
+ subdivision?: String;
36
+ subdivisionFullname?: String;
37
+ }
38
+ export type OSLocation = {
39
+ name: string;
40
+ address?: Address;
41
+ default?: boolean;
42
+ timeZone?: string;
43
+ };
44
+ export type Operation = BaseOperation & {
45
+ enabled: boolean;
46
+ fulfillmentIds: string[];
47
+ asapOptions?: AsapScheduling;
48
+ allowAsapFutureHandling?: boolean;
49
+ businessDaysAheadHandlingOptions?: number;
50
+ operationType: OperationType;
51
+ preOrderOptions?: PreorderScheduling;
52
+ defaultDispatchType?: DispatchType;
53
+ operationGroupId: string;
54
+ locationId: string;
55
+ locationDetails?: OSLocation;
56
+ };
57
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,23 @@
1
+ import * as operationsSDK from '@wix/auto_sdk_restaurants_operations';
2
+ import { TimeSlot } from '../types/fulfillments-types.js';
3
+ export declare const createTimeSlotId: (startTime: Date, endTime: Date, maxTimeOptions?: number) => string;
4
+ export declare function hasSameByField<T>(field: keyof T, arr: T[]): boolean;
5
+ export declare function getMinValueObjects<T>(key: keyof T, arr: T[]): T[];
6
+ export declare function getMinTime(info: operationsSDK.FulfillmentInfo): number;
7
+ export declare function getFastestTimeOptionsByFulfillmentInfo(arr: operationsSDK.FulfillmentInfo[]): operationsSDK.FulfillmentInfo[];
8
+ export declare function getSlowestTimeOptionByFulfillmentInfo(arr: operationsSDK.FulfillmentInfo[]): operationsSDK.FulfillmentInfo;
9
+ export declare const createTimeRangeByFulfillmentInfo: (arr: operationsSDK.FulfillmentInfo[]) => {
10
+ maxTimeOptions: number | undefined;
11
+ durationRangeOptions?: undefined;
12
+ } | {
13
+ durationRangeOptions: {
14
+ minDuration: number | undefined;
15
+ maxDuration: number | undefined;
16
+ };
17
+ maxTimeOptions?: undefined;
18
+ };
19
+ export declare function hasSameTime(arr: operationsSDK.FulfillmentDetails[]): boolean;
20
+ export declare const resolveDifferentMinOrderPriceOptionByFulfillmentInfo: (fulfillmentInfo: operationsSDK.FulfillmentInfo[]) => operationsSDK.FulfillmentInfo | undefined;
21
+ export declare const resolveSameMinOrderPriceOptionByFulfillmentInfo: (fulfillmentInfo: operationsSDK.FulfillmentInfo[]) => operationsSDK.FulfillmentInfo;
22
+ export declare const resolveFulfillmentInfo: (fulfillmentInfo: operationsSDK.FulfillmentInfo[]) => operationsSDK.FulfillmentInfo | undefined;
23
+ export declare const processFulfillmentTimeSlotByOperationList: (operationTimeSlot: operationsSDK.TimeSlotForOperation) => [string, TimeSlot[] | undefined];
@@ -0,0 +1,144 @@
1
+ import * as operationsSDK from '@wix/auto_sdk_restaurants_operations';
2
+ import { DispatchType } from '../types/fulfillments-types.js';
3
+ export const createTimeSlotId = (startTime, endTime, maxTimeOptions = 0) =>
4
+ // maxTimeOptions is used to avoid collisions when order pacing is enabled
5
+ `${startTime?.toUTCString()}-${endTime?.toUTCString()}-${maxTimeOptions}`;
6
+ export function hasSameByField(field, arr) {
7
+ const [first, ...rest] = arr;
8
+ return rest.every((item) => item[field] === first?.[field]);
9
+ }
10
+ export function getMinValueObjects(key, arr) {
11
+ return arr.slice(1).reduce((min, item) => {
12
+ if (Number(item[key]) < Number(min[0]?.[key])) {
13
+ return [item];
14
+ }
15
+ else if (Number(item[key]) === Number(min[0]?.[key])) {
16
+ return [...min, item];
17
+ }
18
+ return min;
19
+ }, (arr[0] ? [arr[0]] : []));
20
+ }
21
+ export function getMinTime(info) {
22
+ return info.durationRange
23
+ ? Number(info.durationRange.minDuration)
24
+ : Number(info.maxTime);
25
+ }
26
+ export function getFastestTimeOptionsByFulfillmentInfo(arr) {
27
+ const [first, ...rest] = arr;
28
+ if (!first) {
29
+ return [];
30
+ }
31
+ return rest.reduce((fastestOptions, current) => {
32
+ const currentTime = getMinTime(current);
33
+ const fastestTime = getMinTime(fastestOptions[0]);
34
+ if (currentTime < fastestTime) {
35
+ return [current];
36
+ }
37
+ else if (currentTime === fastestTime) {
38
+ return [...fastestOptions, current];
39
+ }
40
+ return fastestOptions;
41
+ }, [first]);
42
+ }
43
+ export function getSlowestTimeOptionByFulfillmentInfo(arr) {
44
+ return arr.reduce((max, item) => {
45
+ const { durationRange, maxTime: maxTimeOptions } = item;
46
+ let maxTime;
47
+ if (max.durationRange) {
48
+ maxTime = Number(max.durationRange?.maxDuration || 0);
49
+ }
50
+ else {
51
+ maxTime = Number(max.maxTime || 0);
52
+ }
53
+ if (durationRange) {
54
+ return Number(durationRange.maxDuration) > maxTime ? item : max;
55
+ }
56
+ else {
57
+ return Number(maxTimeOptions) > maxTime ? item : max;
58
+ }
59
+ }, {});
60
+ }
61
+ export const createTimeRangeByFulfillmentInfo = (arr) => {
62
+ const fastestOption = getFastestTimeOptionsByFulfillmentInfo(arr)[0];
63
+ const slowestOption = getSlowestTimeOptionByFulfillmentInfo(arr);
64
+ const minDuration = fastestOption?.durationRange?.minDuration ?? fastestOption?.maxTime;
65
+ const maxDuration = slowestOption.durationRange?.maxDuration ?? slowestOption.maxTime;
66
+ if (minDuration === maxDuration) {
67
+ return { maxTimeOptions: minDuration };
68
+ }
69
+ else {
70
+ return { durationRangeOptions: { minDuration, maxDuration } };
71
+ }
72
+ };
73
+ export function hasSameTime(arr) {
74
+ return (hasSameByField('fulfillmentTimeType', arr) &&
75
+ (arr[0]?.fulfillmentTimeType === operationsSDK.FulfillmentTimeType.MAX_TIME
76
+ ? hasSameByField('maxTimeOptions', arr)
77
+ : arr.every((details) => {
78
+ const { durationRangeOptions } = details;
79
+ return (durationRangeOptions?.maxDuration ===
80
+ arr[0]?.durationRangeOptions?.maxDuration &&
81
+ durationRangeOptions?.minDuration ===
82
+ arr[0]?.durationRangeOptions?.minDuration);
83
+ })));
84
+ }
85
+ export const resolveDifferentMinOrderPriceOptionByFulfillmentInfo = (fulfillmentInfo) => {
86
+ const hasSameFee = hasSameByField('fee', fulfillmentInfo);
87
+ if (hasSameFee && hasSameTime(fulfillmentInfo)) {
88
+ // if fee and time are the same, return the object with the min order price with the min free delivery price threshold
89
+ return getMinValueObjects('freeFulfillmentPriceThreshold', getMinValueObjects('minOrderPrice', fulfillmentInfo))[0];
90
+ }
91
+ else {
92
+ // if the fee is the same and time is different, return the fee
93
+ const fee = hasSameFee ? fulfillmentInfo[0]?.fee : undefined;
94
+ // if free delivery price threshold is the same, return free delivery price threshold
95
+ const freeFulfillmentPriceThreshold = hasSameByField('freeFulfillmentPriceThreshold', fulfillmentInfo)
96
+ ? fulfillmentInfo[0]?.freeFulfillmentPriceThreshold
97
+ : undefined;
98
+ // create a time range object from all the fulfillments
99
+ return {
100
+ fee,
101
+ ...createTimeRangeByFulfillmentInfo(fulfillmentInfo),
102
+ freeFulfillmentPriceThreshold,
103
+ };
104
+ }
105
+ };
106
+ export const resolveSameMinOrderPriceOptionByFulfillmentInfo = (fulfillmentInfo) => {
107
+ // filtering fulfillment details by order of precedent: fee, time, free delivery price threshold
108
+ const cheapestFulfillmentInfo = getMinValueObjects('fee', fulfillmentInfo);
109
+ const fastestFulfillmentInfo = getFastestTimeOptionsByFulfillmentInfo(cheapestFulfillmentInfo);
110
+ return getMinValueObjects('freeFulfillmentPriceThreshold', fastestFulfillmentInfo)[0];
111
+ };
112
+ export const resolveFulfillmentInfo = (fulfillmentInfo) => {
113
+ if (hasSameByField('minOrderPrice', fulfillmentInfo)) {
114
+ return resolveSameMinOrderPriceOptionByFulfillmentInfo(fulfillmentInfo);
115
+ }
116
+ else {
117
+ return resolveDifferentMinOrderPriceOptionByFulfillmentInfo(fulfillmentInfo);
118
+ }
119
+ };
120
+ export const processFulfillmentTimeSlotByOperationList = (operationTimeSlot) => {
121
+ return [
122
+ operationTimeSlot.operationId ?? '',
123
+ operationTimeSlot.timeslotsPerFulfillmentType?.map((fulfillmentTimeSlot) => {
124
+ const { timeSlot, fulfilmentType, fulfillmentInfo } = fulfillmentTimeSlot;
125
+ const { startTime, endTime, orderSchedulingType } = timeSlot ?? {};
126
+ const selectedFulfillmentInfo = resolveFulfillmentInfo(fulfillmentInfo);
127
+ const fulfillmentDetails = {
128
+ maxTimeOptions: selectedFulfillmentInfo?.maxTime,
129
+ durationRangeOptions: selectedFulfillmentInfo?.durationRange,
130
+ ...selectedFulfillmentInfo,
131
+ };
132
+ return {
133
+ id: createTimeSlotId(startTime, endTime),
134
+ startTime: startTime,
135
+ endTime: endTime,
136
+ dispatchType: fulfilmentType === 'DELIVERY'
137
+ ? DispatchType.DELIVERY
138
+ : DispatchType.PICKUP,
139
+ startsNow: orderSchedulingType === operationsSDK.OrderSchedulingType.ASAP,
140
+ fulfillmentDetails,
141
+ };
142
+ }),
143
+ ];
144
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/headless-restaurants-olo",
3
- "version": "0.0.14",
3
+ "version": "0.0.16",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -40,6 +40,7 @@
40
40
  "@typescript-eslint/eslint-plugin": "^6.21.0",
41
41
  "@typescript-eslint/parser": "^6.21.0",
42
42
  "@vitest/ui": "^3.1.4",
43
+ "@wix/headless-components": "0.0.0",
43
44
  "eslint": "^8.57.0",
44
45
  "eslint-config-prettier": "^10.1.8",
45
46
  "eslint-plugin-react": "^7.34.1",
@@ -55,8 +56,9 @@
55
56
  "@radix-ui/react-slot": "^1.1.0",
56
57
  "@wix/auto_sdk_restaurants_items": "^1.0.48",
57
58
  "@wix/ecom": "^1.0.1461",
59
+ "@wix/headless-components": "0.0.26",
58
60
  "@wix/headless-media": "0.0.17",
59
- "@wix/headless-restaurants-menus": "0.0.19",
61
+ "@wix/headless-restaurants-menus": "0.0.20",
60
62
  "@wix/headless-utils": "0.0.7",
61
63
  "@wix/redirects": "^1.0.0",
62
64
  "@wix/restaurants": "^1.0.396",
@@ -64,9 +66,6 @@
64
66
  "@wix/services-definitions": "^0.1.4",
65
67
  "@wix/services-manager-react": "^0.1.26"
66
68
  },
67
- "peerDependencies": {
68
- "@wix/headless-components": "^0.0.0"
69
- },
70
69
  "publishConfig": {
71
70
  "registry": "https://registry.npmjs.org/",
72
71
  "access": "public"
@@ -77,5 +76,5 @@
77
76
  "groupId": "com.wixpress.headless-components"
78
77
  }
79
78
  },
80
- "falconPackageHash": "d55bda80573cab9d81fb40395046c186392cfb841af6c59bd7eb2e07"
79
+ "falconPackageHash": "916d8efd6fea1907af999eee9708352f2f73eb4fabb59d25b129c9fc"
81
80
  }