@qite/tide-booking-component 1.4.78 → 1.4.80
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/build/build-cjs/index.js +771 -473
- package/build/build-cjs/src/qsm/types.d.ts +2 -0
- package/build/build-cjs/src/search-results/store/search-results-slice.d.ts +10 -1
- package/build/build-cjs/src/search-results/types.d.ts +5 -4
- package/build/build-cjs/src/search-results/utils/search-results-utils.d.ts +9 -2
- package/build/build-esm/index.js +769 -438
- package/build/build-esm/src/qsm/types.d.ts +2 -0
- package/build/build-esm/src/search-results/store/search-results-slice.d.ts +10 -1
- package/build/build-esm/src/search-results/types.d.ts +5 -4
- package/build/build-esm/src/search-results/utils/search-results-utils.d.ts +9 -2
- package/package.json +2 -2
- package/src/booking-wizard/features/price-details/selectors.ts +1 -1
- package/src/content/features/content-page/content-page-self-contained.tsx +4 -4
- package/src/qsm/components/QSMContainer/qsm-container.tsx +9 -0
- package/src/search-results/components/hotel/hotel-accommodation-results.tsx +97 -99
- package/src/search-results/components/hotel/hotel-card.tsx +29 -7
- package/src/search-results/components/search-results-container/flight-search-results.tsx +2 -2
- package/src/search-results/components/search-results-container/search-results-container.tsx +191 -40
- package/src/search-results/features/flights/flight-search-results-self-contained.tsx +21 -2
- package/src/search-results/features/hotels/hotel-flight-search-results-self-contained.tsx +21 -2
- package/src/search-results/features/hotels/hotel-search-results-self-contained.tsx +21 -2
- package/src/search-results/features/roundtrips/roundtrip-search-results-self-contained.tsx +21 -2
- package/src/search-results/store/search-results-slice.ts +19 -1
- package/src/search-results/types.ts +5 -5
- package/src/search-results/utils/search-results-utils.ts +185 -2
- package/build/build-cjs/src/search-results/components/filters/utility.d.ts +0 -3
- package/build/build-esm/src/search-results/components/filters/utility.d.ts +0 -3
- package/src/search-results/components/filters/utility.tsx +0 -79
|
@@ -1,5 +1,155 @@
|
|
|
1
|
-
import { BookingPackageItem } from '@qite/tide-client';
|
|
2
|
-
import { Filter } from '../types';
|
|
1
|
+
import { BookingPackageItem, PackagingAccommodationResponse } from '@qite/tide-client';
|
|
2
|
+
import { Filter, TideTag } from '../types';
|
|
3
|
+
import { first, flatMap } from 'lodash';
|
|
4
|
+
|
|
5
|
+
export const enrichFiltersWithResults = (results: BookingPackageItem[], filters: Filter[] | undefined, tags: TideTag[]): Filter[] => {
|
|
6
|
+
if (!results || results.length === 0 || !filters) {
|
|
7
|
+
return filters ?? [];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
return filters.map((filter) => {
|
|
11
|
+
let updatedFilter = { ...filter };
|
|
12
|
+
|
|
13
|
+
if (filter.property === 'price' && (filter.min == null || filter.max == null)) {
|
|
14
|
+
const prices = results.map((r) => r.price ?? 0).filter((p) => p > 0);
|
|
15
|
+
if (prices.length > 0) {
|
|
16
|
+
updatedFilter.min = Math.floor(Math.min(...prices));
|
|
17
|
+
updatedFilter.max = Math.ceil(Math.max(...prices));
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (filter.property === 'accommodation') {
|
|
22
|
+
const map = new Map<string, { name?: string; code: string }>();
|
|
23
|
+
|
|
24
|
+
results.forEach((r) => {
|
|
25
|
+
if (r.accommodationCode) {
|
|
26
|
+
map.set(r.accommodationCode, {
|
|
27
|
+
name: r.accommodationName,
|
|
28
|
+
code: r.accommodationCode
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
updatedFilter.options = Array.from(map.values()).map((accommodation) => ({
|
|
34
|
+
label: accommodation.name ?? accommodation.code,
|
|
35
|
+
value: accommodation.code,
|
|
36
|
+
isChecked: false
|
|
37
|
+
}));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (filter.property === 'regime') {
|
|
41
|
+
const map = new Map<string, { name?: string; code: string }>();
|
|
42
|
+
|
|
43
|
+
results.forEach((r) => {
|
|
44
|
+
if (r.regimeCode) {
|
|
45
|
+
map.set(r.regimeCode, {
|
|
46
|
+
name: r.regimeName,
|
|
47
|
+
code: r.regimeCode
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
updatedFilter.options = Array.from(map.values()).map((regime) => ({
|
|
53
|
+
label: regime.name ?? regime.code,
|
|
54
|
+
value: regime.code,
|
|
55
|
+
isChecked: false
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (filter.property === 'theme') {
|
|
60
|
+
const map = new Map<number, { name: string; id: number }>();
|
|
61
|
+
|
|
62
|
+
results.forEach((r) => {
|
|
63
|
+
r.tagIds?.forEach((tagId) => {
|
|
64
|
+
const tag = tags.find((t) => t.id === tagId);
|
|
65
|
+
if (tag && tag.id != null && tag.name != null) {
|
|
66
|
+
map.set(tag.id, { name: tag.name, id: tag.id });
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
updatedFilter.options = Array.from(map.values()).map((theme) => ({
|
|
72
|
+
label: theme.name,
|
|
73
|
+
value: theme.id,
|
|
74
|
+
isChecked: false
|
|
75
|
+
}));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return updatedFilter;
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export const enrichFiltersWithPackageAccoResults = (results: PackagingAccommodationResponse[], filters: Filter[] | undefined, tags: TideTag[]): Filter[] => {
|
|
83
|
+
if (!results || results.length === 0 || !filters) {
|
|
84
|
+
return filters ?? [];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return filters.map((filter) => {
|
|
88
|
+
let updatedFilter = { ...filter };
|
|
89
|
+
|
|
90
|
+
if (filter.property === 'price' && (filter.min == null || filter.max == null)) {
|
|
91
|
+
const prices = results.map((r) => r.price ?? 0).filter((p) => p > 0);
|
|
92
|
+
if (prices.length > 0) {
|
|
93
|
+
updatedFilter.min = Math.floor(Math.min(...prices));
|
|
94
|
+
updatedFilter.max = Math.ceil(Math.max(...prices));
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (filter.property === 'accommodation') {
|
|
99
|
+
const map = new Map<string, { name?: string; code: string }>();
|
|
100
|
+
|
|
101
|
+
results.forEach((r) => {
|
|
102
|
+
const rooms = flatMap(r.rooms);
|
|
103
|
+
if (rooms) {
|
|
104
|
+
rooms.map((room) => {
|
|
105
|
+
room.options.map((option) => {
|
|
106
|
+
if (option.accommodationCode) {
|
|
107
|
+
map.set(option.accommodationCode, {
|
|
108
|
+
name: option.accommodationName,
|
|
109
|
+
code: option.accommodationCode
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
updatedFilter.options = Array.from(map.values()).map((accommodation) => ({
|
|
118
|
+
label: accommodation.name ?? accommodation.code,
|
|
119
|
+
value: accommodation.code,
|
|
120
|
+
isChecked: false
|
|
121
|
+
}));
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (filter.property === 'regime') {
|
|
125
|
+
const map = new Map<string, { name?: string; code: string }>();
|
|
126
|
+
|
|
127
|
+
results.forEach((r) => {
|
|
128
|
+
const rooms = flatMap(r.rooms);
|
|
129
|
+
if (rooms) {
|
|
130
|
+
rooms.map((room) => {
|
|
131
|
+
room.options.map((option) => {
|
|
132
|
+
if (option.regimeCode) {
|
|
133
|
+
map.set(option.regimeCode, {
|
|
134
|
+
name: option.regimeName,
|
|
135
|
+
code: option.regimeCode
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
updatedFilter.options = Array.from(map.values()).map((regime) => ({
|
|
144
|
+
label: regime.name ?? regime.code,
|
|
145
|
+
value: regime.code,
|
|
146
|
+
isChecked: false
|
|
147
|
+
}));
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return updatedFilter;
|
|
151
|
+
});
|
|
152
|
+
};
|
|
3
153
|
|
|
4
154
|
export const applyFilters = (results: BookingPackageItem[], filters: Filter[]) => {
|
|
5
155
|
return results.filter((r) => {
|
|
@@ -40,3 +190,36 @@ export const applyFilters = (results: BookingPackageItem[], filters: Filter[]) =
|
|
|
40
190
|
});
|
|
41
191
|
});
|
|
42
192
|
};
|
|
193
|
+
|
|
194
|
+
export const applyFiltersToPackageAccoResults = (results: PackagingAccommodationResponse[], filters: Filter[]) => {
|
|
195
|
+
return results.filter((r) => {
|
|
196
|
+
return filters.every((filter) => {
|
|
197
|
+
if (!filter.isFrontendFilter) return true;
|
|
198
|
+
|
|
199
|
+
// ACCOMMODATION
|
|
200
|
+
if (filter.property === 'accommodation') {
|
|
201
|
+
const selected = filter.options?.filter((o) => o.isChecked).map((o) => o.value);
|
|
202
|
+
if (!selected || selected.length === 0) return true;
|
|
203
|
+
const roomOptions = r.rooms.flatMap((room) => room.options);
|
|
204
|
+
return roomOptions.some((option) => selected.includes(option.accommodationCode));
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// REGIME
|
|
208
|
+
if (filter.property === 'regime') {
|
|
209
|
+
const selected = filter.options?.filter((o) => o.isChecked).map((o) => o.value);
|
|
210
|
+
if (!selected || selected.length === 0) return true;
|
|
211
|
+
const roomOptions = r.rooms.flatMap((room) => room.options);
|
|
212
|
+
return roomOptions.some((option) => selected.includes(option.regimeCode));
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// PRICE
|
|
216
|
+
if (filter.property === 'price') {
|
|
217
|
+
if (filter.selectedMin != null && r.price < filter.selectedMin) return false;
|
|
218
|
+
if (filter.selectedMax != null && r.price > filter.selectedMax) return false;
|
|
219
|
+
return true;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return true;
|
|
223
|
+
});
|
|
224
|
+
});
|
|
225
|
+
};
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { BookingPackageItem } from '@qite/tide-client/build/types';
|
|
2
|
-
import { Filter, TideTag } from '../../types';
|
|
3
|
-
|
|
4
|
-
export const enrichFiltersWithResults = (results: BookingPackageItem[], filters: Filter[] | undefined, tags: TideTag[]): Filter[] => {
|
|
5
|
-
if (!results || results.length === 0 || !filters) {
|
|
6
|
-
return filters ?? [];
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
return filters.map((filter) => {
|
|
10
|
-
let updatedFilter = { ...filter };
|
|
11
|
-
|
|
12
|
-
if (filter.property === 'price' && (filter.min == null || filter.max == null)) {
|
|
13
|
-
const prices = results.map((r) => r.price ?? 0).filter((p) => p > 0);
|
|
14
|
-
if (prices.length > 0) {
|
|
15
|
-
updatedFilter.min = Math.floor(Math.min(...prices));
|
|
16
|
-
updatedFilter.max = Math.ceil(Math.max(...prices));
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if (filter.property === 'accommodation') {
|
|
21
|
-
const map = new Map<string, { name?: string; code: string }>();
|
|
22
|
-
|
|
23
|
-
results.forEach((r) => {
|
|
24
|
-
if (r.accommodationCode) {
|
|
25
|
-
map.set(r.accommodationCode, {
|
|
26
|
-
name: r.accommodationName,
|
|
27
|
-
code: r.accommodationCode
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
updatedFilter.options = Array.from(map.values()).map((accommodation) => ({
|
|
33
|
-
label: accommodation.name ?? accommodation.code,
|
|
34
|
-
value: accommodation.code,
|
|
35
|
-
isChecked: false
|
|
36
|
-
}));
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (filter.property === 'regime') {
|
|
40
|
-
const map = new Map<string, { name?: string; code: string }>();
|
|
41
|
-
|
|
42
|
-
results.forEach((r) => {
|
|
43
|
-
if (r.regimeCode) {
|
|
44
|
-
map.set(r.regimeCode, {
|
|
45
|
-
name: r.regimeName,
|
|
46
|
-
code: r.regimeCode
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
updatedFilter.options = Array.from(map.values()).map((regime) => ({
|
|
52
|
-
label: regime.name ?? regime.code,
|
|
53
|
-
value: regime.code,
|
|
54
|
-
isChecked: false
|
|
55
|
-
}));
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (filter.property === 'theme') {
|
|
59
|
-
const map = new Map<number, { name: string; id: number }>();
|
|
60
|
-
|
|
61
|
-
results.forEach((r) => {
|
|
62
|
-
r.tagIds?.forEach((tagId) => {
|
|
63
|
-
const tag = tags.find((t) => t.id === tagId);
|
|
64
|
-
if (tag && tag.id != null && tag.name != null) {
|
|
65
|
-
map.set(tag.id, { name: tag.name, id: tag.id });
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
updatedFilter.options = Array.from(map.values()).map((theme) => ({
|
|
71
|
-
label: theme.name,
|
|
72
|
-
value: theme.id,
|
|
73
|
-
isChecked: false
|
|
74
|
-
}));
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return updatedFilter;
|
|
78
|
-
});
|
|
79
|
-
};
|