willba-component-library 0.1.80 → 0.1.81

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.80",
3
+ "version": "0.1.81",
4
4
  "description": "A stroybook 6 with TypeScript demo",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.esm.js",
@@ -68,20 +68,21 @@ export const useFilterBar = ({
68
68
  }, [selectedFilter])
69
69
 
70
70
  useEffect(() => {
71
- // Handle default selected tab
72
71
  if (typeof window === 'undefined') return
72
+
73
73
  const defaultTab =
74
74
  tabs?.length === 1 ? tabs[0] : tabs?.find((tab) => tab.default)
75
75
 
76
- const currentPath =
77
- window.location.pathname.includes(Pages.EVENTS) ||
78
- defaultTab?.path === Pages.EVENTS
79
- ? Pages.EVENTS
80
- : window.location.pathname.includes(Pages.ROOMS) ||
81
- defaultTab?.path === Pages.ROOMS
82
- ? Pages.ROOMS
83
- : Pages.EVENTS
76
+ const findMatchingPath = () => {
77
+ const paths = [Pages.EVENTS, Pages.ROOMS]
78
+ return paths.find(
79
+ (path) =>
80
+ window.location.pathname.includes(path) ||
81
+ (defaultTab && defaultTab.path === path)
82
+ )
83
+ }
84
84
 
85
+ const currentPath = findMatchingPath() || Pages.EVENTS
85
86
  setSelectedPath(currentPath)
86
87
  }, [])
87
88