@odynn/awayz-hotels 0.13.5 → 0.13.7
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.
|
@@ -1,57 +1,57 @@
|
|
|
1
1
|
import "react/jsx-runtime";
|
|
2
|
-
import { b as
|
|
3
|
-
import { g as
|
|
4
|
-
import { E as
|
|
2
|
+
import { b as ae } from "../../index-CJj9N0Xq.js";
|
|
3
|
+
import { g as ce } from "../../dateUtils-C1hKW8MF.js";
|
|
4
|
+
import { E as K } from "../../DateFormats-DZD30Nea.js";
|
|
5
5
|
import "../../arrayExtensions-CFEBYUok.js";
|
|
6
|
-
import { useState as
|
|
7
|
-
import
|
|
8
|
-
import { isPartialHotelDetails as
|
|
9
|
-
import { useAwayzContext as
|
|
6
|
+
import { useState as se, useMemo as D } from "react";
|
|
7
|
+
import ie from "../../stores/useHotelsStore.js";
|
|
8
|
+
import { isPartialHotelDetails as re, fetchTransferPartners as ne, fetchPointsCheck as le, fetchAvailableRooms as he, combineUpdatedHotelData as I, fallbackBestCheckout as ue, fetchBestCheckout as De } from "./useHotelDetails.api.js";
|
|
9
|
+
import { useAwayzContext as me, useWallet as fe, EAmountsDisplayFeature as ke } from "@odynn/awayz-core";
|
|
10
10
|
import { useQuery as r } from "@tanstack/react-query";
|
|
11
11
|
import { h as n } from "../../moment-BGjjqtLQ.js";
|
|
12
|
-
import { livePointsCheckTimeout as
|
|
13
|
-
import { HotelChains as
|
|
14
|
-
import { IhgFreeNightCards as
|
|
15
|
-
import { HotelService as
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
const
|
|
19
|
-
var
|
|
12
|
+
import { livePointsCheckTimeout as de } from "../../configs/defaults.js";
|
|
13
|
+
import { HotelChains as pe } from "../../definitions/HotelChains.js";
|
|
14
|
+
import { IhgFreeNightCards as ye } from "../../definitions/IhgFreeNightCards.js";
|
|
15
|
+
import { HotelService as ge } from "../../services/hotel/HotelService.js";
|
|
16
|
+
import { isDuffelHotelId as Ce } from "../../utilities/hotelUtils/hotelUtils.js";
|
|
17
|
+
import { calculatePointsAsCash as Fe } from "../../utilities/pointsAsCashUtils.js";
|
|
18
|
+
const Ie = (a) => {
|
|
19
|
+
var R, A, O, q, S, _, G, B, E, N, P, w, T;
|
|
20
20
|
if (!a)
|
|
21
21
|
throw new Error(
|
|
22
22
|
"Hotel is required in order to initiate the hotel details flow"
|
|
23
23
|
);
|
|
24
|
-
const { user:
|
|
24
|
+
const { user: m, config: f, featureFlags: k } = me(), { updateHotel: g, searchParams: o } = ie(), s = re(a), [e, L] = se({
|
|
25
25
|
checkinDate: s ? n(a.checkinDate) : o == null ? void 0 : o.checkinDate,
|
|
26
26
|
checkoutDate: s ? n(a.checkoutDate) : o == null ? void 0 : o.checkoutDate
|
|
27
27
|
}), {
|
|
28
28
|
data: i,
|
|
29
|
-
isFetching:
|
|
30
|
-
isFetched:
|
|
29
|
+
isFetching: U,
|
|
30
|
+
isFetched: d
|
|
31
31
|
} = r({
|
|
32
32
|
queryKey: [
|
|
33
33
|
"hotelDetails",
|
|
34
34
|
a.hotelId,
|
|
35
35
|
a.hotelGroup,
|
|
36
|
-
(
|
|
37
|
-
(
|
|
36
|
+
(R = e == null ? void 0 : e.checkinDate) == null ? void 0 : R.valueOf(),
|
|
37
|
+
(A = e == null ? void 0 : e.checkoutDate) == null ? void 0 : A.valueOf()
|
|
38
38
|
],
|
|
39
39
|
queryFn: () => {
|
|
40
40
|
var c;
|
|
41
|
-
return
|
|
41
|
+
return ge.searchByHotelId({
|
|
42
42
|
hotel_group: a.hotelGroup,
|
|
43
43
|
hotel_id: a.hotelId,
|
|
44
44
|
check_in_date: n(e.checkinDate).format(
|
|
45
|
-
|
|
45
|
+
K.ServerDate
|
|
46
46
|
),
|
|
47
47
|
check_out_date: n(e.checkoutDate).format(
|
|
48
|
-
|
|
48
|
+
K.ServerDate
|
|
49
49
|
),
|
|
50
50
|
guests: a.guests,
|
|
51
51
|
rooms: a.rooms,
|
|
52
|
-
currency: ((c =
|
|
52
|
+
currency: ((c = m == null ? void 0 : m.userRegion) == null ? void 0 : c.currency) || ae,
|
|
53
53
|
cash_or_points: ["cash", "points"],
|
|
54
|
-
use_duffel:
|
|
54
|
+
use_duffel: f == null ? void 0 : f.supportsDuffel
|
|
55
55
|
});
|
|
56
56
|
},
|
|
57
57
|
enabled: s && !!e.checkinDate && !!e.checkoutDate,
|
|
@@ -59,22 +59,22 @@ const Ne = (a) => {
|
|
|
59
59
|
}), t = D(() => {
|
|
60
60
|
var c;
|
|
61
61
|
return s ? i != null && i.success && ((c = i.data) != null && c[0]) ? i.data[0] : {} : a;
|
|
62
|
-
}, [s, i, a]), h = D(() =>
|
|
63
|
-
|
|
62
|
+
}, [s, i, a]), h = D(() => ce(e.checkinDate, e.checkoutDate), [e]), x = (c, l) => {
|
|
63
|
+
L({
|
|
64
64
|
checkinDate: n(c),
|
|
65
65
|
checkoutDate: n(l)
|
|
66
66
|
});
|
|
67
|
-
}, { userCards: u } = fe(),
|
|
67
|
+
}, { userCards: u } = fe(), C = D(() => (t == null ? void 0 : t.hotelGroup) === pe.IHG ? ye.some(
|
|
68
68
|
(c) => u == null ? void 0 : u.some((l) => l.name === c)
|
|
69
|
-
) : !0, [u]), { data:
|
|
69
|
+
) : !0, [u]), { data: W, isFetching: z } = r({
|
|
70
70
|
queryKey: ["transferPartners", t.hotelGroup],
|
|
71
|
-
queryFn: () =>
|
|
71
|
+
queryFn: () => ne(t.hotelGroup),
|
|
72
72
|
enabled: !!t.hotelGroup,
|
|
73
73
|
placeholderData: []
|
|
74
74
|
}), {
|
|
75
|
-
data:
|
|
76
|
-
isFetching:
|
|
77
|
-
isFetched:
|
|
75
|
+
data: M,
|
|
76
|
+
isFetching: F,
|
|
77
|
+
isFetched: Q
|
|
78
78
|
} = r({
|
|
79
79
|
queryKey: [
|
|
80
80
|
"hotelPointsCheck",
|
|
@@ -84,16 +84,16 @@ const Ne = (a) => {
|
|
|
84
84
|
(q = e == null ? void 0 : e.checkoutDate) == null ? void 0 : q.valueOf()
|
|
85
85
|
],
|
|
86
86
|
queryFn: ({ signal: c }) => {
|
|
87
|
-
const l = AbortSignal.timeout(
|
|
88
|
-
return
|
|
87
|
+
const l = AbortSignal.timeout(de), oe = AbortSignal.any([c, l]);
|
|
88
|
+
return le({
|
|
89
89
|
hotel: t,
|
|
90
90
|
checkinDate: e.checkinDate,
|
|
91
91
|
checkoutDate: e.checkoutDate,
|
|
92
92
|
updateHotel: g,
|
|
93
|
-
signal:
|
|
93
|
+
signal: oe
|
|
94
94
|
});
|
|
95
95
|
},
|
|
96
|
-
enabled: !!e.checkinDate && !!e.checkoutDate && !!t.liveScrapingCheckNeeded && (!s ||
|
|
96
|
+
enabled: !!e.checkinDate && !!e.checkoutDate && !!t.liveScrapingCheckNeeded && (k == null ? void 0 : k.amountsDisplayFeature) === ke.CASH_AND_TRAVEL_PARTNER_POINTS && (!s || d),
|
|
97
97
|
// We don't throw an error on fail so we can gracefully handle fallback
|
|
98
98
|
retry: !1,
|
|
99
99
|
refetchOnWindowFocus: !1,
|
|
@@ -102,23 +102,23 @@ const Ne = (a) => {
|
|
|
102
102
|
pointsHotelDetails: t,
|
|
103
103
|
pointsRooms: t.rooms ?? []
|
|
104
104
|
}
|
|
105
|
-
}), { pointsRooms:
|
|
105
|
+
}), { pointsRooms: V, pointsHotelDetails: p } = M || {
|
|
106
106
|
pointsHotelDetails: t,
|
|
107
107
|
pointsRooms: []
|
|
108
108
|
}, {
|
|
109
109
|
data: Y,
|
|
110
|
-
isFetching:
|
|
110
|
+
isFetching: v,
|
|
111
111
|
isFetched: j
|
|
112
112
|
} = r({
|
|
113
113
|
queryKey: [
|
|
114
114
|
"fetchAvailableRooms",
|
|
115
|
-
(
|
|
116
|
-
(
|
|
115
|
+
(S = t.cashBookingOffers) == null ? void 0 : S.accommodationId,
|
|
116
|
+
(_ = e == null ? void 0 : e.checkinDate) == null ? void 0 : _.valueOf(),
|
|
117
117
|
(G = e == null ? void 0 : e.checkoutDate) == null ? void 0 : G.valueOf(),
|
|
118
118
|
o == null ? void 0 : o.guests,
|
|
119
119
|
o == null ? void 0 : o.rooms
|
|
120
120
|
],
|
|
121
|
-
queryFn: () =>
|
|
121
|
+
queryFn: () => he({
|
|
122
122
|
hotel: t,
|
|
123
123
|
checkinDate: e.checkinDate,
|
|
124
124
|
checkoutDate: e.checkoutDate,
|
|
@@ -127,82 +127,82 @@ const Ne = (a) => {
|
|
|
127
127
|
updateHotel: g,
|
|
128
128
|
numberOfNights: h
|
|
129
129
|
}),
|
|
130
|
-
enabled: !!e.checkinDate && !!e.checkoutDate && !!((
|
|
130
|
+
enabled: !!e.checkinDate && !!e.checkoutDate && !!((B = t.cashBookingOffers) != null && B.accommodationId) && (!s || d),
|
|
131
131
|
retry: !1,
|
|
132
132
|
placeholderData: {
|
|
133
133
|
cashHotelDetails: t,
|
|
134
134
|
cashRooms: []
|
|
135
135
|
}
|
|
136
|
-
}), { cashRooms: J, cashHotelDetails:
|
|
136
|
+
}), { cashRooms: J, cashHotelDetails: y } = Y || {
|
|
137
137
|
cashHotelDetails: t,
|
|
138
138
|
cashRooms: []
|
|
139
|
-
},
|
|
140
|
-
() =>
|
|
141
|
-
[t,
|
|
139
|
+
}, X = D(
|
|
140
|
+
() => I(t, p, y),
|
|
141
|
+
[t, p, y]
|
|
142
142
|
), {
|
|
143
|
-
data:
|
|
144
|
-
isFetching:
|
|
145
|
-
isFetched:
|
|
143
|
+
data: Z,
|
|
144
|
+
isFetching: $,
|
|
145
|
+
isFetched: ee
|
|
146
146
|
} = r({
|
|
147
147
|
queryKey: [
|
|
148
148
|
"bestCheckout",
|
|
149
149
|
t.hotelId,
|
|
150
150
|
t.hotelGroup,
|
|
151
|
-
(
|
|
152
|
-
(
|
|
153
|
-
|
|
151
|
+
(E = e == null ? void 0 : e.checkinDate) == null ? void 0 : E.valueOf(),
|
|
152
|
+
(N = e == null ? void 0 : e.checkoutDate) == null ? void 0 : N.valueOf(),
|
|
153
|
+
C
|
|
154
154
|
],
|
|
155
|
-
queryFn: () =>
|
|
156
|
-
|
|
155
|
+
queryFn: () => De(
|
|
156
|
+
X,
|
|
157
157
|
h,
|
|
158
|
-
|
|
158
|
+
C
|
|
159
159
|
),
|
|
160
|
-
enabled: !
|
|
160
|
+
enabled: !Ce(t.hotelId) && !F && (t.liveScrapingCheckNeeded ? Q : !0) && !v && ((P = t.cashBookingOffers) != null && P.accommodationId ? j : !0) && h > 0 && t.points >= 0 && (!s || d),
|
|
161
161
|
retry: !1,
|
|
162
162
|
placeholderData: {
|
|
163
|
-
bestCheckout:
|
|
163
|
+
bestCheckout: ue(t, h),
|
|
164
164
|
isAvailable: !1
|
|
165
165
|
}
|
|
166
|
-
}), { bestCheckout:
|
|
166
|
+
}), { bestCheckout: b, isAvailable: H } = Z || {
|
|
167
167
|
isAvailable: !1
|
|
168
|
-
}, { data:
|
|
168
|
+
}, { data: te } = r({
|
|
169
169
|
queryKey: [
|
|
170
170
|
"pointsAsCash",
|
|
171
171
|
t.hotelId,
|
|
172
172
|
t.hotelGroup,
|
|
173
|
-
(
|
|
174
|
-
(
|
|
173
|
+
(w = e == null ? void 0 : e.checkinDate) == null ? void 0 : w.valueOf(),
|
|
174
|
+
(T = e == null ? void 0 : e.checkoutDate) == null ? void 0 : T.valueOf()
|
|
175
175
|
],
|
|
176
|
-
queryFn: () =>
|
|
177
|
-
enabled:
|
|
176
|
+
queryFn: () => Fe(b.totalCashCost),
|
|
177
|
+
enabled: ee && H,
|
|
178
178
|
retry: !1
|
|
179
179
|
});
|
|
180
180
|
return {
|
|
181
|
-
transferPartners:
|
|
182
|
-
loadingTransferPartners:
|
|
181
|
+
transferPartners: W || [],
|
|
182
|
+
loadingTransferPartners: z,
|
|
183
183
|
// Hotel Details
|
|
184
|
-
loadingHotelDetails:
|
|
184
|
+
loadingHotelDetails: U,
|
|
185
185
|
// Points Check
|
|
186
|
-
pointsRooms:
|
|
187
|
-
loadingLivePointsCheck:
|
|
186
|
+
pointsRooms: V || [],
|
|
187
|
+
loadingLivePointsCheck: F,
|
|
188
188
|
// Cash Rooms
|
|
189
189
|
cashRooms: J || [],
|
|
190
|
-
loadingCashRooms:
|
|
190
|
+
loadingCashRooms: v,
|
|
191
191
|
// Best Checkout
|
|
192
|
-
bestCheckout:
|
|
193
|
-
loadingBestCheckout:
|
|
192
|
+
bestCheckout: b,
|
|
193
|
+
loadingBestCheckout: $,
|
|
194
194
|
// Combined availability
|
|
195
|
-
isAvailable:
|
|
195
|
+
isAvailable: H,
|
|
196
196
|
// Points as Cash
|
|
197
|
-
pointsAsCash:
|
|
198
|
-
hotelDetails:
|
|
197
|
+
pointsAsCash: te,
|
|
198
|
+
hotelDetails: I(
|
|
199
199
|
t,
|
|
200
|
-
|
|
201
|
-
|
|
200
|
+
p,
|
|
201
|
+
y
|
|
202
202
|
),
|
|
203
|
-
updateDates:
|
|
203
|
+
updateDates: x
|
|
204
204
|
};
|
|
205
205
|
};
|
|
206
206
|
export {
|
|
207
|
-
|
|
207
|
+
Ie as useHotelDetails
|
|
208
208
|
};
|
|
@@ -85,7 +85,7 @@ const a = (e) => {
|
|
|
85
85
|
beds: e.beds
|
|
86
86
|
};
|
|
87
87
|
}, T = (e) => {
|
|
88
|
-
var n, t, i, s, o, _, m, c, u, r, l, y, g, f, h, v, C, k,
|
|
88
|
+
var n, t, i, s, o, _, m, c, u, r, l, y, g, f, h, v, C, k, P, b;
|
|
89
89
|
if (e)
|
|
90
90
|
return {
|
|
91
91
|
searchRoomRateId: e.search_room_rate_id,
|
|
@@ -124,8 +124,8 @@ const a = (e) => {
|
|
|
124
124
|
keyCollection: e.key_collection,
|
|
125
125
|
cheapestRateTotalAmount: a(e.cheapest_rate_total_amount),
|
|
126
126
|
cheapestRateCurrency: e.cheapest_rate_currency ?? "",
|
|
127
|
-
chain: { name: ((
|
|
128
|
-
brand: { name: ((
|
|
127
|
+
chain: { name: ((P = e.chain) == null ? void 0 : P.name) ?? "" },
|
|
128
|
+
brand: { name: ((b = e.brand) == null ? void 0 : b.name) ?? "" },
|
|
129
129
|
supportedLoyaltyProgramme: e.supported_loyalty_programme,
|
|
130
130
|
amenities: e.amenities ?? []
|
|
131
131
|
};
|
|
@@ -224,7 +224,8 @@ const a = (e) => {
|
|
|
224
224
|
// Calculated separately
|
|
225
225
|
pointsCalculated: 0,
|
|
226
226
|
// Calculated separately
|
|
227
|
-
starRating: w(e)
|
|
227
|
+
starRating: w(e),
|
|
228
|
+
datePointsRetrieved: e.date_points_retrieved
|
|
228
229
|
};
|
|
229
230
|
}, S = (e) => {
|
|
230
231
|
var n, t, i, s, o;
|