willba-component-library 0.0.77 → 0.0.79

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.0.77",
3
+ "version": "0.0.79",
4
4
  "description": "A stroybook 6 with TypeScript demo",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.esm.js",
@@ -76,6 +76,7 @@ export default function FilterBar({ vendor, language }: FilterBarProps) {
76
76
  onClick={() => handleSelectedFilter(3)}
77
77
  style={fontWigthBold(selectedFilter === 3)}
78
78
  />
79
+ {/* TODO - Add strapi settings to add or remove functionality */}
79
80
  {/* <Divider />
80
81
  <SelectButton
81
82
  label={t('categories.label')}
@@ -1,4 +1,4 @@
1
- import { useState } from 'react'
1
+ import { useEffect, useMemo, useState } from 'react'
2
2
  import { DateRange } from 'react-day-picker'
3
3
  import { format } from 'date-fns'
4
4
 
@@ -9,6 +9,36 @@ export default function useFilterBar() {
9
9
  const [guestsKids, setGuestsKids] = useState(0)
10
10
  const [categories, setCategories] = useState(0)
11
11
 
12
+ useEffect(() => {
13
+ const urlSearchParams = new URLSearchParams(window.location.search)
14
+
15
+ const startDateParam = urlSearchParams.get('startDate')
16
+ const endDateParam = urlSearchParams.get('endDate')
17
+ const parsedGuestsAdults = parseInt(
18
+ urlSearchParams.get('guestsAdults') || '1',
19
+ 10
20
+ )
21
+ const parsedGuestsKids = parseInt(
22
+ urlSearchParams.get('guestsKids') || '0',
23
+ 10
24
+ )
25
+ const parsedCategories = parseInt(
26
+ urlSearchParams.get('categories') || '0',
27
+ 10
28
+ )
29
+
30
+ if (startDateParam && endDateParam) {
31
+ setCalendarRange({
32
+ from: new Date(startDateParam),
33
+ to: new Date(endDateParam),
34
+ })
35
+ }
36
+
37
+ setGuestsAdults(parsedGuestsAdults)
38
+ setGuestsKids(parsedGuestsKids)
39
+ setCategories(parsedCategories)
40
+ }, [])
41
+
12
42
  const handleSelectedFilter = (id: number | boolean) => {
13
43
  setSelectedFilter(id)
14
44
  }
@@ -37,6 +67,14 @@ export default function useFilterBar() {
37
67
  handleSelectedFilter(false)
38
68
  }
39
69
 
70
+ useEffect(() => {
71
+ document.body.style.overflow = selectedFilter ? 'hidden' : 'visible'
72
+
73
+ return () => {
74
+ document.body.style.overflow = 'visible' // Reset overflow when component unmounts
75
+ }
76
+ }, [selectedFilter])
77
+
40
78
  return {
41
79
  selectedFilter,
42
80
  guestsAdults,