@wix/headless-restaurants-olo 0.0.42 → 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.
- package/cjs/dist/react/ItemDetails.d.ts +7 -0
- package/cjs/dist/react/ItemDetails.js +12 -5
- package/cjs/dist/react/core/ItemDetails.d.ts +1 -0
- package/cjs/dist/react/core/ItemDetails.js +2 -0
- package/cjs/dist/services/fulfillments-service.d.ts +2 -2
- package/cjs/dist/services/fulfillments-service.js +2 -6
- package/cjs/dist/services/item-details-service.d.ts +2 -0
- package/cjs/dist/services/item-details-service.js +3 -1
- package/cjs/dist/services/olo-settings-service.d.ts +4 -5
- package/cjs/dist/services/olo-settings-service.js +11 -10
- package/dist/react/ItemDetails.d.ts +7 -0
- package/dist/react/ItemDetails.js +12 -5
- package/dist/react/core/ItemDetails.d.ts +1 -0
- package/dist/react/core/ItemDetails.js +2 -0
- package/dist/services/fulfillments-service.d.ts +2 -2
- package/dist/services/fulfillments-service.js +2 -6
- package/dist/services/item-details-service.d.ts +2 -0
- package/dist/services/item-details-service.js +3 -1
- package/dist/services/olo-settings-service.d.ts +4 -5
- package/dist/services/olo-settings-service.js +11 -10
- package/package.json +2 -2
|
@@ -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
|
}
|
|
@@ -109,6 +115,7 @@ export interface SpecialRequestProps {
|
|
|
109
115
|
children?: AsChildChildren<{
|
|
110
116
|
value: string;
|
|
111
117
|
onChange: (value: string) => void;
|
|
118
|
+
allowSpecialRequest: boolean;
|
|
112
119
|
}>;
|
|
113
120
|
/** Placeholder text for the textarea */
|
|
114
121
|
placeholder?: string;
|
|
@@ -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
|
-
|
|
93
|
-
|
|
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';
|
|
@@ -224,7 +224,14 @@ Quantity.displayName = 'Quantity';
|
|
|
224
224
|
* ```
|
|
225
225
|
*/
|
|
226
226
|
export const SpecialRequest = React.forwardRef(({ className, labelClassName, placeholder = 'Any special requests or dietary restrictions?', maxLength = 200, rows = 3, label = 'Special Requests', asChild, children, ...props }, ref) => {
|
|
227
|
-
return (_jsx(CoreItemDetails.SpecialRequest, { children: ({ value, onChange,
|
|
227
|
+
return (_jsx(CoreItemDetails.SpecialRequest, { children: ({ value, onChange, allowSpecialRequest, }) => {
|
|
228
|
+
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, onChange: onChange, "data-testid": TestIds.itemSpecialRequest, customElement: children, customElementProps: {
|
|
229
|
+
label,
|
|
230
|
+
value,
|
|
231
|
+
onChange,
|
|
232
|
+
allowSpecialRequest,
|
|
233
|
+
}, content: value, ...props, children: allowSpecialRequest && (_jsxs(_Fragment, { children: [label && _jsx("label", { className: labelClassName, children: label }), _jsx("textarea", { value: value, onChange: (e) => onChange(e.target.value), placeholder: placeholder, maxLength: maxLength, rows: rows, className: className, children: value })] })) }));
|
|
234
|
+
} }));
|
|
228
235
|
});
|
|
229
236
|
SpecialRequest.displayName = 'SpecialRequest';
|
|
230
237
|
/**
|
|
@@ -14,6 +14,7 @@ interface ItemDetailsSpecialRequestProps {
|
|
|
14
14
|
children: (props: {
|
|
15
15
|
value: string;
|
|
16
16
|
onChange: (value: string) => void;
|
|
17
|
+
allowSpecialRequest: boolean;
|
|
17
18
|
}) => React.ReactNode;
|
|
18
19
|
}
|
|
19
20
|
export declare const SpecialRequest: React.FC<ItemDetailsSpecialRequestProps>;
|
|
@@ -11,6 +11,7 @@ export const Root = ({ children, itemDetailsServiceConfig, }) => {
|
|
|
11
11
|
};
|
|
12
12
|
export const SpecialRequest = ({ children, }) => {
|
|
13
13
|
const service = useService(ItemServiceDefinition);
|
|
14
|
+
const allowSpecialRequest = service.allowSpecialRequest;
|
|
14
15
|
const initialSpecialRequest = service.specialRequest?.get?.() ?? '';
|
|
15
16
|
const [value, setValue] = useState(initialSpecialRequest);
|
|
16
17
|
const onChange = (newValue) => {
|
|
@@ -22,6 +23,7 @@ export const SpecialRequest = ({ children, }) => {
|
|
|
22
23
|
return children({
|
|
23
24
|
value,
|
|
24
25
|
onChange,
|
|
26
|
+
allowSpecialRequest,
|
|
25
27
|
// placeholder: 'Any special requests or dietary restrictions?',
|
|
26
28
|
// maxLength: 200
|
|
27
29
|
});
|
|
@@ -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
|
|
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
|
|
151
|
+
operation,
|
|
156
152
|
fulfillments: fulfillments.items.filter((f) => f.enabled),
|
|
157
153
|
};
|
|
158
154
|
};
|
|
@@ -15,6 +15,7 @@ export interface ItemServiceAPI {
|
|
|
15
15
|
item?: Signal<EnhancedItem | undefined>;
|
|
16
16
|
quantity: Signal<number>;
|
|
17
17
|
specialRequest: Signal<string>;
|
|
18
|
+
allowSpecialRequest: boolean;
|
|
18
19
|
lineItem: ReadOnlySignal<LineItem>;
|
|
19
20
|
onHandleAddToCart: (onClick: (lineItem: LineItem) => void) => void;
|
|
20
21
|
buttonState: ReadOnlySignal<AddToCartButtonState | undefined>;
|
|
@@ -67,6 +68,7 @@ export interface ItemServiceConfig {
|
|
|
67
68
|
item?: EnhancedItem;
|
|
68
69
|
operationId?: string;
|
|
69
70
|
availabilityStatus?: AvailabilityStatus;
|
|
71
|
+
allowSpecialRequest?: boolean;
|
|
70
72
|
editItemMode?: boolean;
|
|
71
73
|
editingItemValues?: {
|
|
72
74
|
quantity?: number;
|
|
@@ -50,6 +50,7 @@ export const ItemService = implementService.withConfig()(ItemServiceDefinition,
|
|
|
50
50
|
endDate: undefined,
|
|
51
51
|
weeklyAvailabilitySummary: undefined,
|
|
52
52
|
};
|
|
53
|
+
const allowSpecialRequest = config.allowSpecialRequest ?? true;
|
|
53
54
|
const signalsService = getService(SignalsServiceDefinition);
|
|
54
55
|
const oloSettingsService = getService(OLOSettingsServiceDefinition);
|
|
55
56
|
const availabilityStatus = signalsService.signal(config.availabilityStatus ?? AvailabilityStatus.AVAILABLE);
|
|
@@ -131,7 +132,7 @@ export const ItemService = implementService.withConfig()(ItemServiceDefinition,
|
|
|
131
132
|
sectionId: config.sectionId ?? config.item?.sectionId,
|
|
132
133
|
priceVariant: getPriceVariantOptions(selectedVariant.get(), formatCurrency),
|
|
133
134
|
modifierGroups: getLineItemModifiers(selectedModifiers.get(), modifierGroups, formatCurrency),
|
|
134
|
-
specialRequests: specialRequest
|
|
135
|
+
specialRequests: specialRequest?.get() || undefined,
|
|
135
136
|
},
|
|
136
137
|
},
|
|
137
138
|
};
|
|
@@ -215,6 +216,7 @@ export const ItemService = implementService.withConfig()(ItemServiceDefinition,
|
|
|
215
216
|
addToCartButtonDisabled,
|
|
216
217
|
price,
|
|
217
218
|
futureAvailability,
|
|
219
|
+
allowSpecialRequest,
|
|
218
220
|
};
|
|
219
221
|
});
|
|
220
222
|
/**
|
|
@@ -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?:
|
|
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
|
|
36
|
-
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',
|
|
49
|
-
.find();
|
|
49
|
+
.in('operationId', currentOperation._id)
|
|
50
|
+
.find()).items.map((menu) => menu.menuId);
|
|
50
51
|
return {
|
|
51
|
-
operationGroup
|
|
52
|
+
operationGroup,
|
|
52
53
|
operation,
|
|
53
|
-
menuIdsByOperation
|
|
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
|
}
|
|
@@ -109,6 +115,7 @@ export interface SpecialRequestProps {
|
|
|
109
115
|
children?: AsChildChildren<{
|
|
110
116
|
value: string;
|
|
111
117
|
onChange: (value: string) => void;
|
|
118
|
+
allowSpecialRequest: boolean;
|
|
112
119
|
}>;
|
|
113
120
|
/** Placeholder text for the textarea */
|
|
114
121
|
placeholder?: string;
|
|
@@ -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
|
-
|
|
93
|
-
|
|
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';
|
|
@@ -224,7 +224,14 @@ Quantity.displayName = 'Quantity';
|
|
|
224
224
|
* ```
|
|
225
225
|
*/
|
|
226
226
|
export const SpecialRequest = React.forwardRef(({ className, labelClassName, placeholder = 'Any special requests or dietary restrictions?', maxLength = 200, rows = 3, label = 'Special Requests', asChild, children, ...props }, ref) => {
|
|
227
|
-
return (_jsx(CoreItemDetails.SpecialRequest, { children: ({ value, onChange,
|
|
227
|
+
return (_jsx(CoreItemDetails.SpecialRequest, { children: ({ value, onChange, allowSpecialRequest, }) => {
|
|
228
|
+
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, onChange: onChange, "data-testid": TestIds.itemSpecialRequest, customElement: children, customElementProps: {
|
|
229
|
+
label,
|
|
230
|
+
value,
|
|
231
|
+
onChange,
|
|
232
|
+
allowSpecialRequest,
|
|
233
|
+
}, content: value, ...props, children: allowSpecialRequest && (_jsxs(_Fragment, { children: [label && _jsx("label", { className: labelClassName, children: label }), _jsx("textarea", { value: value, onChange: (e) => onChange(e.target.value), placeholder: placeholder, maxLength: maxLength, rows: rows, className: className, children: value })] })) }));
|
|
234
|
+
} }));
|
|
228
235
|
});
|
|
229
236
|
SpecialRequest.displayName = 'SpecialRequest';
|
|
230
237
|
/**
|
|
@@ -14,6 +14,7 @@ interface ItemDetailsSpecialRequestProps {
|
|
|
14
14
|
children: (props: {
|
|
15
15
|
value: string;
|
|
16
16
|
onChange: (value: string) => void;
|
|
17
|
+
allowSpecialRequest: boolean;
|
|
17
18
|
}) => React.ReactNode;
|
|
18
19
|
}
|
|
19
20
|
export declare const SpecialRequest: React.FC<ItemDetailsSpecialRequestProps>;
|
|
@@ -11,6 +11,7 @@ export const Root = ({ children, itemDetailsServiceConfig, }) => {
|
|
|
11
11
|
};
|
|
12
12
|
export const SpecialRequest = ({ children, }) => {
|
|
13
13
|
const service = useService(ItemServiceDefinition);
|
|
14
|
+
const allowSpecialRequest = service.allowSpecialRequest;
|
|
14
15
|
const initialSpecialRequest = service.specialRequest?.get?.() ?? '';
|
|
15
16
|
const [value, setValue] = useState(initialSpecialRequest);
|
|
16
17
|
const onChange = (newValue) => {
|
|
@@ -22,6 +23,7 @@ export const SpecialRequest = ({ children, }) => {
|
|
|
22
23
|
return children({
|
|
23
24
|
value,
|
|
24
25
|
onChange,
|
|
26
|
+
allowSpecialRequest,
|
|
25
27
|
// placeholder: 'Any special requests or dietary restrictions?',
|
|
26
28
|
// maxLength: 200
|
|
27
29
|
});
|
|
@@ -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
|
|
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
|
|
151
|
+
operation,
|
|
156
152
|
fulfillments: fulfillments.items.filter((f) => f.enabled),
|
|
157
153
|
};
|
|
158
154
|
};
|
|
@@ -15,6 +15,7 @@ export interface ItemServiceAPI {
|
|
|
15
15
|
item?: Signal<EnhancedItem | undefined>;
|
|
16
16
|
quantity: Signal<number>;
|
|
17
17
|
specialRequest: Signal<string>;
|
|
18
|
+
allowSpecialRequest: boolean;
|
|
18
19
|
lineItem: ReadOnlySignal<LineItem>;
|
|
19
20
|
onHandleAddToCart: (onClick: (lineItem: LineItem) => void) => void;
|
|
20
21
|
buttonState: ReadOnlySignal<AddToCartButtonState | undefined>;
|
|
@@ -67,6 +68,7 @@ export interface ItemServiceConfig {
|
|
|
67
68
|
item?: EnhancedItem;
|
|
68
69
|
operationId?: string;
|
|
69
70
|
availabilityStatus?: AvailabilityStatus;
|
|
71
|
+
allowSpecialRequest?: boolean;
|
|
70
72
|
editItemMode?: boolean;
|
|
71
73
|
editingItemValues?: {
|
|
72
74
|
quantity?: number;
|
|
@@ -50,6 +50,7 @@ export const ItemService = implementService.withConfig()(ItemServiceDefinition,
|
|
|
50
50
|
endDate: undefined,
|
|
51
51
|
weeklyAvailabilitySummary: undefined,
|
|
52
52
|
};
|
|
53
|
+
const allowSpecialRequest = config.allowSpecialRequest ?? true;
|
|
53
54
|
const signalsService = getService(SignalsServiceDefinition);
|
|
54
55
|
const oloSettingsService = getService(OLOSettingsServiceDefinition);
|
|
55
56
|
const availabilityStatus = signalsService.signal(config.availabilityStatus ?? AvailabilityStatus.AVAILABLE);
|
|
@@ -131,7 +132,7 @@ export const ItemService = implementService.withConfig()(ItemServiceDefinition,
|
|
|
131
132
|
sectionId: config.sectionId ?? config.item?.sectionId,
|
|
132
133
|
priceVariant: getPriceVariantOptions(selectedVariant.get(), formatCurrency),
|
|
133
134
|
modifierGroups: getLineItemModifiers(selectedModifiers.get(), modifierGroups, formatCurrency),
|
|
134
|
-
specialRequests: specialRequest
|
|
135
|
+
specialRequests: specialRequest?.get() || undefined,
|
|
135
136
|
},
|
|
136
137
|
},
|
|
137
138
|
};
|
|
@@ -215,6 +216,7 @@ export const ItemService = implementService.withConfig()(ItemServiceDefinition,
|
|
|
215
216
|
addToCartButtonDisabled,
|
|
216
217
|
price,
|
|
217
218
|
futureAvailability,
|
|
219
|
+
allowSpecialRequest,
|
|
218
220
|
};
|
|
219
221
|
});
|
|
220
222
|
/**
|
|
@@ -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?:
|
|
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
|
|
36
|
-
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',
|
|
49
|
-
.find();
|
|
49
|
+
.in('operationId', currentOperation._id)
|
|
50
|
+
.find()).items.map((menu) => menu.menuId);
|
|
50
51
|
return {
|
|
51
|
-
operationGroup
|
|
52
|
+
operationGroup,
|
|
52
53
|
operation,
|
|
53
|
-
menuIdsByOperation
|
|
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.
|
|
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": "
|
|
81
|
+
"falconPackageHash": "8b0e8f84677d9e75b1242a120c014e61d8e0279095afd8bf291e54aa"
|
|
82
82
|
}
|