@wix/headless-restaurants-olo 0.0.23 → 0.0.25
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 +4 -3
- package/cjs/dist/react/ItemDetails.js +3 -9
- package/cjs/dist/react/ModifierGroup.js +2 -2
- package/cjs/dist/react/Settings.d.ts +24 -21
- package/cjs/dist/react/Settings.js +34 -4
- package/cjs/dist/react/core/ItemDetails.d.ts +1 -0
- package/cjs/dist/react/core/ItemDetails.js +8 -3
- package/cjs/dist/react/core/ModifierGroup.js +2 -4
- package/cjs/dist/react/core/OLO.js +2 -16
- package/cjs/dist/react/core/Settings.d.ts +41 -65
- package/cjs/dist/react/core/Settings.js +83 -113
- package/cjs/dist/services/common-types.d.ts +7 -7
- package/cjs/dist/services/fulfillments-service.js +22 -18
- package/cjs/dist/services/item-details-service.d.ts +7 -0
- package/cjs/dist/services/item-details-service.js +42 -6
- package/cjs/dist/services/utils.d.ts +3 -2
- package/cjs/dist/services/utils.js +32 -10
- package/cjs/dist/types/fulfillments-types.d.ts +7 -4
- package/dist/react/ItemDetails.d.ts +4 -3
- package/dist/react/ItemDetails.js +3 -9
- package/dist/react/ModifierGroup.js +2 -2
- package/dist/react/Settings.d.ts +24 -21
- package/dist/react/Settings.js +34 -4
- package/dist/react/core/ItemDetails.d.ts +1 -0
- package/dist/react/core/ItemDetails.js +8 -3
- package/dist/react/core/ModifierGroup.js +2 -4
- package/dist/react/core/OLO.js +2 -16
- package/dist/react/core/Settings.d.ts +41 -65
- package/dist/react/core/Settings.js +83 -113
- package/dist/services/common-types.d.ts +7 -7
- package/dist/services/fulfillments-service.js +22 -18
- package/dist/services/item-details-service.d.ts +7 -0
- package/dist/services/item-details-service.js +42 -6
- package/dist/services/utils.d.ts +3 -2
- package/dist/services/utils.js +32 -10
- package/dist/types/fulfillments-types.d.ts +7 -4
- package/package.json +2 -2
|
@@ -71,7 +71,7 @@ export declare const Variants: React.ForwardRefExoticComponent<ItemDetailsVarian
|
|
|
71
71
|
export interface SpecialRequestProps {
|
|
72
72
|
asChild?: boolean;
|
|
73
73
|
children?: AsChildChildren<{
|
|
74
|
-
|
|
74
|
+
value: string;
|
|
75
75
|
onChange: (value: string) => void;
|
|
76
76
|
}>;
|
|
77
77
|
/** Placeholder text for the textarea */
|
|
@@ -99,7 +99,7 @@ export interface AddToCartButtonProps {
|
|
|
99
99
|
asChild?: boolean;
|
|
100
100
|
className?: string;
|
|
101
101
|
addToCartLabelMap: Record<AddToCartButtonState, string>;
|
|
102
|
-
children
|
|
102
|
+
children?: AsChildChildren<{
|
|
103
103
|
lineItem: LineItem;
|
|
104
104
|
buttonState: AddToCartButtonState;
|
|
105
105
|
addToCartButtonDisabled?: boolean;
|
|
@@ -108,7 +108,8 @@ export interface AddToCartButtonProps {
|
|
|
108
108
|
/** Text label for the button */
|
|
109
109
|
label: React.ReactNode;
|
|
110
110
|
formattedPrice: string;
|
|
111
|
-
|
|
111
|
+
modifierGroupHasError: boolean;
|
|
112
|
+
}>;
|
|
112
113
|
}
|
|
113
114
|
export declare const AddToCartButton: React.ForwardRefExoticComponent<AddToCartButtonProps & React.RefAttributes<HTMLElement>>;
|
|
114
115
|
export interface ItemDetailsQuantityProps {
|
|
@@ -39,7 +39,7 @@ export const Variants = React.forwardRef(({ children, className, asChild, varian
|
|
|
39
39
|
});
|
|
40
40
|
Variants.displayName = 'ItemDetails.Variants';
|
|
41
41
|
export const AddToCartButton = React.forwardRef(({ asChild, children, className, addToCartLabelMap, ...props }, ref) => {
|
|
42
|
-
return (_jsx(CoreItemDetails.LineItemComponent, { addToCartLabelMap: addToCartLabelMap, children: ({ lineItem, buttonState, addToCartButtonDisabled, loadingState, labelText, formattedPrice, }) => {
|
|
42
|
+
return (_jsx(CoreItemDetails.LineItemComponent, { addToCartLabelMap: addToCartLabelMap, children: ({ lineItem, buttonState, addToCartButtonDisabled, loadingState, labelText, formattedPrice, modifierGroupHasError, }) => {
|
|
43
43
|
const label = (_jsxs(_Fragment, { children: [_jsx("span", { children: labelText }), " ", _jsx("span", { children: " | " }), _jsx("span", { children: formattedPrice })] }));
|
|
44
44
|
return (_jsx(AsChildSlot, { asChild: asChild, className: className, customElement: children, customElementProps: {
|
|
45
45
|
buttonState,
|
|
@@ -49,14 +49,8 @@ export const AddToCartButton = React.forwardRef(({ asChild, children, className,
|
|
|
49
49
|
lineItems: [lineItem],
|
|
50
50
|
label,
|
|
51
51
|
formattedPrice,
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
buttonState,
|
|
55
|
-
addToCartButtonDisabled,
|
|
56
|
-
loadingState,
|
|
57
|
-
label,
|
|
58
|
-
formattedPrice,
|
|
59
|
-
}) }) }));
|
|
52
|
+
modifierGroupHasError,
|
|
53
|
+
}, ref: ref, ...props, children: _jsx(Commerce.Actions.AddToCart, { asChild: false, label: label, className: className, lineItems: [lineItem], ...props }) }));
|
|
60
54
|
} }));
|
|
61
55
|
});
|
|
62
56
|
AddToCartButton.displayName = 'AddToCartButton';
|
|
@@ -44,12 +44,12 @@ export const Description = React.forwardRef(({ ruleTypeMap, className, asChild,
|
|
|
44
44
|
} }));
|
|
45
45
|
});
|
|
46
46
|
Description.displayName = 'ItemDetailsModifierGroup.Description';
|
|
47
|
-
export const Error = React.forwardRef(({ ruleTypeMap, className, asChild, children }, ref) => {
|
|
47
|
+
export const Error = React.forwardRef(({ ruleTypeMap, className, asChild, children, ...otherProps }, ref) => {
|
|
48
48
|
return (_jsx(GroupError, { ruleTypeMap: ruleTypeMap, children: ({ error }) => {
|
|
49
49
|
if (!error) {
|
|
50
50
|
return null;
|
|
51
51
|
}
|
|
52
|
-
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild,
|
|
52
|
+
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, "data-testid": TestIds.modifierGroupError, className: className, customElement: children, customElementProps: { error }, content: error, ...otherProps, children: _jsx("p", { className: className, children: error }) }));
|
|
53
53
|
} }));
|
|
54
54
|
});
|
|
55
55
|
Error.displayName = 'ItemDetailsModifierGroup.Error';
|
|
@@ -1,31 +1,33 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { FulfillmentsServiceConfig } from '../types/fulfillments-types.js';
|
|
2
3
|
import { AsChildChildren } from '@wix/headless-utils/react';
|
|
4
|
+
/**
|
|
5
|
+
* Props for the Settings Root component
|
|
6
|
+
*/
|
|
7
|
+
export interface RootProps {
|
|
8
|
+
/** Child components that will have access to the settings context */
|
|
9
|
+
children: (props: {
|
|
10
|
+
isLoading: boolean;
|
|
11
|
+
}) => React.ReactNode;
|
|
12
|
+
/** Optional pre-loaded fulfillments service configuration */
|
|
13
|
+
fulfillmentsServiceConfig?: FulfillmentsServiceConfig;
|
|
14
|
+
}
|
|
3
15
|
/**
|
|
4
16
|
* Root headless component for OLO Settings
|
|
5
|
-
* Provides
|
|
17
|
+
* Provides service context for settings components
|
|
6
18
|
*
|
|
7
19
|
* @example
|
|
8
20
|
* ```tsx
|
|
9
|
-
* <Settings.Root>
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* <div>
|
|
13
|
-
* )
|
|
14
|
-
*
|
|
15
|
-
* ) : (
|
|
16
|
-
* <div>
|
|
17
|
-
* <h2>{currentDetails.name}</h2>
|
|
18
|
-
* <p>{currentDetails.address}</p>
|
|
19
|
-
* <p>Accepting Orders: {extraData.acceptingOrders ? 'Yes' : 'No'}</p>
|
|
20
|
-
* <p>Delivery Fee: ${extraData.deliveryFee}</p>
|
|
21
|
-
* <p>Min Order: ${extraData.minOrderAmount}</p>
|
|
22
|
-
* <p>Free Delivery: ${extraData.freeDeliveryThreshold}</p>
|
|
23
|
-
* </div>
|
|
24
|
-
* )
|
|
25
|
-
* )}
|
|
21
|
+
* <Settings.Root fulfillmentsServiceConfig={config}>
|
|
22
|
+
* <Settings.CurrentTimeSlot>
|
|
23
|
+
* {({ timeSlot, hasDetails }) => (
|
|
24
|
+
* <div>{timeSlot?.dispatchType}</div>
|
|
25
|
+
* )}
|
|
26
|
+
* </Settings.CurrentTimeSlot>
|
|
26
27
|
* </Settings.Root>
|
|
27
28
|
* ```
|
|
28
29
|
*/
|
|
30
|
+
export declare const Root: React.FC<RootProps>;
|
|
29
31
|
interface CurrentTimeSlotProps {
|
|
30
32
|
/** Children render prop that receives the current details */
|
|
31
33
|
children?: AsChildChildren<{
|
|
@@ -114,9 +116,10 @@ interface CurrentLocationProps {
|
|
|
114
116
|
* ```
|
|
115
117
|
*/
|
|
116
118
|
export declare const CurrentLocation: React.FC<CurrentLocationProps>;
|
|
117
|
-
interface ExtraDataProps {
|
|
119
|
+
interface ExtraDataProps extends Omit<React.ComponentPropsWithoutRef<'div'>, 'children'> {
|
|
120
|
+
asChild?: boolean;
|
|
118
121
|
/** Children render prop that receives the extra settings data */
|
|
119
|
-
children
|
|
122
|
+
children?: AsChildChildren<{
|
|
120
123
|
extraData: {
|
|
121
124
|
acceptingOrders: boolean;
|
|
122
125
|
deliveryFee?: number;
|
|
@@ -128,7 +131,7 @@ interface ExtraDataProps {
|
|
|
128
131
|
orderingDisabledReason?: string;
|
|
129
132
|
};
|
|
130
133
|
hasExtraData: boolean;
|
|
131
|
-
}
|
|
134
|
+
}> | React.ReactNode;
|
|
132
135
|
}
|
|
133
136
|
/**
|
|
134
137
|
* Headless component for extra settings data
|
|
@@ -1,8 +1,38 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { CoreSettings } from './core/index.js';
|
|
4
|
-
// import { OLOSettingsServiceConfig } from '../services/olo-settings-service.js';
|
|
5
4
|
import { AsChildSlot } from '@wix/headless-utils/react';
|
|
5
|
+
// ========================================
|
|
6
|
+
// OLO SETTINGS HEADLESS COMPONENTS
|
|
7
|
+
// ========================================
|
|
8
|
+
// Headless components that wrap CoreSettings and provide convenient service management
|
|
9
|
+
// These components handle service initialization and provide render props for UI
|
|
10
|
+
// ========================================
|
|
11
|
+
// ROOT COMPONENT
|
|
12
|
+
// ========================================
|
|
13
|
+
var TestIds;
|
|
14
|
+
(function (TestIds) {
|
|
15
|
+
TestIds["settingsRoot"] = "settings-root";
|
|
16
|
+
})(TestIds || (TestIds = {}));
|
|
17
|
+
/**
|
|
18
|
+
* Root headless component for OLO Settings
|
|
19
|
+
* Provides service context for settings components
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```tsx
|
|
23
|
+
* <Settings.Root fulfillmentsServiceConfig={config}>
|
|
24
|
+
* <Settings.CurrentTimeSlot>
|
|
25
|
+
* {({ timeSlot, hasDetails }) => (
|
|
26
|
+
* <div>{timeSlot?.dispatchType}</div>
|
|
27
|
+
* )}
|
|
28
|
+
* </Settings.CurrentTimeSlot>
|
|
29
|
+
* </Settings.Root>
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export const Root = ({ children, fulfillmentsServiceConfig, }) => {
|
|
33
|
+
return (_jsx(CoreSettings.Root, { fulfillmentsServiceConfig: fulfillmentsServiceConfig, "data-testid": TestIds.settingsRoot, children: ({ isLoading }) => children({ isLoading }) }));
|
|
34
|
+
};
|
|
35
|
+
Root.displayName = 'Settings.Root';
|
|
6
36
|
/**
|
|
7
37
|
* Headless component for current store details
|
|
8
38
|
* Provides access to store name, address, contact info, and hours
|
|
@@ -89,6 +119,6 @@ export const CurrentLocation = ({ children, className, asChild, }) => {
|
|
|
89
119
|
* </Settings.ExtraData>
|
|
90
120
|
* ```
|
|
91
121
|
*/
|
|
92
|
-
export const ExtraData = ({ children }) => {
|
|
93
|
-
return _jsx(CoreSettings.ExtraData, { children: children });
|
|
122
|
+
export const ExtraData = ({ children, asChild, className, ...rest }) => {
|
|
123
|
+
return (_jsx(CoreSettings.ExtraData, { children: ({ extraData, hasExtraData }) => (_jsx(AsChildSlot, { asChild: asChild, className: className, customElement: children, customElementProps: { extraData, hasExtraData }, content: hasExtraData ? (_jsx("div", { children: extraData.acceptingOrders ? 'Accepting Orders' : 'Closed' })) : null, ...rest, children: hasExtraData ? (_jsx("div", { children: extraData.acceptingOrders ? 'Accepting Orders' : 'Closed' })) : null })) }));
|
|
94
124
|
};
|
|
@@ -26,6 +26,7 @@ interface ItemDetailsLineItemProps {
|
|
|
26
26
|
addToCartButtonDisabled: boolean;
|
|
27
27
|
labelText: string;
|
|
28
28
|
formattedPrice: string;
|
|
29
|
+
modifierGroupHasError: boolean;
|
|
29
30
|
}) => React.ReactNode;
|
|
30
31
|
}
|
|
31
32
|
export declare const LineItemComponent: React.FC<ItemDetailsLineItemProps>;
|
|
@@ -24,11 +24,14 @@ export const Root = ({ children, itemDetailsServiceConfig, }) => {
|
|
|
24
24
|
return (_jsx(WixServices, { servicesMap: createServicesMap().addService(ItemServiceDefinition, ItemService, config), children: children({ item: itemDetailsServiceConfig?.item ?? selectedItem }) }));
|
|
25
25
|
};
|
|
26
26
|
export const SpecialRequest = ({ children, }) => {
|
|
27
|
-
const [value, setValue] = useState('');
|
|
28
27
|
const service = useService(ItemServiceDefinition);
|
|
28
|
+
const initialSpecialRequest = service.specialRequest?.get?.() ?? '';
|
|
29
|
+
const [value, setValue] = useState(initialSpecialRequest);
|
|
29
30
|
const onChange = (newValue) => {
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
if (typeof newValue === 'string') {
|
|
32
|
+
setValue(newValue);
|
|
33
|
+
service.updateSpecialRequest(newValue);
|
|
34
|
+
}
|
|
32
35
|
};
|
|
33
36
|
return children({
|
|
34
37
|
value,
|
|
@@ -48,6 +51,7 @@ export const LineItemComponent = ({ addToCartLabelMap, children, }) => {
|
|
|
48
51
|
const formatCurrency = oloSettingsService.formatCurrency;
|
|
49
52
|
const formattedPrice = formatCurrency(price);
|
|
50
53
|
const labelText = addToCartLabelMap[buttonState];
|
|
54
|
+
const modifierGroupHasError = service.doesModifierGroupHaveError?.get?.() ?? false;
|
|
51
55
|
return children({
|
|
52
56
|
loadingState,
|
|
53
57
|
lineItem,
|
|
@@ -55,6 +59,7 @@ export const LineItemComponent = ({ addToCartLabelMap, children, }) => {
|
|
|
55
59
|
addToCartButtonDisabled,
|
|
56
60
|
labelText,
|
|
57
61
|
formattedPrice,
|
|
62
|
+
modifierGroupHasError,
|
|
58
63
|
});
|
|
59
64
|
};
|
|
60
65
|
export const QuantityComponent = ({ children, }) => {
|
|
@@ -49,8 +49,7 @@ export const ModifiersComponent = ({ children, }) => {
|
|
|
49
49
|
};
|
|
50
50
|
export const Description = ({ ruleTypeMap, children, }) => {
|
|
51
51
|
const { ruleType, modifierGroup } = useModifiersContext();
|
|
52
|
-
const
|
|
53
|
-
const description = getRuleTypeMapValue(ruleTypeMap, ruleType, modifierGroupName, modifierGroup.rule);
|
|
52
|
+
const description = getRuleTypeMapValue(ruleTypeMap, ruleType, modifierGroup.rule);
|
|
54
53
|
return children({ description });
|
|
55
54
|
};
|
|
56
55
|
export const GroupError = ({ ruleTypeMap, children, }) => {
|
|
@@ -58,10 +57,9 @@ export const GroupError = ({ ruleTypeMap, children, }) => {
|
|
|
58
57
|
const { ruleType, modifierGroup } = useModifiersContext();
|
|
59
58
|
const groupId = modifierGroup._id || '';
|
|
60
59
|
const modifierGroupErrors = service.modifierGroupError?.get() || {};
|
|
61
|
-
const modifierGroupName = modifierGroup.name || '';
|
|
62
60
|
let error;
|
|
63
61
|
if (modifierGroupErrors[groupId]) {
|
|
64
|
-
error = getRuleTypeMapValue(ruleTypeMap, ruleType,
|
|
62
|
+
error = getRuleTypeMapValue(ruleTypeMap, ruleType, modifierGroup.rule);
|
|
65
63
|
}
|
|
66
64
|
return children({ error });
|
|
67
65
|
};
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
3
|
import { createServicesMap } from '@wix/services-manager';
|
|
4
4
|
import { WixServices } from '@wix/services-manager-react';
|
|
5
5
|
// import { ItemService, ItemServiceDefinition, loadItemServiceConfig } from '@/components/restaurants-olo/services/itemDetailsService';
|
|
6
6
|
import { OLOSettingsService, OLOSettingsServiceDefinition, } from '@wix/headless-restaurants-olo/services';
|
|
7
|
-
import { FulfillmentsService, FulfillmentsServiceDefinition, loadFulfillmentsServiceConfig, } from '../../services/fulfillments-service.js';
|
|
8
7
|
/**
|
|
9
8
|
* Core OLO Root component that sets up service management
|
|
10
9
|
* Provides ItemService and CurrentCartService to child components
|
|
@@ -25,9 +24,6 @@ import { FulfillmentsService, FulfillmentsServiceDefinition, loadFulfillmentsSer
|
|
|
25
24
|
* ```
|
|
26
25
|
*/
|
|
27
26
|
export const Root = ({ itemId, itemServiceConfig, cartServiceConfig, oloSettingsServiceConfig, children, }) => {
|
|
28
|
-
const [fulfillmentsServiceConfig, setFulfillmentsServiceConfig] = useState({
|
|
29
|
-
operation: oloSettingsServiceConfig?.operation ?? undefined,
|
|
30
|
-
});
|
|
31
27
|
// const [servicesManager, setServicesManager] = useState<ServicesManager | null>(null);
|
|
32
28
|
// const [isLoading, setIsLoading] = useState(true);
|
|
33
29
|
// const [error, setError] = useState<string | undefined>();
|
|
@@ -90,17 +86,7 @@ export const Root = ({ itemId, itemServiceConfig, cartServiceConfig, oloSettings
|
|
|
90
86
|
// hasServices
|
|
91
87
|
// });
|
|
92
88
|
console.log('oloSettingsServiceConfig', oloSettingsServiceConfig);
|
|
93
|
-
|
|
94
|
-
if (oloSettingsServiceConfig?.operation?._id) {
|
|
95
|
-
loadFulfillmentsServiceConfig(oloSettingsServiceConfig.operation).then((config) => {
|
|
96
|
-
console.log('config', config);
|
|
97
|
-
setFulfillmentsServiceConfig(config);
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
}, [oloSettingsServiceConfig?.operation?._id]);
|
|
101
|
-
return (_jsx(WixServices, { servicesMap: createServicesMap()
|
|
102
|
-
.addService(OLOSettingsServiceDefinition, OLOSettingsService, oloSettingsServiceConfig)
|
|
103
|
-
.addService(FulfillmentsServiceDefinition, FulfillmentsService, fulfillmentsServiceConfig), children: children }));
|
|
89
|
+
return (_jsx(WixServices, { servicesMap: createServicesMap().addService(OLOSettingsServiceDefinition, OLOSettingsService, oloSettingsServiceConfig), children: children }));
|
|
104
90
|
};
|
|
105
91
|
/**
|
|
106
92
|
* Convenience wrapper that combines Root with ServicesManagerProvider
|
|
@@ -1,89 +1,58 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import * as operationsSDK from '@wix/auto_sdk_restaurants_operations';
|
|
3
|
-
import { TimeSlot } from '../../types/fulfillments-types.js';
|
|
4
|
-
interface
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
interface CurrentLocation {
|
|
11
|
-
name: string;
|
|
12
|
-
}
|
|
13
|
-
interface ExtraData {
|
|
14
|
-
acceptingOrders: boolean;
|
|
15
|
-
deliveryFee?: number;
|
|
16
|
-
minOrderAmount?: number;
|
|
17
|
-
freeDeliveryThreshold?: number;
|
|
18
|
-
taxRate?: number;
|
|
19
|
-
serviceCharge?: number;
|
|
20
|
-
isOnline?: boolean;
|
|
21
|
-
orderingDisabledReason?: string;
|
|
22
|
-
}
|
|
23
|
-
interface SettingsData {
|
|
24
|
-
currentTime: CurrentTime;
|
|
25
|
-
currentFulfillment: CurrentFulfillment;
|
|
26
|
-
currentLocation: CurrentLocation;
|
|
27
|
-
selectedFulfillment: any;
|
|
28
|
-
extraData: ExtraData;
|
|
29
|
-
isLoading: boolean;
|
|
30
|
-
error?: string | null;
|
|
31
|
-
}
|
|
32
|
-
interface SettingsRootProps {
|
|
33
|
-
children: (props: SettingsData) => React.ReactNode;
|
|
3
|
+
import { FulfillmentsServiceConfig, TimeSlot } from '../../types/fulfillments-types.js';
|
|
4
|
+
export interface RootProps {
|
|
5
|
+
children: (props: {
|
|
6
|
+
isLoading: boolean;
|
|
7
|
+
}) => React.ReactNode;
|
|
8
|
+
fulfillmentsServiceConfig?: FulfillmentsServiceConfig;
|
|
34
9
|
}
|
|
35
10
|
/**
|
|
36
|
-
* Core Settings component that provides
|
|
37
|
-
*
|
|
11
|
+
* Core Settings Root component that provides service context
|
|
12
|
+
* Wraps children with both OLOSettingsService and FulfillmentsService providers
|
|
38
13
|
*
|
|
39
14
|
* @example
|
|
40
15
|
* ```tsx
|
|
41
|
-
* <CoreSettings.Root>
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* <div>
|
|
45
|
-
* )
|
|
46
|
-
*
|
|
47
|
-
* ) : (
|
|
48
|
-
* <div>
|
|
49
|
-
* <h2>{currentDetails.name}</h2>
|
|
50
|
-
* <p>Accepting Orders: {extraData.acceptingOrders ? 'Yes' : 'No'}</p>
|
|
51
|
-
* <p>Delivery Fee: ${extraData.deliveryFee}</p>
|
|
52
|
-
* </div>
|
|
53
|
-
* )
|
|
54
|
-
* )}
|
|
16
|
+
* <CoreSettings.Root fulfillmentsServiceConfig={config}>
|
|
17
|
+
* <CoreSettings.CurrentTimeSlot>
|
|
18
|
+
* {({ timeSlot, hasDetails }) => (
|
|
19
|
+
* <div>{timeSlot?.dispatchType}</div>
|
|
20
|
+
* )}
|
|
21
|
+
* </CoreSettings.CurrentTimeSlot>
|
|
55
22
|
* </CoreSettings.Root>
|
|
56
23
|
* ```
|
|
57
24
|
*/
|
|
58
|
-
export declare const Root: React.FC<
|
|
59
|
-
interface CurrentTimeSlotProps {
|
|
25
|
+
export declare const Root: React.FC<RootProps>;
|
|
26
|
+
export interface CurrentTimeSlotProps {
|
|
60
27
|
children: (props: {
|
|
61
28
|
timeSlot: TimeSlot;
|
|
62
29
|
hasDetails: boolean;
|
|
63
30
|
}) => React.ReactNode;
|
|
64
31
|
}
|
|
65
32
|
/**
|
|
66
|
-
* Component that provides access to current
|
|
33
|
+
* Component that provides access to current time slot
|
|
67
34
|
*
|
|
68
35
|
* @example
|
|
69
36
|
* ```tsx
|
|
70
37
|
* <CoreSettings.CurrentTimeSlot>
|
|
71
|
-
* {({
|
|
38
|
+
* {({ timeSlot, hasDetails }) => (
|
|
72
39
|
* hasDetails ? (
|
|
73
40
|
* <div>
|
|
74
|
-
* <h3>{
|
|
41
|
+
* <h3>{timeSlot.dispatchType}</h3>
|
|
75
42
|
* </div>
|
|
76
43
|
* ) : (
|
|
77
|
-
* <div>No
|
|
44
|
+
* <div>No time slot selected</div>
|
|
78
45
|
* )
|
|
79
46
|
* )}
|
|
80
47
|
* </CoreSettings.CurrentTimeSlot>
|
|
81
48
|
* ```
|
|
82
49
|
*/
|
|
83
50
|
export declare const CurrentTimeSlot: React.FC<CurrentTimeSlotProps>;
|
|
84
|
-
interface CurrentFulfillmentProps {
|
|
51
|
+
export interface CurrentFulfillmentProps {
|
|
85
52
|
children: (props: {
|
|
86
|
-
fulfillment:
|
|
53
|
+
fulfillment: {
|
|
54
|
+
current?: operationsSDK.TimeSlot;
|
|
55
|
+
};
|
|
87
56
|
hasFulfillment: boolean;
|
|
88
57
|
availableOptions: string[];
|
|
89
58
|
}) => React.ReactNode;
|
|
@@ -106,9 +75,11 @@ interface CurrentFulfillmentProps {
|
|
|
106
75
|
* ```
|
|
107
76
|
*/
|
|
108
77
|
export declare const CurrentFulfillment: React.FC<CurrentFulfillmentProps>;
|
|
109
|
-
interface CurrentLocationProps {
|
|
78
|
+
export interface CurrentLocationProps {
|
|
110
79
|
children: (props: {
|
|
111
|
-
location:
|
|
80
|
+
location: {
|
|
81
|
+
name: string;
|
|
82
|
+
};
|
|
112
83
|
hasLocation: boolean;
|
|
113
84
|
}) => React.ReactNode;
|
|
114
85
|
}
|
|
@@ -118,21 +89,27 @@ interface CurrentLocationProps {
|
|
|
118
89
|
* @example
|
|
119
90
|
* ```tsx
|
|
120
91
|
* <CoreSettings.CurrentLocation>
|
|
121
|
-
* {({ location,
|
|
92
|
+
* {({ location, hasLocation }) => (
|
|
122
93
|
* <div>
|
|
123
|
-
* <p>{location.
|
|
124
|
-
* {hasCoordinates && (
|
|
125
|
-
* <p>Coordinates: {location.latitude}, {location.longitude}</p>
|
|
126
|
-
* )}
|
|
94
|
+
* <p>{location.name}</p>
|
|
127
95
|
* </div>
|
|
128
96
|
* )}
|
|
129
97
|
* </CoreSettings.CurrentLocation>
|
|
130
98
|
* ```
|
|
131
99
|
*/
|
|
132
100
|
export declare const CurrentLocation: React.FC<CurrentLocationProps>;
|
|
133
|
-
interface ExtraDataProps {
|
|
101
|
+
export interface ExtraDataProps {
|
|
134
102
|
children: (props: {
|
|
135
|
-
extraData:
|
|
103
|
+
extraData: {
|
|
104
|
+
acceptingOrders: boolean;
|
|
105
|
+
deliveryFee?: number;
|
|
106
|
+
minOrderAmount?: number;
|
|
107
|
+
freeDeliveryThreshold?: number;
|
|
108
|
+
taxRate?: number;
|
|
109
|
+
serviceCharge?: number;
|
|
110
|
+
isOnline?: boolean;
|
|
111
|
+
orderingDisabledReason?: string;
|
|
112
|
+
};
|
|
136
113
|
hasExtraData: boolean;
|
|
137
114
|
}) => React.ReactNode;
|
|
138
115
|
}
|
|
@@ -154,4 +131,3 @@ interface ExtraDataProps {
|
|
|
154
131
|
* ```
|
|
155
132
|
*/
|
|
156
133
|
export declare const ExtraData: React.FC<ExtraDataProps>;
|
|
157
|
-
export {};
|