@odynn/awayz-hotels 0.2.8 → 0.2.9
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/components/Banners/Ratings/Ratings.js +15 -15
- package/dist/components/HotelResult/HotelResult.js +25 -25
- package/dist/hooks/useHotelDetails/useHotelDetails.js +26 -26
- package/dist/lib/utilities/hotelUtils/hotelUtils.d.ts +7 -0
- package/dist/utilities/hotelUtils/hotelUtils.js +19 -15
- package/package.json +1 -1
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
import { jsxs as a, jsx as n } from "react/jsx-runtime";
|
|
2
|
-
import { a as
|
|
3
|
-
import '../../../assets/Ratings.css';var
|
|
4
|
-
const
|
|
2
|
+
import { a as p, b as o } from "../../../index-D8bHwbxH.js";
|
|
3
|
+
import '../../../assets/Ratings.css';var h = /* @__PURE__ */ ((r) => (r.INHERIT = "inherit", r.PRIMARY = "primary", r.LIGHT = "light", r.DARK = "dark", r))(h || {});
|
|
4
|
+
const f = ({
|
|
5
5
|
starRating: r,
|
|
6
6
|
userRating: e,
|
|
7
|
-
color:
|
|
8
|
-
fill:
|
|
9
|
-
starColor:
|
|
7
|
+
color: m = "dark",
|
|
8
|
+
fill: t = !1,
|
|
9
|
+
starColor: l = "primary"
|
|
10
10
|
/* PRIMARY */
|
|
11
11
|
}) => {
|
|
12
|
-
const
|
|
13
|
-
if (!r &&
|
|
14
|
-
const
|
|
15
|
-
return /* @__PURE__ */ a("div", { className: `rating ${
|
|
16
|
-
|
|
12
|
+
const s = !e || e === 0 || e.toString().toLowerCase() === "none";
|
|
13
|
+
if (!r && s) return null;
|
|
14
|
+
const d = typeof e == "number" ? Math.round(e) : typeof e == "string" && !isNaN(Number(e)) ? Math.round(Number(e)) : e, c = r ? t ? /* @__PURE__ */ n(p, { className: l }) : /* @__PURE__ */ n(o, { className: l }) : null;
|
|
15
|
+
return /* @__PURE__ */ a("div", { className: `rating ${m}`, children: [
|
|
16
|
+
c,
|
|
17
17
|
r ? /* @__PURE__ */ a("p", { children: [
|
|
18
18
|
r,
|
|
19
19
|
"-star"
|
|
20
20
|
] }) : null,
|
|
21
|
-
|
|
21
|
+
s ? null : /* @__PURE__ */ a("p", { children: [
|
|
22
22
|
"(",
|
|
23
|
-
|
|
23
|
+
d,
|
|
24
24
|
" rating)"
|
|
25
25
|
] })
|
|
26
26
|
] });
|
|
27
27
|
};
|
|
28
28
|
export {
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
h as ERatingColor,
|
|
30
|
+
f as default
|
|
31
31
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs as o, jsx as t } from "react/jsx-runtime";
|
|
2
|
-
import { useState as N, useRef as
|
|
2
|
+
import { useState as N, useRef as x, useEffect as m } from "react";
|
|
3
3
|
import '../../assets/_styles.css';/* empty css */
|
|
4
4
|
import { o as S } from "../../stringUtils-CvWpky85.js";
|
|
5
5
|
import "../../moment-BGjjqtLQ.js";
|
|
@@ -7,8 +7,8 @@ import "../../arrayExtensions-cyilNkdJ.js";
|
|
|
7
7
|
import { UnavailableDate as B } from "../Banners/UnavailableDate/UnavailableDate.js";
|
|
8
8
|
import { c as j, d as w, e as T, f as G, g as E } from "../../index-D8bHwbxH.js";
|
|
9
9
|
import { HotelChains as v } from "../../definitions/HotelChains.js";
|
|
10
|
-
import
|
|
11
|
-
import { getBookingOptions as L } from "../../utilities/hotelUtils/hotelUtils.js";
|
|
10
|
+
import U, { ERatingColor as z } from "../Banners/Ratings/Ratings.js";
|
|
11
|
+
import { getBookingOptions as D, getHotelImageUrls as L } from "../../utilities/hotelUtils/hotelUtils.js";
|
|
12
12
|
import { CashValue as M } from "@odynn/awayz-core";
|
|
13
13
|
const O = (...e) => e.join(" ");
|
|
14
14
|
function P(e) {
|
|
@@ -16,7 +16,7 @@ function P(e) {
|
|
|
16
16
|
let n = e == null ? void 0 : e.toString().split(".")[0];
|
|
17
17
|
return n == null ? void 0 : n.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
18
18
|
}
|
|
19
|
-
const
|
|
19
|
+
const oe = ({
|
|
20
20
|
details: e,
|
|
21
21
|
onHotelSelect: n,
|
|
22
22
|
onViewDetails: C,
|
|
@@ -25,37 +25,37 @@ const te = ({
|
|
|
25
25
|
showBookableTag: R = !1,
|
|
26
26
|
customBookableTag: F = "Bookable"
|
|
27
27
|
}) => {
|
|
28
|
-
var
|
|
29
|
-
const [
|
|
28
|
+
var f;
|
|
29
|
+
const [r, u] = N(c), d = x(null), {
|
|
30
30
|
transferPartners: a,
|
|
31
31
|
bestBookingOption: l,
|
|
32
32
|
alternateBookingOption: s,
|
|
33
|
-
hasPoints:
|
|
34
|
-
} =
|
|
33
|
+
hasPoints: I
|
|
34
|
+
} = D(e), [i, V] = N(0), h = a == null ? void 0 : a[i], p = typeof e.cashValue.amount == "number" ? e.cashValue.amount : parseFloat(e.cashValue.amount), { currency: b } = e.cashValue, g = (h == null ? void 0 : h.value) > 0 || (l == null ? void 0 : l.value) > 0 || (s == null ? void 0 : s.value) > 0 || p > 0;
|
|
35
35
|
m(() => {
|
|
36
36
|
c !== void 0 && u(c);
|
|
37
37
|
}, [c]), m(() => {
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
return
|
|
41
|
-
clearTimeout(
|
|
38
|
+
const H = setTimeout(() => {
|
|
39
|
+
const k = i >= (a == null ? void 0 : a.length) - 1 ? 0 : i + 1;
|
|
40
|
+
return V(k), () => {
|
|
41
|
+
clearTimeout(H);
|
|
42
42
|
};
|
|
43
43
|
}, 2e3);
|
|
44
|
-
}, [
|
|
44
|
+
}, [i, a == null ? void 0 : a.length]);
|
|
45
45
|
const A = v.isHotelChain(e.hotelGroup);
|
|
46
46
|
return m(() => {
|
|
47
|
-
|
|
47
|
+
r && d.current.scrollIntoView({
|
|
48
48
|
behavior: "smooth",
|
|
49
49
|
block: "center"
|
|
50
50
|
});
|
|
51
|
-
}, [
|
|
51
|
+
}, [r]), /* @__PURE__ */ o(
|
|
52
52
|
"div",
|
|
53
53
|
{
|
|
54
54
|
ref: d,
|
|
55
55
|
className: O(
|
|
56
56
|
y ? "hotel-result" : "awayz-hotel-result",
|
|
57
57
|
// insufficient_points ? 'insufficient-points' : '',
|
|
58
|
-
|
|
58
|
+
r ? "go-to-journey-button" : ""
|
|
59
59
|
),
|
|
60
60
|
"data-testid": "search-result",
|
|
61
61
|
children: [
|
|
@@ -64,7 +64,7 @@ const te = ({
|
|
|
64
64
|
{
|
|
65
65
|
className: "content",
|
|
66
66
|
onClick: () => {
|
|
67
|
-
u(!
|
|
67
|
+
u(!r), n(e);
|
|
68
68
|
},
|
|
69
69
|
children: [
|
|
70
70
|
/* @__PURE__ */ o("div", { className: "details", children: [
|
|
@@ -73,7 +73,7 @@ const te = ({
|
|
|
73
73
|
{
|
|
74
74
|
className: "hotel-image",
|
|
75
75
|
style: {
|
|
76
|
-
backgroundImage: `url(${e.images[0]})`
|
|
76
|
+
backgroundImage: `url(${L(e.images)[0]})`
|
|
77
77
|
},
|
|
78
78
|
children: /* @__PURE__ */ o("div", { className: "hotel-chain", children: [
|
|
79
79
|
/* @__PURE__ */ t(j, {}),
|
|
@@ -84,15 +84,15 @@ const te = ({
|
|
|
84
84
|
/* @__PURE__ */ o("div", { className: "info", children: [
|
|
85
85
|
/* @__PURE__ */ o("div", { className: "hotel-data", children: [
|
|
86
86
|
/* @__PURE__ */ o("div", { className: "hotel-information", children: [
|
|
87
|
-
!!((
|
|
87
|
+
!!((f = e.cashBookingOffers) != null && f.accommodationId) && R && /* @__PURE__ */ o("div", { children: [
|
|
88
88
|
/* @__PURE__ */ t(w, {}),
|
|
89
89
|
/* @__PURE__ */ t("p", { children: F })
|
|
90
90
|
] }),
|
|
91
91
|
/* @__PURE__ */ t(
|
|
92
|
-
|
|
92
|
+
U,
|
|
93
93
|
{
|
|
94
94
|
starRating: e.chainRating ?? 0,
|
|
95
|
-
starColor:
|
|
95
|
+
starColor: z.PRIMARY,
|
|
96
96
|
userRating: e.reviewRating ?? "",
|
|
97
97
|
fill: !0
|
|
98
98
|
}
|
|
@@ -115,8 +115,8 @@ const te = ({
|
|
|
115
115
|
/* @__PURE__ */ t(
|
|
116
116
|
B,
|
|
117
117
|
{
|
|
118
|
-
hasPoints:
|
|
119
|
-
isAvailable:
|
|
118
|
+
hasPoints: I,
|
|
119
|
+
isAvailable: g,
|
|
120
120
|
selectedHotel: () => {
|
|
121
121
|
},
|
|
122
122
|
chainName: e.hotelGroup
|
|
@@ -124,7 +124,7 @@ const te = ({
|
|
|
124
124
|
)
|
|
125
125
|
] })
|
|
126
126
|
] }),
|
|
127
|
-
|
|
127
|
+
g && /* @__PURE__ */ o("div", { className: "payments", children: [
|
|
128
128
|
A && /* @__PURE__ */ o("div", { className: "payment-details", children: [
|
|
129
129
|
/* @__PURE__ */ t("p", { children: "POINTS" }),
|
|
130
130
|
/* @__PURE__ */ t("p", { children: P(e.awardPoints) }),
|
|
@@ -154,5 +154,5 @@ const te = ({
|
|
|
154
154
|
);
|
|
155
155
|
};
|
|
156
156
|
export {
|
|
157
|
-
|
|
157
|
+
oe as HotelResult
|
|
158
158
|
};
|
|
@@ -2,35 +2,35 @@ import { useState as L, useMemo as Q } from "react";
|
|
|
2
2
|
import { h as i } from "../../moment-BGjjqtLQ.js";
|
|
3
3
|
import "../../arrayExtensions-cyilNkdJ.js";
|
|
4
4
|
import U from "../../stores/useHotelsStore.js";
|
|
5
|
-
import { fetchTransferPartners as
|
|
6
|
-
import { calculatePointsAsCash as
|
|
7
|
-
import { useQuery as
|
|
8
|
-
const
|
|
9
|
-
i(t.startOf("day")).diff(i(
|
|
10
|
-
),
|
|
5
|
+
import { fetchTransferPartners as W, fetchPointsCheck as _, fetchAvailableRooms as j, fetchBestCheckout as z, combineUpdatedHotelData as O, fallbackBestCheckout as J } from "./useHotelDetails.api.js";
|
|
6
|
+
import { calculatePointsAsCash as V } from "../../utilities/pointsAsCashUtils.js";
|
|
7
|
+
import { useQuery as a } from "@tanstack/react-query";
|
|
8
|
+
const X = (t, c) => Math.abs(
|
|
9
|
+
i(t.startOf("day")).diff(i(c.endOf("day")), "days")
|
|
10
|
+
), ce = (t) => {
|
|
11
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:
|
|
16
|
+
const { updateHotel: c, searchParams: o } = U(), [e, q] = L({
|
|
17
17
|
checkinDate: o == null ? void 0 : o.checkinDate,
|
|
18
18
|
checkoutDate: o == null ? void 0 : o.checkoutDate
|
|
19
|
-
}), s = Q(() =>
|
|
19
|
+
}), s = Q(() => X(e.checkinDate, e.checkoutDate), [e]), H = (x, E) => {
|
|
20
20
|
q({
|
|
21
21
|
checkinDate: i(x),
|
|
22
22
|
checkoutDate: i(E)
|
|
23
23
|
});
|
|
24
|
-
}, { data: R, isFetching: A } =
|
|
24
|
+
}, { data: R, isFetching: A } = a({
|
|
25
25
|
queryKey: ["transferPartners", t.hotelGroup],
|
|
26
|
-
queryFn: () =>
|
|
26
|
+
queryFn: () => W(t.hotelGroup),
|
|
27
27
|
enabled: !!t.hotelGroup,
|
|
28
28
|
placeholderData: []
|
|
29
29
|
}), {
|
|
30
30
|
data: B,
|
|
31
31
|
isFetching: n,
|
|
32
|
-
isFetched:
|
|
33
|
-
} =
|
|
32
|
+
isFetched: I
|
|
33
|
+
} = a({
|
|
34
34
|
queryKey: [
|
|
35
35
|
"hotelPointsCheck",
|
|
36
36
|
t.hotelId,
|
|
@@ -38,11 +38,11 @@ const Y = (t, a) => Math.abs(
|
|
|
38
38
|
(k = e == null ? void 0 : e.checkinDate) == null ? void 0 : k.valueOf(),
|
|
39
39
|
(f = e == null ? void 0 : e.checkoutDate) == null ? void 0 : f.valueOf()
|
|
40
40
|
],
|
|
41
|
-
queryFn: () =>
|
|
41
|
+
queryFn: () => _({
|
|
42
42
|
hotel: t,
|
|
43
43
|
checkinDate: e.checkinDate,
|
|
44
44
|
checkoutDate: e.checkoutDate,
|
|
45
|
-
updateHotel:
|
|
45
|
+
updateHotel: c
|
|
46
46
|
}),
|
|
47
47
|
enabled: !!e.checkinDate && !!e.checkoutDate && !!t.liveScrapingCheckNeeded,
|
|
48
48
|
// We don't throw an error on fail so we can gracefully handle fallback
|
|
@@ -51,14 +51,14 @@ const Y = (t, a) => Math.abs(
|
|
|
51
51
|
pointsHotelDetails: t,
|
|
52
52
|
pointsRooms: t.rooms ?? []
|
|
53
53
|
}
|
|
54
|
-
}), { pointsRooms:
|
|
54
|
+
}), { pointsRooms: G, pointsHotelDetails: r } = B || {
|
|
55
55
|
pointsHotelDetails: t,
|
|
56
56
|
pointsRooms: []
|
|
57
57
|
}, {
|
|
58
58
|
data: K,
|
|
59
59
|
isFetching: u,
|
|
60
60
|
isFetched: S
|
|
61
|
-
} =
|
|
61
|
+
} = a({
|
|
62
62
|
queryKey: [
|
|
63
63
|
"fetchAvailableRooms",
|
|
64
64
|
(d = t.cashBookingOffers) == null ? void 0 : d.accommodationId,
|
|
@@ -67,13 +67,13 @@ const Y = (t, a) => Math.abs(
|
|
|
67
67
|
o == null ? void 0 : o.guests,
|
|
68
68
|
o == null ? void 0 : o.rooms
|
|
69
69
|
],
|
|
70
|
-
queryFn: () =>
|
|
70
|
+
queryFn: () => j({
|
|
71
71
|
hotel: t,
|
|
72
72
|
checkinDate: e.checkinDate,
|
|
73
73
|
checkoutDate: e.checkoutDate,
|
|
74
74
|
guests: o.guests,
|
|
75
75
|
rooms: o.rooms,
|
|
76
|
-
updateHotel:
|
|
76
|
+
updateHotel: c,
|
|
77
77
|
numberOfNights: s
|
|
78
78
|
}),
|
|
79
79
|
enabled: !!e.checkinDate && !!e.checkoutDate && !!((y = t.cashBookingOffers) != null && y.accommodationId),
|
|
@@ -89,7 +89,7 @@ const Y = (t, a) => Math.abs(
|
|
|
89
89
|
data: N,
|
|
90
90
|
isFetching: M,
|
|
91
91
|
isFetched: P
|
|
92
|
-
} =
|
|
92
|
+
} = a({
|
|
93
93
|
queryKey: [
|
|
94
94
|
"bestCheckout",
|
|
95
95
|
t.hotelId,
|
|
@@ -97,19 +97,19 @@ const Y = (t, a) => Math.abs(
|
|
|
97
97
|
(b = e == null ? void 0 : e.checkinDate) == null ? void 0 : b.valueOf(),
|
|
98
98
|
(C = e == null ? void 0 : e.checkoutDate) == null ? void 0 : C.valueOf()
|
|
99
99
|
],
|
|
100
|
-
queryFn: () =>
|
|
100
|
+
queryFn: () => z(
|
|
101
101
|
O(t, r, h),
|
|
102
102
|
s
|
|
103
103
|
),
|
|
104
|
-
enabled: !n && (t.liveScrapingCheckNeeded ?
|
|
104
|
+
enabled: !t.hotelId.startsWith("duff_") && !n && (t.liveScrapingCheckNeeded ? I : !0) && !u && ((g = t.cashBookingOffers) != null && g.accommodationId ? S : !0) && s > 0,
|
|
105
105
|
retry: !1,
|
|
106
106
|
placeholderData: {
|
|
107
|
-
bestCheckout:
|
|
107
|
+
bestCheckout: J(t, s),
|
|
108
108
|
isAvailable: !1
|
|
109
109
|
}
|
|
110
110
|
}), { bestCheckout: l, isAvailable: D } = N || {
|
|
111
111
|
isAvailable: !1
|
|
112
|
-
}, { data: T } =
|
|
112
|
+
}, { data: T } = a({
|
|
113
113
|
queryKey: [
|
|
114
114
|
"pointsAsCash",
|
|
115
115
|
t.hotelId,
|
|
@@ -117,7 +117,7 @@ const Y = (t, a) => Math.abs(
|
|
|
117
117
|
(v = e == null ? void 0 : e.checkinDate) == null ? void 0 : v.valueOf(),
|
|
118
118
|
(F = e == null ? void 0 : e.checkoutDate) == null ? void 0 : F.valueOf()
|
|
119
119
|
],
|
|
120
|
-
queryFn: () =>
|
|
120
|
+
queryFn: () => V(l.totalCashCost),
|
|
121
121
|
enabled: P && D,
|
|
122
122
|
retry: !1
|
|
123
123
|
});
|
|
@@ -125,7 +125,7 @@ const Y = (t, a) => Math.abs(
|
|
|
125
125
|
transferPartners: R,
|
|
126
126
|
loadingTransferPartners: A,
|
|
127
127
|
// Points Check
|
|
128
|
-
pointsRooms:
|
|
128
|
+
pointsRooms: G,
|
|
129
129
|
loadingLivePointsCheck: n,
|
|
130
130
|
// Cash Rooms
|
|
131
131
|
cashRooms: w,
|
|
@@ -146,5 +146,5 @@ const Y = (t, a) => Math.abs(
|
|
|
146
146
|
};
|
|
147
147
|
};
|
|
148
148
|
export {
|
|
149
|
-
|
|
149
|
+
ce as useHotelDetails
|
|
150
150
|
};
|
|
@@ -32,3 +32,10 @@ export declare const getBookingOptions: (searchResult: IHotelDetails) => {
|
|
|
32
32
|
* @returns The points value for the hotel search result.
|
|
33
33
|
*/
|
|
34
34
|
export declare const getPointsValue: (result: IHotelDetails) => number;
|
|
35
|
+
type ImageUrl = string;
|
|
36
|
+
type ImageObject = {
|
|
37
|
+
url: string;
|
|
38
|
+
};
|
|
39
|
+
type ImageData = ImageUrl | ImageObject;
|
|
40
|
+
export declare function getHotelImageUrls(images?: ImageData[] | null): string[];
|
|
41
|
+
export {};
|
|
@@ -1,22 +1,26 @@
|
|
|
1
|
-
import { HotelChains as
|
|
2
|
-
const
|
|
3
|
-
var
|
|
4
|
-
const
|
|
1
|
+
import { HotelChains as a } from "../../definitions/HotelChains.js";
|
|
2
|
+
const s = (t) => {
|
|
3
|
+
var r;
|
|
4
|
+
const n = t.freeNight || t.nthNightFree !== 0 ? t.awardPoints : t.points, o = {
|
|
5
5
|
type: "",
|
|
6
6
|
value: -1
|
|
7
|
-
},
|
|
8
|
-
return
|
|
9
|
-
transferPartners: ((
|
|
7
|
+
}, i = typeof t.cashValue.amount == "number" ? t.cashValue.amount : parseFloat(t.cashValue.amount), e = { ...o };
|
|
8
|
+
return t.bestValue === "cash" ? (o.type = "cash", o.value = i, e.type = "points", e.value = n || -1) : t.bestValue === "points" && (o.type = "points", o.value = n || -1, e.type = "cash", e.value = i), {
|
|
9
|
+
transferPartners: ((r = t.partners) == null ? void 0 : r.map((p) => ({
|
|
10
10
|
...p,
|
|
11
|
-
value:
|
|
11
|
+
value: n ? Math.ceil(n * p.ratio) : -1
|
|
12
12
|
}))) || [],
|
|
13
|
-
bestBookingOption:
|
|
14
|
-
alternateBookingOption:
|
|
15
|
-
points:
|
|
16
|
-
hasPoints: typeof
|
|
13
|
+
bestBookingOption: o,
|
|
14
|
+
alternateBookingOption: e,
|
|
15
|
+
points: n || -1,
|
|
16
|
+
hasPoints: typeof n == "number" && n > 0
|
|
17
17
|
};
|
|
18
|
-
},
|
|
18
|
+
}, u = (t) => (t == null ? void 0 : t.hotelGroup) === a.IHG ? t.freeNight || t.nthNightFree ? t.awardPoints : t.points : t.awardPoints;
|
|
19
|
+
function y(t) {
|
|
20
|
+
return !t || !Array.isArray(t) || t.length === 0 ? [] : t.map((n) => typeof n == "string" ? n : n && typeof n == "object" && "url" in n ? n.url : "").filter((n) => n !== "");
|
|
21
|
+
}
|
|
19
22
|
export {
|
|
20
|
-
|
|
21
|
-
|
|
23
|
+
s as getBookingOptions,
|
|
24
|
+
y as getHotelImageUrls,
|
|
25
|
+
u as getPointsValue
|
|
22
26
|
};
|