@odynn/awayz-hotels 0.1.14 → 0.1.16
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,10 +1,10 @@
|
|
|
1
|
-
import { HotelService as
|
|
1
|
+
import { HotelService as f } from "../../services/hotel/HotelService.js";
|
|
2
2
|
import { BookingService as d } from "../../services/booking/BookingService.js";
|
|
3
|
-
import { HotelChains as
|
|
3
|
+
import { HotelChains as l } from "../../definitions/HotelChains.js";
|
|
4
4
|
import { EBestCheckoutType as m } from "../../enums/EBestCheckoutType.js";
|
|
5
|
-
import { EGuestType as
|
|
6
|
-
const w = async (o) => await
|
|
7
|
-
|
|
5
|
+
import { EGuestType as C } from "../../services/booking/BookingService.enums.js";
|
|
6
|
+
const w = async (o) => await f.getTransferPartners(
|
|
7
|
+
l.toProgram(o)
|
|
8
8
|
), T = async ({
|
|
9
9
|
hotel: o,
|
|
10
10
|
checkinDate: s,
|
|
@@ -12,13 +12,13 @@ const w = async (o) => await h.getTransferPartners(
|
|
|
12
12
|
updateHotel: t
|
|
13
13
|
}) => {
|
|
14
14
|
let e = !1, i = o, r = o.rooms ?? [];
|
|
15
|
-
if (!o.liveScrapingCheckNeeded || o.hotelGroup ===
|
|
15
|
+
if (!o.liveScrapingCheckNeeded || o.hotelGroup === l.Marriott)
|
|
16
16
|
return {
|
|
17
17
|
pointsHotelDetails: o,
|
|
18
18
|
pointsRooms: r,
|
|
19
19
|
shouldFallbackBestCheckout: e
|
|
20
20
|
};
|
|
21
|
-
const u = await
|
|
21
|
+
const u = await f.hotelPointsCheck({
|
|
22
22
|
hotelGroup: o.hotelGroup,
|
|
23
23
|
hotelId: o.hotelId,
|
|
24
24
|
checkinDate: s,
|
|
@@ -54,13 +54,13 @@ const w = async (o) => await h.getTransferPartners(
|
|
|
54
54
|
cashHotelDetails: o,
|
|
55
55
|
cashRooms: []
|
|
56
56
|
};
|
|
57
|
-
const u = (
|
|
57
|
+
const u = (h) => Array.from({ length: h }, () => ({ type: C.ADULT })), n = await d.getAvailableRooms({
|
|
58
58
|
checkinDate: s,
|
|
59
59
|
checkoutDate: a,
|
|
60
60
|
accommodationId: o.cashBookingOffers.accommodationId,
|
|
61
61
|
guests: u(t),
|
|
62
62
|
rooms: e
|
|
63
|
-
}),
|
|
63
|
+
}), p = {
|
|
64
64
|
...o,
|
|
65
65
|
cashValue: {
|
|
66
66
|
...o.cashValue,
|
|
@@ -68,12 +68,12 @@ const w = async (o) => await h.getTransferPartners(
|
|
|
68
68
|
currency: n.currency ?? o.cashValue.currency
|
|
69
69
|
}
|
|
70
70
|
};
|
|
71
|
-
return i(o.hotelId, o.hotelGroup,
|
|
72
|
-
cashHotelDetails:
|
|
71
|
+
return i(o.hotelId, o.hotelGroup, p), {
|
|
72
|
+
cashHotelDetails: p,
|
|
73
73
|
cashRooms: n.availableRooms
|
|
74
74
|
};
|
|
75
75
|
}, B = async (o, s) => {
|
|
76
|
-
const { success: a, data: t } = await
|
|
76
|
+
const { success: a, data: t } = await f.getRecommendations({
|
|
77
77
|
days: s,
|
|
78
78
|
hotels: [o]
|
|
79
79
|
});
|
|
@@ -81,21 +81,21 @@ const w = async (o) => await h.getTransferPartners(
|
|
|
81
81
|
bestCheckout: t,
|
|
82
82
|
isAvailable: t.nightlyPointsCost > 0 || t.nightlyCashCost > 0
|
|
83
83
|
} : {
|
|
84
|
-
bestCheckout:
|
|
84
|
+
bestCheckout: y(o, s),
|
|
85
85
|
isAvailable: !1
|
|
86
86
|
};
|
|
87
|
-
},
|
|
88
|
-
var t, e
|
|
87
|
+
}, y = (o, s) => {
|
|
88
|
+
var t, e;
|
|
89
89
|
return {
|
|
90
|
-
bestCheckoutMethod:
|
|
90
|
+
bestCheckoutMethod: l.isHotelChain(o.hotelGroup) ? o.bestValue : m.CASH,
|
|
91
91
|
nightlyCashCost: ((t = o.cashValue) == null ? void 0 : t.amount) || 0,
|
|
92
92
|
nightlyPointsCost: o.points || 0,
|
|
93
93
|
awardPoints: o.points || 0,
|
|
94
94
|
totalCashCost: (((e = o.cashValue) == null ? void 0 : e.amount) || 0) * s,
|
|
95
95
|
totalPointsCost: (o.points || 0) * s,
|
|
96
|
-
currency:
|
|
96
|
+
currency: "USD",
|
|
97
97
|
sufficientPoints: !0,
|
|
98
|
-
rewardsProgram:
|
|
98
|
+
rewardsProgram: l.toProgram(o.hotelGroup),
|
|
99
99
|
optimalProgram: {
|
|
100
100
|
programs: [],
|
|
101
101
|
remainingPointsBalance: 0
|
|
@@ -117,7 +117,7 @@ const w = async (o) => await h.getTransferPartners(
|
|
|
117
117
|
};
|
|
118
118
|
export {
|
|
119
119
|
G as combineUpdatedHotelData,
|
|
120
|
-
|
|
120
|
+
y as fallbackBestCheckout,
|
|
121
121
|
A as fetchAvailableRooms,
|
|
122
122
|
B as fetchBestCheckout,
|
|
123
123
|
T as fetchPointsCheck,
|
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
import { useMemo as
|
|
2
|
-
import { h as
|
|
1
|
+
import { useMemo as M } from "react";
|
|
2
|
+
import { h as F } from "../../moment-BGjjqtLQ.js";
|
|
3
3
|
import "../../arrayExtensions-cyilNkdJ.js";
|
|
4
|
-
import
|
|
5
|
-
import { fetchTransferPartners as
|
|
6
|
-
import { calculatePointsAsCash as
|
|
4
|
+
import T from "../../stores/useHotelsStore.js";
|
|
5
|
+
import { fetchTransferPartners as x, fetchPointsCheck as E, fetchAvailableRooms as L, fetchBestCheckout as Q, combineUpdatedHotelData as g, fallbackBestCheckout as U } from "./useHotelDetails.api.js";
|
|
6
|
+
import { calculatePointsAsCash as j } from "../../utilities/pointsAsCashUtils.js";
|
|
7
7
|
import { useQuery as o } from "@tanstack/react-query";
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
),
|
|
11
|
-
var
|
|
8
|
+
const z = (t, c) => Math.abs(
|
|
9
|
+
F(t.startOf("day")).diff(F(c.endOf("day")), "days")
|
|
10
|
+
), $ = (t) => {
|
|
11
|
+
var r, d, k, f, D, p, y, b, C, v;
|
|
12
12
|
if (!t)
|
|
13
13
|
throw new Error(
|
|
14
14
|
"Hotel is required in order to initiate the hotel details flow"
|
|
15
15
|
);
|
|
16
|
-
const { updateHotel:
|
|
16
|
+
const { updateHotel: c, searchParams: e } = T(), a = M(() => e ? z(
|
|
17
17
|
e.checkinDate,
|
|
18
18
|
e.checkoutDate
|
|
19
|
-
) : 0, [e]), { data:
|
|
19
|
+
) : 0, [e]), { data: m, isFetching: O } = o({
|
|
20
20
|
queryKey: ["transferPartners", t.hotelGroup],
|
|
21
|
-
queryFn: () =>
|
|
21
|
+
queryFn: () => x(t.hotelGroup),
|
|
22
22
|
enabled: !!t.hotelGroup,
|
|
23
23
|
placeholderData: []
|
|
24
24
|
}), {
|
|
25
|
-
data:
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
data: q,
|
|
26
|
+
isFetching: s,
|
|
27
|
+
isFetched: H
|
|
28
28
|
} = o({
|
|
29
29
|
queryKey: [
|
|
30
30
|
"hotelPointsCheck",
|
|
31
31
|
t.hotelId,
|
|
32
32
|
t.hotelGroup,
|
|
33
|
-
(
|
|
34
|
-
(
|
|
33
|
+
(r = e == null ? void 0 : e.checkinDate) == null ? void 0 : r.valueOf(),
|
|
34
|
+
(d = e == null ? void 0 : e.checkoutDate) == null ? void 0 : d.valueOf()
|
|
35
35
|
],
|
|
36
|
-
queryFn: () =>
|
|
36
|
+
queryFn: () => E({
|
|
37
37
|
hotel: t,
|
|
38
38
|
checkinDate: e.checkinDate,
|
|
39
39
|
checkoutDate: e.checkoutDate,
|
|
40
|
-
updateHotel:
|
|
40
|
+
updateHotel: c
|
|
41
41
|
}),
|
|
42
42
|
enabled: !!e && !!e.checkinDate && !!e.checkoutDate && !!t.liveScrapingCheckNeeded,
|
|
43
43
|
// We don't throw an error on fail so we can gracefully handle fallback
|
|
@@ -47,14 +47,14 @@ const j = (t, a) => Math.abs(
|
|
|
47
47
|
pointsRooms: t.rooms ?? [],
|
|
48
48
|
shouldFallbackBestCheckout: !1
|
|
49
49
|
}
|
|
50
|
-
}), { pointsRooms:
|
|
50
|
+
}), { pointsRooms: R, pointsHotelDetails: i, shouldFallbackBestCheckout: B } = q || {
|
|
51
51
|
pointsHotelDetails: t,
|
|
52
52
|
pointsRooms: [],
|
|
53
53
|
shouldFallbackBestCheckout: !1
|
|
54
54
|
}, {
|
|
55
|
-
data:
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
data: A,
|
|
56
|
+
isFetching: n,
|
|
57
|
+
isFetched: G
|
|
58
58
|
} = o({
|
|
59
59
|
queryKey: [
|
|
60
60
|
"fetchAvailableRooms",
|
|
@@ -64,14 +64,14 @@ const j = (t, a) => Math.abs(
|
|
|
64
64
|
e == null ? void 0 : e.guests,
|
|
65
65
|
e == null ? void 0 : e.rooms
|
|
66
66
|
],
|
|
67
|
-
queryFn: () =>
|
|
67
|
+
queryFn: () => L({
|
|
68
68
|
hotel: t,
|
|
69
69
|
checkinDate: e.checkinDate,
|
|
70
70
|
checkoutDate: e.checkoutDate,
|
|
71
71
|
guests: e.guests,
|
|
72
72
|
rooms: e.rooms,
|
|
73
|
-
updateHotel:
|
|
74
|
-
numberOfNights:
|
|
73
|
+
updateHotel: c,
|
|
74
|
+
numberOfNights: a
|
|
75
75
|
}),
|
|
76
76
|
enabled: !!e && !!e.checkinDate && !!e.checkoutDate && !!((p = t.cashBookingOffers) != null && p.accommodationId),
|
|
77
77
|
retry: !1,
|
|
@@ -79,64 +79,68 @@ const j = (t, a) => Math.abs(
|
|
|
79
79
|
cashHotelDetails: t,
|
|
80
80
|
cashRooms: []
|
|
81
81
|
}
|
|
82
|
-
}), { cashRooms:
|
|
82
|
+
}), { cashRooms: I, cashHotelDetails: l } = A || {
|
|
83
83
|
cashHotelDetails: t,
|
|
84
84
|
cashRooms: []
|
|
85
|
-
}, {
|
|
85
|
+
}, {
|
|
86
|
+
data: K,
|
|
87
|
+
isFetching: w,
|
|
88
|
+
isFetched: S
|
|
89
|
+
} = o({
|
|
86
90
|
queryKey: [
|
|
87
91
|
"bestCheckout",
|
|
88
92
|
t.hotelId,
|
|
89
93
|
t.hotelGroup,
|
|
90
94
|
(y = e == null ? void 0 : e.checkinDate) == null ? void 0 : y.valueOf(),
|
|
91
|
-
(
|
|
95
|
+
(b = e == null ? void 0 : e.checkoutDate) == null ? void 0 : b.valueOf()
|
|
92
96
|
],
|
|
93
|
-
queryFn: () =>
|
|
94
|
-
|
|
95
|
-
|
|
97
|
+
queryFn: () => Q(
|
|
98
|
+
g(t, i, l),
|
|
99
|
+
a
|
|
96
100
|
),
|
|
97
|
-
enabled: !
|
|
101
|
+
enabled: !s && (t.liveScrapingCheckNeeded ? H : !0) && !n && G && !B && a > 0,
|
|
98
102
|
retry: !1,
|
|
99
103
|
placeholderData: {
|
|
100
|
-
bestCheckout:
|
|
104
|
+
bestCheckout: U(t, a),
|
|
101
105
|
isAvailable: !1
|
|
102
106
|
}
|
|
103
|
-
}), { bestCheckout:
|
|
107
|
+
}), { bestCheckout: u, isAvailable: h } = K || {
|
|
104
108
|
isAvailable: !1
|
|
105
|
-
}, { data:
|
|
109
|
+
}, { data: N } = o({
|
|
106
110
|
queryKey: [
|
|
107
111
|
"pointsAsCash",
|
|
108
112
|
t.hotelId,
|
|
109
113
|
t.hotelGroup,
|
|
110
|
-
(
|
|
114
|
+
(C = e == null ? void 0 : e.checkinDate) == null ? void 0 : C.valueOf(),
|
|
111
115
|
(v = e == null ? void 0 : e.checkoutDate) == null ? void 0 : v.valueOf()
|
|
112
116
|
],
|
|
113
|
-
queryFn: () =>
|
|
114
|
-
enabled:
|
|
117
|
+
queryFn: () => j(u.totalCashCost),
|
|
118
|
+
enabled: S && h,
|
|
115
119
|
retry: !1
|
|
116
120
|
});
|
|
117
121
|
return {
|
|
118
|
-
transferPartners:
|
|
119
|
-
loadingTransferPartners:
|
|
122
|
+
transferPartners: m,
|
|
123
|
+
loadingTransferPartners: O,
|
|
120
124
|
// Points Check
|
|
121
|
-
pointsRooms:
|
|
122
|
-
loadingLivePointsCheck:
|
|
125
|
+
pointsRooms: R,
|
|
126
|
+
loadingLivePointsCheck: s,
|
|
123
127
|
// Cash Rooms
|
|
124
|
-
cashRooms:
|
|
128
|
+
cashRooms: I,
|
|
125
129
|
loadingCashRooms: n,
|
|
126
130
|
// Best Checkout
|
|
127
|
-
bestCheckout:
|
|
128
|
-
loadingBestCheckout:
|
|
131
|
+
bestCheckout: u,
|
|
132
|
+
loadingBestCheckout: w,
|
|
129
133
|
// Combined availability
|
|
130
|
-
isAvailable:
|
|
134
|
+
isAvailable: h,
|
|
131
135
|
// Points as Cash
|
|
132
|
-
pointsAsCash:
|
|
133
|
-
hotelDetails:
|
|
136
|
+
pointsAsCash: N,
|
|
137
|
+
hotelDetails: g(
|
|
134
138
|
t,
|
|
135
|
-
|
|
136
|
-
|
|
139
|
+
i,
|
|
140
|
+
l
|
|
137
141
|
)
|
|
138
142
|
};
|
|
139
143
|
};
|
|
140
144
|
export {
|
|
141
|
-
|
|
145
|
+
$ as useHotelDetails
|
|
142
146
|
};
|
|
@@ -118,8 +118,8 @@ export interface IPlaceResponse {
|
|
|
118
118
|
country: INameCode;
|
|
119
119
|
state: INameCode;
|
|
120
120
|
description: string;
|
|
121
|
-
|
|
122
|
-
|
|
121
|
+
search_type: string;
|
|
122
|
+
search_id: string;
|
|
123
123
|
}
|
|
124
124
|
export interface IHotelResponse {
|
|
125
125
|
city: string;
|
|
@@ -130,8 +130,9 @@ export interface IHotelResponse {
|
|
|
130
130
|
hotel_id: string;
|
|
131
131
|
hotel_name: string;
|
|
132
132
|
description: string;
|
|
133
|
-
|
|
134
|
-
|
|
133
|
+
search_type: string;
|
|
134
|
+
search_id: string;
|
|
135
|
+
type: string;
|
|
135
136
|
}
|
|
136
137
|
export interface ISearchLocation {
|
|
137
138
|
searchId: string;
|
|
@@ -28,17 +28,17 @@ class H {
|
|
|
28
28
|
success: !1,
|
|
29
29
|
message: (e == null ? void 0 : e.message) || "Error fetching location data"
|
|
30
30
|
};
|
|
31
|
-
const t = (o) => o.
|
|
31
|
+
const t = (o) => o.type === C.HOTEL;
|
|
32
32
|
return {
|
|
33
33
|
success: !0,
|
|
34
34
|
data: e.data.cities.map(
|
|
35
35
|
(o) => {
|
|
36
|
-
const {
|
|
36
|
+
const { search_id: p, search_type: _, description: d, coordinates: y, city: g } = o, n = {
|
|
37
37
|
searchId: p,
|
|
38
38
|
searchType: _,
|
|
39
39
|
description: d,
|
|
40
|
-
coordinates:
|
|
41
|
-
city:
|
|
40
|
+
coordinates: y,
|
|
41
|
+
city: g
|
|
42
42
|
};
|
|
43
43
|
return t(o) ? (n.country = {
|
|
44
44
|
code: o.country_code,
|