@odynn/awayz-hotels 0.1.17 → 0.1.19
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,58 +1,64 @@
|
|
|
1
1
|
import { jsxs as o, jsx as t } from "react/jsx-runtime";
|
|
2
|
-
import { useState as
|
|
2
|
+
import { useState as g, useRef as V, useEffect as u } from "react";
|
|
3
3
|
import '../../assets/_styles.css';/* empty css */
|
|
4
|
-
import { o as
|
|
4
|
+
import { o as b } from "../../stringUtils-CvWpky85.js";
|
|
5
5
|
import "../../moment-BGjjqtLQ.js";
|
|
6
6
|
import "../../arrayExtensions-cyilNkdJ.js";
|
|
7
7
|
import { UnavailableDate as x } from "../Banners/UnavailableDate/UnavailableDate.js";
|
|
8
|
-
import { c as C, d as H, e as
|
|
9
|
-
import { HotelChains as
|
|
10
|
-
import
|
|
11
|
-
import { getBookingOptions as
|
|
12
|
-
const
|
|
13
|
-
function
|
|
8
|
+
import { c as C, d as H, e as w, f as j } from "../../index-B2vRnlU4.js";
|
|
9
|
+
import { HotelChains as v } from "../../definitions/HotelChains.js";
|
|
10
|
+
import k, { ERatingColor as B } from "../Banners/Ratings/Ratings.js";
|
|
11
|
+
import { getBookingOptions as T } from "../../utilities/hotelUtils/hotelUtils.js";
|
|
12
|
+
const D = (...e) => e.join(" ");
|
|
13
|
+
function G(e) {
|
|
14
14
|
if (!e || isNaN(e) || e < 0) return "N/A";
|
|
15
15
|
let n = e == null ? void 0 : e.toString().split(".")[0];
|
|
16
16
|
return n == null ? void 0 : n.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
17
17
|
}
|
|
18
|
-
const
|
|
18
|
+
const M = (e, n) => {
|
|
19
19
|
if (e <= 0) return "N/A";
|
|
20
|
-
var
|
|
20
|
+
var a = new Intl.NumberFormat("en-US", {
|
|
21
21
|
style: "currency",
|
|
22
22
|
currency: "USD"
|
|
23
23
|
});
|
|
24
|
-
return e ?
|
|
25
|
-
},
|
|
24
|
+
return e ? a.format(Math.round(e)).toString().split(".")[0] : a.format(0);
|
|
25
|
+
}, Q = ({
|
|
26
26
|
details: e,
|
|
27
27
|
onHotelSelect: n,
|
|
28
|
-
onViewDetails:
|
|
29
|
-
customStyling:
|
|
28
|
+
onViewDetails: a,
|
|
29
|
+
customStyling: y = !1,
|
|
30
30
|
isSelected: i
|
|
31
31
|
}) => {
|
|
32
|
-
const [
|
|
33
|
-
transferPartners:
|
|
34
|
-
bestBookingOption:
|
|
35
|
-
alternateBookingOption:
|
|
36
|
-
hasPoints:
|
|
37
|
-
} =
|
|
38
|
-
|
|
39
|
-
i !== void 0 &&
|
|
40
|
-
}, [i]),
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
return F(
|
|
44
|
-
clearTimeout(
|
|
32
|
+
const [l, d] = g(i), p = V(null), {
|
|
33
|
+
transferPartners: r,
|
|
34
|
+
bestBookingOption: s,
|
|
35
|
+
alternateBookingOption: h,
|
|
36
|
+
hasPoints: R
|
|
37
|
+
} = T(e), [c, F] = g(0), m = r == null ? void 0 : r[c], N = typeof e.cashValue.amount == "number" ? e.cashValue.amount : parseFloat(e.cashValue.amount), f = (m == null ? void 0 : m.value) > 0 || (s == null ? void 0 : s.value) > 0 || (h == null ? void 0 : h.value) > 0 || N > 0;
|
|
38
|
+
u(() => {
|
|
39
|
+
i !== void 0 && d(i);
|
|
40
|
+
}, [i]), u(() => {
|
|
41
|
+
const A = setTimeout(() => {
|
|
42
|
+
const I = c >= (r == null ? void 0 : r.length) - 1 ? 0 : c + 1;
|
|
43
|
+
return F(I), () => {
|
|
44
|
+
clearTimeout(A);
|
|
45
45
|
};
|
|
46
46
|
}, 2e3);
|
|
47
|
-
}, [
|
|
48
|
-
const S =
|
|
49
|
-
return
|
|
47
|
+
}, [c, r == null ? void 0 : r.length]);
|
|
48
|
+
const S = v.isHotelChain(e.hotelGroup);
|
|
49
|
+
return u(() => {
|
|
50
|
+
l && p.current.scrollIntoView({
|
|
51
|
+
behavior: "smooth",
|
|
52
|
+
block: "center"
|
|
53
|
+
});
|
|
54
|
+
}, [l]), /* @__PURE__ */ o(
|
|
50
55
|
"div",
|
|
51
56
|
{
|
|
52
|
-
|
|
53
|
-
|
|
57
|
+
ref: p,
|
|
58
|
+
className: D(
|
|
59
|
+
y ? "hotel-result" : "awayz-hotel-result",
|
|
54
60
|
// insufficient_points ? 'insufficient-points' : '',
|
|
55
|
-
|
|
61
|
+
l ? "go-to-journey-button" : ""
|
|
56
62
|
),
|
|
57
63
|
"data-testid": "search-result",
|
|
58
64
|
children: [
|
|
@@ -61,7 +67,7 @@ const D = (e, n) => {
|
|
|
61
67
|
{
|
|
62
68
|
className: "content",
|
|
63
69
|
onClick: () => {
|
|
64
|
-
|
|
70
|
+
d(!l), n(e);
|
|
65
71
|
},
|
|
66
72
|
children: [
|
|
67
73
|
/* @__PURE__ */ o("div", { className: "details", children: [
|
|
@@ -74,7 +80,7 @@ const D = (e, n) => {
|
|
|
74
80
|
},
|
|
75
81
|
children: /* @__PURE__ */ o("div", { className: "hotel-chain", children: [
|
|
76
82
|
/* @__PURE__ */ t(C, {}),
|
|
77
|
-
/* @__PURE__ */ t("p", { children:
|
|
83
|
+
/* @__PURE__ */ t("p", { children: v.toString(e.hotelGroup) })
|
|
78
84
|
] })
|
|
79
85
|
}
|
|
80
86
|
),
|
|
@@ -82,10 +88,10 @@ const D = (e, n) => {
|
|
|
82
88
|
/* @__PURE__ */ o("div", { className: "hotel-data", children: [
|
|
83
89
|
/* @__PURE__ */ o("div", { className: "hotel-information", children: [
|
|
84
90
|
/* @__PURE__ */ t(
|
|
85
|
-
|
|
91
|
+
k,
|
|
86
92
|
{
|
|
87
93
|
starRating: e.chainRating ?? 0,
|
|
88
|
-
starColor:
|
|
94
|
+
starColor: B.PRIMARY,
|
|
89
95
|
userRating: e.reviewRating ?? "",
|
|
90
96
|
fill: !0
|
|
91
97
|
}
|
|
@@ -95,9 +101,9 @@ const D = (e, n) => {
|
|
|
95
101
|
/* @__PURE__ */ t("p", { children: "Free Night" })
|
|
96
102
|
] }),
|
|
97
103
|
typeof e.nthNightFree == "number" && e.nthNightFree > 0 && /* @__PURE__ */ o("div", { children: [
|
|
98
|
-
/* @__PURE__ */ t(
|
|
104
|
+
/* @__PURE__ */ t(w, {}),
|
|
99
105
|
/* @__PURE__ */ o("p", { children: [
|
|
100
|
-
|
|
106
|
+
b(e.nthNightFree),
|
|
101
107
|
" Night Free"
|
|
102
108
|
] })
|
|
103
109
|
] })
|
|
@@ -108,8 +114,8 @@ const D = (e, n) => {
|
|
|
108
114
|
/* @__PURE__ */ t(
|
|
109
115
|
x,
|
|
110
116
|
{
|
|
111
|
-
hasPoints:
|
|
112
|
-
isAvailable:
|
|
117
|
+
hasPoints: R,
|
|
118
|
+
isAvailable: f,
|
|
113
119
|
selectedHotel: () => {
|
|
114
120
|
},
|
|
115
121
|
chainName: e.hotelGroup
|
|
@@ -117,15 +123,15 @@ const D = (e, n) => {
|
|
|
117
123
|
)
|
|
118
124
|
] })
|
|
119
125
|
] }),
|
|
120
|
-
|
|
126
|
+
f && /* @__PURE__ */ o("div", { className: "payments", children: [
|
|
121
127
|
S && /* @__PURE__ */ o("div", { className: "payment-details", children: [
|
|
122
128
|
/* @__PURE__ */ t("p", { children: "POINTS" }),
|
|
123
|
-
/* @__PURE__ */ t("p", { children:
|
|
129
|
+
/* @__PURE__ */ t("p", { children: G(e.awardPoints) }),
|
|
124
130
|
e.bestValue === "points" && /* @__PURE__ */ t("p", { className: "best-value", children: "Best Value" })
|
|
125
131
|
] }),
|
|
126
132
|
/* @__PURE__ */ o("div", { className: "payment-details", children: [
|
|
127
133
|
/* @__PURE__ */ t("p", { children: "CASH" }),
|
|
128
|
-
/* @__PURE__ */ t("p", { children:
|
|
134
|
+
/* @__PURE__ */ t("p", { children: M(N) }),
|
|
129
135
|
e.bestValue === "cash" && /* @__PURE__ */ t("p", { className: "best-value", children: "Best Value" })
|
|
130
136
|
] })
|
|
131
137
|
] })
|
|
@@ -137,9 +143,9 @@ const D = (e, n) => {
|
|
|
137
143
|
{
|
|
138
144
|
"data-testid": "go-to-journey-button",
|
|
139
145
|
onClick: () => {
|
|
140
|
-
|
|
146
|
+
a(e);
|
|
141
147
|
},
|
|
142
|
-
children: /* @__PURE__ */ t(
|
|
148
|
+
children: /* @__PURE__ */ t(j, {})
|
|
143
149
|
}
|
|
144
150
|
)
|
|
145
151
|
]
|
|
@@ -147,5 +153,5 @@ const D = (e, n) => {
|
|
|
147
153
|
);
|
|
148
154
|
};
|
|
149
155
|
export {
|
|
150
|
-
|
|
156
|
+
Q as HotelResult
|
|
151
157
|
};
|
|
@@ -1,144 +1,150 @@
|
|
|
1
|
-
import { useMemo as
|
|
2
|
-
import { h as
|
|
1
|
+
import { useState as L, useMemo as Q } from "react";
|
|
2
|
+
import { h as i } from "../../moment-BGjjqtLQ.js";
|
|
3
3
|
import "../../arrayExtensions-cyilNkdJ.js";
|
|
4
|
-
import
|
|
5
|
-
import { fetchTransferPartners as
|
|
6
|
-
import { calculatePointsAsCash as
|
|
7
|
-
import { useQuery as
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
),
|
|
11
|
-
var
|
|
4
|
+
import U from "../../stores/useHotelsStore.js";
|
|
5
|
+
import { fetchTransferPartners as j, fetchPointsCheck as z, fetchAvailableRooms as J, fetchBestCheckout as V, combineUpdatedHotelData as O, fallbackBestCheckout as W } from "./useHotelDetails.api.js";
|
|
6
|
+
import { calculatePointsAsCash as X } from "../../utilities/pointsAsCashUtils.js";
|
|
7
|
+
import { useQuery as c } from "@tanstack/react-query";
|
|
8
|
+
const Y = (t, a) => Math.abs(
|
|
9
|
+
i(t.startOf("day")).diff(i(a.endOf("day")), "days")
|
|
10
|
+
), ae = (t) => {
|
|
11
|
+
var k, f, d, p, m, y, b, C, g, v, F;
|
|
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:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
)
|
|
16
|
+
const { updateHotel: a, searchParams: o } = U(), [e, q] = L({
|
|
17
|
+
checkinDate: o == null ? void 0 : o.checkinDate,
|
|
18
|
+
checkoutDate: o == null ? void 0 : o.checkoutDate
|
|
19
|
+
}), s = Q(() => Y(e.checkinDate, e.checkoutDate), [e]), H = (x, E) => {
|
|
20
|
+
q({
|
|
21
|
+
checkinDate: i(x),
|
|
22
|
+
checkoutDate: i(E)
|
|
23
|
+
});
|
|
24
|
+
}, { data: R, isFetching: A } = c({
|
|
20
25
|
queryKey: ["transferPartners", t.hotelGroup],
|
|
21
|
-
queryFn: () =>
|
|
26
|
+
queryFn: () => j(t.hotelGroup),
|
|
22
27
|
enabled: !!t.hotelGroup,
|
|
23
28
|
placeholderData: []
|
|
24
29
|
}), {
|
|
25
|
-
data:
|
|
26
|
-
isFetching:
|
|
27
|
-
isFetched:
|
|
28
|
-
} =
|
|
30
|
+
data: B,
|
|
31
|
+
isFetching: n,
|
|
32
|
+
isFetched: G
|
|
33
|
+
} = c({
|
|
29
34
|
queryKey: [
|
|
30
35
|
"hotelPointsCheck",
|
|
31
36
|
t.hotelId,
|
|
32
37
|
t.hotelGroup,
|
|
33
|
-
(
|
|
34
|
-
(
|
|
38
|
+
(k = e == null ? void 0 : e.checkinDate) == null ? void 0 : k.valueOf(),
|
|
39
|
+
(f = e == null ? void 0 : e.checkoutDate) == null ? void 0 : f.valueOf()
|
|
35
40
|
],
|
|
36
|
-
queryFn: () =>
|
|
41
|
+
queryFn: () => z({
|
|
37
42
|
hotel: t,
|
|
38
43
|
checkinDate: e.checkinDate,
|
|
39
44
|
checkoutDate: e.checkoutDate,
|
|
40
|
-
updateHotel:
|
|
45
|
+
updateHotel: a
|
|
41
46
|
}),
|
|
42
|
-
enabled: !!e
|
|
47
|
+
enabled: !!e.checkinDate && !!e.checkoutDate && !!t.liveScrapingCheckNeeded,
|
|
43
48
|
// We don't throw an error on fail so we can gracefully handle fallback
|
|
44
49
|
retry: !1,
|
|
45
50
|
placeholderData: {
|
|
46
51
|
pointsHotelDetails: t,
|
|
47
52
|
pointsRooms: t.rooms ?? []
|
|
48
53
|
}
|
|
49
|
-
}), { pointsRooms:
|
|
54
|
+
}), { pointsRooms: I, pointsHotelDetails: r } = B || {
|
|
50
55
|
pointsHotelDetails: t,
|
|
51
56
|
pointsRooms: []
|
|
52
57
|
}, {
|
|
53
|
-
data:
|
|
54
|
-
isFetching:
|
|
55
|
-
isFetched:
|
|
56
|
-
} =
|
|
58
|
+
data: K,
|
|
59
|
+
isFetching: u,
|
|
60
|
+
isFetched: S
|
|
61
|
+
} = c({
|
|
57
62
|
queryKey: [
|
|
58
63
|
"fetchAvailableRooms",
|
|
59
|
-
(
|
|
60
|
-
(
|
|
61
|
-
(
|
|
62
|
-
|
|
63
|
-
|
|
64
|
+
(d = t.cashBookingOffers) == null ? void 0 : d.accommodationId,
|
|
65
|
+
(p = e == null ? void 0 : e.checkinDate) == null ? void 0 : p.valueOf(),
|
|
66
|
+
(m = e == null ? void 0 : e.checkoutDate) == null ? void 0 : m.valueOf(),
|
|
67
|
+
o == null ? void 0 : o.guests,
|
|
68
|
+
o == null ? void 0 : o.rooms
|
|
64
69
|
],
|
|
65
|
-
queryFn: () =>
|
|
70
|
+
queryFn: () => J({
|
|
66
71
|
hotel: t,
|
|
67
72
|
checkinDate: e.checkinDate,
|
|
68
73
|
checkoutDate: e.checkoutDate,
|
|
69
|
-
guests:
|
|
70
|
-
rooms:
|
|
71
|
-
updateHotel:
|
|
72
|
-
numberOfNights:
|
|
74
|
+
guests: o.guests,
|
|
75
|
+
rooms: o.rooms,
|
|
76
|
+
updateHotel: a,
|
|
77
|
+
numberOfNights: s
|
|
73
78
|
}),
|
|
74
|
-
enabled: !!e
|
|
79
|
+
enabled: !!e.checkinDate && !!e.checkoutDate && !!((y = t.cashBookingOffers) != null && y.accommodationId),
|
|
75
80
|
retry: !1,
|
|
76
81
|
placeholderData: {
|
|
77
82
|
cashHotelDetails: t,
|
|
78
83
|
cashRooms: []
|
|
79
84
|
}
|
|
80
|
-
}), { cashRooms:
|
|
85
|
+
}), { cashRooms: w, cashHotelDetails: h } = K || {
|
|
81
86
|
cashHotelDetails: t,
|
|
82
87
|
cashRooms: []
|
|
83
88
|
}, {
|
|
84
|
-
data:
|
|
85
|
-
isFetching:
|
|
86
|
-
isFetched:
|
|
87
|
-
} =
|
|
89
|
+
data: N,
|
|
90
|
+
isFetching: M,
|
|
91
|
+
isFetched: P
|
|
92
|
+
} = c({
|
|
88
93
|
queryKey: [
|
|
89
94
|
"bestCheckout",
|
|
90
95
|
t.hotelId,
|
|
91
96
|
t.hotelGroup,
|
|
92
|
-
(
|
|
93
|
-
(
|
|
97
|
+
(b = e == null ? void 0 : e.checkinDate) == null ? void 0 : b.valueOf(),
|
|
98
|
+
(C = e == null ? void 0 : e.checkoutDate) == null ? void 0 : C.valueOf()
|
|
94
99
|
],
|
|
95
|
-
queryFn: () =>
|
|
96
|
-
|
|
97
|
-
|
|
100
|
+
queryFn: () => V(
|
|
101
|
+
O(t, r, h),
|
|
102
|
+
s
|
|
98
103
|
),
|
|
99
|
-
enabled: !
|
|
104
|
+
enabled: !n && (t.liveScrapingCheckNeeded ? G : !0) && !u && ((g = t.cashBookingOffers) != null && g.accommodationId ? S : !0) && s > 0,
|
|
100
105
|
retry: !1,
|
|
101
106
|
placeholderData: {
|
|
102
|
-
bestCheckout:
|
|
107
|
+
bestCheckout: W(t, s),
|
|
103
108
|
isAvailable: !1
|
|
104
109
|
}
|
|
105
|
-
}), { bestCheckout: l, isAvailable:
|
|
110
|
+
}), { bestCheckout: l, isAvailable: D } = N || {
|
|
106
111
|
isAvailable: !1
|
|
107
|
-
}, { data:
|
|
112
|
+
}, { data: T } = c({
|
|
108
113
|
queryKey: [
|
|
109
114
|
"pointsAsCash",
|
|
110
115
|
t.hotelId,
|
|
111
116
|
t.hotelGroup,
|
|
112
|
-
(
|
|
113
|
-
(
|
|
117
|
+
(v = e == null ? void 0 : e.checkinDate) == null ? void 0 : v.valueOf(),
|
|
118
|
+
(F = e == null ? void 0 : e.checkoutDate) == null ? void 0 : F.valueOf()
|
|
114
119
|
],
|
|
115
|
-
queryFn: () =>
|
|
116
|
-
enabled:
|
|
120
|
+
queryFn: () => X(l.totalCashCost),
|
|
121
|
+
enabled: P && D,
|
|
117
122
|
retry: !1
|
|
118
123
|
});
|
|
119
124
|
return {
|
|
120
|
-
transferPartners:
|
|
121
|
-
loadingTransferPartners:
|
|
125
|
+
transferPartners: R,
|
|
126
|
+
loadingTransferPartners: A,
|
|
122
127
|
// Points Check
|
|
123
|
-
pointsRooms:
|
|
124
|
-
loadingLivePointsCheck:
|
|
128
|
+
pointsRooms: I,
|
|
129
|
+
loadingLivePointsCheck: n,
|
|
125
130
|
// Cash Rooms
|
|
126
|
-
cashRooms:
|
|
127
|
-
loadingCashRooms:
|
|
131
|
+
cashRooms: w,
|
|
132
|
+
loadingCashRooms: u,
|
|
128
133
|
// Best Checkout
|
|
129
134
|
bestCheckout: l,
|
|
130
|
-
loadingBestCheckout:
|
|
135
|
+
loadingBestCheckout: M,
|
|
131
136
|
// Combined availability
|
|
132
|
-
isAvailable:
|
|
137
|
+
isAvailable: D,
|
|
133
138
|
// Points as Cash
|
|
134
|
-
pointsAsCash:
|
|
135
|
-
hotelDetails:
|
|
139
|
+
pointsAsCash: T,
|
|
140
|
+
hotelDetails: O(
|
|
136
141
|
t,
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
)
|
|
142
|
+
r,
|
|
143
|
+
h
|
|
144
|
+
),
|
|
145
|
+
updateDates: H
|
|
140
146
|
};
|
|
141
147
|
};
|
|
142
148
|
export {
|
|
143
|
-
|
|
149
|
+
ae as useHotelDetails
|
|
144
150
|
};
|