@odynn/awayz-hotels 0.2.10 → 0.2.11
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,48 +1,48 @@
|
|
|
1
1
|
import { jsxs as o, jsx as t } from "react/jsx-runtime";
|
|
2
|
-
import { useState as
|
|
2
|
+
import { useState as N, useRef as x, useEffect as m } from "react";
|
|
3
3
|
import '../../assets/_styles.css';/* empty css */
|
|
4
|
-
import { o as
|
|
4
|
+
import { o as S } from "../../stringUtils-CvWpky85.js";
|
|
5
5
|
import "../../moment-BGjjqtLQ.js";
|
|
6
6
|
import "../../arrayExtensions-cyilNkdJ.js";
|
|
7
|
-
import { UnavailableDate as
|
|
8
|
-
import { c as
|
|
9
|
-
import { HotelChains as
|
|
10
|
-
import
|
|
11
|
-
import { getBookingOptions as
|
|
12
|
-
import { CashValue as
|
|
13
|
-
const
|
|
14
|
-
function
|
|
7
|
+
import { UnavailableDate as B } from "../Banners/UnavailableDate/UnavailableDate.js";
|
|
8
|
+
import { c as j, d as w, e as T, f as G, g as E } from "../../index-D8bHwbxH.js";
|
|
9
|
+
import { HotelChains as v } from "../../definitions/HotelChains.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
|
+
import { CashValue as M } from "@odynn/awayz-core";
|
|
13
|
+
const O = (...e) => e.join(" ");
|
|
14
|
+
function P(e) {
|
|
15
15
|
if (!e || isNaN(e) || e < 0) return "N/A";
|
|
16
|
-
let
|
|
17
|
-
return
|
|
16
|
+
let n = e == null ? void 0 : e.toString().split(".")[0];
|
|
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
|
-
onHotelSelect:
|
|
22
|
-
onViewDetails:
|
|
23
|
-
customStyling:
|
|
24
|
-
isSelected:
|
|
25
|
-
showBookableTag:
|
|
26
|
-
customBookableTag:
|
|
21
|
+
onHotelSelect: n,
|
|
22
|
+
onViewDetails: C,
|
|
23
|
+
customStyling: y = !1,
|
|
24
|
+
isSelected: c,
|
|
25
|
+
showBookableTag: R = !1,
|
|
26
|
+
customBookableTag: F = "Bookable"
|
|
27
27
|
}) => {
|
|
28
|
-
var f
|
|
29
|
-
const [r, u] =
|
|
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
|
-
|
|
37
|
-
}, [
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
return
|
|
41
|
-
clearTimeout(
|
|
36
|
+
c !== void 0 && u(c);
|
|
37
|
+
}, [c]), m(() => {
|
|
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
|
-
const
|
|
45
|
+
const A = v.isHotelChain(e.hotelGroup);
|
|
46
46
|
return m(() => {
|
|
47
47
|
r && d.current.scrollIntoView({
|
|
48
48
|
behavior: "smooth",
|
|
@@ -52,8 +52,8 @@ const ce = ({
|
|
|
52
52
|
"div",
|
|
53
53
|
{
|
|
54
54
|
ref: d,
|
|
55
|
-
className:
|
|
56
|
-
|
|
55
|
+
className: O(
|
|
56
|
+
y ? "hotel-result" : "awayz-hotel-result",
|
|
57
57
|
// insufficient_points ? 'insufficient-points' : '',
|
|
58
58
|
r ? "go-to-journey-button" : ""
|
|
59
59
|
),
|
|
@@ -64,7 +64,7 @@ const ce = ({
|
|
|
64
64
|
{
|
|
65
65
|
className: "content",
|
|
66
66
|
onClick: () => {
|
|
67
|
-
u(!r),
|
|
67
|
+
u(!r), n(e);
|
|
68
68
|
},
|
|
69
69
|
children: [
|
|
70
70
|
/* @__PURE__ */ o("div", { className: "details", children: [
|
|
@@ -73,38 +73,38 @@ const ce = ({
|
|
|
73
73
|
{
|
|
74
74
|
className: "hotel-image",
|
|
75
75
|
style: {
|
|
76
|
-
backgroundImage: `url(${
|
|
76
|
+
backgroundImage: `url(${L(e.images)[0]})`
|
|
77
77
|
},
|
|
78
78
|
children: /* @__PURE__ */ o("div", { className: "hotel-chain", children: [
|
|
79
|
-
/* @__PURE__ */ t(
|
|
80
|
-
/* @__PURE__ */ t("p", { children:
|
|
79
|
+
/* @__PURE__ */ t(j, {}),
|
|
80
|
+
/* @__PURE__ */ t("p", { children: v.toString(e.hotelGroup) })
|
|
81
81
|
] })
|
|
82
82
|
}
|
|
83
83
|
),
|
|
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
|
-
!!((
|
|
88
|
-
/* @__PURE__ */ t(
|
|
89
|
-
/* @__PURE__ */ t("p", { children:
|
|
87
|
+
!!((f = e.cashBookingOffers) != null && f.accommodationId) && R && /* @__PURE__ */ o("div", { children: [
|
|
88
|
+
/* @__PURE__ */ t(w, {}),
|
|
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
|
}
|
|
99
99
|
),
|
|
100
100
|
e.freeNight && /* @__PURE__ */ o("div", { children: [
|
|
101
|
-
/* @__PURE__ */ t(
|
|
101
|
+
/* @__PURE__ */ t(T, {}),
|
|
102
102
|
/* @__PURE__ */ t("p", { children: "Free Night" })
|
|
103
103
|
] }),
|
|
104
104
|
typeof e.nthNightFree == "number" && e.nthNightFree > 0 && /* @__PURE__ */ o("div", { children: [
|
|
105
|
-
/* @__PURE__ */ t(
|
|
105
|
+
/* @__PURE__ */ t(G, {}),
|
|
106
106
|
/* @__PURE__ */ o("p", { children: [
|
|
107
|
-
|
|
107
|
+
S(e.nthNightFree),
|
|
108
108
|
" Night Free"
|
|
109
109
|
] })
|
|
110
110
|
] })
|
|
@@ -113,9 +113,9 @@ const ce = ({
|
|
|
113
113
|
/* @__PURE__ */ t("p", { className: "hotel-address", children: e.address })
|
|
114
114
|
] }),
|
|
115
115
|
/* @__PURE__ */ t(
|
|
116
|
-
|
|
116
|
+
B,
|
|
117
117
|
{
|
|
118
|
-
hasPoints:
|
|
118
|
+
hasPoints: I,
|
|
119
119
|
isAvailable: g,
|
|
120
120
|
selectedHotel: () => {
|
|
121
121
|
},
|
|
@@ -125,14 +125,14 @@ const ce = ({
|
|
|
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
|
-
/* @__PURE__ */ t("p", { children:
|
|
130
|
+
/* @__PURE__ */ t("p", { children: P(e.awardPoints) }),
|
|
131
131
|
e.bestValue === "points" && /* @__PURE__ */ t("p", { className: "best-value", children: "Best Value" })
|
|
132
132
|
] }),
|
|
133
133
|
/* @__PURE__ */ o("div", { className: "payment-details", children: [
|
|
134
134
|
/* @__PURE__ */ t("p", { children: "CASH" }),
|
|
135
|
-
/* @__PURE__ */ t(
|
|
135
|
+
/* @__PURE__ */ t(M, { amount: p, currency: b }),
|
|
136
136
|
e.bestValue === "cash" && /* @__PURE__ */ t("p", { className: "best-value", children: "Best Value" })
|
|
137
137
|
] })
|
|
138
138
|
] })
|
|
@@ -144,9 +144,9 @@ const ce = ({
|
|
|
144
144
|
{
|
|
145
145
|
"data-testid": "go-to-journey-button",
|
|
146
146
|
onClick: () => {
|
|
147
|
-
|
|
147
|
+
C(e);
|
|
148
148
|
},
|
|
149
|
-
children: /* @__PURE__ */ t(
|
|
149
|
+
children: /* @__PURE__ */ t(E, {})
|
|
150
150
|
}
|
|
151
151
|
)
|
|
152
152
|
]
|
|
@@ -154,5 +154,5 @@ const ce = ({
|
|
|
154
154
|
);
|
|
155
155
|
};
|
|
156
156
|
export {
|
|
157
|
-
|
|
157
|
+
oe as HotelResult
|
|
158
158
|
};
|
|
@@ -69,22 +69,6 @@ const t = {
|
|
|
69
69
|
}
|
|
70
70
|
return "#212121";
|
|
71
71
|
},
|
|
72
|
-
// TODO: Update this to correct type
|
|
73
|
-
// toPartner: (partner: any) => {
|
|
74
|
-
// switch (partner.program?.toLowerCase()) {
|
|
75
|
-
// case 'amex membership rewards points':
|
|
76
|
-
// return 'AMEX MR';
|
|
77
|
-
// case 'bilt rewards':
|
|
78
|
-
// return 'Bilt Rewards';
|
|
79
|
-
// case 'chase ultimate rewards points':
|
|
80
|
-
// return 'Chase UR';
|
|
81
|
-
// case 'virgin atlantic':
|
|
82
|
-
// return 'Virgin Atlantic';
|
|
83
|
-
// case 'capital one miles':
|
|
84
|
-
// return 'Capital One';
|
|
85
|
-
// }
|
|
86
|
-
// return partner.program;
|
|
87
|
-
// },
|
|
88
72
|
toProgram: (e) => {
|
|
89
73
|
switch (e == null ? void 0 : e.toLowerCase()) {
|
|
90
74
|
case t.Marriott:
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import { useMutation as
|
|
2
|
-
import { HotelService as
|
|
3
|
-
import { ESearchType as
|
|
1
|
+
import { useMutation as u } from "@tanstack/react-query";
|
|
2
|
+
import { HotelService as a } from "../../services/hotel/HotelService.js";
|
|
3
|
+
import { ESearchType as I } from "../../services/hotel/HotelService.types.js";
|
|
4
4
|
import { HotelChains as t } from "../../definitions/HotelChains.js";
|
|
5
5
|
import { h as c } from "../../moment-BGjjqtLQ.js";
|
|
6
|
-
import
|
|
7
|
-
import { useAwayzContext as
|
|
8
|
-
|
|
6
|
+
import f from "../../stores/useHotelsStore.js";
|
|
7
|
+
import { useAwayzContext as w, awayzClient as l } from "@odynn/awayz-core";
|
|
8
|
+
import "../../arrayExtensions-cyilNkdJ.js";
|
|
9
|
+
import "react";
|
|
10
|
+
var s = /* @__PURE__ */ ((o) => (o.CHECK_USER = "CHECK_USER", o.USER_REGIONS = "USER_REGIONS", o.CONVERT_CURRENCY = "CONVERT_CURRENCY", o.CLIENT_COMPONENT_KEY = "CLIENT_COMPONENT_KEY", o.SEARCH_LIMIT = "SEARCH_LIMIT", o))(s || {});
|
|
11
|
+
const D = (o) => {
|
|
9
12
|
if (!o.checkinDate || !o.checkoutDate)
|
|
10
13
|
throw new Error("Checkin and checkout dates are required");
|
|
11
14
|
if (!o.coordinates)
|
|
@@ -18,7 +21,7 @@ const _ = (o) => {
|
|
|
18
21
|
)}`
|
|
19
22
|
);
|
|
20
23
|
});
|
|
21
|
-
},
|
|
24
|
+
}, y = (o) => {
|
|
22
25
|
if (!o.checkinDate || !o.checkoutDate)
|
|
23
26
|
throw new Error("Checkin and checkout dates are required");
|
|
24
27
|
if (!o.hotelId)
|
|
@@ -29,21 +32,21 @@ const _ = (o) => {
|
|
|
29
32
|
throw new Error(
|
|
30
33
|
`Invalid hotel group: ${o.hotelGroup}. Please use one of the following: ${t.toList().join(", ")}`
|
|
31
34
|
);
|
|
32
|
-
},
|
|
33
|
-
const { setHotels: o, hotels: r, setSearchParams:
|
|
34
|
-
mutate:
|
|
35
|
-
status:
|
|
36
|
-
isError:
|
|
37
|
-
error:
|
|
38
|
-
} =
|
|
35
|
+
}, U = () => {
|
|
36
|
+
const { setHotels: o, hotels: r, setSearchParams: h } = f(), { config: i } = w(), {
|
|
37
|
+
mutate: d,
|
|
38
|
+
status: E,
|
|
39
|
+
isError: _,
|
|
40
|
+
error: S
|
|
41
|
+
} = u({
|
|
39
42
|
mutationFn: async (e) => {
|
|
40
|
-
|
|
43
|
+
D(e), o([]), h({
|
|
41
44
|
checkinDate: c(e.checkinDate),
|
|
42
45
|
checkoutDate: c(e.checkoutDate),
|
|
43
46
|
guests: e.guests || 2,
|
|
44
47
|
rooms: e.rooms || 1
|
|
45
48
|
});
|
|
46
|
-
const
|
|
49
|
+
const n = {
|
|
47
50
|
check_in_date: e.checkinDate,
|
|
48
51
|
check_out_date: e.checkoutDate,
|
|
49
52
|
guests: e.guests || 2,
|
|
@@ -55,28 +58,31 @@ const _ = (o) => {
|
|
|
55
58
|
search_range: e.searchRange || 10,
|
|
56
59
|
range_type: e.rangeType || "mi",
|
|
57
60
|
hotel_groups: e.hotelGroups || t.toList(),
|
|
58
|
-
type: e.searchType ||
|
|
59
|
-
external_inventory: (
|
|
61
|
+
type: e.searchType || I.CITY,
|
|
62
|
+
external_inventory: (i == null ? void 0 : i.externalInventory) || !1
|
|
60
63
|
};
|
|
61
|
-
return await
|
|
64
|
+
return await a.searchByCoords(n);
|
|
62
65
|
},
|
|
63
66
|
onSuccess: (e) => {
|
|
64
67
|
e.success && o(e.data);
|
|
68
|
+
},
|
|
69
|
+
onSettled: () => {
|
|
70
|
+
l.invalidateQueries({ queryKey: [s.SEARCH_LIMIT] });
|
|
65
71
|
}
|
|
66
72
|
}), {
|
|
67
|
-
mutate:
|
|
68
|
-
status:
|
|
69
|
-
isError:
|
|
70
|
-
error:
|
|
71
|
-
} =
|
|
73
|
+
mutate: m,
|
|
74
|
+
status: p,
|
|
75
|
+
isError: C,
|
|
76
|
+
error: k
|
|
77
|
+
} = u({
|
|
72
78
|
mutationFn: async (e) => {
|
|
73
|
-
|
|
79
|
+
y(e), o([]), h({
|
|
74
80
|
checkinDate: c(e.checkinDate),
|
|
75
81
|
checkoutDate: c(e.checkoutDate),
|
|
76
82
|
guests: e.guests || 2,
|
|
77
83
|
rooms: e.rooms || 1
|
|
78
84
|
});
|
|
79
|
-
const
|
|
85
|
+
const n = {
|
|
80
86
|
check_in_date: e.checkinDate,
|
|
81
87
|
check_out_date: e.checkoutDate,
|
|
82
88
|
hotel_id: e.hotelId,
|
|
@@ -86,23 +92,26 @@ const _ = (o) => {
|
|
|
86
92
|
cash_or_points: e.cashOrPoints || ["cash", "points"],
|
|
87
93
|
hotel_group: e.hotelGroup
|
|
88
94
|
};
|
|
89
|
-
return await
|
|
95
|
+
return await a.searchByHotelId(n);
|
|
90
96
|
},
|
|
91
97
|
onSuccess: (e) => {
|
|
92
98
|
e.success && o(e.data);
|
|
99
|
+
},
|
|
100
|
+
onSettled: () => {
|
|
101
|
+
l.invalidateQueries({ queryKey: [s.SEARCH_LIMIT] });
|
|
93
102
|
}
|
|
94
103
|
});
|
|
95
104
|
return {
|
|
96
105
|
results: r,
|
|
97
|
-
loading:
|
|
98
|
-
isCoordsSearchError:
|
|
99
|
-
coordsSearchError:
|
|
100
|
-
isHotelIdSearchError:
|
|
101
|
-
hotelIdSearchError:
|
|
102
|
-
searchByCoords:
|
|
103
|
-
searchByHotelId:
|
|
106
|
+
loading: E === "pending" || p === "pending",
|
|
107
|
+
isCoordsSearchError: _,
|
|
108
|
+
coordsSearchError: S,
|
|
109
|
+
isHotelIdSearchError: C,
|
|
110
|
+
hotelIdSearchError: k,
|
|
111
|
+
searchByCoords: d,
|
|
112
|
+
searchByHotelId: m
|
|
104
113
|
};
|
|
105
114
|
};
|
|
106
115
|
export {
|
|
107
|
-
|
|
116
|
+
U as useHotelSearch
|
|
108
117
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@odynn/awayz-hotels",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.11",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist"
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
]
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@odynn/awayz-core": "^0.2.
|
|
68
|
+
"@odynn/awayz-core": "^0.2.17",
|
|
69
69
|
"@tanstack/react-query": "^5.66.9"
|
|
70
70
|
}
|
|
71
71
|
}
|