@open-tender/utils 0.5.61 → 0.5.63
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/dist/cjs/hooks/useAccordion.d.ts +1 -1
- package/dist/cjs/hooks/useAccordion.js +7 -1
- package/dist/cjs/hooks/useBuilder.d.ts +1 -0
- package/dist/cjs/hooks/useBuilder.js +5 -1
- package/dist/cjs/utils/cart.js +1 -1
- package/dist/esm/hooks/useAccordion.d.ts +1 -1
- package/dist/esm/hooks/useAccordion.js +7 -1
- package/dist/esm/hooks/useBuilder.d.ts +1 -0
- package/dist/esm/hooks/useBuilder.js +5 -1
- package/dist/esm/utils/cart.js +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { CartItem, CartLevels, ConfigAccordion } from '@open-tender/types';
|
|
3
|
-
export declare const useAccordion: (builtItem: CartItem, toggleOption: (levels: CartLevels) => void, cartId?: number | null, config?: ConfigAccordion) => {
|
|
3
|
+
export declare const useAccordion: (builtItem: CartItem, toggleOption: (levels: CartLevels) => void, cartId?: number | null, config?: ConfigAccordion, setImageUrl?: ((imageUrl: string | null) => void) | undefined) => {
|
|
4
4
|
open: string | null;
|
|
5
5
|
setOpen: import("react").Dispatch<import("react").SetStateAction<string | null>>;
|
|
6
6
|
groups: import("@open-tender/types").CartItemGroups;
|
|
@@ -3,7 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useAccordion = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
|
-
const useAccordion = (builtItem, toggleOption, cartId, config
|
|
6
|
+
const useAccordion = (builtItem, toggleOption, cartId, config, setImageUrl //
|
|
7
|
+
) => {
|
|
7
8
|
var _a;
|
|
8
9
|
const { hasCals: showCals = false, hasCustomize = false, hasMadeFor: showMadeFor = true, hasNotes: showNotes = true } = config || {};
|
|
9
10
|
const [open, setOpen] = (0, react_1.useState)(null);
|
|
@@ -29,6 +30,11 @@ const useAccordion = (builtItem, toggleOption, cartId, config) => {
|
|
|
29
30
|
const toggleSize = (optionId) => {
|
|
30
31
|
if (sizeGroup) {
|
|
31
32
|
toggleOption([[sizeGroup.id, optionId]]);
|
|
33
|
+
if (setImageUrl) {
|
|
34
|
+
const selectedOption = sizeGroup.options.find(o => o.id === optionId);
|
|
35
|
+
if (selectedOption && (selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.imageUrl))
|
|
36
|
+
setImageUrl(selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.imageUrl);
|
|
37
|
+
}
|
|
32
38
|
setOpen(null);
|
|
33
39
|
}
|
|
34
40
|
};
|
|
@@ -12,4 +12,5 @@ export declare const useBuilder: (orderItem: CartItem, orderTimeoutCallback?: ()
|
|
|
12
12
|
decrementOption: (levels: CartLevels) => CartItem;
|
|
13
13
|
setOptionQuantity: (levels: CartLevels, quantity: number) => CartItem;
|
|
14
14
|
setGroups: (groups: CartItemGroups) => void;
|
|
15
|
+
setImageUrl: (imageUrl: string | null) => void;
|
|
15
16
|
};
|
|
@@ -138,6 +138,9 @@ const useBuilder = (orderItem, orderTimeoutCallback) => {
|
|
|
138
138
|
const pricedItem = (0, utils_1.calcPrices)(Object.assign(Object.assign({}, item), { groups }));
|
|
139
139
|
setItem(pricedItem);
|
|
140
140
|
};
|
|
141
|
+
const setImageUrl = (imageUrl) => {
|
|
142
|
+
setItem(prev => (Object.assign(Object.assign({}, prev), { imageUrl })));
|
|
143
|
+
};
|
|
141
144
|
return {
|
|
142
145
|
item,
|
|
143
146
|
increment,
|
|
@@ -150,7 +153,8 @@ const useBuilder = (orderItem, orderTimeoutCallback) => {
|
|
|
150
153
|
incrementOption,
|
|
151
154
|
decrementOption,
|
|
152
155
|
setOptionQuantity,
|
|
153
|
-
setGroups
|
|
156
|
+
setGroups,
|
|
157
|
+
setImageUrl
|
|
154
158
|
};
|
|
155
159
|
};
|
|
156
160
|
exports.useBuilder = useBuilder;
|
package/dist/cjs/utils/cart.js
CHANGED
|
@@ -214,7 +214,7 @@ const makeOrderItemGroups = (optionGroups, isEdit, soldOut = [], requestedAt = n
|
|
|
214
214
|
const quantity = isSoldOut
|
|
215
215
|
? 0
|
|
216
216
|
: o.opt_is_default && !isEdit
|
|
217
|
-
? o.min_quantity
|
|
217
|
+
? o.min_quantity
|
|
218
218
|
: 0;
|
|
219
219
|
const cals = ((_a = o.nutritional_info) === null || _a === void 0 ? void 0 : _a.calories)
|
|
220
220
|
? parseInt(o.nutritional_info.calories.toString())
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { CartItem, CartLevels, ConfigAccordion } from '@open-tender/types';
|
|
3
|
-
export declare const useAccordion: (builtItem: CartItem, toggleOption: (levels: CartLevels) => void, cartId?: number | null, config?: ConfigAccordion) => {
|
|
3
|
+
export declare const useAccordion: (builtItem: CartItem, toggleOption: (levels: CartLevels) => void, cartId?: number | null, config?: ConfigAccordion, setImageUrl?: ((imageUrl: string | null) => void) | undefined) => {
|
|
4
4
|
open: string | null;
|
|
5
5
|
setOpen: import("react").Dispatch<import("react").SetStateAction<string | null>>;
|
|
6
6
|
groups: import("@open-tender/types").CartItemGroups;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
2
|
import { calcNutritionalInfo } from '../utils';
|
|
3
|
-
export const useAccordion = (builtItem, toggleOption, cartId, config
|
|
3
|
+
export const useAccordion = (builtItem, toggleOption, cartId, config, setImageUrl //
|
|
4
|
+
) => {
|
|
4
5
|
var _a;
|
|
5
6
|
const { hasCals: showCals = false, hasCustomize = false, hasMadeFor: showMadeFor = true, hasNotes: showNotes = true } = config || {};
|
|
6
7
|
const [open, setOpen] = useState(null);
|
|
@@ -26,6 +27,11 @@ export const useAccordion = (builtItem, toggleOption, cartId, config) => {
|
|
|
26
27
|
const toggleSize = (optionId) => {
|
|
27
28
|
if (sizeGroup) {
|
|
28
29
|
toggleOption([[sizeGroup.id, optionId]]);
|
|
30
|
+
if (setImageUrl) {
|
|
31
|
+
const selectedOption = sizeGroup.options.find(o => o.id === optionId);
|
|
32
|
+
if (selectedOption && (selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.imageUrl))
|
|
33
|
+
setImageUrl(selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.imageUrl);
|
|
34
|
+
}
|
|
29
35
|
setOpen(null);
|
|
30
36
|
}
|
|
31
37
|
};
|
|
@@ -12,4 +12,5 @@ export declare const useBuilder: (orderItem: CartItem, orderTimeoutCallback?: ()
|
|
|
12
12
|
decrementOption: (levels: CartLevels) => CartItem;
|
|
13
13
|
setOptionQuantity: (levels: CartLevels, quantity: number) => CartItem;
|
|
14
14
|
setGroups: (groups: CartItemGroups) => void;
|
|
15
|
+
setImageUrl: (imageUrl: string | null) => void;
|
|
15
16
|
};
|
|
@@ -135,6 +135,9 @@ export const useBuilder = (orderItem, orderTimeoutCallback) => {
|
|
|
135
135
|
const pricedItem = calcPrices(Object.assign(Object.assign({}, item), { groups }));
|
|
136
136
|
setItem(pricedItem);
|
|
137
137
|
};
|
|
138
|
+
const setImageUrl = (imageUrl) => {
|
|
139
|
+
setItem(prev => (Object.assign(Object.assign({}, prev), { imageUrl })));
|
|
140
|
+
};
|
|
138
141
|
return {
|
|
139
142
|
item,
|
|
140
143
|
increment,
|
|
@@ -147,6 +150,7 @@ export const useBuilder = (orderItem, orderTimeoutCallback) => {
|
|
|
147
150
|
incrementOption,
|
|
148
151
|
decrementOption,
|
|
149
152
|
setOptionQuantity,
|
|
150
|
-
setGroups
|
|
153
|
+
setGroups,
|
|
154
|
+
setImageUrl
|
|
151
155
|
};
|
|
152
156
|
};
|
package/dist/esm/utils/cart.js
CHANGED
|
@@ -199,7 +199,7 @@ const makeOrderItemGroups = (optionGroups, isEdit, soldOut = [], requestedAt = n
|
|
|
199
199
|
const quantity = isSoldOut
|
|
200
200
|
? 0
|
|
201
201
|
: o.opt_is_default && !isEdit
|
|
202
|
-
? o.min_quantity
|
|
202
|
+
? o.min_quantity
|
|
203
203
|
: 0;
|
|
204
204
|
const cals = ((_a = o.nutritional_info) === null || _a === void 0 ? void 0 : _a.calories)
|
|
205
205
|
? parseInt(o.nutritional_info.calories.toString())
|
package/package.json
CHANGED