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