@odynn/awayz-hotels 0.1.1 → 0.1.3
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/HotelResult/HotelResult.js +29 -29
- package/dist/hooks/useHotelSearch/useHotelSearch.js +54 -29
- package/dist/lib/components/HotelResult/HotelResult.d.ts +2 -2
- package/dist/lib/components/HotelResults/HotelResults.d.ts +2 -2
- package/dist/lib/hooks/useHotelSearch/useHotelSearch.types.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as a, jsx as t } from "react/jsx-runtime";
|
|
2
2
|
import { useState as N, useEffect as g } from "react";
|
|
3
3
|
import '../../assets/_styles.css';/* empty css */
|
|
4
|
-
import { o as
|
|
4
|
+
import { o as I } from "../../arrayExtensions-epDH0p9g.js";
|
|
5
5
|
import { UnavailableDate as x } from "../Banners/UnavailableDate/UnavailableDate.js";
|
|
6
6
|
import { c as C, d as H, e as V, f as b } from "../../index-B2vRnlU4.js";
|
|
7
7
|
import { HotelChains as f } from "../../definitions/HotelChains.js";
|
|
@@ -10,10 +10,10 @@ import { getBookingOptions as B } from "../../utilities/hotelUtils/hotelUtils.js
|
|
|
10
10
|
const T = (...e) => e.join(" ");
|
|
11
11
|
function k(e) {
|
|
12
12
|
if (!e || isNaN(e) || e < 0) return "N/A";
|
|
13
|
-
let
|
|
14
|
-
return
|
|
13
|
+
let o = e == null ? void 0 : e.toString().split(".")[0];
|
|
14
|
+
return o == null ? void 0 : o.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
15
15
|
}
|
|
16
|
-
const D = (e,
|
|
16
|
+
const D = (e, o) => {
|
|
17
17
|
if (e <= 0) return "N/A";
|
|
18
18
|
var r = new Intl.NumberFormat("en-US", {
|
|
19
19
|
style: "currency",
|
|
@@ -22,29 +22,29 @@ const D = (e, n) => {
|
|
|
22
22
|
return e ? r.format(Math.round(e)).toString().split(".")[0] : r.format(0);
|
|
23
23
|
}, q = ({
|
|
24
24
|
details: e,
|
|
25
|
-
onHotelSelect:
|
|
25
|
+
onHotelSelect: o,
|
|
26
26
|
onViewDetails: r,
|
|
27
27
|
customStyling: v = !1,
|
|
28
28
|
isSelected: i
|
|
29
29
|
}) => {
|
|
30
30
|
const [m, u] = N(i), {
|
|
31
|
-
transferPartners:
|
|
31
|
+
transferPartners: n,
|
|
32
32
|
bestBookingOption: c,
|
|
33
33
|
alternateBookingOption: s,
|
|
34
34
|
hasPoints: y
|
|
35
|
-
} = B(e), [l, F] = N(0), h =
|
|
35
|
+
} = B(e), [l, F] = N(0), h = n == null ? void 0 : n[l], d = typeof e.cashValue.amount == "number" ? e.cashValue.amount : parseFloat(e.cashValue.amount), p = (h == null ? void 0 : h.value) > 0 || (c == null ? void 0 : c.value) > 0 || (s == null ? void 0 : s.value) > 0 || d > 0;
|
|
36
36
|
g(() => {
|
|
37
37
|
i !== void 0 && u(i);
|
|
38
38
|
}, [i]), g(() => {
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
return F(
|
|
42
|
-
clearTimeout(
|
|
39
|
+
const R = setTimeout(() => {
|
|
40
|
+
const A = l >= (n == null ? void 0 : n.length) - 1 ? 0 : l + 1;
|
|
41
|
+
return F(A), () => {
|
|
42
|
+
clearTimeout(R);
|
|
43
43
|
};
|
|
44
44
|
}, 2e3);
|
|
45
|
-
}, [l,
|
|
45
|
+
}, [l, n == null ? void 0 : n.length]);
|
|
46
46
|
const S = f.isHotelChain(e.hotelGroup);
|
|
47
|
-
return /* @__PURE__ */
|
|
47
|
+
return /* @__PURE__ */ a(
|
|
48
48
|
"div",
|
|
49
49
|
{
|
|
50
50
|
className: T(
|
|
@@ -54,15 +54,15 @@ const D = (e, n) => {
|
|
|
54
54
|
),
|
|
55
55
|
"data-testid": "search-result",
|
|
56
56
|
children: [
|
|
57
|
-
/* @__PURE__ */
|
|
57
|
+
/* @__PURE__ */ a(
|
|
58
58
|
"div",
|
|
59
59
|
{
|
|
60
60
|
className: "content",
|
|
61
61
|
onClick: () => {
|
|
62
|
-
u(!m),
|
|
62
|
+
u(!m), o(e);
|
|
63
63
|
},
|
|
64
64
|
children: [
|
|
65
|
-
/* @__PURE__ */
|
|
65
|
+
/* @__PURE__ */ a("div", { className: "details", children: [
|
|
66
66
|
/* @__PURE__ */ t(
|
|
67
67
|
"div",
|
|
68
68
|
{
|
|
@@ -70,15 +70,15 @@ const D = (e, n) => {
|
|
|
70
70
|
style: {
|
|
71
71
|
backgroundImage: `url(${e.images[0]})`
|
|
72
72
|
},
|
|
73
|
-
children: /* @__PURE__ */
|
|
73
|
+
children: /* @__PURE__ */ a("div", { className: "hotel-chain", children: [
|
|
74
74
|
/* @__PURE__ */ t(C, {}),
|
|
75
75
|
/* @__PURE__ */ t("p", { children: f.toString(e.hotelGroup) })
|
|
76
76
|
] })
|
|
77
77
|
}
|
|
78
78
|
),
|
|
79
|
-
/* @__PURE__ */
|
|
80
|
-
/* @__PURE__ */
|
|
81
|
-
/* @__PURE__ */
|
|
79
|
+
/* @__PURE__ */ a("div", { className: "info", children: [
|
|
80
|
+
/* @__PURE__ */ a("div", { className: "hotel-data", children: [
|
|
81
|
+
/* @__PURE__ */ a("div", { className: "hotel-information", children: [
|
|
82
82
|
/* @__PURE__ */ t(
|
|
83
83
|
j,
|
|
84
84
|
{
|
|
@@ -88,14 +88,14 @@ const D = (e, n) => {
|
|
|
88
88
|
fill: !0
|
|
89
89
|
}
|
|
90
90
|
),
|
|
91
|
-
e.freeNight && /* @__PURE__ */
|
|
91
|
+
e.freeNight && /* @__PURE__ */ a("div", { children: [
|
|
92
92
|
/* @__PURE__ */ t(H, {}),
|
|
93
93
|
/* @__PURE__ */ t("p", { children: "Free Night" })
|
|
94
94
|
] }),
|
|
95
|
-
typeof e.nthNightFree == "number" && e.nthNightFree > 0 && /* @__PURE__ */
|
|
95
|
+
typeof e.nthNightFree == "number" && e.nthNightFree > 0 && /* @__PURE__ */ a("div", { children: [
|
|
96
96
|
/* @__PURE__ */ t(V, {}),
|
|
97
|
-
/* @__PURE__ */
|
|
98
|
-
|
|
97
|
+
/* @__PURE__ */ a("p", { children: [
|
|
98
|
+
I(e.nthNightFree),
|
|
99
99
|
" Night Free"
|
|
100
100
|
] })
|
|
101
101
|
] })
|
|
@@ -115,13 +115,13 @@ const D = (e, n) => {
|
|
|
115
115
|
)
|
|
116
116
|
] })
|
|
117
117
|
] }),
|
|
118
|
-
p && /* @__PURE__ */
|
|
119
|
-
S && /* @__PURE__ */
|
|
118
|
+
p && /* @__PURE__ */ a("div", { className: "payments", children: [
|
|
119
|
+
S && /* @__PURE__ */ a("div", { className: "payment-details", children: [
|
|
120
120
|
/* @__PURE__ */ t("p", { children: "POINTS" }),
|
|
121
121
|
/* @__PURE__ */ t("p", { children: k(e.awardPoints) }),
|
|
122
122
|
e.bestValue === "points" && /* @__PURE__ */ t("p", { className: "best-value", children: "Best Value" })
|
|
123
123
|
] }),
|
|
124
|
-
/* @__PURE__ */
|
|
124
|
+
/* @__PURE__ */ a("div", { className: "payment-details", children: [
|
|
125
125
|
/* @__PURE__ */ t("p", { children: "CASH" }),
|
|
126
126
|
/* @__PURE__ */ t("p", { children: D(d) }),
|
|
127
127
|
e.bestValue === "cash" && /* @__PURE__ */ t("p", { className: "best-value", children: "Best Value" })
|
|
@@ -135,7 +135,7 @@ const D = (e, n) => {
|
|
|
135
135
|
{
|
|
136
136
|
"data-testid": "go-to-journey-button",
|
|
137
137
|
onClick: () => {
|
|
138
|
-
r(e
|
|
138
|
+
r(e);
|
|
139
139
|
},
|
|
140
140
|
children: /* @__PURE__ */ t(b, {})
|
|
141
141
|
}
|
|
@@ -1,32 +1,57 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
import { HotelService as
|
|
3
|
-
import { ESearchType as
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { useState as n } from "react";
|
|
2
|
+
import { HotelService as i } from "../../services/hotel/HotelService.js";
|
|
3
|
+
import { ESearchType as p } from "../../services/hotel/HotelService.types.js";
|
|
4
|
+
import { HotelChains as r } from "../../definitions/HotelChains.js";
|
|
5
|
+
const m = () => {
|
|
6
|
+
const [h, s] = n([]), [u, c] = n(!1), l = (e) => {
|
|
7
|
+
if (!e.checkinDate || !e.checkoutDate)
|
|
8
|
+
throw new Error("Checkin and checkout dates are required");
|
|
9
|
+
if (!e.coordinates)
|
|
10
|
+
throw new Error("Coordinates are required");
|
|
11
|
+
e.hotelGroups && e.hotelGroups.forEach((o) => {
|
|
12
|
+
if (!r.toList().includes(o))
|
|
13
|
+
throw new Error(
|
|
14
|
+
`Invalid hotel group: ${o}. Please use one of the following: ${r.toList().join(
|
|
15
|
+
", "
|
|
16
|
+
)}`
|
|
17
|
+
);
|
|
18
|
+
});
|
|
19
|
+
}, a = async (e) => {
|
|
20
|
+
l(e), c(!0);
|
|
21
|
+
const o = {
|
|
22
|
+
check_in_date: e.checkinDate,
|
|
23
|
+
check_out_date: e.checkoutDate,
|
|
24
|
+
guests: e.guests || 2,
|
|
25
|
+
rooms: e.rooms || 1,
|
|
26
|
+
cash_or_points: e.cashOrPoints || ["cash", "points"],
|
|
27
|
+
currency: e.currency || "USD",
|
|
28
|
+
lat: e.coordinates.latitude,
|
|
29
|
+
lon: e.coordinates.longitude,
|
|
30
|
+
search_range: e.searchRange || 10,
|
|
31
|
+
range_type: e.rangeType || "mi",
|
|
32
|
+
hotel_groups: e.hotelGroups || r.toList(),
|
|
33
|
+
type: e.searchType || p.CITY
|
|
34
|
+
}, t = await i.searchByCoords(o);
|
|
35
|
+
t.success && s(t.data), c(!1);
|
|
36
|
+
}, d = (e) => {
|
|
37
|
+
if (!e.checkinDate || !e.checkoutDate)
|
|
38
|
+
throw new Error("Checkin and checkout dates are required");
|
|
39
|
+
if (!e.hotelId)
|
|
40
|
+
throw new Error("Hotel ID is required");
|
|
41
|
+
if (!e.hotelGroup)
|
|
42
|
+
throw new Error("Hotel group is required");
|
|
43
|
+
if (!r.toList().includes(e.hotelGroup))
|
|
44
|
+
throw new Error(
|
|
45
|
+
`Invalid hotel group: ${e.hotelGroup}. Please use one of the following: ${r.toList().join(", ")}`
|
|
46
|
+
);
|
|
47
|
+
};
|
|
6
48
|
return {
|
|
7
49
|
results: h,
|
|
8
|
-
loading:
|
|
9
|
-
searchByCoords:
|
|
10
|
-
t(!0);
|
|
11
|
-
const c = {
|
|
12
|
-
check_in_date: e.checkinDate,
|
|
13
|
-
check_out_date: e.checkoutDate,
|
|
14
|
-
guests: e.guests || 2,
|
|
15
|
-
rooms: e.rooms || 1,
|
|
16
|
-
cash_or_points: e.cashOrPoints || ["cash", "points"],
|
|
17
|
-
currency: e.currency || "USD",
|
|
18
|
-
lat: e.coords.latitude,
|
|
19
|
-
lon: e.coords.longitude,
|
|
20
|
-
search_range: e.searchRange || 10,
|
|
21
|
-
range_type: e.rangeType || "mi",
|
|
22
|
-
hotel_groups: e.hotelGroups || ["accor"],
|
|
23
|
-
type: e.searchType || u.CITY
|
|
24
|
-
}, o = await n.searchByCoords(c);
|
|
25
|
-
o.success && s(o.data), t(!1);
|
|
26
|
-
},
|
|
50
|
+
loading: u,
|
|
51
|
+
searchByCoords: a,
|
|
27
52
|
searchByHotelId: async (e) => {
|
|
28
|
-
|
|
29
|
-
const
|
|
53
|
+
d(e), c(!0);
|
|
54
|
+
const o = {
|
|
30
55
|
check_in_date: e.checkinDate,
|
|
31
56
|
check_out_date: e.checkoutDate,
|
|
32
57
|
hotel_id: e.hotelId,
|
|
@@ -35,11 +60,11 @@ const _ = () => {
|
|
|
35
60
|
currency: e.currency || "USD",
|
|
36
61
|
cash_or_points: e.cashOrPoints || ["cash", "points"],
|
|
37
62
|
hotel_group: e.hotelGroup
|
|
38
|
-
},
|
|
39
|
-
|
|
63
|
+
}, t = await i.searchByHotelId(o);
|
|
64
|
+
t.success && s(t.data), c(!1);
|
|
40
65
|
}
|
|
41
66
|
};
|
|
42
67
|
};
|
|
43
68
|
export {
|
|
44
|
-
|
|
69
|
+
m as useHotelSearch
|
|
45
70
|
};
|
|
@@ -7,11 +7,11 @@ export interface IHotelResultProps {
|
|
|
7
7
|
/**
|
|
8
8
|
* Callback function to handle the selection of a hotel.
|
|
9
9
|
*/
|
|
10
|
-
onHotelSelect: (
|
|
10
|
+
onHotelSelect: (hotel: IHotelDetails) => void;
|
|
11
11
|
/**
|
|
12
12
|
* Callback function to handle viewing the details of a hotel.
|
|
13
13
|
*/
|
|
14
|
-
onViewDetails: (
|
|
14
|
+
onViewDetails: (hotel: IHotelDetails) => void;
|
|
15
15
|
/**
|
|
16
16
|
* Flag to determine if custom styling should be used. If `false`, the component will use the default Awayz Style.
|
|
17
17
|
*/
|
|
@@ -7,11 +7,11 @@ export interface IHotelResultsProps {
|
|
|
7
7
|
/**
|
|
8
8
|
* Callback function to handle the selection of a hotel.
|
|
9
9
|
*/
|
|
10
|
-
onHotelSelect: (
|
|
10
|
+
onHotelSelect: (hotel: IHotelDetails) => void;
|
|
11
11
|
/**
|
|
12
12
|
* Callback function to handle viewing the details of a hotel.
|
|
13
13
|
*/
|
|
14
|
-
onViewDetails: (
|
|
14
|
+
onViewDetails: (hotel: IHotelDetails) => void;
|
|
15
15
|
/**
|
|
16
16
|
* Flag to determine if custom styling should be used. If `false`, the component will use the default Awayz Style.
|
|
17
17
|
*/
|