willba-component-library 0.1.30 → 0.1.31

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.30",
3
+ "version": "0.1.31",
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({
76
76
  setIsMobile(false)
77
77
  return
78
78
  }
79
+
79
80
  if (targetFilterBarRef.current && selectedFilter) {
80
81
  window.scrollTo({
81
82
  behavior: 'smooth',
@@ -1,4 +1,4 @@
1
- import React from 'react'
1
+ import React, { useEffect } from 'react'
2
2
 
3
3
  import { GuestsCountPropsType } from '../../../FilterBarTypes'
4
4
 
@@ -12,6 +12,10 @@ export default function GuestCount({
12
12
  count,
13
13
  minVal,
14
14
  }: GuestsCountPropsType) {
15
+ useEffect(() => {
16
+ if (minVal) updateGuestsCount(`guests-${id}`, minVal)
17
+ }, [])
18
+
15
19
  const handleDecrement = () => {
16
20
  if (count > minVal) {
17
21
  updateGuestsCount(`guests-${id}`, count - 1)
@@ -107,29 +107,23 @@ export default function useFilterBar({
107
107
  const currentSearchParams = new URLSearchParams(window.location.search)
108
108
  const updatedParams = new URLSearchParams()
109
109
 
110
- // Copy existing parameters to updatedParams
111
110
  for (const [key, value] of currentSearchParams.entries()) {
112
111
  updatedParams.append(key, value)
113
112
  }
114
113
 
115
- // Update parameters based on newParams
116
114
  for (const [key, value] of Object.entries(newParams)) {
117
115
  if (value) {
118
- console.log(value)
119
116
  updatedParams.set(key, value.toString())
120
117
  } else {
121
- // Remove parameter if value is falsy
122
118
  updatedParams.delete(key)
123
119
  }
124
120
  }
125
121
 
126
- console.log(updatedParams.toString())
127
-
128
122
  const baseUrl = window.location.origin + window.location.pathname
129
123
 
130
- // Construct the updated URL with the modified query parameters
131
124
  const updatedUrl = `${baseUrl}?${updatedParams.toString()}`
132
125
 
126
+ handleSelectedFilter(false)
133
127
  return (window.location.href = updatedUrl)
134
128
  } else {
135
129
  const querySearchParams = new URLSearchParams()
@@ -140,12 +134,11 @@ export default function useFilterBar({
140
134
  }
141
135
  }
142
136
 
137
+ handleSelectedFilter(false)
143
138
  return (window.location.href = `${redirectUrl}/${selectedPath}${
144
139
  querySearchParams ? `?${querySearchParams.toString()}` : ''
145
140
  }`)
146
141
  }
147
-
148
- handleSelectedFilter(false)
149
142
  }
150
143
 
151
144
  const handleResetFilters = () => {