@open-tender/store 1.1.200 → 1.1.201

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,11 +1,11 @@
1
1
  import { MenuCategory } from '@open-tender/types';
2
2
  import { CategoryNavItemProps } from '@open-tender/ui';
3
3
  import { ReactNode } from 'react';
4
- declare const CategoryNavItem: ({ index, category, children, navigate, scrollToIndex }: {
5
- index?: number;
4
+ declare const CategoryNavItem: ({ category, isScrollable, isActive, children, navigate }: {
6
5
  category: MenuCategory;
7
- navigate: (route: string) => void;
6
+ isScrollable?: boolean;
7
+ isActive?: boolean;
8
+ navigate?: (route: string) => void;
8
9
  children: (props: CategoryNavItemProps) => ReactNode;
9
- scrollToIndex?: (index: number) => void;
10
10
  }) => ReactNode;
11
11
  export default CategoryNavItem;
@@ -4,24 +4,21 @@ var ui_1 = require("@open-tender/ui");
4
4
  var hooks_1 = require("../app/hooks");
5
5
  var slices_1 = require("../slices");
6
6
  var CategoryNavItem = function (_a) {
7
- var index = _a.index, category = _a.category, children = _a.children, navigate = _a.navigate, scrollToIndex = _a.scrollToIndex;
7
+ var category = _a.category, isScrollable = _a.isScrollable, isActive = _a.isActive, children = _a.children, navigate = _a.navigate;
8
8
  var dispatch = (0, hooks_1.useAppDispatch)();
9
9
  var apiUrl = (0, hooks_1.useAppSelector)(slices_1.selectKioskApi);
10
10
  var display_category_nav_page = (0, hooks_1.useAppSelector)(slices_1.selectStoreSettings).display_category_nav_page;
11
11
  var current = (0, hooks_1.useAppSelector)(slices_1.selectCurrentCategory);
12
- var isCurrent = (current === null || current === void 0 ? void 0 : current.id) === category.id;
12
+ var isCurrent = isActive || (current === null || current === void 0 ? void 0 : current.id) === category.id;
13
13
  var _b = (0, hooks_1.useAppSelector)(slices_1.selectKioskConfig), categoryNavItem = _b.categoryNavItem, categoryNavItemSelected = _b.categoryNavItemSelected;
14
14
  var config = isCurrent ? categoryNavItemSelected : categoryNavItem;
15
15
  var name = category.name;
16
16
  var imageUrl = (0, ui_1.makeImageUrl)(category);
17
17
  var browse = function () {
18
18
  dispatch((0, slices_1.setCurrentCategory)(category));
19
- if (scrollToIndex && index !== undefined) {
20
- scrollToIndex(index);
21
- }
22
- else {
19
+ !isScrollable &&
20
+ navigate &&
23
21
  navigate(display_category_nav_page ? '/menu/category' : '/menu');
24
- }
25
22
  };
26
23
  var handlers = { browse: browse };
27
24
  if (!config)
@@ -31,7 +28,8 @@ var CategoryNavItem = function (_a) {
31
28
  handlers: handlers,
32
29
  title: name,
33
30
  imageUrl: imageUrl,
34
- apiUrl: apiUrl
31
+ apiUrl: apiUrl,
32
+ disabled: isScrollable
35
33
  });
36
34
  };
37
35
  exports.default = CategoryNavItem;
@@ -1,11 +1,11 @@
1
1
  import { MenuCategory } from '@open-tender/types';
2
2
  import { CategoryNavItemProps } from '@open-tender/ui';
3
3
  import { ReactNode } from 'react';
4
- declare const CategoryNavItem: ({ index, category, children, navigate, scrollToIndex }: {
5
- index?: number;
4
+ declare const CategoryNavItem: ({ category, isScrollable, isActive, children, navigate }: {
6
5
  category: MenuCategory;
7
- navigate: (route: string) => void;
6
+ isScrollable?: boolean;
7
+ isActive?: boolean;
8
+ navigate?: (route: string) => void;
8
9
  children: (props: CategoryNavItemProps) => ReactNode;
9
- scrollToIndex?: (index: number) => void;
10
10
  }) => ReactNode;
11
11
  export default CategoryNavItem;
@@ -2,24 +2,21 @@ import { makeImageUrl } from '@open-tender/ui';
2
2
  import { useAppDispatch, useAppSelector } from '../app/hooks';
3
3
  import { selectCurrentCategory, selectKioskApi, selectKioskConfig, selectStoreSettings, setCurrentCategory } from '../slices';
4
4
  var CategoryNavItem = function (_a) {
5
- var index = _a.index, category = _a.category, children = _a.children, navigate = _a.navigate, scrollToIndex = _a.scrollToIndex;
5
+ var category = _a.category, isScrollable = _a.isScrollable, isActive = _a.isActive, children = _a.children, navigate = _a.navigate;
6
6
  var dispatch = useAppDispatch();
7
7
  var apiUrl = useAppSelector(selectKioskApi);
8
8
  var display_category_nav_page = useAppSelector(selectStoreSettings).display_category_nav_page;
9
9
  var current = useAppSelector(selectCurrentCategory);
10
- var isCurrent = (current === null || current === void 0 ? void 0 : current.id) === category.id;
10
+ var isCurrent = isActive || (current === null || current === void 0 ? void 0 : current.id) === category.id;
11
11
  var _b = useAppSelector(selectKioskConfig), categoryNavItem = _b.categoryNavItem, categoryNavItemSelected = _b.categoryNavItemSelected;
12
12
  var config = isCurrent ? categoryNavItemSelected : categoryNavItem;
13
13
  var name = category.name;
14
14
  var imageUrl = makeImageUrl(category);
15
15
  var browse = function () {
16
16
  dispatch(setCurrentCategory(category));
17
- if (scrollToIndex && index !== undefined) {
18
- scrollToIndex(index);
19
- }
20
- else {
17
+ !isScrollable &&
18
+ navigate &&
21
19
  navigate(display_category_nav_page ? '/menu/category' : '/menu');
22
- }
23
20
  };
24
21
  var handlers = { browse: browse };
25
22
  if (!config)
@@ -29,7 +26,8 @@ var CategoryNavItem = function (_a) {
29
26
  handlers: handlers,
30
27
  title: name,
31
28
  imageUrl: imageUrl,
32
- apiUrl: apiUrl
29
+ apiUrl: apiUrl,
30
+ disabled: isScrollable
33
31
  });
34
32
  };
35
33
  export default CategoryNavItem;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-tender/store",
3
- "version": "1.1.200",
3
+ "version": "1.1.201",
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,8 +61,8 @@
61
61
  },
62
62
  "peerDependencies": {
63
63
  "@emotion/react": "^11.11.1",
64
- "@open-tender/types": "^0.4.82",
65
- "@open-tender/ui": "^0.4.15",
64
+ "@open-tender/types": "^0.4.83",
65
+ "@open-tender/ui": "^0.4.17",
66
66
  "@open-tender/utils": "^0.4.61",
67
67
  "@reduxjs/toolkit": "^2.0.1",
68
68
  "date-fns": "2.30.0",