willba-component-library 0.0.80 → 0.0.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/lib/components/FilterBar/FilterBarTypes.d.ts +10 -3
- package/lib/components/FilterBar/components/guests/GuestCount/GuestCount.d.ts +1 -1
- package/lib/components/FilterBar/components/guests/Guests.d.ts +1 -1
- package/lib/components/FilterBar/hooks/useFilterBar.d.ts +4 -3
- package/lib/index.d.ts +1 -1
- package/lib/index.esm.js +13 -18
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +13 -18
- package/lib/index.js.map +1 -1
- package/lib/index.umd.js +13 -18
- package/lib/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/components/FilterBar/FilterBar.tsx +1 -2
- package/src/components/FilterBar/FilterBarTypes.ts +11 -3
- package/src/components/FilterBar/components/guests/GuestCount/GuestCount.tsx +8 -11
- package/src/components/FilterBar/components/guests/Guests.tsx +9 -2
- package/src/components/FilterBar/hooks/useFilterBar.tsx +10 -13
package/package.json
CHANGED
|
@@ -45,11 +45,9 @@ export default function FilterBar({
|
|
|
45
45
|
categories,
|
|
46
46
|
calendarRange,
|
|
47
47
|
setCalendarRange,
|
|
48
|
-
setAgeCategoryCounts,
|
|
49
48
|
setCategories,
|
|
50
49
|
handleSelectedFilter,
|
|
51
50
|
handleSubmit,
|
|
52
|
-
|
|
53
51
|
updateGuestsCount,
|
|
54
52
|
} = useFilterBar(ageCategories)
|
|
55
53
|
|
|
@@ -104,6 +102,7 @@ export default function FilterBar({
|
|
|
104
102
|
<Guests
|
|
105
103
|
updateGuestsCount={updateGuestsCount}
|
|
106
104
|
ageCategories={ageCategories}
|
|
105
|
+
ageCategoryCounts={ageCategoryCounts}
|
|
107
106
|
/>
|
|
108
107
|
)}
|
|
109
108
|
{selectedFilter === 4 && (
|
|
@@ -1,17 +1,25 @@
|
|
|
1
|
+
export interface AgeCategoryCount {
|
|
2
|
+
[categoryId: string]: number
|
|
3
|
+
}
|
|
4
|
+
|
|
1
5
|
export interface AgeCategoryType {
|
|
2
6
|
id: string
|
|
3
7
|
name: string
|
|
4
8
|
minAge: number | null
|
|
5
9
|
maxAge: number | null
|
|
6
|
-
|
|
10
|
+
minVal: number
|
|
7
11
|
}
|
|
8
12
|
|
|
9
13
|
export interface GuestsPropsType {
|
|
10
14
|
ageCategories: AgeCategoryType[]
|
|
11
|
-
updateGuestsCount: (arg1:
|
|
15
|
+
updateGuestsCount: (arg1: number, arg2: number) => void
|
|
16
|
+
ageCategoryCounts: AgeCategoryCount | {}
|
|
12
17
|
}
|
|
13
18
|
|
|
14
19
|
export interface GuestsCountPropsType {
|
|
15
20
|
label: string
|
|
16
|
-
|
|
21
|
+
id: number
|
|
22
|
+
updateGuestsCount: (arg1: number, arg2: number) => void
|
|
23
|
+
count: number
|
|
24
|
+
minVal: number
|
|
17
25
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import { useTranslation } from 'react-i18next'
|
|
1
|
+
import React from 'react'
|
|
3
2
|
|
|
4
3
|
import { GuestsCountPropsType } from '../../../FilterBarTypes'
|
|
5
4
|
|
|
@@ -7,23 +6,21 @@ import './GuestCount.css'
|
|
|
7
6
|
|
|
8
7
|
export default function GuestCount({
|
|
9
8
|
label,
|
|
9
|
+
id,
|
|
10
10
|
updateGuestsCount,
|
|
11
|
+
count,
|
|
12
|
+
minVal,
|
|
11
13
|
}: GuestsCountPropsType) {
|
|
12
|
-
const { t } = useTranslation('filterBar')
|
|
13
|
-
|
|
14
|
-
const [count, setCount] = useState(0)
|
|
15
|
-
|
|
16
14
|
const handleDecrement = () => {
|
|
17
|
-
if (count >
|
|
18
|
-
|
|
19
|
-
updateGuestsCount(label, count - 1)
|
|
15
|
+
if (count > minVal) {
|
|
16
|
+
updateGuestsCount(id, count - 1)
|
|
20
17
|
}
|
|
21
18
|
}
|
|
22
19
|
|
|
23
20
|
const handleIncrement = () => {
|
|
24
|
-
|
|
25
|
-
updateGuestsCount(label, count + 1)
|
|
21
|
+
updateGuestsCount(id, count + 1)
|
|
26
22
|
}
|
|
23
|
+
|
|
27
24
|
return (
|
|
28
25
|
<div className="will-guests-filter-inner">
|
|
29
26
|
<span className="will-guests-filter-label">{label}</span>
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react'
|
|
2
2
|
import { useTranslation } from 'react-i18next'
|
|
3
3
|
|
|
4
4
|
import GuestCount from './GuestCount/GuestCount'
|
|
5
|
-
import { GuestsPropsType } from '../../FilterBarTypes'
|
|
5
|
+
import { AgeCategoryCount, GuestsPropsType } from '../../FilterBarTypes'
|
|
6
6
|
|
|
7
7
|
import './Guests.css'
|
|
8
8
|
|
|
9
9
|
export default function Guests({
|
|
10
10
|
ageCategories,
|
|
11
11
|
updateGuestsCount,
|
|
12
|
+
ageCategoryCounts,
|
|
12
13
|
}: GuestsPropsType) {
|
|
13
14
|
const { t } = useTranslation('filterBar')
|
|
14
15
|
|
|
@@ -21,8 +22,14 @@ export default function Guests({
|
|
|
21
22
|
{ageCategories?.map((category) => (
|
|
22
23
|
<GuestCount
|
|
23
24
|
key={category.id}
|
|
25
|
+
id={parseInt(category.id)}
|
|
24
26
|
label={category.name}
|
|
27
|
+
minVal={category.minVal}
|
|
25
28
|
updateGuestsCount={updateGuestsCount}
|
|
29
|
+
count={
|
|
30
|
+
(ageCategoryCounts as AgeCategoryCount)[category.id] ||
|
|
31
|
+
category.minVal
|
|
32
|
+
}
|
|
26
33
|
/>
|
|
27
34
|
))}
|
|
28
35
|
</div>
|
|
@@ -2,6 +2,8 @@ import { useEffect, useState } from 'react'
|
|
|
2
2
|
import { DateRange } from 'react-day-picker'
|
|
3
3
|
import { format } from 'date-fns'
|
|
4
4
|
|
|
5
|
+
import { AgeCategoryCount } from '../FilterBarTypes'
|
|
6
|
+
|
|
5
7
|
export default function useFilterBar(ageCategories: any) {
|
|
6
8
|
const [selectedFilter, setSelectedFilter] = useState<number | boolean>(false)
|
|
7
9
|
const [calendarRange, setCalendarRange] = useState<DateRange | undefined>()
|
|
@@ -9,12 +11,14 @@ export default function useFilterBar(ageCategories: any) {
|
|
|
9
11
|
const [categories, setCategories] = useState<number>(0)
|
|
10
12
|
|
|
11
13
|
//
|
|
12
|
-
const [ageCategoryCounts, setAgeCategoryCounts] = useState(
|
|
14
|
+
const [ageCategoryCounts, setAgeCategoryCounts] = useState<AgeCategoryCount>(
|
|
15
|
+
{}
|
|
16
|
+
)
|
|
13
17
|
|
|
14
|
-
const updateGuestsCount = (
|
|
18
|
+
const updateGuestsCount = (id: number, newCount: number) => {
|
|
15
19
|
setAgeCategoryCounts((prevCounts) => ({
|
|
16
20
|
...prevCounts,
|
|
17
|
-
[
|
|
21
|
+
[id]: newCount,
|
|
18
22
|
}))
|
|
19
23
|
}
|
|
20
24
|
|
|
@@ -25,13 +29,8 @@ export default function useFilterBar(ageCategories: any) {
|
|
|
25
29
|
|
|
26
30
|
const startDateParam = urlSearchParams.get('startDate')
|
|
27
31
|
const endDateParam = urlSearchParams.get('endDate')
|
|
28
|
-
const
|
|
29
|
-
urlSearchParams.get('
|
|
30
|
-
10
|
|
31
|
-
)
|
|
32
|
-
const parsedGuestsKids = parseInt(
|
|
33
|
-
urlSearchParams.get('guestsKids') || '0',
|
|
34
|
-
10
|
|
32
|
+
const ageCategoryCountsParam = JSON.parse(
|
|
33
|
+
urlSearchParams.get('ageCategoryCounts') || '{}'
|
|
35
34
|
)
|
|
36
35
|
const parsedCategories = parseInt(
|
|
37
36
|
urlSearchParams.get('categories') || '0',
|
|
@@ -44,9 +43,7 @@ export default function useFilterBar(ageCategories: any) {
|
|
|
44
43
|
to: new Date(endDateParam),
|
|
45
44
|
})
|
|
46
45
|
}
|
|
47
|
-
|
|
48
|
-
// setGuestsAdults(parsedGuestsAdults)
|
|
49
|
-
// setGuestsKids(parsedGuestsKids)
|
|
46
|
+
setAgeCategoryCounts(ageCategoryCountsParam)
|
|
50
47
|
setCategories(parsedCategories)
|
|
51
48
|
}, [])
|
|
52
49
|
|