@open-tender/cloud 0.1.41 → 0.1.42

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.
@@ -41,6 +41,15 @@ const tagsSlice = (0, toolkit_1.createSlice)({
41
41
  initialState,
42
42
  reducers: {
43
43
  resetTags: () => initialState,
44
+ toggleTag: (state, action) => {
45
+ var _a;
46
+ const tag = action.payload;
47
+ const exists = (_a = state.selectedTags) === null || _a === void 0 ? void 0 : _a.find(i => i.tag_id === tag.tag_id);
48
+ const current = state.selectedTags || [];
49
+ state.selectedTags = exists
50
+ ? current.filter(i => i.tag_id !== tag.tag_id)
51
+ : [...current, tag];
52
+ },
44
53
  setSelectedTags: (state, action) => {
45
54
  state.selectedTags = action.payload;
46
55
  }
@@ -75,8 +84,8 @@ exports.selectSelectedTagNames = (0, toolkit_1.createSelector)((state) => {
75
84
  return [];
76
85
  const selected = selectedTags.map(i => {
77
86
  var _a;
78
- const allergen = tags.find(a => a.allergen_id === i.allergen_id);
79
- return allergen ? (_a = allergen.name) !== null && _a !== void 0 ? _a : '' : '';
87
+ const tag = tags.find(a => a.tag_id === i.tag_id);
88
+ return tag ? (_a = tag.name) !== null && _a !== void 0 ? _a : '' : '';
80
89
  });
81
90
  return selected;
82
91
  });
@@ -37,6 +37,15 @@ const tagsSlice = createSlice({
37
37
  initialState,
38
38
  reducers: {
39
39
  resetTags: () => initialState,
40
+ toggleTag: (state, action) => {
41
+ var _a;
42
+ const tag = action.payload;
43
+ const exists = (_a = state.selectedTags) === null || _a === void 0 ? void 0 : _a.find(i => i.tag_id === tag.tag_id);
44
+ const current = state.selectedTags || [];
45
+ state.selectedTags = exists
46
+ ? current.filter(i => i.tag_id !== tag.tag_id)
47
+ : [...current, tag];
48
+ },
40
49
  setSelectedTags: (state, action) => {
41
50
  state.selectedTags = action.payload;
42
51
  }
@@ -69,8 +78,8 @@ export const selectSelectedTagNames = createSelector((state) => {
69
78
  return [];
70
79
  const selected = selectedTags.map(i => {
71
80
  var _a;
72
- const allergen = tags.find(a => a.allergen_id === i.allergen_id);
73
- return allergen ? (_a = allergen.name) !== null && _a !== void 0 ? _a : '' : '';
81
+ const tag = tags.find(a => a.tag_id === i.tag_id);
82
+ return tag ? (_a = tag.name) !== null && _a !== void 0 ? _a : '' : '';
74
83
  });
75
84
  return selected;
76
85
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-tender/cloud",
3
- "version": "0.1.41",
3
+ "version": "0.1.42",
4
4
  "description": "A library of hooks, reducers, utility functions, and types for use with Open Tender applications that utilize our cloud-based Order API.",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -49,7 +49,7 @@
49
49
  "typescript": "^4.8.2"
50
50
  },
51
51
  "peerDependencies": {
52
- "@open-tender/types": "^0.2.38",
52
+ "@open-tender/types": "^0.2.40",
53
53
  "@open-tender/utils": "^0.1.95",
54
54
  "@reduxjs/toolkit": "^1.8.5",
55
55
  "react": "^18.2.0"