@open-tender/store 1.1.212 → 1.1.214

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,5 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ var ui_1 = require("@open-tender/ui");
4
+ var react_1 = require("react");
3
5
  var hooks_1 = require("../app/hooks");
4
6
  var slices_1 = require("../slices");
5
7
  var CategoryNavOther = function (_a) {
@@ -10,6 +12,23 @@ var CategoryNavOther = function (_a) {
10
12
  var currentSection = (0, hooks_1.useAppSelector)(slices_1.selectCurrentSection);
11
13
  var isCurrent = path === currentSection;
12
14
  var config = isCurrent ? categoryNavItemSelected : categoryNavItem;
15
+ var _c = (0, hooks_1.useAppSelector)(slices_1.selectMenu), _d = _c.featured, featured = _d === void 0 ? [] : _d, _e = _c.favorites, favorites = _e === void 0 ? [] : _e, _f = _c.recents, recents = _f === void 0 ? [] : _f;
16
+ var getCategoryItemImage = (0, react_1.useCallback)(function () {
17
+ switch (title.toLowerCase()) {
18
+ case 'featured':
19
+ return featured.length && featured.length > 0
20
+ ? (0, ui_1.makeImageUrl)(featured[0])
21
+ : null;
22
+ case 'favorites':
23
+ return favorites.length && favorites.length > 0
24
+ ? (0, ui_1.makeImageUrl)(favorites[0])
25
+ : null;
26
+ default:
27
+ return recents.length && recents.length > 0
28
+ ? (0, ui_1.makeImageUrl)(recents[0])
29
+ : null;
30
+ }
31
+ }, [favorites, featured, title, recents]);
13
32
  var browse = function () {
14
33
  dispatch((0, slices_1.setCurrentCategory)(null));
15
34
  navigate(path);
@@ -21,7 +40,7 @@ var CategoryNavOther = function (_a) {
21
40
  config: config,
22
41
  handlers: handlers,
23
42
  title: title,
24
- imageUrl: null,
43
+ imageUrl: getCategoryItemImage(),
25
44
  apiUrl: apiUrl,
26
45
  displayImage: displayImage
27
46
  });
@@ -1,5 +1,7 @@
1
+ import { makeImageUrl } from '@open-tender/ui';
2
+ import { useCallback } from 'react';
1
3
  import { useAppDispatch, useAppSelector } from '../app/hooks';
2
- import { selectCurrentSection, selectKioskApi, selectKioskConfig, setCurrentCategory } from '../slices';
4
+ import { selectCurrentSection, selectKioskApi, selectKioskConfig, selectMenu, setCurrentCategory } from '../slices';
3
5
  var CategoryNavOther = function (_a) {
4
6
  var title = _a.title, path = _a.path, displayImage = _a.displayImage, navigate = _a.navigate, children = _a.children;
5
7
  var dispatch = useAppDispatch();
@@ -8,6 +10,23 @@ var CategoryNavOther = function (_a) {
8
10
  var currentSection = useAppSelector(selectCurrentSection);
9
11
  var isCurrent = path === currentSection;
10
12
  var config = isCurrent ? categoryNavItemSelected : categoryNavItem;
13
+ var _c = useAppSelector(selectMenu), _d = _c.featured, featured = _d === void 0 ? [] : _d, _e = _c.favorites, favorites = _e === void 0 ? [] : _e, _f = _c.recents, recents = _f === void 0 ? [] : _f;
14
+ var getCategoryItemImage = useCallback(function () {
15
+ switch (title.toLowerCase()) {
16
+ case 'featured':
17
+ return featured.length && featured.length > 0
18
+ ? makeImageUrl(featured[0])
19
+ : null;
20
+ case 'favorites':
21
+ return favorites.length && favorites.length > 0
22
+ ? makeImageUrl(favorites[0])
23
+ : null;
24
+ default:
25
+ return recents.length && recents.length > 0
26
+ ? makeImageUrl(recents[0])
27
+ : null;
28
+ }
29
+ }, [favorites, featured, title, recents]);
11
30
  var browse = function () {
12
31
  dispatch(setCurrentCategory(null));
13
32
  navigate(path);
@@ -19,7 +38,7 @@ var CategoryNavOther = function (_a) {
19
38
  config: config,
20
39
  handlers: handlers,
21
40
  title: title,
22
- imageUrl: null,
41
+ imageUrl: getCategoryItemImage(),
23
42
  apiUrl: apiUrl,
24
43
  displayImage: displayImage
25
44
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-tender/store",
3
- "version": "1.1.212",
3
+ "version": "1.1.214",
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.87",
64
+ "@open-tender/types": "^0.4.88",
65
65
  "@open-tender/ui": "^0.4.24",
66
66
  "@open-tender/utils": "^0.4.67",
67
67
  "@reduxjs/toolkit": "^2.0.1",