willba-component-library 0.1.30 → 0.1.32
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 +20 -15
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +20 -15
- package/lib/index.js.map +1 -1
- package/lib/index.umd.js +20 -15
- package/lib/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/components/FilterBar/FilterBar.tsx +5 -4
- package/src/components/FilterBar/components/guests/GuestCount/GuestCount.tsx +5 -1
- package/src/components/FilterBar/components/guests/Guests.tsx +3 -1
- package/src/components/FilterBar/hooks/useFilterBar.tsx +2 -9
- package/src/locales/en/filterBar.json +5 -3
- package/src/locales/fi/filterBar.json +5 -3
package/package.json
CHANGED
|
@@ -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',
|
|
@@ -119,8 +120,8 @@ export default function FilterBar({
|
|
|
119
120
|
|
|
120
121
|
<div className="will-filter-bar-header">
|
|
121
122
|
<SelectButton
|
|
122
|
-
label={'
|
|
123
|
-
description={'
|
|
123
|
+
label={t('calendar.label')}
|
|
124
|
+
description={t('calendar.labelPlaceholder')}
|
|
124
125
|
onClick={() => handleSelectedFilter(1)}
|
|
125
126
|
style={fontWeightBold(selectedFilter === 1)}
|
|
126
127
|
/>
|
|
@@ -130,8 +131,8 @@ export default function FilterBar({
|
|
|
130
131
|
<Divider />
|
|
131
132
|
|
|
132
133
|
<SelectButton
|
|
133
|
-
label={'
|
|
134
|
-
description={'
|
|
134
|
+
label={t('guests.label')}
|
|
135
|
+
description={t('guests.labelPlaceholder')}
|
|
135
136
|
onClick={() => handleSelectedFilter(2)}
|
|
136
137
|
style={fontWeightBold(selectedFilter === 2)}
|
|
137
138
|
/>
|
|
@@ -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)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
+
import { useTranslation } from 'react-i18next'
|
|
2
3
|
|
|
3
4
|
import GuestCount from './GuestCount/GuestCount'
|
|
4
5
|
import { AgeCategoryCount, GuestsPropsType } from '../../FilterBarTypes'
|
|
@@ -10,9 +11,10 @@ export default function Guests({
|
|
|
10
11
|
updateGuestsCount,
|
|
11
12
|
ageCategoryCounts,
|
|
12
13
|
}: GuestsPropsType) {
|
|
14
|
+
const { t } = useTranslation('filterBar')
|
|
13
15
|
return (
|
|
14
16
|
<div className="will-filter-bar-guests">
|
|
15
|
-
<h3 className="will-guests-filter-title">
|
|
17
|
+
<h3 className="will-guests-filter-title">{t('guests.title')}</h3>
|
|
16
18
|
|
|
17
19
|
<div className="will-guests-filter-container">
|
|
18
20
|
{ageCategories?.map((category) => (
|
|
@@ -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 = () => {
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"calendar": {
|
|
3
|
+
"label": "When",
|
|
4
|
+
"labelPlaceholder": "Add check-in and check-out",
|
|
3
5
|
"startDate": "Start date",
|
|
4
6
|
"endDate": "End date",
|
|
5
7
|
"title": "Calendar"
|
|
6
8
|
},
|
|
7
9
|
"guests": {
|
|
8
|
-
"label": "
|
|
9
|
-
"
|
|
10
|
-
"
|
|
10
|
+
"label": "Who",
|
|
11
|
+
"labelPlaceholder": "Add guests",
|
|
12
|
+
"title": "Who's coming?",
|
|
11
13
|
"adultsLabel": "Adults",
|
|
12
14
|
"kidsLabel": "kids"
|
|
13
15
|
},
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"calendar": {
|
|
3
|
+
"label": "Milloin",
|
|
4
|
+
"labelPlaceholder": "Lisää check-in ja check-out",
|
|
3
5
|
"startDate": "Alku",
|
|
4
6
|
"endDate": "Loppu",
|
|
5
7
|
"title": "Kalenteri"
|
|
6
8
|
},
|
|
7
9
|
"guests": {
|
|
8
|
-
"label": "
|
|
9
|
-
"
|
|
10
|
-
"
|
|
10
|
+
"label": "Kuka",
|
|
11
|
+
"labelPlaceholder": "Lisää vieraat",
|
|
12
|
+
"title": "Ketkä ovat tulossa?",
|
|
11
13
|
"adultsLabel": "Aikuiset",
|
|
12
14
|
"kidsLabel": "lapset"
|
|
13
15
|
},
|