@wix/headless-restaurants-olo 0.0.13 → 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.
- package/cjs/dist/mappers/operation-mapper.d.ts +3 -0
- package/cjs/dist/mappers/operation-mapper.js +95 -0
- package/cjs/dist/react/ItemDetails.d.ts +0 -31
- package/cjs/dist/react/ItemDetails.js +2 -23
- package/cjs/dist/react/OLO.d.ts +3 -2
- package/cjs/dist/react/OLOMenus.d.ts +20 -0
- package/cjs/dist/react/OLOMenus.js +22 -0
- package/cjs/dist/react/Settings.d.ts +160 -0
- package/cjs/dist/react/Settings.js +94 -0
- package/cjs/dist/react/core/ItemDetails.js +3 -1
- package/cjs/dist/react/core/OLO.js +16 -2
- package/cjs/dist/react/core/OLOMenus.d.ts +7 -0
- package/cjs/dist/react/core/OLOMenus.js +12 -0
- package/cjs/dist/react/core/Settings.d.ts +157 -0
- package/cjs/dist/react/core/Settings.js +192 -0
- package/cjs/dist/react/core/index.d.ts +1 -0
- package/cjs/dist/react/core/index.js +1 -0
- package/cjs/dist/react/index.d.ts +2 -0
- package/cjs/dist/react/index.js +2 -0
- package/cjs/dist/services/fulfillments-service.d.ts +13 -0
- package/cjs/dist/services/fulfillments-service.js +64 -0
- package/cjs/dist/services/index.d.ts +1 -0
- package/cjs/dist/services/index.js +1 -0
- package/cjs/dist/services/item-details-service.js +1 -1
- package/cjs/dist/services/olo-settings-service.d.ts +14 -8
- package/cjs/dist/services/olo-settings-service.js +24 -5
- package/cjs/dist/types/fulfillments-types.d.ts +33 -0
- package/cjs/dist/types/fulfillments-types.js +7 -0
- package/cjs/dist/types/operation.d.ts +57 -0
- package/cjs/dist/types/operation.js +1 -0
- package/cjs/dist/utils/fulfillments-utils.d.ts +23 -0
- package/cjs/dist/utils/fulfillments-utils.js +144 -0
- package/dist/mappers/operation-mapper.d.ts +3 -0
- package/dist/mappers/operation-mapper.js +95 -0
- package/dist/react/ItemDetails.d.ts +0 -31
- package/dist/react/ItemDetails.js +2 -23
- package/dist/react/OLO.d.ts +3 -2
- package/dist/react/OLOMenus.d.ts +20 -0
- package/dist/react/OLOMenus.js +22 -0
- package/dist/react/Settings.d.ts +160 -0
- package/dist/react/Settings.js +94 -0
- package/dist/react/core/ItemDetails.js +3 -1
- package/dist/react/core/OLO.js +16 -2
- package/dist/react/core/OLOMenus.d.ts +7 -0
- package/dist/react/core/OLOMenus.js +12 -0
- package/dist/react/core/Settings.d.ts +157 -0
- package/dist/react/core/Settings.js +192 -0
- package/dist/react/core/index.d.ts +1 -0
- package/dist/react/core/index.js +1 -0
- package/dist/react/index.d.ts +2 -0
- package/dist/react/index.js +2 -0
- package/dist/services/fulfillments-service.d.ts +13 -0
- package/dist/services/fulfillments-service.js +64 -0
- package/dist/services/index.d.ts +1 -0
- package/dist/services/index.js +1 -0
- package/dist/services/item-details-service.js +1 -1
- package/dist/services/olo-settings-service.d.ts +14 -8
- package/dist/services/olo-settings-service.js +24 -5
- package/dist/types/fulfillments-types.d.ts +33 -0
- package/dist/types/fulfillments-types.js +7 -0
- package/dist/types/operation.d.ts +57 -0
- package/dist/types/operation.js +1 -0
- package/dist/utils/fulfillments-utils.d.ts +23 -0
- package/dist/utils/fulfillments-utils.js +144 -0
- package/package.json +5 -5
|
@@ -1,18 +1,22 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as operationsApi from '@wix/auto_sdk_restaurants_operations';
|
|
1
|
+
import { operations as operationsSDK, operationGroups as operationGroupsSDK } from '@wix/restaurants';
|
|
3
2
|
import { type Signal } from '@wix/services-definitions/core-services/signals';
|
|
3
|
+
import { MenusServiceConfig } from '@wix/restaurants/services';
|
|
4
4
|
export interface OLOSettingsServiceAPI {
|
|
5
|
-
operationGroup: Signal<
|
|
6
|
-
operation: Signal<
|
|
5
|
+
operationGroup: Signal<operationGroupsSDK.OperationGroup | undefined>;
|
|
6
|
+
operation: Signal<operationsSDK.Operation | undefined>;
|
|
7
7
|
selectedItem?: Signal<unknown>;
|
|
8
8
|
isLoading: Signal<boolean>;
|
|
9
9
|
error: Signal<string | null>;
|
|
10
10
|
availabilityDispatchAction?: Signal<(() => void) | undefined>;
|
|
11
|
+
currentFulfillment: Signal<string>;
|
|
12
|
+
currentTimeSlot: Signal<string>;
|
|
13
|
+
filterMenus: (menus: MenusServiceConfig['menus']) => MenusServiceConfig['menus'];
|
|
11
14
|
}
|
|
12
15
|
export interface OLOSettingsServiceConfig {
|
|
13
|
-
operationGroup?:
|
|
14
|
-
operation?:
|
|
16
|
+
operationGroup?: operationGroupsSDK.OperationGroup;
|
|
17
|
+
operation?: operationsSDK.Operation;
|
|
15
18
|
availabilityDispatchAction?: () => void;
|
|
19
|
+
menuIdsByOperation?: string[];
|
|
16
20
|
}
|
|
17
21
|
export declare const OLOSettingsServiceDefinition: string & {
|
|
18
22
|
__api: OLOSettingsServiceAPI;
|
|
@@ -25,8 +29,9 @@ export declare const OLOSettingsService: import("@wix/services-definitions").Ser
|
|
|
25
29
|
isServiceDefinition?: boolean;
|
|
26
30
|
} & OLOSettingsServiceAPI, OLOSettingsServiceConfig>;
|
|
27
31
|
export declare function loadOLOSettingsServiceConfig(): Promise<{
|
|
28
|
-
operationGroup:
|
|
29
|
-
operation:
|
|
32
|
+
operationGroup: operationGroupsSDK.OperationGroup | undefined;
|
|
33
|
+
operation: import("../types/operation.js").Operation;
|
|
34
|
+
menuIdsByOperation: (string | null | undefined)[];
|
|
30
35
|
isLoading?: undefined;
|
|
31
36
|
error?: undefined;
|
|
32
37
|
} | {
|
|
@@ -34,4 +39,5 @@ export declare function loadOLOSettingsServiceConfig(): Promise<{
|
|
|
34
39
|
operation: undefined;
|
|
35
40
|
isLoading: boolean;
|
|
36
41
|
error: string;
|
|
42
|
+
menuIdsByOperation?: undefined;
|
|
37
43
|
}>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineService, implementService } from '@wix/services-definitions';
|
|
2
|
-
import
|
|
3
|
-
import * as operationsApi from '@wix/auto_sdk_restaurants_operations';
|
|
2
|
+
import { operations as operationsSDK, operationGroups as operationGroupsSDK, menuOrderingSettings as menuOrderingSettingsSDK, } from '@wix/restaurants';
|
|
4
3
|
import { SignalsServiceDefinition, } from '@wix/services-definitions/core-services/signals';
|
|
4
|
+
import { OperationMapper } from '../mappers/operation-mapper.js';
|
|
5
5
|
export const OLOSettingsServiceDefinition = defineService('oloSettings');
|
|
6
6
|
export const OLOSettingsService = implementService.withConfig()(OLOSettingsServiceDefinition, ({ getService, config }) => {
|
|
7
7
|
const signalsService = getService(SignalsServiceDefinition);
|
|
@@ -11,6 +11,12 @@ export const OLOSettingsService = implementService.withConfig()(OLOSettingsServi
|
|
|
11
11
|
const selectedItem = signalsService.signal(null);
|
|
12
12
|
const isLoading = signalsService.signal(false);
|
|
13
13
|
const error = signalsService.signal(null);
|
|
14
|
+
const currentFulfillment = signalsService.signal('Pickup');
|
|
15
|
+
const currentTimeSlot = signalsService.signal('10-14');
|
|
16
|
+
// const isAsap = operation.get()?.orderSchedulingType === OrderSchedulingType.ASAP;
|
|
17
|
+
const filterMenus = (menus) => {
|
|
18
|
+
return menus?.filter((menu) => menu.visible && config.menuIdsByOperation?.includes(menu._id || ''));
|
|
19
|
+
};
|
|
14
20
|
return {
|
|
15
21
|
operationGroup,
|
|
16
22
|
operation,
|
|
@@ -18,18 +24,31 @@ export const OLOSettingsService = implementService.withConfig()(OLOSettingsServi
|
|
|
18
24
|
error,
|
|
19
25
|
selectedItem,
|
|
20
26
|
availabilityDispatchAction,
|
|
27
|
+
currentFulfillment,
|
|
28
|
+
currentTimeSlot,
|
|
29
|
+
filterMenus,
|
|
21
30
|
};
|
|
22
31
|
});
|
|
23
32
|
export async function loadOLOSettingsServiceConfig() {
|
|
24
33
|
try {
|
|
25
34
|
// Fetch operation groups and operations in parallel
|
|
26
35
|
const [operationGroupsResponse, operationsResponse] = await Promise.all([
|
|
27
|
-
|
|
28
|
-
|
|
36
|
+
operationGroupsSDK.queryOperationGroups().find(),
|
|
37
|
+
operationsSDK.queryOperation().find(),
|
|
29
38
|
]);
|
|
39
|
+
const [currentOperation] = operationsResponse.items;
|
|
40
|
+
if (!currentOperation) {
|
|
41
|
+
throw new Error('Operation not found');
|
|
42
|
+
}
|
|
43
|
+
const operation = OperationMapper(currentOperation);
|
|
44
|
+
const menuIdsByOperation = await menuOrderingSettingsSDK
|
|
45
|
+
.queryMenuOrderingSettings()
|
|
46
|
+
.in('operationId', operationsResponse.items[0]?._id)
|
|
47
|
+
.find();
|
|
30
48
|
return {
|
|
31
49
|
operationGroup: operationGroupsResponse.items[0] || undefined,
|
|
32
|
-
operation
|
|
50
|
+
operation,
|
|
51
|
+
menuIdsByOperation: menuIdsByOperation.items.map((menu) => menu.menuId),
|
|
33
52
|
};
|
|
34
53
|
}
|
|
35
54
|
catch (error) {
|
|
@@ -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,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,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/headless-restaurants-olo",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.15",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"prebuild": "cd ../
|
|
7
|
+
"prebuild": "cd ../ecom && yarn build",
|
|
8
8
|
"build": "npm run build:esm && npm run build:cjs",
|
|
9
9
|
"build:esm": "tsc -p tsconfig.json",
|
|
10
10
|
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"@wix/auto_sdk_restaurants_items": "^1.0.48",
|
|
57
57
|
"@wix/ecom": "^1.0.1461",
|
|
58
58
|
"@wix/headless-media": "0.0.17",
|
|
59
|
-
"@wix/headless-restaurants-menus": "0.0.
|
|
59
|
+
"@wix/headless-restaurants-menus": "0.0.19",
|
|
60
60
|
"@wix/headless-utils": "0.0.7",
|
|
61
61
|
"@wix/redirects": "^1.0.0",
|
|
62
62
|
"@wix/restaurants": "^1.0.396",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"@wix/services-manager-react": "^0.1.26"
|
|
66
66
|
},
|
|
67
67
|
"peerDependencies": {
|
|
68
|
-
"@wix/headless-components": "
|
|
68
|
+
"@wix/headless-components": "^0.0.0"
|
|
69
69
|
},
|
|
70
70
|
"publishConfig": {
|
|
71
71
|
"registry": "https://registry.npmjs.org/",
|
|
@@ -77,5 +77,5 @@
|
|
|
77
77
|
"groupId": "com.wixpress.headless-components"
|
|
78
78
|
}
|
|
79
79
|
},
|
|
80
|
-
"falconPackageHash": "
|
|
80
|
+
"falconPackageHash": "71ec66f326eb20964a9b1df3e46c9cad2246603e42239226a8cacaf6"
|
|
81
81
|
}
|