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/lib/index.esm.js +6 -6
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +6 -6
- package/lib/index.js.map +1 -1
- package/lib/index.umd.js +6 -6
- package/lib/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/components/FilterBar/FilterBar.tsx +1 -0
- package/src/components/FilterBar/components/guests/GuestCount/GuestCount.tsx +5 -1
- package/src/components/FilterBar/hooks/useFilterBar.tsx +2 -9
package/package.json
CHANGED
|
@@ -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 = () => {
|