@odynn/awayz-hotels 0.6.14 → 0.6.15
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/dist/configs/defaults.js +3 -2
- package/dist/hooks/useHotelDetails/useHotelDetails.api.js +75 -70
- package/dist/hooks/useHotelDetails/useHotelDetails.js +132 -87
- package/dist/lib/configs/defaults.d.ts +1 -0
- package/dist/lib/hooks/useHotelDetails/useHotelDetails.api.d.ts +24 -1
- package/dist/lib/hooks/useHotelDetails/useHotelDetails.d.ts +3 -1
- package/dist/lib/services/hotel/HotelService.d.ts +1 -1
- package/dist/services/hotel/HotelService.js +44 -43
- package/package.json +1 -1
package/dist/configs/defaults.js
CHANGED
|
@@ -6,7 +6,7 @@ const o = {
|
|
|
6
6
|
[e.LANDMARK]: 4,
|
|
7
7
|
[e.HOTEL]: 5,
|
|
8
8
|
[e.AIRPORT]: 6
|
|
9
|
-
}, c = 60, l = {
|
|
9
|
+
}, c = 60, i = 15e3, l = {
|
|
10
10
|
searchId: "duffel_test_hotel_search",
|
|
11
11
|
searchType: e.HOTEL,
|
|
12
12
|
description: "Duffel Test Hotel",
|
|
@@ -25,5 +25,6 @@ const o = {
|
|
|
25
25
|
export {
|
|
26
26
|
o as defaultLocationSortOrder,
|
|
27
27
|
c as defaultSimilarityThreshold,
|
|
28
|
-
l as duffelTestHotelLocation
|
|
28
|
+
l as duffelTestHotelLocation,
|
|
29
|
+
i as livePointsCheckTimeout
|
|
29
30
|
};
|
|
@@ -1,107 +1,111 @@
|
|
|
1
1
|
import { HotelChains as p } from "../../definitions/HotelChains.js";
|
|
2
|
-
import { EBestCheckoutType as
|
|
2
|
+
import { EBestCheckoutType as h } from "../../enums/EBestCheckoutType.js";
|
|
3
3
|
import { BookingService as y } from "../../services/booking/BookingService.js";
|
|
4
4
|
import { EGuestType as C } from "../../services/booking/BookingService.enums.js";
|
|
5
|
-
import { HotelService as
|
|
6
|
-
const w = async (s) => await
|
|
5
|
+
import { HotelService as f } from "../../services/hotel/HotelService.js";
|
|
6
|
+
const w = async (s) => await f.getTransferPartners(
|
|
7
7
|
p.toProgram(s)
|
|
8
|
-
), T = async ({
|
|
8
|
+
), T = (s) => !!s.hotelGroup && !!s.hotelId && !!s.checkinDate && !!s.checkoutDate && !!s.rooms && !!s.guests, A = async ({
|
|
9
9
|
hotel: s,
|
|
10
10
|
checkinDate: t,
|
|
11
|
-
checkoutDate:
|
|
12
|
-
updateHotel:
|
|
11
|
+
checkoutDate: o,
|
|
12
|
+
updateHotel: a,
|
|
13
|
+
signal: e
|
|
13
14
|
}) => {
|
|
14
|
-
let
|
|
15
|
+
let r = s, c = s.rooms ?? [];
|
|
15
16
|
if (!s.liveScrapingCheckNeeded || s.hotelGroup === p.Marriott)
|
|
16
17
|
return {
|
|
17
18
|
pointsHotelDetails: s,
|
|
18
|
-
pointsRooms:
|
|
19
|
+
pointsRooms: c
|
|
19
20
|
};
|
|
20
|
-
let
|
|
21
|
+
let u = !1, i = null;
|
|
21
22
|
try {
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
const n = await f.hotelPointsCheck(
|
|
24
|
+
{
|
|
25
|
+
hotelGroup: s.hotelGroup,
|
|
26
|
+
hotelId: s.hotelId,
|
|
27
|
+
checkinDate: t,
|
|
28
|
+
checkoutDate: o
|
|
29
|
+
},
|
|
30
|
+
e
|
|
31
|
+
);
|
|
32
|
+
u = n.success, i = n.data;
|
|
29
33
|
} catch {
|
|
30
|
-
|
|
34
|
+
u = !1, i = null;
|
|
31
35
|
}
|
|
32
|
-
if (
|
|
33
|
-
const
|
|
34
|
-
|
|
36
|
+
if (u) {
|
|
37
|
+
const n = i, m = !(n.points.pointsValue > 0) && s.bestValue === h.POINTS;
|
|
38
|
+
r = {
|
|
35
39
|
...s,
|
|
36
|
-
awardPoints:
|
|
37
|
-
points:
|
|
38
|
-
pointsType:
|
|
39
|
-
bestValue:
|
|
40
|
-
},
|
|
40
|
+
awardPoints: n.points.awardPointsValue ?? n.points.pointsValue,
|
|
41
|
+
points: n.points.pointsValue,
|
|
42
|
+
pointsType: n.points.pointsType,
|
|
43
|
+
bestValue: m ? h.NONE : s.bestValue
|
|
44
|
+
}, c = n.rooms ?? s.rooms ?? [], a(s.hotelId, s.hotelGroup, r);
|
|
41
45
|
}
|
|
42
46
|
return {
|
|
43
|
-
pointsHotelDetails:
|
|
44
|
-
pointsRooms:
|
|
47
|
+
pointsHotelDetails: r,
|
|
48
|
+
pointsRooms: c
|
|
45
49
|
};
|
|
46
|
-
},
|
|
50
|
+
}, B = async ({
|
|
47
51
|
hotel: s,
|
|
48
52
|
checkinDate: t,
|
|
49
|
-
checkoutDate:
|
|
50
|
-
guests:
|
|
51
|
-
rooms:
|
|
52
|
-
updateHotel:
|
|
53
|
-
numberOfNights:
|
|
53
|
+
checkoutDate: o,
|
|
54
|
+
guests: a,
|
|
55
|
+
rooms: e,
|
|
56
|
+
updateHotel: r,
|
|
57
|
+
numberOfNights: c
|
|
54
58
|
}) => {
|
|
55
|
-
var
|
|
56
|
-
if (!((
|
|
59
|
+
var l;
|
|
60
|
+
if (!((l = s == null ? void 0 : s.cashBookingOffers) != null && l.accommodationId))
|
|
57
61
|
return {
|
|
58
62
|
cashHotelDetails: s,
|
|
59
63
|
cashRooms: []
|
|
60
64
|
};
|
|
61
|
-
const
|
|
65
|
+
const u = (m) => Array.from({ length: m }, () => ({ type: C.ADULT })), i = await y.getAvailableRooms({
|
|
62
66
|
checkinDate: t,
|
|
63
|
-
checkoutDate:
|
|
67
|
+
checkoutDate: o,
|
|
64
68
|
accommodationId: s.cashBookingOffers.accommodationId,
|
|
65
|
-
guests:
|
|
66
|
-
rooms:
|
|
67
|
-
}),
|
|
69
|
+
guests: u(a),
|
|
70
|
+
rooms: e
|
|
71
|
+
}), n = {
|
|
68
72
|
...s,
|
|
69
73
|
cashValue: {
|
|
70
74
|
...s.cashValue,
|
|
71
|
-
amount:
|
|
72
|
-
currency:
|
|
75
|
+
amount: i.cheapestRate / c || s.cashValue.amount || 0,
|
|
76
|
+
currency: i.currency ?? s.cashValue.currency
|
|
73
77
|
}
|
|
74
78
|
};
|
|
75
|
-
return
|
|
76
|
-
cashHotelDetails:
|
|
77
|
-
cashRooms:
|
|
79
|
+
return r(s.hotelId, s.hotelGroup, n), {
|
|
80
|
+
cashHotelDetails: n,
|
|
81
|
+
cashRooms: i.availableRooms
|
|
78
82
|
};
|
|
79
|
-
},
|
|
80
|
-
const { success:
|
|
83
|
+
}, G = async (s, t, o) => {
|
|
84
|
+
const { success: a, data: e } = await f.getRecommendations({
|
|
81
85
|
days: t,
|
|
82
86
|
hotel: s
|
|
83
87
|
});
|
|
84
|
-
return
|
|
88
|
+
return a && e ? {
|
|
85
89
|
bestCheckout: {
|
|
86
|
-
...
|
|
87
|
-
nightlyPointsCost:
|
|
90
|
+
...e,
|
|
91
|
+
nightlyPointsCost: o ? e.awardPoints : e.nightlyPointsCost
|
|
88
92
|
},
|
|
89
|
-
isAvailable:
|
|
93
|
+
isAvailable: e.nightlyPointsCost > 0 || e.nightlyCashCost > 0
|
|
90
94
|
} : {
|
|
91
95
|
bestCheckout: d(s, t),
|
|
92
96
|
isAvailable: !1
|
|
93
97
|
};
|
|
94
98
|
}, d = (s, t) => {
|
|
95
|
-
var
|
|
96
|
-
const
|
|
99
|
+
var r, c, u, i;
|
|
100
|
+
const o = ((r = s.cashBookingOffers) == null ? void 0 : r.cheapestRateTotalAmount) ?? ((c = s.cashValue) == null ? void 0 : c.amount) ?? 0, a = ((u = s.cashBookingOffers) == null ? void 0 : u.cheapestRateCurrency) ?? ((i = s.cashValue) == null ? void 0 : i.currency) ?? "USD";
|
|
97
101
|
return {
|
|
98
|
-
bestCheckoutMethod: p.isHotelChain(s.hotelGroup) ? s.bestValue :
|
|
99
|
-
nightlyCashCost:
|
|
102
|
+
bestCheckoutMethod: p.isHotelChain(s.hotelGroup) ? s.bestValue : h.CASH,
|
|
103
|
+
nightlyCashCost: o,
|
|
100
104
|
nightlyPointsCost: s.points || 0,
|
|
101
105
|
awardPoints: s.points || 0,
|
|
102
|
-
totalCashCost:
|
|
106
|
+
totalCashCost: o * t,
|
|
103
107
|
totalPointsCost: (s.points || 0) * t,
|
|
104
|
-
currency:
|
|
108
|
+
currency: a,
|
|
105
109
|
sufficientPoints: !0,
|
|
106
110
|
rewardsProgram: p.toProgram(s.hotelGroup),
|
|
107
111
|
optimalProgram: {
|
|
@@ -110,25 +114,26 @@ const w = async (s) => await h.getTransferPartners(
|
|
|
110
114
|
totalProgramPointsValuation: 0
|
|
111
115
|
}
|
|
112
116
|
};
|
|
113
|
-
},
|
|
114
|
-
let
|
|
115
|
-
return t && (
|
|
117
|
+
}, I = (s, t, o) => {
|
|
118
|
+
let a = s;
|
|
119
|
+
return t && (a = {
|
|
116
120
|
...s,
|
|
117
121
|
points: t.points,
|
|
118
122
|
awardPoints: t.awardPoints,
|
|
119
123
|
pointsType: t.pointsType,
|
|
120
124
|
bestValue: t.bestValue
|
|
121
|
-
}),
|
|
122
|
-
...
|
|
123
|
-
cashValue:
|
|
124
|
-
rooms:
|
|
125
|
-
}),
|
|
125
|
+
}), o && (a = {
|
|
126
|
+
...a,
|
|
127
|
+
cashValue: o.cashValue,
|
|
128
|
+
rooms: o.rooms
|
|
129
|
+
}), a;
|
|
126
130
|
};
|
|
127
131
|
export {
|
|
128
|
-
|
|
132
|
+
I as combineUpdatedHotelData,
|
|
129
133
|
d as fallbackBestCheckout,
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
w as fetchTransferPartners
|
|
134
|
+
B as fetchAvailableRooms,
|
|
135
|
+
G as fetchBestCheckout,
|
|
136
|
+
A as fetchPointsCheck,
|
|
137
|
+
w as fetchTransferPartners,
|
|
138
|
+
T as isPartialHotelDetails
|
|
134
139
|
};
|
|
@@ -1,159 +1,204 @@
|
|
|
1
|
-
import { g as
|
|
1
|
+
import { g as oe } from "../../dateUtils-C1hKW8MF.js";
|
|
2
|
+
import { E as N } from "../../DateFormats-DZD30Nea.js";
|
|
2
3
|
import "../../arrayExtensions-CFEBYUok.js";
|
|
3
|
-
import { useState as
|
|
4
|
-
import
|
|
5
|
-
import { fetchTransferPartners as
|
|
6
|
-
import { useWallet as
|
|
7
|
-
import { useQuery as
|
|
8
|
-
import { h as
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
4
|
+
import { useState as ce, useMemo as D } from "react";
|
|
5
|
+
import ae from "../../stores/useHotelsStore.js";
|
|
6
|
+
import { isPartialHotelDetails as se, fetchTransferPartners as ie, fetchPointsCheck as re, fetchAvailableRooms as ne, combineUpdatedHotelData as T, fallbackBestCheckout as le, fetchBestCheckout as he } from "./useHotelDetails.api.js";
|
|
7
|
+
import { useAwayzContext as ue, useWallet as De } from "@odynn/awayz-core";
|
|
8
|
+
import { useQuery as r } from "@tanstack/react-query";
|
|
9
|
+
import { h as n } from "../../moment-BGjjqtLQ.js";
|
|
10
|
+
import { livePointsCheckTimeout as fe } from "../../configs/defaults.js";
|
|
11
|
+
import { HotelChains as me } from "../../definitions/HotelChains.js";
|
|
12
|
+
import { IhgFreeNightCards as ke } from "../../definitions/IhgFreeNightCards.js";
|
|
13
|
+
import { HotelService as de } from "../../services/hotel/HotelService.js";
|
|
14
|
+
import { calculatePointsAsCash as pe } from "../../utilities/pointsAsCashUtils.js";
|
|
15
|
+
const ge = "USD", we = (c) => {
|
|
16
|
+
var b, H, R, O, q, A, S, G, _, B, w, K, P, E;
|
|
17
|
+
if (!c)
|
|
15
18
|
throw new Error(
|
|
16
19
|
"Hotel is required in order to initiate the hotel details flow"
|
|
17
20
|
);
|
|
18
|
-
const { updateHotel:
|
|
19
|
-
checkinDate: o == null ? void 0 : o.checkinDate,
|
|
20
|
-
checkoutDate: o == null ? void 0 : o.checkoutDate
|
|
21
|
-
}),
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
const { user: f } = ue(), { updateHotel: p, searchParams: o } = ae(), s = se(c), [e, U] = ce({
|
|
22
|
+
checkinDate: s ? n(c.checkinDate) : o == null ? void 0 : o.checkinDate,
|
|
23
|
+
checkoutDate: s ? n(c.checkoutDate) : o == null ? void 0 : o.checkoutDate
|
|
24
|
+
}), {
|
|
25
|
+
data: i,
|
|
26
|
+
isFetching: W,
|
|
27
|
+
isFetched: m
|
|
28
|
+
} = r({
|
|
29
|
+
queryKey: [
|
|
30
|
+
"hotelDetails",
|
|
31
|
+
c.hotelId,
|
|
32
|
+
c.hotelGroup,
|
|
33
|
+
(b = e == null ? void 0 : e.checkinDate) == null ? void 0 : b.valueOf(),
|
|
34
|
+
(H = e == null ? void 0 : e.checkoutDate) == null ? void 0 : H.valueOf()
|
|
35
|
+
],
|
|
36
|
+
queryFn: () => {
|
|
37
|
+
var a;
|
|
38
|
+
return de.searchByHotelId({
|
|
39
|
+
hotel_group: c.hotelGroup,
|
|
40
|
+
hotel_id: c.hotelId,
|
|
41
|
+
check_in_date: n(e.checkinDate).format(
|
|
42
|
+
N.ServerDate
|
|
43
|
+
),
|
|
44
|
+
check_out_date: n(e.checkoutDate).format(
|
|
45
|
+
N.ServerDate
|
|
46
|
+
),
|
|
47
|
+
guests: c.guests,
|
|
48
|
+
rooms: c.rooms,
|
|
49
|
+
currency: ((a = f == null ? void 0 : f.userRegion) == null ? void 0 : a.currency) || ge,
|
|
50
|
+
cash_or_points: ["cash", "points"]
|
|
51
|
+
});
|
|
52
|
+
},
|
|
53
|
+
enabled: s && !!e.checkinDate && !!e.checkoutDate,
|
|
54
|
+
retry: !1
|
|
55
|
+
}), t = D(() => {
|
|
56
|
+
var a;
|
|
57
|
+
return s ? i != null && i.success && ((a = i.data) != null && a[0]) ? i.data[0] : {} : c;
|
|
58
|
+
}, [s, i, c]), h = D(() => oe(e.checkinDate, e.checkoutDate), [e]), x = (a, l) => {
|
|
59
|
+
U({
|
|
60
|
+
checkinDate: n(a),
|
|
61
|
+
checkoutDate: n(l)
|
|
25
62
|
});
|
|
26
|
-
}, { userCards:
|
|
27
|
-
(
|
|
28
|
-
) : !0, [
|
|
63
|
+
}, { userCards: u } = De(), g = D(() => (t == null ? void 0 : t.hotelGroup) === me.IHG ? ke.some(
|
|
64
|
+
(a) => u == null ? void 0 : u.some((l) => l.name === a)
|
|
65
|
+
) : !0, [u]), { data: L, isFetching: z } = r({
|
|
29
66
|
queryKey: ["transferPartners", t.hotelGroup],
|
|
30
|
-
queryFn: () =>
|
|
67
|
+
queryFn: () => ie(t.hotelGroup),
|
|
31
68
|
enabled: !!t.hotelGroup,
|
|
32
69
|
placeholderData: []
|
|
33
70
|
}), {
|
|
34
|
-
data:
|
|
35
|
-
isFetching:
|
|
36
|
-
isFetched:
|
|
37
|
-
} =
|
|
71
|
+
data: I,
|
|
72
|
+
isFetching: y,
|
|
73
|
+
isFetched: M
|
|
74
|
+
} = r({
|
|
38
75
|
queryKey: [
|
|
39
76
|
"hotelPointsCheck",
|
|
40
77
|
t.hotelId,
|
|
41
78
|
t.hotelGroup,
|
|
42
|
-
(
|
|
43
|
-
(
|
|
79
|
+
(R = e == null ? void 0 : e.checkinDate) == null ? void 0 : R.valueOf(),
|
|
80
|
+
(O = e == null ? void 0 : e.checkoutDate) == null ? void 0 : O.valueOf()
|
|
44
81
|
],
|
|
45
|
-
queryFn: () =>
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
82
|
+
queryFn: ({ signal: a }) => {
|
|
83
|
+
const l = AbortSignal.timeout(fe), te = AbortSignal.any([a, l]);
|
|
84
|
+
return re({
|
|
85
|
+
hotel: t,
|
|
86
|
+
checkinDate: e.checkinDate,
|
|
87
|
+
checkoutDate: e.checkoutDate,
|
|
88
|
+
updateHotel: p,
|
|
89
|
+
signal: te
|
|
90
|
+
});
|
|
91
|
+
},
|
|
92
|
+
enabled: !!e.checkinDate && !!e.checkoutDate && !!t.liveScrapingCheckNeeded && (!s || m),
|
|
52
93
|
// We don't throw an error on fail so we can gracefully handle fallback
|
|
53
94
|
retry: !1,
|
|
95
|
+
refetchOnWindowFocus: !1,
|
|
96
|
+
// stop refetching on tab focus
|
|
54
97
|
placeholderData: {
|
|
55
98
|
pointsHotelDetails: t,
|
|
56
99
|
pointsRooms: t.rooms ?? []
|
|
57
100
|
}
|
|
58
|
-
}), { pointsRooms:
|
|
101
|
+
}), { pointsRooms: Q, pointsHotelDetails: k } = I || {
|
|
59
102
|
pointsHotelDetails: t,
|
|
60
103
|
pointsRooms: []
|
|
61
104
|
}, {
|
|
62
|
-
data:
|
|
63
|
-
isFetching:
|
|
64
|
-
isFetched:
|
|
65
|
-
} =
|
|
105
|
+
data: Y,
|
|
106
|
+
isFetching: v,
|
|
107
|
+
isFetched: j
|
|
108
|
+
} = r({
|
|
66
109
|
queryKey: [
|
|
67
110
|
"fetchAvailableRooms",
|
|
68
|
-
(
|
|
69
|
-
(
|
|
70
|
-
(
|
|
111
|
+
(q = t.cashBookingOffers) == null ? void 0 : q.accommodationId,
|
|
112
|
+
(A = e == null ? void 0 : e.checkinDate) == null ? void 0 : A.valueOf(),
|
|
113
|
+
(S = e == null ? void 0 : e.checkoutDate) == null ? void 0 : S.valueOf(),
|
|
71
114
|
o == null ? void 0 : o.guests,
|
|
72
115
|
o == null ? void 0 : o.rooms
|
|
73
116
|
],
|
|
74
|
-
queryFn: () =>
|
|
117
|
+
queryFn: () => ne({
|
|
75
118
|
hotel: t,
|
|
76
119
|
checkinDate: e.checkinDate,
|
|
77
120
|
checkoutDate: e.checkoutDate,
|
|
78
121
|
guests: o.guests,
|
|
79
122
|
rooms: o.rooms,
|
|
80
|
-
updateHotel:
|
|
81
|
-
numberOfNights:
|
|
123
|
+
updateHotel: p,
|
|
124
|
+
numberOfNights: h
|
|
82
125
|
}),
|
|
83
|
-
enabled: !!e.checkinDate && !!e.checkoutDate && !!((
|
|
126
|
+
enabled: !!e.checkinDate && !!e.checkoutDate && !!((G = t.cashBookingOffers) != null && G.accommodationId) && (!s || m),
|
|
84
127
|
retry: !1,
|
|
85
128
|
placeholderData: {
|
|
86
129
|
cashHotelDetails: t,
|
|
87
130
|
cashRooms: []
|
|
88
131
|
}
|
|
89
|
-
}), { cashRooms:
|
|
132
|
+
}), { cashRooms: J, cashHotelDetails: d } = Y || {
|
|
90
133
|
cashHotelDetails: t,
|
|
91
134
|
cashRooms: []
|
|
92
|
-
},
|
|
93
|
-
() =>
|
|
94
|
-
[t,
|
|
135
|
+
}, V = D(
|
|
136
|
+
() => T(t, k, d),
|
|
137
|
+
[t, k, d]
|
|
95
138
|
), {
|
|
96
|
-
data:
|
|
97
|
-
isFetching:
|
|
98
|
-
isFetched:
|
|
99
|
-
} =
|
|
139
|
+
data: X,
|
|
140
|
+
isFetching: Z,
|
|
141
|
+
isFetched: $
|
|
142
|
+
} = r({
|
|
100
143
|
queryKey: [
|
|
101
144
|
"bestCheckout",
|
|
102
145
|
t.hotelId,
|
|
103
146
|
t.hotelGroup,
|
|
104
|
-
(
|
|
105
|
-
(
|
|
106
|
-
|
|
147
|
+
(_ = e == null ? void 0 : e.checkinDate) == null ? void 0 : _.valueOf(),
|
|
148
|
+
(B = e == null ? void 0 : e.checkoutDate) == null ? void 0 : B.valueOf(),
|
|
149
|
+
g
|
|
107
150
|
],
|
|
108
|
-
queryFn: () =>
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
151
|
+
queryFn: () => he(
|
|
152
|
+
V,
|
|
153
|
+
h,
|
|
154
|
+
g
|
|
112
155
|
),
|
|
113
|
-
enabled: !t.hotelId.startsWith("duff_") && !
|
|
156
|
+
enabled: !((w = t.hotelId) != null && w.startsWith("duff_")) && !y && (t.liveScrapingCheckNeeded ? M : !0) && !v && ((K = t.cashBookingOffers) != null && K.accommodationId ? j : !0) && h > 0 && t.points >= 0 && (!s || m),
|
|
114
157
|
retry: !1,
|
|
115
158
|
placeholderData: {
|
|
116
|
-
bestCheckout:
|
|
159
|
+
bestCheckout: le(t, h),
|
|
117
160
|
isAvailable: !1
|
|
118
161
|
}
|
|
119
|
-
}), { bestCheckout:
|
|
162
|
+
}), { bestCheckout: C, isAvailable: F } = X || {
|
|
120
163
|
isAvailable: !1
|
|
121
|
-
}, { data:
|
|
164
|
+
}, { data: ee } = r({
|
|
122
165
|
queryKey: [
|
|
123
166
|
"pointsAsCash",
|
|
124
167
|
t.hotelId,
|
|
125
168
|
t.hotelGroup,
|
|
126
|
-
(
|
|
127
|
-
(
|
|
169
|
+
(P = e == null ? void 0 : e.checkinDate) == null ? void 0 : P.valueOf(),
|
|
170
|
+
(E = e == null ? void 0 : e.checkoutDate) == null ? void 0 : E.valueOf()
|
|
128
171
|
],
|
|
129
|
-
queryFn: () =>
|
|
130
|
-
enabled:
|
|
172
|
+
queryFn: () => pe(C.totalCashCost),
|
|
173
|
+
enabled: $ && F,
|
|
131
174
|
retry: !1
|
|
132
175
|
});
|
|
133
176
|
return {
|
|
134
|
-
transferPartners:
|
|
135
|
-
loadingTransferPartners:
|
|
177
|
+
transferPartners: L || [],
|
|
178
|
+
loadingTransferPartners: z,
|
|
179
|
+
// Hotel Details
|
|
180
|
+
loadingHotelDetails: W,
|
|
136
181
|
// Points Check
|
|
137
|
-
pointsRooms:
|
|
138
|
-
loadingLivePointsCheck:
|
|
182
|
+
pointsRooms: Q || [],
|
|
183
|
+
loadingLivePointsCheck: y,
|
|
139
184
|
// Cash Rooms
|
|
140
|
-
cashRooms:
|
|
141
|
-
loadingCashRooms:
|
|
185
|
+
cashRooms: J || [],
|
|
186
|
+
loadingCashRooms: v,
|
|
142
187
|
// Best Checkout
|
|
143
|
-
bestCheckout:
|
|
144
|
-
loadingBestCheckout:
|
|
188
|
+
bestCheckout: C,
|
|
189
|
+
loadingBestCheckout: Z,
|
|
145
190
|
// Combined availability
|
|
146
|
-
isAvailable:
|
|
191
|
+
isAvailable: F,
|
|
147
192
|
// Points as Cash
|
|
148
|
-
pointsAsCash:
|
|
149
|
-
hotelDetails:
|
|
193
|
+
pointsAsCash: ee,
|
|
194
|
+
hotelDetails: T(
|
|
150
195
|
t,
|
|
151
|
-
|
|
152
|
-
|
|
196
|
+
k,
|
|
197
|
+
d
|
|
153
198
|
),
|
|
154
|
-
updateDates:
|
|
199
|
+
updateDates: x
|
|
155
200
|
};
|
|
156
201
|
};
|
|
157
202
|
export {
|
|
158
|
-
|
|
203
|
+
we as useHotelDetails
|
|
159
204
|
};
|
|
@@ -8,6 +8,7 @@ export declare const defaultLocationSortOrder: {
|
|
|
8
8
|
readonly "Airport Search": 6;
|
|
9
9
|
};
|
|
10
10
|
export declare const defaultSimilarityThreshold = 60;
|
|
11
|
+
export declare const livePointsCheckTimeout = 15000;
|
|
11
12
|
export declare const duffelTestHotelLocation: {
|
|
12
13
|
searchId: string;
|
|
13
14
|
searchType: ESearchType;
|
|
@@ -14,6 +14,27 @@ interface IHotelPointsCheckParams {
|
|
|
14
14
|
checkoutDate: Moment;
|
|
15
15
|
updateHotel: (hotelId: string, hotelGroup: string, updated: IHotelDetails) => void;
|
|
16
16
|
}
|
|
17
|
+
export interface IPartialHotelDetails {
|
|
18
|
+
hotelId: string;
|
|
19
|
+
hotelGroup: string;
|
|
20
|
+
checkinDate: Date;
|
|
21
|
+
checkoutDate: Date;
|
|
22
|
+
rooms: number;
|
|
23
|
+
guests: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Type guard to determine if a hotel object is of type IPartialHotelDetails.
|
|
27
|
+
*
|
|
28
|
+
* Checks for the existence of required properties in a partial hotel details object:
|
|
29
|
+
* - hotelGroup
|
|
30
|
+
* - hotelId
|
|
31
|
+
* - checkinDate
|
|
32
|
+
* - checkoutDate
|
|
33
|
+
*
|
|
34
|
+
* @param hotel - The hotel object to check, can be either IHotelDetails or IPartialHotelDetails
|
|
35
|
+
* @returns {boolean} True if the object is an IPartialHotelDetails
|
|
36
|
+
*/
|
|
37
|
+
export declare const isPartialHotelDetails: (hotel: IHotelDetails | IPartialHotelDetails) => hotel is IPartialHotelDetails;
|
|
17
38
|
/**
|
|
18
39
|
* Fetches the points check for a given hotel and updates the hotel details accordingly.
|
|
19
40
|
*
|
|
@@ -29,7 +50,9 @@ interface IHotelPointsCheckParams {
|
|
|
29
50
|
* - If points are available, the hotel details are updated with the points information.
|
|
30
51
|
* - If points are not available and the best value was points, the best value is updated to none.
|
|
31
52
|
*/
|
|
32
|
-
export declare const fetchPointsCheck: ({ hotel, checkinDate, checkoutDate, updateHotel }: IHotelPointsCheckParams
|
|
53
|
+
export declare const fetchPointsCheck: ({ hotel, checkinDate, checkoutDate, updateHotel, signal }: IHotelPointsCheckParams & {
|
|
54
|
+
signal?: AbortSignal;
|
|
55
|
+
}) => Promise<IPointsCheckResult>;
|
|
33
56
|
interface IRoomsResult {
|
|
34
57
|
cashHotelDetails: IHotelDetails;
|
|
35
58
|
cashRooms: IRoom[];
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { IPartialHotelDetails } from './useHotelDetails.api';
|
|
1
2
|
import { IHotelDetails } from '../../components/HotelResult/HotelResult.types';
|
|
2
|
-
export declare const useHotelDetails: (
|
|
3
|
+
export declare const useHotelDetails: (hotelInput: IHotelDetails | IPartialHotelDetails) => {
|
|
3
4
|
transferPartners: import('./useHotelDetails.types').ITransferPartner[];
|
|
4
5
|
loadingTransferPartners: boolean;
|
|
6
|
+
loadingHotelDetails: boolean;
|
|
5
7
|
pointsRooms: import('../../main').IRoom[];
|
|
6
8
|
loadingLivePointsCheck: boolean;
|
|
7
9
|
cashRooms: import('../../main').IRoom[];
|
|
@@ -7,7 +7,7 @@ declare class _HotelService {
|
|
|
7
7
|
searchByCoords: (request: ISearchHotelsParams) => Promise<TServiceResponse<IHotelDetails[]>>;
|
|
8
8
|
searchByHotelId: (request: ISearchByHotelIdRequest) => Promise<TServiceResponse<IHotelDetails[]>>;
|
|
9
9
|
getTransferPartners: (program: string) => Promise<ITransferPartner[]>;
|
|
10
|
-
hotelPointsCheck: (args: IHotelPointsCheckArgs) => Promise<{
|
|
10
|
+
hotelPointsCheck: (args: IHotelPointsCheckArgs, signal?: AbortSignal) => Promise<{
|
|
11
11
|
success: any;
|
|
12
12
|
data: ILiveHotelCheck | null;
|
|
13
13
|
message?: undefined;
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
var
|
|
2
|
-
var E = (
|
|
3
|
-
var
|
|
4
|
-
import { clientInstance as
|
|
5
|
-
import { s as
|
|
1
|
+
var f = Object.defineProperty;
|
|
2
|
+
var E = (i, a, s) => a in i ? f(i, a, { enumerable: !0, configurable: !0, writable: !0, value: s }) : i[a] = s;
|
|
3
|
+
var n = (i, a, s) => E(i, typeof a != "symbol" ? a + "" : a, s);
|
|
4
|
+
import { clientInstance as _, clientNoRetryInstance as C } from "@odynn/awayz-core";
|
|
5
|
+
import { s as T } from "../../stringUtils-DFhHh7H1.js";
|
|
6
6
|
import "../../moment-BGjjqtLQ.js";
|
|
7
7
|
import "../../arrayExtensions-CFEBYUok.js";
|
|
8
|
-
import { c as
|
|
8
|
+
import { c as m } from "../../objectUtils-DOsrxUF7.js";
|
|
9
9
|
import { E as h } from "../../DateFormats-DZD30Nea.js";
|
|
10
10
|
import "react";
|
|
11
11
|
import { EHotelEndpoints as l } from "../../configs/endpoints.js";
|
|
12
12
|
import { EBestCheckoutType as p } from "../../enums/EBestCheckoutType.js";
|
|
13
|
-
import { EBestValueType as
|
|
14
|
-
import { ESearchType as
|
|
15
|
-
class
|
|
13
|
+
import { EBestValueType as P } from "../../enums/EBestValueType.js";
|
|
14
|
+
import { ESearchType as S } from "./HotelService.types.js";
|
|
15
|
+
class v {
|
|
16
16
|
constructor() {
|
|
17
|
-
|
|
17
|
+
n(this, "getLocations", async (a) => {
|
|
18
18
|
try {
|
|
19
|
-
const { data: s } = await
|
|
19
|
+
const { data: s } = await _.get(
|
|
20
20
|
l.GET_LOCATIONS,
|
|
21
21
|
{
|
|
22
22
|
params: {
|
|
23
|
-
search:
|
|
23
|
+
search: T(a)
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
);
|
|
@@ -29,22 +29,22 @@ class S {
|
|
|
29
29
|
success: !1,
|
|
30
30
|
message: (s == null ? void 0 : s.message) || "Error fetching location data"
|
|
31
31
|
};
|
|
32
|
-
const o = (e) => e.search_type ===
|
|
32
|
+
const o = (e) => e.search_type === S.HOTEL;
|
|
33
33
|
return {
|
|
34
34
|
success: !0,
|
|
35
35
|
data: s.data.cities.map(
|
|
36
36
|
(e) => {
|
|
37
|
-
const { search_id:
|
|
38
|
-
searchId:
|
|
37
|
+
const { search_id: c, search_type: r, description: d, coordinates: g, city: y } = e, u = {
|
|
38
|
+
searchId: c,
|
|
39
39
|
searchType: r,
|
|
40
40
|
description: d,
|
|
41
41
|
coordinates: g,
|
|
42
|
-
city:
|
|
42
|
+
city: y
|
|
43
43
|
};
|
|
44
|
-
return o(e) ? (
|
|
44
|
+
return o(e) ? (u.country = {
|
|
45
45
|
code: e.country_code,
|
|
46
46
|
name: e.country
|
|
47
|
-
},
|
|
47
|
+
}, u.hotelChain = e.hotel_group, u.hotelName = e.hotel_name) : (u.country = e.country, u.state = e.state), u;
|
|
48
48
|
}
|
|
49
49
|
)
|
|
50
50
|
};
|
|
@@ -57,16 +57,16 @@ class S {
|
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
59
|
});
|
|
60
|
-
|
|
60
|
+
n(this, "searchByCoords", async (a) => {
|
|
61
61
|
var s, o;
|
|
62
62
|
try {
|
|
63
|
-
const { data: t } = await
|
|
63
|
+
const { data: t } = await _.post(l.SEARCH_HOTELS, {
|
|
64
64
|
...a,
|
|
65
65
|
use_duffel: !0
|
|
66
66
|
});
|
|
67
67
|
return t != null && t.success ? {
|
|
68
68
|
success: !0,
|
|
69
|
-
data:
|
|
69
|
+
data: m(
|
|
70
70
|
(s = t.data) == null ? void 0 : s.hotels
|
|
71
71
|
)
|
|
72
72
|
} : {
|
|
@@ -80,16 +80,16 @@ class S {
|
|
|
80
80
|
};
|
|
81
81
|
}
|
|
82
82
|
});
|
|
83
|
-
|
|
83
|
+
n(this, "searchByHotelId", async (a) => {
|
|
84
84
|
var s, o;
|
|
85
85
|
try {
|
|
86
|
-
const { data: t } = await
|
|
86
|
+
const { data: t } = await _.post(l.GET_HOTEL_DATA, {
|
|
87
87
|
...a,
|
|
88
88
|
use_duffel: !0
|
|
89
89
|
});
|
|
90
90
|
return t != null && t.success ? {
|
|
91
91
|
success: !0,
|
|
92
|
-
data:
|
|
92
|
+
data: m(
|
|
93
93
|
(s = t.data) == null ? void 0 : s.hotels
|
|
94
94
|
)
|
|
95
95
|
} : {
|
|
@@ -103,9 +103,9 @@ class S {
|
|
|
103
103
|
};
|
|
104
104
|
}
|
|
105
105
|
});
|
|
106
|
-
|
|
106
|
+
n(this, "getTransferPartners", async (a) => {
|
|
107
107
|
try {
|
|
108
|
-
const { data: s } = await
|
|
108
|
+
const { data: s } = await _.get(
|
|
109
109
|
l.GET_TRANSFER_PARTNERS,
|
|
110
110
|
{
|
|
111
111
|
params: {
|
|
@@ -113,38 +113,39 @@ class S {
|
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
);
|
|
116
|
-
return
|
|
116
|
+
return m(s.data);
|
|
117
117
|
} catch {
|
|
118
118
|
return [];
|
|
119
119
|
}
|
|
120
120
|
});
|
|
121
|
-
|
|
122
|
-
var
|
|
123
|
-
const
|
|
121
|
+
n(this, "hotelPointsCheck", async (a, s) => {
|
|
122
|
+
var t;
|
|
123
|
+
const o = {
|
|
124
124
|
hotel_group: a.hotelGroup,
|
|
125
125
|
hotel_id: a.hotelId,
|
|
126
126
|
check_in_date: a.checkinDate.format(h.ServerDate),
|
|
127
127
|
check_out_date: a.checkoutDate.format(h.ServerDate)
|
|
128
128
|
};
|
|
129
129
|
try {
|
|
130
|
-
const { data:
|
|
130
|
+
const { data: e } = await C.post(
|
|
131
131
|
l.HOTEL_POINTS_CHECK,
|
|
132
|
-
|
|
133
|
-
|
|
132
|
+
o,
|
|
133
|
+
{ signal: s }
|
|
134
|
+
), c = ((t = e.data) == null ? void 0 : t.length) > 0 ? e.data[0] : null;
|
|
134
135
|
return {
|
|
135
|
-
success:
|
|
136
|
-
data:
|
|
136
|
+
success: e.success,
|
|
137
|
+
data: c == null ? null : m(c)
|
|
137
138
|
};
|
|
138
|
-
} catch (
|
|
139
|
-
const
|
|
139
|
+
} catch (e) {
|
|
140
|
+
const c = e;
|
|
140
141
|
return {
|
|
141
142
|
success: !1,
|
|
142
143
|
data: null,
|
|
143
|
-
message: (
|
|
144
|
+
message: (c == null ? void 0 : c.message) ?? "Error fetching hotel data"
|
|
144
145
|
};
|
|
145
146
|
}
|
|
146
147
|
});
|
|
147
|
-
|
|
148
|
+
n(this, "getRecommendations", async ({
|
|
148
149
|
hotel: a,
|
|
149
150
|
days: s
|
|
150
151
|
}) => {
|
|
@@ -161,7 +162,7 @@ class S {
|
|
|
161
162
|
],
|
|
162
163
|
days: s,
|
|
163
164
|
cash_or_points: ["cash", "points"]
|
|
164
|
-
}, { data: t } = await
|
|
165
|
+
}, { data: t } = await _.post(
|
|
165
166
|
l.GET_BEST_CHECKOUT,
|
|
166
167
|
o
|
|
167
168
|
), e = t.data[0];
|
|
@@ -177,7 +178,7 @@ class S {
|
|
|
177
178
|
awardPoints: e.award_points,
|
|
178
179
|
rewardsProgram: e.hotel_rewards_program,
|
|
179
180
|
valueCents: e.value_cents,
|
|
180
|
-
bestCheckoutMethod: e.best_user_checkout_method ===
|
|
181
|
+
bestCheckoutMethod: e.best_user_checkout_method === P.CASH ? p.CASH : p.POINTS,
|
|
181
182
|
optimalProgram: {
|
|
182
183
|
totalProgramPointsValuation: e.optimal_user_program_checkout.total_program_points_valuation,
|
|
183
184
|
remainingPointsBalance: e.optimal_user_program_checkout.primary_offer_remaining_points_balance,
|
|
@@ -206,7 +207,7 @@ class S {
|
|
|
206
207
|
});
|
|
207
208
|
}
|
|
208
209
|
}
|
|
209
|
-
const
|
|
210
|
+
const b = new v();
|
|
210
211
|
export {
|
|
211
|
-
|
|
212
|
+
b as HotelService
|
|
212
213
|
};
|