@open-tender/store 1.1.201 → 1.1.202
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.
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { MenuItem, MenuItemFavorite } from '@open-tender/types';
|
|
2
2
|
import { CategoryItemProps } from '@open-tender/ui';
|
|
3
3
|
import { ReactNode } from 'react';
|
|
4
|
-
|
|
4
|
+
interface CategoryItemInterface {
|
|
5
5
|
item: MenuItem;
|
|
6
6
|
favorite?: MenuItemFavorite;
|
|
7
7
|
allergenAlerts?: string[];
|
|
8
8
|
placeholder?: string;
|
|
9
9
|
navigate: (route: string) => void;
|
|
10
10
|
children: (props: CategoryItemProps) => ReactNode;
|
|
11
|
-
}
|
|
12
|
-
|
|
11
|
+
}
|
|
12
|
+
declare const _default: import("react").MemoExoticComponent<({ item, favorite, allergenAlerts, placeholder, navigate, children }: CategoryItemInterface) => ReactNode>;
|
|
13
|
+
export default _default;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
var tslib_1 = require("tslib");
|
|
4
4
|
var utils_1 = require("@open-tender/utils");
|
|
5
|
+
var react_1 = require("react");
|
|
5
6
|
var hooks_1 = require("../app/hooks");
|
|
6
7
|
var slices_1 = require("../slices");
|
|
7
8
|
var CategoryItem = function (_a) {
|
|
@@ -16,14 +17,18 @@ var CategoryItem = function (_a) {
|
|
|
16
17
|
var displaySettings = {};
|
|
17
18
|
var _b = displaySettings || {}, _c = _b.calories, showCals = _c === void 0 ? false : _c, _d = _b.tags, showTags = _d === void 0 ? false : _d, _e = _b.allergens, showAllergens = _e === void 0 ? false : _e;
|
|
18
19
|
var showDesc = 'SHOW';
|
|
19
|
-
var orderItem =
|
|
20
|
-
|
|
20
|
+
var orderItem = (0, react_1.useMemo)(function () {
|
|
21
|
+
return favorite
|
|
22
|
+
? tslib_1.__assign(tslib_1.__assign({}, (0, utils_1.rehydrateOrderItem)(item, favorite.item)), { index: -1 }) : (0, utils_1.makeOrderItem)(item, undefined, soldOut, undefined, hasPoints);
|
|
23
|
+
}, [favorite, hasPoints, item, soldOut]);
|
|
21
24
|
var cartItem = (0, utils_1.useOrderItem)(orderItem, favorite, allergenAlerts, cartCounts, showCals, showTags, showAllergens, showDesc);
|
|
22
|
-
var
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
var handlers = (0, react_1.useMemo)(function () {
|
|
26
|
+
var browse = function () {
|
|
27
|
+
dispatch((0, slices_1.setCurrentItem)(cartItem));
|
|
28
|
+
navigate('/menu/item');
|
|
29
|
+
};
|
|
30
|
+
return { browse: browse };
|
|
31
|
+
}, [navigate, dispatch, cartItem]);
|
|
27
32
|
if (!config)
|
|
28
33
|
return null;
|
|
29
34
|
return children({
|
|
@@ -35,4 +40,10 @@ var CategoryItem = function (_a) {
|
|
|
35
40
|
displayCals: display_cals
|
|
36
41
|
});
|
|
37
42
|
};
|
|
38
|
-
exports.default = CategoryItem;
|
|
43
|
+
exports.default = (0, react_1.memo)(CategoryItem, areEqualProps);
|
|
44
|
+
function areEqualProps(oldProps, newProps) {
|
|
45
|
+
var _a, _b, _c, _d;
|
|
46
|
+
return (oldProps.item.id === newProps.item.id &&
|
|
47
|
+
((_a = oldProps.favorite) === null || _a === void 0 ? void 0 : _a.item.id) === ((_b = newProps.favorite) === null || _b === void 0 ? void 0 : _b.item.id) &&
|
|
48
|
+
((_c = oldProps.allergenAlerts) === null || _c === void 0 ? void 0 : _c.length) === ((_d = newProps.allergenAlerts) === null || _d === void 0 ? void 0 : _d.length));
|
|
49
|
+
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { MenuItem, MenuItemFavorite } from '@open-tender/types';
|
|
2
2
|
import { CategoryItemProps } from '@open-tender/ui';
|
|
3
3
|
import { ReactNode } from 'react';
|
|
4
|
-
|
|
4
|
+
interface CategoryItemInterface {
|
|
5
5
|
item: MenuItem;
|
|
6
6
|
favorite?: MenuItemFavorite;
|
|
7
7
|
allergenAlerts?: string[];
|
|
8
8
|
placeholder?: string;
|
|
9
9
|
navigate: (route: string) => void;
|
|
10
10
|
children: (props: CategoryItemProps) => ReactNode;
|
|
11
|
-
}
|
|
12
|
-
|
|
11
|
+
}
|
|
12
|
+
declare const _default: import("react").MemoExoticComponent<({ item, favorite, allergenAlerts, placeholder, navigate, children }: CategoryItemInterface) => ReactNode>;
|
|
13
|
+
export default _default;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { __assign } from "tslib";
|
|
2
2
|
import { makeOrderItem, rehydrateOrderItem, useOrderItem } from '@open-tender/utils';
|
|
3
|
+
import { memo, useMemo } from 'react';
|
|
3
4
|
import { useAppDispatch, useAppSelector } from '../app/hooks';
|
|
4
5
|
import { selectCartCounts, selectKioskApi, selectKioskConfig, selectMenu, selectStoreSettings, setCurrentItem } from '../slices';
|
|
5
6
|
var CategoryItem = function (_a) {
|
|
@@ -14,14 +15,18 @@ var CategoryItem = function (_a) {
|
|
|
14
15
|
var displaySettings = {};
|
|
15
16
|
var _b = displaySettings || {}, _c = _b.calories, showCals = _c === void 0 ? false : _c, _d = _b.tags, showTags = _d === void 0 ? false : _d, _e = _b.allergens, showAllergens = _e === void 0 ? false : _e;
|
|
16
17
|
var showDesc = 'SHOW';
|
|
17
|
-
var orderItem =
|
|
18
|
-
|
|
18
|
+
var orderItem = useMemo(function () {
|
|
19
|
+
return favorite
|
|
20
|
+
? __assign(__assign({}, rehydrateOrderItem(item, favorite.item)), { index: -1 }) : makeOrderItem(item, undefined, soldOut, undefined, hasPoints);
|
|
21
|
+
}, [favorite, hasPoints, item, soldOut]);
|
|
19
22
|
var cartItem = useOrderItem(orderItem, favorite, allergenAlerts, cartCounts, showCals, showTags, showAllergens, showDesc);
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
var handlers = useMemo(function () {
|
|
24
|
+
var browse = function () {
|
|
25
|
+
dispatch(setCurrentItem(cartItem));
|
|
26
|
+
navigate('/menu/item');
|
|
27
|
+
};
|
|
28
|
+
return { browse: browse };
|
|
29
|
+
}, [navigate, dispatch, cartItem]);
|
|
25
30
|
if (!config)
|
|
26
31
|
return null;
|
|
27
32
|
return children({
|
|
@@ -33,4 +38,10 @@ var CategoryItem = function (_a) {
|
|
|
33
38
|
displayCals: display_cals
|
|
34
39
|
});
|
|
35
40
|
};
|
|
36
|
-
export default CategoryItem;
|
|
41
|
+
export default memo(CategoryItem, areEqualProps);
|
|
42
|
+
function areEqualProps(oldProps, newProps) {
|
|
43
|
+
var _a, _b, _c, _d;
|
|
44
|
+
return (oldProps.item.id === newProps.item.id &&
|
|
45
|
+
((_a = oldProps.favorite) === null || _a === void 0 ? void 0 : _a.item.id) === ((_b = newProps.favorite) === null || _b === void 0 ? void 0 : _b.item.id) &&
|
|
46
|
+
((_c = oldProps.allergenAlerts) === null || _c === void 0 ? void 0 : _c.length) === ((_d = newProps.allergenAlerts) === null || _d === void 0 ? void 0 : _d.length));
|
|
47
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-tender/store",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.202",
|
|
4
4
|
"description": "A library of hooks, reducers, utility functions, and types for use with Open Tender applications that utilize our in-store POS API",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
63
|
"@emotion/react": "^11.11.1",
|
|
64
|
-
"@open-tender/types": "^0.4.
|
|
64
|
+
"@open-tender/types": "^0.4.84",
|
|
65
65
|
"@open-tender/ui": "^0.4.17",
|
|
66
66
|
"@open-tender/utils": "^0.4.61",
|
|
67
67
|
"@reduxjs/toolkit": "^2.0.1",
|