@odynn/awayz-hotels 0.6.15 → 0.6.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.
- package/dist/enums-D9aZqf8G.js +4 -0
- package/dist/hooks/useAvailabilityAlertNotifications/useAvailabilityAlertNotifications.js +1 -1
- package/dist/hooks/useAvailabilityAlerts/useAvailabilityAlerts.js +1 -1
- package/dist/hooks/useHotelDetails/useHotelDetails.api.js +73 -69
- package/dist/hooks/useHotelDetails/useHotelDetails.js +102 -100
- package/dist/hooks/useHotelSearch/useHotelSearch.js +70 -67
- package/dist/hooks/useLocationSearch/useLocationSearch.js +1 -1
- package/dist/index-yqIid8Pw.js +5 -0
- package/dist/lib/hooks/useHotelSearch/useHotelSearch.types.d.ts +12 -0
- package/dist/lib/services/hotel/HotelService.types.d.ts +2 -0
- package/dist/services/hotel/HotelService.js +2 -4
- package/package.json +1 -1
- package/dist/enums-DxmoBOKL.js +0 -4
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var R = /* @__PURE__ */ ((S) => (S.LOCATIONS = "LOCATIONS", S.CHECK_USER = "CHECK_USER", S.USER_REGIONS = "USER_REGIONS", S.CONVERT_CURRENCY = "CONVERT_CURRENCY", S.CLIENT_COMPONENT_KEY = "CLIENT_COMPONENT_KEY", S.SEARCH_LIMIT = "SEARCH_LIMIT", S.PROGRAMS = "PROGRAMS", S.USER_PROGRAMS = "USER_PROGRAMS", S.LINKED_USER_PROGRAMS = "LINKED_USER_PROGRAMS", S.BANKS = "BANKS", S.CARDS = "CARDS", S.USER_CARDS = "USER_CARDS", S.TRIPS = "TRIPS", S.UNCATEGORISED_BOOKINGS = "UNCATEGORISED_BOOKINGS", S.BOOKING = "BOOKING", S.VALUE_CENTS = "VALUE_CENTS", S.AVAILABILITY_ALERTS = "AVAILABILITY_ALERTS", S.ALERT_NOTIFICATIONS = "ALERT_NOTIFICATIONS", S.POINTS_AS_CASH = "POINTS_AS_CASH", S))(R || {});
|
|
2
|
+
export {
|
|
3
|
+
R as E
|
|
4
|
+
};
|
|
@@ -2,7 +2,7 @@ import { awayzClient as i } from "@odynn/awayz-core";
|
|
|
2
2
|
import { useQuery as m, useMutation as y } from "@tanstack/react-query";
|
|
3
3
|
import "../../moment-BGjjqtLQ.js";
|
|
4
4
|
import "../../arrayExtensions-CFEBYUok.js";
|
|
5
|
-
import { E as e } from "../../enums-
|
|
5
|
+
import { E as e } from "../../enums-D9aZqf8G.js";
|
|
6
6
|
import "react";
|
|
7
7
|
import { AvailabilityAlertsService as r } from "../../services/availabilityAlerts/AvailabilityAlertsService.js";
|
|
8
8
|
const E = () => {
|
|
@@ -3,7 +3,7 @@ import { useQuery as f, useMutation as p } from "@tanstack/react-query";
|
|
|
3
3
|
import "../../moment-BGjjqtLQ.js";
|
|
4
4
|
import "../../arrayExtensions-CFEBYUok.js";
|
|
5
5
|
import { c as b } from "../../objectUtils-DOsrxUF7.js";
|
|
6
|
-
import { E as u } from "../../enums-
|
|
6
|
+
import { E as u } from "../../enums-D9aZqf8G.js";
|
|
7
7
|
import "react";
|
|
8
8
|
import { AvailabilityAlertsService as w } from "../../services/availabilityAlerts/AvailabilityAlertsService.js";
|
|
9
9
|
const h = ({
|
|
@@ -1,31 +1,35 @@
|
|
|
1
|
+
import "../../moment-BGjjqtLQ.js";
|
|
2
|
+
import "../../arrayExtensions-CFEBYUok.js";
|
|
3
|
+
import { a as C } from "../../index-yqIid8Pw.js";
|
|
4
|
+
import "react";
|
|
1
5
|
import { HotelChains as p } from "../../definitions/HotelChains.js";
|
|
2
|
-
import { EBestCheckoutType as
|
|
6
|
+
import { EBestCheckoutType as f } from "../../enums/EBestCheckoutType.js";
|
|
3
7
|
import { BookingService as y } from "../../services/booking/BookingService.js";
|
|
4
|
-
import { EGuestType as
|
|
5
|
-
import { HotelService as
|
|
6
|
-
const
|
|
7
|
-
p.toProgram(
|
|
8
|
-
),
|
|
9
|
-
hotel:
|
|
10
|
-
checkinDate:
|
|
11
|
-
checkoutDate:
|
|
8
|
+
import { EGuestType as d } from "../../services/booking/BookingService.enums.js";
|
|
9
|
+
import { HotelService as h } from "../../services/hotel/HotelService.js";
|
|
10
|
+
const G = async (t) => await h.getTransferPartners(
|
|
11
|
+
p.toProgram(t)
|
|
12
|
+
), I = (t) => !!t.hotelGroup && !!t.hotelId && !!t.checkinDate && !!t.checkoutDate && !!t.rooms && !!t.guests, v = async ({
|
|
13
|
+
hotel: t,
|
|
14
|
+
checkinDate: o,
|
|
15
|
+
checkoutDate: s,
|
|
12
16
|
updateHotel: a,
|
|
13
17
|
signal: e
|
|
14
18
|
}) => {
|
|
15
|
-
let r =
|
|
16
|
-
if (!
|
|
19
|
+
let r = t, c = t.rooms ?? [];
|
|
20
|
+
if (!t.liveScrapingCheckNeeded || t.hotelGroup === p.Marriott)
|
|
17
21
|
return {
|
|
18
|
-
pointsHotelDetails:
|
|
22
|
+
pointsHotelDetails: t,
|
|
19
23
|
pointsRooms: c
|
|
20
24
|
};
|
|
21
25
|
let u = !1, i = null;
|
|
22
26
|
try {
|
|
23
|
-
const n = await
|
|
27
|
+
const n = await h.hotelPointsCheck(
|
|
24
28
|
{
|
|
25
|
-
hotelGroup:
|
|
26
|
-
hotelId:
|
|
27
|
-
checkinDate:
|
|
28
|
-
checkoutDate:
|
|
29
|
+
hotelGroup: t.hotelGroup,
|
|
30
|
+
hotelId: t.hotelId,
|
|
31
|
+
checkinDate: o,
|
|
32
|
+
checkoutDate: s
|
|
29
33
|
},
|
|
30
34
|
e
|
|
31
35
|
);
|
|
@@ -34,106 +38,106 @@ const w = async (s) => await f.getTransferPartners(
|
|
|
34
38
|
u = !1, i = null;
|
|
35
39
|
}
|
|
36
40
|
if (u) {
|
|
37
|
-
const n = i, m = !(n.points.pointsValue > 0) &&
|
|
41
|
+
const n = i, m = !(n.points.pointsValue > 0) && t.bestValue === f.POINTS;
|
|
38
42
|
r = {
|
|
39
|
-
...
|
|
43
|
+
...t,
|
|
40
44
|
awardPoints: n.points.awardPointsValue ?? n.points.pointsValue,
|
|
41
45
|
points: n.points.pointsValue,
|
|
42
46
|
pointsType: n.points.pointsType,
|
|
43
|
-
bestValue: m ?
|
|
44
|
-
}, c = n.rooms ??
|
|
47
|
+
bestValue: m ? f.NONE : t.bestValue
|
|
48
|
+
}, c = n.rooms ?? t.rooms ?? [], a(t.hotelId, t.hotelGroup, r);
|
|
45
49
|
}
|
|
46
50
|
return {
|
|
47
51
|
pointsHotelDetails: r,
|
|
48
52
|
pointsRooms: c
|
|
49
53
|
};
|
|
50
|
-
},
|
|
51
|
-
hotel:
|
|
52
|
-
checkinDate:
|
|
53
|
-
checkoutDate:
|
|
54
|
+
}, E = async ({
|
|
55
|
+
hotel: t,
|
|
56
|
+
checkinDate: o,
|
|
57
|
+
checkoutDate: s,
|
|
54
58
|
guests: a,
|
|
55
59
|
rooms: e,
|
|
56
60
|
updateHotel: r,
|
|
57
61
|
numberOfNights: c
|
|
58
62
|
}) => {
|
|
59
63
|
var l;
|
|
60
|
-
if (!((l =
|
|
64
|
+
if (!((l = t == null ? void 0 : t.cashBookingOffers) != null && l.accommodationId))
|
|
61
65
|
return {
|
|
62
|
-
cashHotelDetails:
|
|
66
|
+
cashHotelDetails: t,
|
|
63
67
|
cashRooms: []
|
|
64
68
|
};
|
|
65
|
-
const u = (m) => Array.from({ length: m }, () => ({ type:
|
|
66
|
-
checkinDate:
|
|
67
|
-
checkoutDate:
|
|
68
|
-
accommodationId:
|
|
69
|
+
const u = (m) => Array.from({ length: m }, () => ({ type: d.ADULT })), i = await y.getAvailableRooms({
|
|
70
|
+
checkinDate: o,
|
|
71
|
+
checkoutDate: s,
|
|
72
|
+
accommodationId: t.cashBookingOffers.accommodationId,
|
|
69
73
|
guests: u(a),
|
|
70
74
|
rooms: e
|
|
71
75
|
}), n = {
|
|
72
|
-
...
|
|
76
|
+
...t,
|
|
73
77
|
cashValue: {
|
|
74
|
-
...
|
|
75
|
-
amount: i.cheapestRate / c ||
|
|
76
|
-
currency: i.currency ??
|
|
78
|
+
...t.cashValue,
|
|
79
|
+
amount: i.cheapestRate / c || t.cashValue.amount || 0,
|
|
80
|
+
currency: i.currency ?? t.cashValue.currency
|
|
77
81
|
}
|
|
78
82
|
};
|
|
79
|
-
return r(
|
|
83
|
+
return r(t.hotelId, t.hotelGroup, n), {
|
|
80
84
|
cashHotelDetails: n,
|
|
81
85
|
cashRooms: i.availableRooms
|
|
82
86
|
};
|
|
83
|
-
},
|
|
84
|
-
const { success: a, data: e } = await
|
|
85
|
-
days:
|
|
86
|
-
hotel:
|
|
87
|
+
}, U = async (t, o, s) => {
|
|
88
|
+
const { success: a, data: e } = await h.getRecommendations({
|
|
89
|
+
days: o,
|
|
90
|
+
hotel: t
|
|
87
91
|
});
|
|
88
92
|
return a && e ? {
|
|
89
93
|
bestCheckout: {
|
|
90
94
|
...e,
|
|
91
|
-
nightlyPointsCost:
|
|
95
|
+
nightlyPointsCost: s ? e.awardPoints : e.nightlyPointsCost
|
|
92
96
|
},
|
|
93
97
|
isAvailable: e.nightlyPointsCost > 0 || e.nightlyCashCost > 0
|
|
94
98
|
} : {
|
|
95
|
-
bestCheckout:
|
|
99
|
+
bestCheckout: P(t, o),
|
|
96
100
|
isAvailable: !1
|
|
97
101
|
};
|
|
98
|
-
},
|
|
102
|
+
}, P = (t, o) => {
|
|
99
103
|
var r, c, u, i;
|
|
100
|
-
const
|
|
104
|
+
const s = ((r = t.cashBookingOffers) == null ? void 0 : r.cheapestRateTotalAmount) ?? ((c = t.cashValue) == null ? void 0 : c.amount) ?? 0, a = ((u = t.cashBookingOffers) == null ? void 0 : u.cheapestRateCurrency) ?? ((i = t.cashValue) == null ? void 0 : i.currency) ?? C;
|
|
101
105
|
return {
|
|
102
|
-
bestCheckoutMethod: p.isHotelChain(
|
|
103
|
-
nightlyCashCost:
|
|
104
|
-
nightlyPointsCost:
|
|
105
|
-
awardPoints:
|
|
106
|
-
totalCashCost:
|
|
107
|
-
totalPointsCost: (
|
|
106
|
+
bestCheckoutMethod: p.isHotelChain(t.hotelGroup) ? t.bestValue : f.CASH,
|
|
107
|
+
nightlyCashCost: s,
|
|
108
|
+
nightlyPointsCost: t.points || 0,
|
|
109
|
+
awardPoints: t.points || 0,
|
|
110
|
+
totalCashCost: s * o,
|
|
111
|
+
totalPointsCost: (t.points || 0) * o,
|
|
108
112
|
currency: a,
|
|
109
113
|
sufficientPoints: !0,
|
|
110
|
-
rewardsProgram: p.toProgram(
|
|
114
|
+
rewardsProgram: p.toProgram(t.hotelGroup),
|
|
111
115
|
optimalProgram: {
|
|
112
116
|
programs: [],
|
|
113
117
|
remainingPointsBalance: 0,
|
|
114
118
|
totalProgramPointsValuation: 0
|
|
115
119
|
}
|
|
116
120
|
};
|
|
117
|
-
},
|
|
118
|
-
let a =
|
|
119
|
-
return
|
|
120
|
-
...
|
|
121
|
-
points:
|
|
122
|
-
awardPoints:
|
|
123
|
-
pointsType:
|
|
124
|
-
bestValue:
|
|
125
|
-
}),
|
|
121
|
+
}, O = (t, o, s) => {
|
|
122
|
+
let a = t;
|
|
123
|
+
return o && (a = {
|
|
124
|
+
...t,
|
|
125
|
+
points: o.points,
|
|
126
|
+
awardPoints: o.awardPoints,
|
|
127
|
+
pointsType: o.pointsType,
|
|
128
|
+
bestValue: o.bestValue
|
|
129
|
+
}), s && (a = {
|
|
126
130
|
...a,
|
|
127
|
-
cashValue:
|
|
128
|
-
rooms:
|
|
131
|
+
cashValue: s.cashValue,
|
|
132
|
+
rooms: s.rooms
|
|
129
133
|
}), a;
|
|
130
134
|
};
|
|
131
135
|
export {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
136
|
+
O as combineUpdatedHotelData,
|
|
137
|
+
P as fallbackBestCheckout,
|
|
138
|
+
E as fetchAvailableRooms,
|
|
139
|
+
U as fetchBestCheckout,
|
|
140
|
+
v as fetchPointsCheck,
|
|
141
|
+
G as fetchTransferPartners,
|
|
142
|
+
I as isPartialHotelDetails
|
|
139
143
|
};
|
|
@@ -1,95 +1,97 @@
|
|
|
1
|
-
import { g as
|
|
2
|
-
import {
|
|
1
|
+
import { g as ae } from "../../dateUtils-C1hKW8MF.js";
|
|
2
|
+
import { a as ce } from "../../index-yqIid8Pw.js";
|
|
3
|
+
import { E as T } from "../../DateFormats-DZD30Nea.js";
|
|
3
4
|
import "../../arrayExtensions-CFEBYUok.js";
|
|
4
|
-
import { useState as
|
|
5
|
-
import
|
|
6
|
-
import { isPartialHotelDetails as
|
|
7
|
-
import { useAwayzContext as
|
|
5
|
+
import { useState as se, useMemo as D } from "react";
|
|
6
|
+
import ie from "../../stores/useHotelsStore.js";
|
|
7
|
+
import { isPartialHotelDetails as re, fetchTransferPartners as ne, fetchPointsCheck as le, fetchAvailableRooms as he, combineUpdatedHotelData as U, fallbackBestCheckout as ue, fetchBestCheckout as De } from "./useHotelDetails.api.js";
|
|
8
|
+
import { useAwayzContext as fe, useWallet as me } from "@odynn/awayz-core";
|
|
8
9
|
import { useQuery as r } from "@tanstack/react-query";
|
|
9
10
|
import { h as n } from "../../moment-BGjjqtLQ.js";
|
|
10
|
-
import { livePointsCheckTimeout as
|
|
11
|
-
import { HotelChains as
|
|
12
|
-
import { IhgFreeNightCards as
|
|
13
|
-
import { HotelService as
|
|
14
|
-
import { calculatePointsAsCash as
|
|
15
|
-
const
|
|
16
|
-
var
|
|
17
|
-
if (!
|
|
11
|
+
import { livePointsCheckTimeout as ke } from "../../configs/defaults.js";
|
|
12
|
+
import { HotelChains as de } from "../../definitions/HotelChains.js";
|
|
13
|
+
import { IhgFreeNightCards as pe } from "../../definitions/IhgFreeNightCards.js";
|
|
14
|
+
import { HotelService as ge } from "../../services/hotel/HotelService.js";
|
|
15
|
+
import { calculatePointsAsCash as ye } from "../../utilities/pointsAsCashUtils.js";
|
|
16
|
+
const Pe = (a) => {
|
|
17
|
+
var H, R, O, q, A, S, _, G, B, w, K, P, E, N;
|
|
18
|
+
if (!a)
|
|
18
19
|
throw new Error(
|
|
19
20
|
"Hotel is required in order to initiate the hotel details flow"
|
|
20
21
|
);
|
|
21
|
-
const { user: f } =
|
|
22
|
-
checkinDate: s ? n(
|
|
23
|
-
checkoutDate: s ? n(
|
|
22
|
+
const { user: f, config: m } = fe(), { updateHotel: g, searchParams: o } = ie(), s = re(a), [e, W] = se({
|
|
23
|
+
checkinDate: s ? n(a.checkinDate) : o == null ? void 0 : o.checkinDate,
|
|
24
|
+
checkoutDate: s ? n(a.checkoutDate) : o == null ? void 0 : o.checkoutDate
|
|
24
25
|
}), {
|
|
25
26
|
data: i,
|
|
26
|
-
isFetching:
|
|
27
|
-
isFetched:
|
|
27
|
+
isFetching: x,
|
|
28
|
+
isFetched: k
|
|
28
29
|
} = r({
|
|
29
30
|
queryKey: [
|
|
30
31
|
"hotelDetails",
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
(
|
|
34
|
-
(
|
|
32
|
+
a.hotelId,
|
|
33
|
+
a.hotelGroup,
|
|
34
|
+
(H = e == null ? void 0 : e.checkinDate) == null ? void 0 : H.valueOf(),
|
|
35
|
+
(R = e == null ? void 0 : e.checkoutDate) == null ? void 0 : R.valueOf()
|
|
35
36
|
],
|
|
36
37
|
queryFn: () => {
|
|
37
|
-
var
|
|
38
|
-
return
|
|
39
|
-
hotel_group:
|
|
40
|
-
hotel_id:
|
|
38
|
+
var c;
|
|
39
|
+
return ge.searchByHotelId({
|
|
40
|
+
hotel_group: a.hotelGroup,
|
|
41
|
+
hotel_id: a.hotelId,
|
|
41
42
|
check_in_date: n(e.checkinDate).format(
|
|
42
|
-
|
|
43
|
+
T.ServerDate
|
|
43
44
|
),
|
|
44
45
|
check_out_date: n(e.checkoutDate).format(
|
|
45
|
-
|
|
46
|
+
T.ServerDate
|
|
46
47
|
),
|
|
47
|
-
guests:
|
|
48
|
-
rooms:
|
|
49
|
-
currency: ((
|
|
50
|
-
cash_or_points: ["cash", "points"]
|
|
48
|
+
guests: a.guests,
|
|
49
|
+
rooms: a.rooms,
|
|
50
|
+
currency: ((c = f == null ? void 0 : f.userRegion) == null ? void 0 : c.currency) || ce,
|
|
51
|
+
cash_or_points: ["cash", "points"],
|
|
52
|
+
use_duffel: m == null ? void 0 : m.useDuffel
|
|
51
53
|
});
|
|
52
54
|
},
|
|
53
55
|
enabled: s && !!e.checkinDate && !!e.checkoutDate,
|
|
54
56
|
retry: !1
|
|
55
57
|
}), t = D(() => {
|
|
56
|
-
var
|
|
57
|
-
return s ? i != null && i.success && ((
|
|
58
|
-
}, [s, i,
|
|
59
|
-
|
|
60
|
-
checkinDate: n(
|
|
58
|
+
var c;
|
|
59
|
+
return s ? i != null && i.success && ((c = i.data) != null && c[0]) ? i.data[0] : {} : a;
|
|
60
|
+
}, [s, i, a]), h = D(() => ae(e.checkinDate, e.checkoutDate), [e]), L = (c, l) => {
|
|
61
|
+
W({
|
|
62
|
+
checkinDate: n(c),
|
|
61
63
|
checkoutDate: n(l)
|
|
62
64
|
});
|
|
63
|
-
}, { userCards: u } =
|
|
64
|
-
(
|
|
65
|
-
) : !0, [u]), { data:
|
|
65
|
+
}, { userCards: u } = me(), y = D(() => (t == null ? void 0 : t.hotelGroup) === de.IHG ? pe.some(
|
|
66
|
+
(c) => u == null ? void 0 : u.some((l) => l.name === c)
|
|
67
|
+
) : !0, [u]), { data: z, isFetching: I } = r({
|
|
66
68
|
queryKey: ["transferPartners", t.hotelGroup],
|
|
67
|
-
queryFn: () =>
|
|
69
|
+
queryFn: () => ne(t.hotelGroup),
|
|
68
70
|
enabled: !!t.hotelGroup,
|
|
69
71
|
placeholderData: []
|
|
70
72
|
}), {
|
|
71
|
-
data:
|
|
72
|
-
isFetching:
|
|
73
|
-
isFetched:
|
|
73
|
+
data: M,
|
|
74
|
+
isFetching: v,
|
|
75
|
+
isFetched: Q
|
|
74
76
|
} = r({
|
|
75
77
|
queryKey: [
|
|
76
78
|
"hotelPointsCheck",
|
|
77
79
|
t.hotelId,
|
|
78
80
|
t.hotelGroup,
|
|
79
|
-
(
|
|
80
|
-
(
|
|
81
|
+
(O = e == null ? void 0 : e.checkinDate) == null ? void 0 : O.valueOf(),
|
|
82
|
+
(q = e == null ? void 0 : e.checkoutDate) == null ? void 0 : q.valueOf()
|
|
81
83
|
],
|
|
82
|
-
queryFn: ({ signal:
|
|
83
|
-
const l = AbortSignal.timeout(
|
|
84
|
-
return
|
|
84
|
+
queryFn: ({ signal: c }) => {
|
|
85
|
+
const l = AbortSignal.timeout(ke), oe = AbortSignal.any([c, l]);
|
|
86
|
+
return le({
|
|
85
87
|
hotel: t,
|
|
86
88
|
checkinDate: e.checkinDate,
|
|
87
89
|
checkoutDate: e.checkoutDate,
|
|
88
|
-
updateHotel:
|
|
89
|
-
signal:
|
|
90
|
+
updateHotel: g,
|
|
91
|
+
signal: oe
|
|
90
92
|
});
|
|
91
93
|
},
|
|
92
|
-
enabled: !!e.checkinDate && !!e.checkoutDate && !!t.liveScrapingCheckNeeded && (!s ||
|
|
94
|
+
enabled: !!e.checkinDate && !!e.checkoutDate && !!t.liveScrapingCheckNeeded && (!s || k),
|
|
93
95
|
// We don't throw an error on fail so we can gracefully handle fallback
|
|
94
96
|
retry: !1,
|
|
95
97
|
refetchOnWindowFocus: !1,
|
|
@@ -98,107 +100,107 @@ const ge = "USD", we = (c) => {
|
|
|
98
100
|
pointsHotelDetails: t,
|
|
99
101
|
pointsRooms: t.rooms ?? []
|
|
100
102
|
}
|
|
101
|
-
}), { pointsRooms:
|
|
103
|
+
}), { pointsRooms: Y, pointsHotelDetails: d } = M || {
|
|
102
104
|
pointsHotelDetails: t,
|
|
103
105
|
pointsRooms: []
|
|
104
106
|
}, {
|
|
105
|
-
data:
|
|
106
|
-
isFetching:
|
|
107
|
-
isFetched:
|
|
107
|
+
data: j,
|
|
108
|
+
isFetching: C,
|
|
109
|
+
isFetched: J
|
|
108
110
|
} = r({
|
|
109
111
|
queryKey: [
|
|
110
112
|
"fetchAvailableRooms",
|
|
111
|
-
(
|
|
112
|
-
(
|
|
113
|
-
(
|
|
113
|
+
(A = t.cashBookingOffers) == null ? void 0 : A.accommodationId,
|
|
114
|
+
(S = e == null ? void 0 : e.checkinDate) == null ? void 0 : S.valueOf(),
|
|
115
|
+
(_ = e == null ? void 0 : e.checkoutDate) == null ? void 0 : _.valueOf(),
|
|
114
116
|
o == null ? void 0 : o.guests,
|
|
115
117
|
o == null ? void 0 : o.rooms
|
|
116
118
|
],
|
|
117
|
-
queryFn: () =>
|
|
119
|
+
queryFn: () => he({
|
|
118
120
|
hotel: t,
|
|
119
121
|
checkinDate: e.checkinDate,
|
|
120
122
|
checkoutDate: e.checkoutDate,
|
|
121
123
|
guests: o.guests,
|
|
122
124
|
rooms: o.rooms,
|
|
123
|
-
updateHotel:
|
|
125
|
+
updateHotel: g,
|
|
124
126
|
numberOfNights: h
|
|
125
127
|
}),
|
|
126
|
-
enabled: !!e.checkinDate && !!e.checkoutDate && !!((G = t.cashBookingOffers) != null && G.accommodationId) && (!s ||
|
|
128
|
+
enabled: !!e.checkinDate && !!e.checkoutDate && !!((G = t.cashBookingOffers) != null && G.accommodationId) && (!s || k),
|
|
127
129
|
retry: !1,
|
|
128
130
|
placeholderData: {
|
|
129
131
|
cashHotelDetails: t,
|
|
130
132
|
cashRooms: []
|
|
131
133
|
}
|
|
132
|
-
}), { cashRooms:
|
|
134
|
+
}), { cashRooms: V, cashHotelDetails: p } = j || {
|
|
133
135
|
cashHotelDetails: t,
|
|
134
136
|
cashRooms: []
|
|
135
|
-
},
|
|
136
|
-
() =>
|
|
137
|
-
[t,
|
|
137
|
+
}, X = D(
|
|
138
|
+
() => U(t, d, p),
|
|
139
|
+
[t, d, p]
|
|
138
140
|
), {
|
|
139
|
-
data:
|
|
140
|
-
isFetching:
|
|
141
|
-
isFetched:
|
|
141
|
+
data: Z,
|
|
142
|
+
isFetching: $,
|
|
143
|
+
isFetched: ee
|
|
142
144
|
} = r({
|
|
143
145
|
queryKey: [
|
|
144
146
|
"bestCheckout",
|
|
145
147
|
t.hotelId,
|
|
146
148
|
t.hotelGroup,
|
|
147
|
-
(
|
|
148
|
-
(
|
|
149
|
-
|
|
149
|
+
(B = e == null ? void 0 : e.checkinDate) == null ? void 0 : B.valueOf(),
|
|
150
|
+
(w = e == null ? void 0 : e.checkoutDate) == null ? void 0 : w.valueOf(),
|
|
151
|
+
y
|
|
150
152
|
],
|
|
151
|
-
queryFn: () =>
|
|
152
|
-
|
|
153
|
+
queryFn: () => De(
|
|
154
|
+
X,
|
|
153
155
|
h,
|
|
154
|
-
|
|
156
|
+
y
|
|
155
157
|
),
|
|
156
|
-
enabled: !((
|
|
158
|
+
enabled: !((K = t.hotelId) != null && K.startsWith("duff_")) && !v && (t.liveScrapingCheckNeeded ? Q : !0) && !C && ((P = t.cashBookingOffers) != null && P.accommodationId ? J : !0) && h > 0 && t.points >= 0 && (!s || k),
|
|
157
159
|
retry: !1,
|
|
158
160
|
placeholderData: {
|
|
159
|
-
bestCheckout:
|
|
161
|
+
bestCheckout: ue(t, h),
|
|
160
162
|
isAvailable: !1
|
|
161
163
|
}
|
|
162
|
-
}), { bestCheckout:
|
|
164
|
+
}), { bestCheckout: F, isAvailable: b } = Z || {
|
|
163
165
|
isAvailable: !1
|
|
164
|
-
}, { data:
|
|
166
|
+
}, { data: te } = r({
|
|
165
167
|
queryKey: [
|
|
166
168
|
"pointsAsCash",
|
|
167
169
|
t.hotelId,
|
|
168
170
|
t.hotelGroup,
|
|
169
|
-
(
|
|
170
|
-
(
|
|
171
|
+
(E = e == null ? void 0 : e.checkinDate) == null ? void 0 : E.valueOf(),
|
|
172
|
+
(N = e == null ? void 0 : e.checkoutDate) == null ? void 0 : N.valueOf()
|
|
171
173
|
],
|
|
172
|
-
queryFn: () =>
|
|
173
|
-
enabled:
|
|
174
|
+
queryFn: () => ye(F.totalCashCost),
|
|
175
|
+
enabled: ee && b,
|
|
174
176
|
retry: !1
|
|
175
177
|
});
|
|
176
178
|
return {
|
|
177
|
-
transferPartners:
|
|
178
|
-
loadingTransferPartners:
|
|
179
|
+
transferPartners: z || [],
|
|
180
|
+
loadingTransferPartners: I,
|
|
179
181
|
// Hotel Details
|
|
180
|
-
loadingHotelDetails:
|
|
182
|
+
loadingHotelDetails: x,
|
|
181
183
|
// Points Check
|
|
182
|
-
pointsRooms:
|
|
183
|
-
loadingLivePointsCheck:
|
|
184
|
+
pointsRooms: Y || [],
|
|
185
|
+
loadingLivePointsCheck: v,
|
|
184
186
|
// Cash Rooms
|
|
185
|
-
cashRooms:
|
|
186
|
-
loadingCashRooms:
|
|
187
|
+
cashRooms: V || [],
|
|
188
|
+
loadingCashRooms: C,
|
|
187
189
|
// Best Checkout
|
|
188
|
-
bestCheckout:
|
|
189
|
-
loadingBestCheckout:
|
|
190
|
+
bestCheckout: F,
|
|
191
|
+
loadingBestCheckout: $,
|
|
190
192
|
// Combined availability
|
|
191
|
-
isAvailable:
|
|
193
|
+
isAvailable: b,
|
|
192
194
|
// Points as Cash
|
|
193
|
-
pointsAsCash:
|
|
194
|
-
hotelDetails:
|
|
195
|
+
pointsAsCash: te,
|
|
196
|
+
hotelDetails: U(
|
|
195
197
|
t,
|
|
196
|
-
|
|
197
|
-
|
|
198
|
+
d,
|
|
199
|
+
p
|
|
198
200
|
),
|
|
199
|
-
updateDates:
|
|
201
|
+
updateDates: L
|
|
200
202
|
};
|
|
201
203
|
};
|
|
202
204
|
export {
|
|
203
|
-
|
|
205
|
+
Pe as useHotelDetails
|
|
204
206
|
};
|
|
@@ -1,51 +1,52 @@
|
|
|
1
|
-
import { useAwayzContext as P, useWallet as
|
|
1
|
+
import { useAwayzContext as P, useWallet as A, awayzClient as d } from "@odynn/awayz-core";
|
|
2
2
|
import { useMutation as m } from "@tanstack/react-query";
|
|
3
|
-
import { g as
|
|
4
|
-
import {
|
|
3
|
+
import { g as N } from "../../dateUtils-C1hKW8MF.js";
|
|
4
|
+
import { D as B, a as p } from "../../index-yqIid8Pw.js";
|
|
5
|
+
import { E as f } from "../../enums-D9aZqf8G.js";
|
|
5
6
|
import "../../arrayExtensions-CFEBYUok.js";
|
|
6
7
|
import "react";
|
|
7
|
-
import { h as
|
|
8
|
-
import { HotelChains as
|
|
9
|
-
import { HotelService as
|
|
10
|
-
import { ESearchType as
|
|
8
|
+
import { h as u } from "../../moment-BGjjqtLQ.js";
|
|
9
|
+
import { HotelChains as i } from "../../definitions/HotelChains.js";
|
|
10
|
+
import { HotelService as k } from "../../services/hotel/HotelService.js";
|
|
11
|
+
import { ESearchType as y } from "../../services/hotel/HotelService.types.js";
|
|
11
12
|
import G from "../../stores/useHotelsStore.js";
|
|
12
|
-
import { checkNthNightFree as
|
|
13
|
-
const
|
|
13
|
+
import { checkNthNightFree as F } from "../../utilities/hotelUtils/freeNightUtils.js";
|
|
14
|
+
const x = (t) => {
|
|
14
15
|
if (!t.checkinDate || !t.checkoutDate)
|
|
15
16
|
throw new Error("Check-in and checkout dates are required.");
|
|
16
17
|
if (!t.coordinates)
|
|
17
18
|
throw new Error("Coordinates are required.");
|
|
18
|
-
t.hotelGroups && t.hotelGroups.forEach((
|
|
19
|
-
if (!
|
|
19
|
+
t.hotelGroups && t.hotelGroups.forEach((h) => {
|
|
20
|
+
if (!i.toList().includes(h))
|
|
20
21
|
throw new Error(
|
|
21
|
-
`Invalid hotel group: ${
|
|
22
|
+
`Invalid hotel group: ${h}. Please use one of the following: ${i.toList().join(
|
|
22
23
|
", "
|
|
23
24
|
)}`
|
|
24
25
|
);
|
|
25
26
|
});
|
|
26
|
-
},
|
|
27
|
+
}, R = (t) => {
|
|
27
28
|
if (!t.checkinDate || !t.checkoutDate)
|
|
28
29
|
throw new Error("Check-in and checkout dates are required.");
|
|
29
30
|
if (!t.hotelName)
|
|
30
31
|
throw new Error("Hotel name is required");
|
|
31
32
|
if (!t.hotelGroup)
|
|
32
33
|
throw new Error("Hotel group is required");
|
|
33
|
-
if (!
|
|
34
|
+
if (!i.toList().includes(t.hotelGroup))
|
|
34
35
|
throw new Error(
|
|
35
|
-
`Invalid hotel group: ${t.hotelGroup}. Please use one of the following: ${
|
|
36
|
+
`Invalid hotel group: ${t.hotelGroup}. Please use one of the following: ${i.toList().join(", ")}`
|
|
36
37
|
);
|
|
37
|
-
},
|
|
38
|
-
const { setHotels: t, hotels:
|
|
39
|
-
mutate:
|
|
38
|
+
}, Z = () => {
|
|
39
|
+
const { setHotels: t, hotels: h, setSearchParams: l } = G(), { config: r } = P(), { userCards: D } = A(), {
|
|
40
|
+
mutate: _,
|
|
40
41
|
isPending: w,
|
|
41
|
-
status:
|
|
42
|
-
isError:
|
|
43
|
-
error:
|
|
42
|
+
status: E,
|
|
43
|
+
isError: S,
|
|
44
|
+
error: C
|
|
44
45
|
} = m({
|
|
45
46
|
mutationFn: async (e) => {
|
|
46
|
-
|
|
47
|
-
checkinDate:
|
|
48
|
-
checkoutDate:
|
|
47
|
+
x(e), t([]), l({
|
|
48
|
+
checkinDate: u(e.checkinDate),
|
|
49
|
+
checkoutDate: u(e.checkoutDate),
|
|
49
50
|
guests: e.guests || 2,
|
|
50
51
|
rooms: e.rooms || 1
|
|
51
52
|
});
|
|
@@ -55,56 +56,57 @@ const A = (t) => {
|
|
|
55
56
|
guests: e.guests || 2,
|
|
56
57
|
rooms: e.rooms || 1,
|
|
57
58
|
cash_or_points: e.cashOrPoints || ["cash", "points"],
|
|
58
|
-
currency: e.currency ||
|
|
59
|
+
currency: e.currency || p,
|
|
59
60
|
lat: e.coordinates.latitude,
|
|
60
61
|
lon: e.coordinates.longitude,
|
|
61
62
|
search_range: e.searchRange || 10,
|
|
62
|
-
range_type: e.rangeType ||
|
|
63
|
-
hotel_groups: e.hotelGroups ||
|
|
64
|
-
type: e.searchType ||
|
|
65
|
-
external_inventory: (
|
|
63
|
+
range_type: e.rangeType || B,
|
|
64
|
+
hotel_groups: e.hotelGroups || i.toList(),
|
|
65
|
+
type: e.searchType || y.CITY,
|
|
66
|
+
external_inventory: (r == null ? void 0 : r.externalInventory) || !1,
|
|
67
|
+
use_duffel: r == null ? void 0 : r.useDuffel
|
|
66
68
|
};
|
|
67
69
|
return {
|
|
68
|
-
...await
|
|
70
|
+
...await k.searchByCoords(o),
|
|
69
71
|
checkinDate: e.checkinDate,
|
|
70
72
|
checkoutDate: e.checkoutDate
|
|
71
73
|
};
|
|
72
74
|
},
|
|
73
75
|
onSuccess: (e) => {
|
|
74
76
|
if (e.success) {
|
|
75
|
-
const { checkinDate: o, checkoutDate:
|
|
76
|
-
...
|
|
77
|
-
nthNightFree:
|
|
78
|
-
hotel:
|
|
79
|
-
cards:
|
|
77
|
+
const { checkinDate: o, checkoutDate: c } = e, n = N(o, c), a = e.data.map((s) => ({
|
|
78
|
+
...s,
|
|
79
|
+
nthNightFree: F({
|
|
80
|
+
hotel: s,
|
|
81
|
+
cards: D ?? [],
|
|
80
82
|
nights: n
|
|
81
83
|
})
|
|
82
84
|
}));
|
|
83
|
-
t(
|
|
85
|
+
t(a);
|
|
84
86
|
}
|
|
85
87
|
},
|
|
86
88
|
onSettled: () => {
|
|
87
|
-
d.invalidateQueries({ queryKey: [
|
|
89
|
+
d.invalidateQueries({ queryKey: [f.SEARCH_LIMIT] });
|
|
88
90
|
}
|
|
89
91
|
});
|
|
90
|
-
function
|
|
91
|
-
let
|
|
92
|
-
const n = e.length < o.length ? e : o,
|
|
93
|
-
for (let
|
|
94
|
-
e[
|
|
95
|
-
return
|
|
92
|
+
function I(e, o) {
|
|
93
|
+
let c = 0;
|
|
94
|
+
const n = e.length < o.length ? e : o, a = e.length >= o.length ? e : o;
|
|
95
|
+
for (let s = 0; s < n.length; s++)
|
|
96
|
+
e[s] === o[s] && c++;
|
|
97
|
+
return c / a.length;
|
|
96
98
|
}
|
|
97
99
|
const {
|
|
98
100
|
mutate: H,
|
|
99
|
-
isPending:
|
|
100
|
-
status:
|
|
101
|
-
isError:
|
|
101
|
+
isPending: L,
|
|
102
|
+
status: T,
|
|
103
|
+
isError: v,
|
|
102
104
|
error: q
|
|
103
105
|
} = m({
|
|
104
106
|
mutationFn: async (e) => {
|
|
105
|
-
|
|
106
|
-
checkinDate:
|
|
107
|
-
checkoutDate:
|
|
107
|
+
R(e), t([]), l({
|
|
108
|
+
checkinDate: u(e.checkinDate),
|
|
109
|
+
checkoutDate: u(e.checkoutDate),
|
|
108
110
|
guests: e.guests || 2,
|
|
109
111
|
rooms: e.rooms || 1
|
|
110
112
|
});
|
|
@@ -114,42 +116,43 @@ const A = (t) => {
|
|
|
114
116
|
guests: e.guests || 2,
|
|
115
117
|
rooms: e.rooms || 1,
|
|
116
118
|
cash_or_points: e.cashOrPoints || ["cash", "points"],
|
|
117
|
-
currency: e.currency ||
|
|
119
|
+
currency: e.currency || p,
|
|
118
120
|
lat: e.coordinates.latitude,
|
|
119
121
|
lon: e.coordinates.longitude,
|
|
120
122
|
search_range: 0.5,
|
|
121
123
|
range_type: "km",
|
|
122
124
|
hotel_groups: [e.hotelGroup],
|
|
123
|
-
type:
|
|
124
|
-
external_inventory: !1
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
125
|
+
type: y.HOTEL,
|
|
126
|
+
external_inventory: !1,
|
|
127
|
+
use_duffel: r == null ? void 0 : r.useDuffel
|
|
128
|
+
}, c = await k.searchByCoords(o);
|
|
129
|
+
if (!c.success)
|
|
130
|
+
throw new Error(c.message || "Hotel search failed");
|
|
128
131
|
const n = 0.8;
|
|
129
|
-
return
|
|
130
|
-
(
|
|
132
|
+
return c.data.filter(
|
|
133
|
+
(s) => I(s.name.toLowerCase(), e.hotelName.toLowerCase()) >= n
|
|
131
134
|
);
|
|
132
135
|
},
|
|
133
136
|
onSuccess: (e) => {
|
|
134
137
|
t(e);
|
|
135
138
|
},
|
|
136
139
|
onSettled: () => {
|
|
137
|
-
d.invalidateQueries({ queryKey: [
|
|
140
|
+
d.invalidateQueries({ queryKey: [f.SEARCH_LIMIT] });
|
|
138
141
|
}
|
|
139
142
|
});
|
|
140
143
|
return {
|
|
141
|
-
results:
|
|
142
|
-
loading:
|
|
143
|
-
isCoordsSearchError:
|
|
144
|
-
coordsSearchError:
|
|
145
|
-
isHotelIdSearchError:
|
|
144
|
+
results: h,
|
|
145
|
+
loading: E === "pending" || T === "pending" || w || L,
|
|
146
|
+
isCoordsSearchError: S,
|
|
147
|
+
coordsSearchError: C,
|
|
148
|
+
isHotelIdSearchError: v,
|
|
146
149
|
hotelIdSearchError: q,
|
|
147
|
-
searchByCoords:
|
|
150
|
+
searchByCoords: _,
|
|
148
151
|
searchByHotelId: H
|
|
149
152
|
};
|
|
150
153
|
};
|
|
151
154
|
export {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
+
Z as useHotelSearch,
|
|
156
|
+
x as validateSearchByCoordsArgs,
|
|
157
|
+
R as validateSearchByHotelIdArgs
|
|
155
158
|
};
|
|
@@ -2,7 +2,7 @@ import { useQuery as u } from "@tanstack/react-query";
|
|
|
2
2
|
import { HotelService as l } from "../../services/hotel/HotelService.js";
|
|
3
3
|
import "../../moment-BGjjqtLQ.js";
|
|
4
4
|
import "../../arrayExtensions-CFEBYUok.js";
|
|
5
|
-
import { E as d } from "../../enums-
|
|
5
|
+
import { E as d } from "../../enums-D9aZqf8G.js";
|
|
6
6
|
import { useState as f, useEffect as L } from "react";
|
|
7
7
|
import { defaultSimilarityThreshold as p, defaultLocationSortOrder as y, duffelTestHotelLocation as T } from "../../configs/defaults.js";
|
|
8
8
|
import { sortLocationResults as E } from "../../utilities/hotelUtils/hotelUtils.js";
|
|
@@ -31,6 +31,12 @@ export interface ISearchByCoordsParams extends ISearchByParams {
|
|
|
31
31
|
* @type ESearchType
|
|
32
32
|
*/
|
|
33
33
|
searchType?: ESearchType;
|
|
34
|
+
/**
|
|
35
|
+
* Optional use duffel
|
|
36
|
+
* @default 'True'
|
|
37
|
+
* @type boolean
|
|
38
|
+
*/
|
|
39
|
+
useDuffel?: boolean;
|
|
34
40
|
}
|
|
35
41
|
export interface ISearchByHotelIdParams extends ISearchByParams {
|
|
36
42
|
/**
|
|
@@ -49,6 +55,12 @@ export interface ISearchByHotelIdParams extends ISearchByParams {
|
|
|
49
55
|
* @type string
|
|
50
56
|
*/
|
|
51
57
|
hotelName: string;
|
|
58
|
+
/**
|
|
59
|
+
* Optional use duffel
|
|
60
|
+
* @default 'True'
|
|
61
|
+
* @type boolean
|
|
62
|
+
*/
|
|
63
|
+
useDuffel?: boolean;
|
|
52
64
|
}
|
|
53
65
|
interface ISearchByParams {
|
|
54
66
|
/**
|
|
@@ -14,6 +14,7 @@ export interface ISearchHotelsParams {
|
|
|
14
14
|
cash_or_points: string[];
|
|
15
15
|
currency: string;
|
|
16
16
|
external_inventory: boolean;
|
|
17
|
+
use_duffel?: boolean;
|
|
17
18
|
}
|
|
18
19
|
export declare enum ESearchType {
|
|
19
20
|
HOTEL = "Hotel Search",
|
|
@@ -157,6 +158,7 @@ export interface ISearchByHotelIdRequest {
|
|
|
157
158
|
rooms: number;
|
|
158
159
|
currency: string;
|
|
159
160
|
cash_or_points: string[];
|
|
161
|
+
use_duffel?: boolean;
|
|
160
162
|
}
|
|
161
163
|
export interface IBestCheckoutResponse {
|
|
162
164
|
award_points: number;
|
|
@@ -61,8 +61,7 @@ class v {
|
|
|
61
61
|
var s, o;
|
|
62
62
|
try {
|
|
63
63
|
const { data: t } = await _.post(l.SEARCH_HOTELS, {
|
|
64
|
-
...a
|
|
65
|
-
use_duffel: !0
|
|
64
|
+
...a
|
|
66
65
|
});
|
|
67
66
|
return t != null && t.success ? {
|
|
68
67
|
success: !0,
|
|
@@ -84,8 +83,7 @@ class v {
|
|
|
84
83
|
var s, o;
|
|
85
84
|
try {
|
|
86
85
|
const { data: t } = await _.post(l.GET_HOTEL_DATA, {
|
|
87
|
-
...a
|
|
88
|
-
use_duffel: !0
|
|
86
|
+
...a
|
|
89
87
|
});
|
|
90
88
|
return t != null && t.success ? {
|
|
91
89
|
success: !0,
|
package/package.json
CHANGED
package/dist/enums-DxmoBOKL.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
var S = /* @__PURE__ */ ((R) => (R.LOCATIONS = "LOCATIONS", R.CHECK_USER = "CHECK_USER", R.USER_REGIONS = "USER_REGIONS", R.CONVERT_CURRENCY = "CONVERT_CURRENCY", R.CLIENT_COMPONENT_KEY = "CLIENT_COMPONENT_KEY", R.SEARCH_LIMIT = "SEARCH_LIMIT", R.PROGRAMS = "PROGRAMS", R.USER_PROGRAMS = "USER_PROGRAMS", R.LINKED_USER_PROGRAMS = "LINKED_USER_PROGRAMS", R.BANKS = "BANKS", R.CARDS = "CARDS", R.USER_CARDS = "USER_CARDS", R.TRIPS = "TRIPS", R.UNCATEGORISED_BOOKINGS = "UNCATEGORISED_BOOKINGS", R.BOOKING = "BOOKING", R.VALUE_CENTS = "VALUE_CENTS", R.AVAILABILITY_ALERTS = "AVAILABILITY_ALERTS", R.ALERT_NOTIFICATIONS = "ALERT_NOTIFICATIONS", R))(S || {});
|
|
2
|
-
export {
|
|
3
|
-
S as E
|
|
4
|
-
};
|