willba-component-library 0.1.22 → 0.1.24

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.22",
3
+ "version": "0.1.24",
4
4
  "description": "A stroybook 6 with TypeScript demo",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.esm.js",
@@ -20,24 +20,18 @@ export const Primary: Story = {
20
20
  {
21
21
  id: '2',
22
22
  name: 'Alle 6 vuotiaat',
23
- minAge: null,
24
- maxAge: 6,
25
23
  minVal: 0,
26
24
  sortOrder: 3,
27
25
  },
28
26
  {
29
27
  id: '3',
30
28
  name: '6-16 vuotiaat',
31
- minAge: 6,
32
- maxAge: 17,
33
29
  minVal: 0,
34
30
  sortOrder: 2,
35
31
  },
36
32
  {
37
33
  id: '1',
38
34
  name: 'Aikuiset',
39
- minAge: 17,
40
- maxAge: null,
41
35
  minVal: 2,
42
36
  sortOrder: 1,
43
37
  },
@@ -42,6 +42,7 @@ export default function FilterBar({
42
42
 
43
43
  setRerenderKey((prevKey) => prevKey + 1)
44
44
  }, [language])
45
+
45
46
  const { t } = useTranslation('filterBar')
46
47
 
47
48
  // Filters
@@ -162,16 +163,12 @@ const AGE_CATEGORIES_FALLBACK = [
162
163
  id: '1',
163
164
  name: 'Adults',
164
165
  sortOrder: 1,
165
- minAge: null,
166
- maxAge: 6,
167
166
  minVal: 0,
168
167
  },
169
168
  {
170
169
  id: '2',
171
170
  name: 'Kids',
172
171
  sortOrder: 2,
173
- minAge: 6,
174
- maxAge: 17,
175
172
  minVal: 0,
176
173
  },
177
174
  ]
@@ -5,22 +5,20 @@ export interface AgeCategoryCount {
5
5
  export interface AgeCategoryType {
6
6
  id: string
7
7
  name: string
8
- minAge: number | null
9
- maxAge: number | null
10
8
  minVal: number
11
9
  sortOrder: number
12
10
  }
13
11
 
14
12
  export interface GuestsPropsType {
15
13
  ageCategories: AgeCategoryType[]
16
- updateGuestsCount: (arg1: number, arg2: number) => void
14
+ updateGuestsCount: (arg1: string, arg2: number) => void
17
15
  ageCategoryCounts: AgeCategoryCount | {}
18
16
  }
19
17
 
20
18
  export interface GuestsCountPropsType {
21
19
  label: string
22
20
  id: number
23
- updateGuestsCount: (arg1: number, arg2: number) => void
21
+ updateGuestsCount: (arg1: string, arg2: number) => void
24
22
  count: number
25
23
  minVal: number
26
24
  sortOrder: number
@@ -14,12 +14,12 @@ export default function GuestCount({
14
14
  }: GuestsCountPropsType) {
15
15
  const handleDecrement = () => {
16
16
  if (count > minVal) {
17
- updateGuestsCount(id, count - 1)
17
+ updateGuestsCount(`guests-${id}`, count - 1)
18
18
  }
19
19
  }
20
20
 
21
21
  const handleIncrement = () => {
22
- updateGuestsCount(id, count + 1)
22
+ updateGuestsCount(`guests-${id}`, count + 1)
23
23
  }
24
24
 
25
25
  return (
@@ -24,8 +24,9 @@ export default function Guests({
24
24
  sortOrder={category.sortOrder}
25
25
  updateGuestsCount={updateGuestsCount}
26
26
  count={
27
- (ageCategoryCounts as AgeCategoryCount)[category.id] ||
28
- category.minVal
27
+ (ageCategoryCounts as AgeCategoryCount)[
28
+ `guests-${category.id}`
29
+ ] || category.minVal
29
30
  }
30
31
  />
31
32
  ))}
@@ -19,7 +19,8 @@ export default function useFilterBar({ redirectUrl }: UseFilterBarPropsType) {
19
19
  {}
20
20
  )
21
21
 
22
- const updateGuestsCount = (id: number, newCount: number) => {
22
+ const updateGuestsCount = (id: string, newCount: number) => {
23
+ console.log(ageCategoryCounts)
23
24
  setAgeCategoryCounts((prevCounts) => ({
24
25
  ...prevCounts,
25
26
  [id]: newCount,
@@ -62,7 +63,7 @@ export default function useFilterBar({ redirectUrl }: UseFilterBarPropsType) {
62
63
  : '',
63
64
  endDate: calendarRange?.to ? format(calendarRange.to, 'yyyy-MM-dd') : '',
64
65
  categories,
65
- //ageCategoryCounts: JSON.stringify(ageCategoryCounts),
66
+ ageCategoryCounts: JSON.stringify(ageCategoryCounts),
66
67
  }
67
68
 
68
69
  for (const [key, value] of Object.entries(params)) {