willba-component-library 0.1.44 → 0.1.45

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "willba-component-library",
3
- "version": "0.1.44",
3
+ "version": "0.1.45",
4
4
  "description": "A stroybook 6 with TypeScript demo",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.esm.js",
@@ -91,9 +91,10 @@ export const useFilterBar = ({
91
91
  : '',
92
92
  endDate: calendarRange?.to ? format(calendarRange.to, 'yyyy-MM-dd') : '',
93
93
  categories,
94
- ageCategoryCounts: Object.entries(ageCategoryCounts).length
95
- ? JSON.stringify(ageCategoryCounts)
96
- : '',
94
+ ageCategoryCounts: handleAgeCategoryRules({
95
+ ageCategoryCounts,
96
+ ageCategories,
97
+ }),
97
98
  }
98
99
 
99
100
  if (currentViewApply) {
@@ -157,3 +158,30 @@ export const useFilterBar = ({
157
158
  setSelectedPath,
158
159
  }
159
160
  }
161
+
162
+ ////////////
163
+
164
+ const handleAgeCategoryRules = ({
165
+ ageCategoryCounts,
166
+ ageCategories,
167
+ }: {
168
+ ageCategoryCounts: AgeCategoryCount
169
+ ageCategories?: AgeCategoryType[]
170
+ }) => {
171
+ if (ageCategories?.length) {
172
+ ageCategories?.map((a) => {
173
+ if (a.minVal) {
174
+ // Age categories rules
175
+ const ageCategory = ageCategoryCounts[`guests-${a.id}`]
176
+
177
+ if (!ageCategory) {
178
+ ageCategoryCounts[`guests-${a.id}`] = a.minVal
179
+ }
180
+ }
181
+ })
182
+ }
183
+
184
+ return Object.entries(ageCategoryCounts).length
185
+ ? JSON.stringify(ageCategoryCounts)
186
+ : ''
187
+ }