@odynn/awayz-hotels 0.2.22 → 0.2.24
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 +40 -39
- package/dist/enums-CEsj8R1d.js +4 -0
- package/dist/hooks/useHotelSearch/useHotelSearch.js +84 -66
- package/dist/hooks/useLocationSearch/useLocationSearch.js +1 -1
- package/dist/lib/hooks/useHotelDetails/useHotelDetails.api.d.ts +1 -1
- package/dist/lib/hooks/useHotelDetails/useHotelDetails.d.ts +1 -1
- package/dist/lib/hooks/useHotelSearch/useHotelSearch.types.d.ts +9 -3
- package/dist/lib/services/hotel/HotelService.d.ts +2 -2
- package/dist/lib/services/hotel/HotelService.types.d.ts +28 -0
- package/dist/lib/utilities/hotelUtils/hotelUtils.d.ts +4 -0
- package/dist/services/hotel/HotelService.js +1 -1
- package/dist/utilities/hotelUtils/hotelUtils.js +52 -48
- package/package.json +2 -2
- package/dist/enums-Boat1JS-.js +0 -4
|
@@ -1,61 +1,62 @@
|
|
|
1
1
|
import { jsxs as o, jsx as t } from "react/jsx-runtime";
|
|
2
|
-
import { useState as
|
|
2
|
+
import { useState as v, useRef as H, 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";
|
|
6
6
|
import "../../arrayExtensions-CFEBYUok.js";
|
|
7
7
|
import { UnavailableDate as B } from "../Banners/UnavailableDate/UnavailableDate.js";
|
|
8
|
-
import { e as
|
|
9
|
-
import { HotelChains as
|
|
8
|
+
import { e as V, f as j, d as w, g as T, h as E } from "../../index-gse40uZM.js";
|
|
9
|
+
import { HotelChains as G } from "../../definitions/HotelChains.js";
|
|
10
10
|
import U, { ERatingColor as z } from "../Banners/Ratings/Ratings.js";
|
|
11
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) {
|
|
15
15
|
if (!e || isNaN(e) || e < 0) return "N/A";
|
|
16
|
-
let
|
|
17
|
-
return
|
|
16
|
+
let i = e == null ? void 0 : e.toString().split(".")[0];
|
|
17
|
+
return i == null ? void 0 : i.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
18
18
|
}
|
|
19
19
|
const oe = ({
|
|
20
20
|
details: e,
|
|
21
|
-
onHotelSelect:
|
|
22
|
-
onViewDetails:
|
|
23
|
-
customStyling:
|
|
24
|
-
isSelected:
|
|
21
|
+
onHotelSelect: i,
|
|
22
|
+
onViewDetails: f,
|
|
23
|
+
customStyling: C = !1,
|
|
24
|
+
isSelected: l,
|
|
25
25
|
showBookableTag: R = !1,
|
|
26
|
-
customBookableTag:
|
|
26
|
+
customBookableTag: y = "Bookable"
|
|
27
27
|
}) => {
|
|
28
28
|
var N;
|
|
29
|
-
const [
|
|
29
|
+
const [r, d] = v(l), u = H(null), {
|
|
30
30
|
transferPartners: a,
|
|
31
|
-
bestBookingOption:
|
|
31
|
+
bestBookingOption: c,
|
|
32
32
|
alternateBookingOption: s,
|
|
33
|
-
hasPoints:
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}, [
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
33
|
+
hasPoints: F,
|
|
34
|
+
cashAmount: p,
|
|
35
|
+
cashCurrency: I,
|
|
36
|
+
isHotelChain: A
|
|
37
|
+
} = D(e), [n, b] = v(0), h = a == null ? void 0 : a[n], g = (h == null ? void 0 : h.value) > 0 || (c == null ? void 0 : c.value) > 0 || (s == null ? void 0 : s.value) > 0 || p > 0;
|
|
38
|
+
return m(() => {
|
|
39
|
+
l !== void 0 && d(l);
|
|
40
|
+
}, [l]), m(() => {
|
|
41
|
+
const k = setTimeout(() => {
|
|
42
|
+
const x = n >= (a == null ? void 0 : a.length) - 1 ? 0 : n + 1;
|
|
43
|
+
return b(x), () => {
|
|
44
|
+
clearTimeout(k);
|
|
42
45
|
};
|
|
43
46
|
}, 2e3);
|
|
44
|
-
}, [
|
|
45
|
-
|
|
46
|
-
return m(() => {
|
|
47
|
-
c && d.current.scrollIntoView({
|
|
47
|
+
}, [n, a == null ? void 0 : a.length]), m(() => {
|
|
48
|
+
r && u.current.scrollIntoView({
|
|
48
49
|
behavior: "smooth",
|
|
49
50
|
block: "center"
|
|
50
51
|
});
|
|
51
|
-
}, [
|
|
52
|
+
}, [r]), /* @__PURE__ */ o(
|
|
52
53
|
"div",
|
|
53
54
|
{
|
|
54
|
-
ref:
|
|
55
|
+
ref: u,
|
|
55
56
|
className: O(
|
|
56
|
-
|
|
57
|
+
C ? "hotel-result" : "awayz-hotel-result",
|
|
57
58
|
// insufficient_points ? 'insufficient-points' : '',
|
|
58
|
-
|
|
59
|
+
r ? "go-to-journey-button" : ""
|
|
59
60
|
),
|
|
60
61
|
"data-testid": "search-result",
|
|
61
62
|
children: [
|
|
@@ -64,7 +65,7 @@ const oe = ({
|
|
|
64
65
|
{
|
|
65
66
|
className: "content",
|
|
66
67
|
onClick: () => {
|
|
67
|
-
|
|
68
|
+
d(!r), i(e);
|
|
68
69
|
},
|
|
69
70
|
children: [
|
|
70
71
|
/* @__PURE__ */ o("div", { className: "details", children: [
|
|
@@ -76,8 +77,8 @@ const oe = ({
|
|
|
76
77
|
backgroundImage: `url(${L(e.images)[0]})`
|
|
77
78
|
},
|
|
78
79
|
children: /* @__PURE__ */ o("div", { className: "hotel-chain", children: [
|
|
79
|
-
/* @__PURE__ */ t(
|
|
80
|
-
/* @__PURE__ */ t("p", { children:
|
|
80
|
+
/* @__PURE__ */ t(V, {}),
|
|
81
|
+
/* @__PURE__ */ t("p", { children: G.toString(e.hotelGroup) })
|
|
81
82
|
] })
|
|
82
83
|
}
|
|
83
84
|
),
|
|
@@ -85,8 +86,8 @@ const oe = ({
|
|
|
85
86
|
/* @__PURE__ */ o("div", { className: "hotel-data", children: [
|
|
86
87
|
/* @__PURE__ */ o("div", { className: "hotel-information", children: [
|
|
87
88
|
!!((N = e.cashBookingOffers) != null && N.accommodationId) && R && /* @__PURE__ */ o("div", { children: [
|
|
88
|
-
/* @__PURE__ */ t(
|
|
89
|
-
/* @__PURE__ */ t("p", { children:
|
|
89
|
+
/* @__PURE__ */ t(j, {}),
|
|
90
|
+
/* @__PURE__ */ t("p", { children: y })
|
|
90
91
|
] }),
|
|
91
92
|
/* @__PURE__ */ t(
|
|
92
93
|
U,
|
|
@@ -98,11 +99,11 @@ const oe = ({
|
|
|
98
99
|
}
|
|
99
100
|
),
|
|
100
101
|
e.freeNight && /* @__PURE__ */ o("div", { children: [
|
|
101
|
-
/* @__PURE__ */ t(
|
|
102
|
+
/* @__PURE__ */ t(w, {}),
|
|
102
103
|
/* @__PURE__ */ t("p", { children: "Free Night" })
|
|
103
104
|
] }),
|
|
104
105
|
typeof e.nthNightFree == "number" && e.nthNightFree > 0 && /* @__PURE__ */ o("div", { children: [
|
|
105
|
-
/* @__PURE__ */ t(
|
|
106
|
+
/* @__PURE__ */ t(T, {}),
|
|
106
107
|
/* @__PURE__ */ o("p", { children: [
|
|
107
108
|
S(e.nthNightFree),
|
|
108
109
|
" Night Free"
|
|
@@ -115,7 +116,7 @@ const oe = ({
|
|
|
115
116
|
/* @__PURE__ */ t(
|
|
116
117
|
B,
|
|
117
118
|
{
|
|
118
|
-
hasPoints:
|
|
119
|
+
hasPoints: F,
|
|
119
120
|
isAvailable: g,
|
|
120
121
|
selectedHotel: () => {
|
|
121
122
|
},
|
|
@@ -132,7 +133,7 @@ const oe = ({
|
|
|
132
133
|
] }),
|
|
133
134
|
/* @__PURE__ */ o("div", { className: "payment-details", children: [
|
|
134
135
|
/* @__PURE__ */ t("p", { children: "CASH" }),
|
|
135
|
-
/* @__PURE__ */ t(M, { amount: p, currency:
|
|
136
|
+
/* @__PURE__ */ t(M, { amount: p, currency: I }),
|
|
136
137
|
e.bestValue === "cash" && /* @__PURE__ */ t("p", { className: "best-value", children: "Best Value" })
|
|
137
138
|
] })
|
|
138
139
|
] })
|
|
@@ -144,7 +145,7 @@ const oe = ({
|
|
|
144
145
|
{
|
|
145
146
|
"data-testid": "go-to-journey-button",
|
|
146
147
|
onClick: () => {
|
|
147
|
-
|
|
148
|
+
f(e);
|
|
148
149
|
},
|
|
149
150
|
children: /* @__PURE__ */ t(E, {})
|
|
150
151
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var C = /* @__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.BANKS = "BANKS", R.CARDS = "CARDS", R.USER_CARDS = "USER_CARDS", R))(C || {});
|
|
2
|
+
export {
|
|
3
|
+
C as E
|
|
4
|
+
};
|
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
import { useMutation as
|
|
2
|
-
import { HotelService as
|
|
3
|
-
import { ESearchType as
|
|
4
|
-
import { HotelChains as
|
|
5
|
-
import { h as
|
|
1
|
+
import { useMutation as d } from "@tanstack/react-query";
|
|
2
|
+
import { HotelService as m } from "../../services/hotel/HotelService.js";
|
|
3
|
+
import { ESearchType as p } from "../../services/hotel/HotelService.types.js";
|
|
4
|
+
import { HotelChains as s } from "../../definitions/HotelChains.js";
|
|
5
|
+
import { h as a } from "../../moment-BGjjqtLQ.js";
|
|
6
6
|
import P from "../../stores/useHotelsStore.js";
|
|
7
|
-
import { useAwayzContext as
|
|
8
|
-
import { g as
|
|
9
|
-
import { E as
|
|
7
|
+
import { useAwayzContext as T, useWallet as B, awayzClient as f } from "@odynn/awayz-core";
|
|
8
|
+
import { g as G } from "../../dateUtils-C1hKW8MF.js";
|
|
9
|
+
import { E as k } from "../../enums-CEsj8R1d.js";
|
|
10
10
|
import "../../arrayExtensions-CFEBYUok.js";
|
|
11
11
|
import "react";
|
|
12
|
-
import { checkNthNightFree as
|
|
12
|
+
import { checkNthNightFree as x } from "../../utilities/hotelUtils/freeNightUtils.js";
|
|
13
13
|
const A = (t) => {
|
|
14
14
|
if (!t.checkinDate || !t.checkoutDate)
|
|
15
15
|
throw new Error("Check-in and checkout dates are required.");
|
|
16
16
|
if (!t.coordinates)
|
|
17
17
|
throw new Error("Coordinates are required.");
|
|
18
|
-
t.hotelGroups && t.hotelGroups.forEach((
|
|
19
|
-
if (!
|
|
18
|
+
t.hotelGroups && t.hotelGroups.forEach((i) => {
|
|
19
|
+
if (!s.toList().includes(i))
|
|
20
20
|
throw new Error(
|
|
21
|
-
`Invalid hotel group: ${
|
|
21
|
+
`Invalid hotel group: ${i}. Please use one of the following: ${s.toList().join(
|
|
22
22
|
", "
|
|
23
23
|
)}`
|
|
24
24
|
);
|
|
25
25
|
});
|
|
26
|
-
},
|
|
26
|
+
}, N = (t) => {
|
|
27
27
|
if (!t.checkinDate || !t.checkoutDate)
|
|
28
28
|
throw new Error("Check-in and checkout dates are required.");
|
|
29
|
-
if (!t.
|
|
30
|
-
throw new Error("Hotel
|
|
29
|
+
if (!t.hotelName)
|
|
30
|
+
throw new Error("Hotel name is required");
|
|
31
31
|
if (!t.hotelGroup)
|
|
32
32
|
throw new Error("Hotel group is required");
|
|
33
|
-
if (!
|
|
33
|
+
if (!s.toList().includes(t.hotelGroup))
|
|
34
34
|
throw new Error(
|
|
35
|
-
`Invalid hotel group: ${t.hotelGroup}. Please use one of the following: ${
|
|
35
|
+
`Invalid hotel group: ${t.hotelGroup}. Please use one of the following: ${s.toList().join(", ")}`
|
|
36
36
|
);
|
|
37
37
|
}, Y = () => {
|
|
38
|
-
const { setHotels: t, hotels:
|
|
39
|
-
mutate:
|
|
40
|
-
isPending:
|
|
41
|
-
status:
|
|
42
|
-
isError:
|
|
43
|
-
error:
|
|
44
|
-
} =
|
|
38
|
+
const { setHotels: t, hotels: i, setSearchParams: l } = P(), { config: u } = T(), { userCards: y } = B(), {
|
|
39
|
+
mutate: D,
|
|
40
|
+
isPending: w,
|
|
41
|
+
status: S,
|
|
42
|
+
isError: _,
|
|
43
|
+
error: E
|
|
44
|
+
} = d({
|
|
45
45
|
mutationFn: async (e) => {
|
|
46
|
-
A(e), t([]),
|
|
47
|
-
checkinDate:
|
|
48
|
-
checkoutDate:
|
|
46
|
+
A(e), t([]), l({
|
|
47
|
+
checkinDate: a(e.checkinDate),
|
|
48
|
+
checkoutDate: a(e.checkoutDate),
|
|
49
49
|
guests: e.guests || 2,
|
|
50
50
|
rooms: e.rooms || 1
|
|
51
51
|
});
|
|
@@ -60,78 +60,96 @@ const A = (t) => {
|
|
|
60
60
|
lon: e.coordinates.longitude,
|
|
61
61
|
search_range: e.searchRange || 10,
|
|
62
62
|
range_type: e.rangeType || "mi",
|
|
63
|
-
hotel_groups: e.hotelGroups ||
|
|
64
|
-
type: e.searchType ||
|
|
65
|
-
external_inventory: (
|
|
63
|
+
hotel_groups: e.hotelGroups || s.toList(),
|
|
64
|
+
type: e.searchType || p.CITY,
|
|
65
|
+
external_inventory: (u == null ? void 0 : u.externalInventory) || !1
|
|
66
66
|
};
|
|
67
67
|
return {
|
|
68
|
-
...await
|
|
68
|
+
...await m.searchByCoords(o),
|
|
69
69
|
checkinDate: e.checkinDate,
|
|
70
70
|
checkoutDate: e.checkoutDate
|
|
71
71
|
};
|
|
72
72
|
},
|
|
73
73
|
onSuccess: (e) => {
|
|
74
74
|
if (e.success) {
|
|
75
|
-
const { checkinDate: o, checkoutDate:
|
|
76
|
-
...
|
|
77
|
-
nthNightFree:
|
|
78
|
-
hotel:
|
|
79
|
-
cards:
|
|
80
|
-
nights:
|
|
75
|
+
const { checkinDate: o, checkoutDate: r } = e, n = G(o, r), h = e.data.map((c) => ({
|
|
76
|
+
...c,
|
|
77
|
+
nthNightFree: x({
|
|
78
|
+
hotel: c,
|
|
79
|
+
cards: y ?? [],
|
|
80
|
+
nights: n
|
|
81
81
|
})
|
|
82
82
|
}));
|
|
83
|
-
t(
|
|
83
|
+
t(h);
|
|
84
84
|
}
|
|
85
85
|
},
|
|
86
86
|
onSettled: () => {
|
|
87
|
-
|
|
87
|
+
f.invalidateQueries({ queryKey: [k.SEARCH_LIMIT] });
|
|
88
88
|
}
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
89
|
+
});
|
|
90
|
+
function C(e, o) {
|
|
91
|
+
let r = 0;
|
|
92
|
+
const n = e.length < o.length ? e : o, h = e.length >= o.length ? e : o;
|
|
93
|
+
for (let c = 0; c < n.length; c++)
|
|
94
|
+
e[c] === o[c] && r++;
|
|
95
|
+
return r / h.length;
|
|
96
|
+
}
|
|
97
|
+
const {
|
|
98
|
+
mutate: H,
|
|
99
|
+
isPending: I,
|
|
100
|
+
status: v,
|
|
101
|
+
isError: L,
|
|
102
|
+
error: q
|
|
103
|
+
} = d({
|
|
96
104
|
mutationFn: async (e) => {
|
|
97
|
-
|
|
98
|
-
checkinDate:
|
|
99
|
-
checkoutDate:
|
|
105
|
+
N(e), t([]), l({
|
|
106
|
+
checkinDate: a(e.checkinDate),
|
|
107
|
+
checkoutDate: a(e.checkoutDate),
|
|
100
108
|
guests: e.guests || 2,
|
|
101
109
|
rooms: e.rooms || 1
|
|
102
110
|
});
|
|
103
111
|
const o = {
|
|
104
112
|
check_in_date: e.checkinDate,
|
|
105
113
|
check_out_date: e.checkoutDate,
|
|
106
|
-
hotel_id: e.hotelId,
|
|
107
|
-
rooms: e.rooms || 1,
|
|
108
114
|
guests: e.guests || 2,
|
|
109
|
-
|
|
115
|
+
rooms: e.rooms || 1,
|
|
110
116
|
cash_or_points: e.cashOrPoints || ["cash", "points"],
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
117
|
+
currency: e.currency || "USD",
|
|
118
|
+
lat: e.coordinates.latitude,
|
|
119
|
+
lon: e.coordinates.longitude,
|
|
120
|
+
search_range: 0.5,
|
|
121
|
+
range_type: "km",
|
|
122
|
+
hotel_groups: [e.hotelGroup],
|
|
123
|
+
type: p.HOTEL,
|
|
124
|
+
external_inventory: !1
|
|
125
|
+
}, r = await m.searchByCoords(o);
|
|
126
|
+
if (!r.success)
|
|
127
|
+
throw new Error(r.message || "Hotel search failed");
|
|
128
|
+
const n = 0.8;
|
|
129
|
+
return r.data.filter(
|
|
130
|
+
(c) => C(c.name.toLowerCase(), e.hotelName.toLowerCase()) >= n
|
|
131
|
+
);
|
|
114
132
|
},
|
|
115
133
|
onSuccess: (e) => {
|
|
116
|
-
|
|
134
|
+
t(e);
|
|
117
135
|
},
|
|
118
136
|
onSettled: () => {
|
|
119
|
-
|
|
137
|
+
f.invalidateQueries({ queryKey: [k.SEARCH_LIMIT] });
|
|
120
138
|
}
|
|
121
139
|
});
|
|
122
140
|
return {
|
|
123
|
-
results:
|
|
124
|
-
loading:
|
|
125
|
-
isCoordsSearchError:
|
|
126
|
-
coordsSearchError:
|
|
127
|
-
isHotelIdSearchError:
|
|
128
|
-
hotelIdSearchError:
|
|
129
|
-
searchByCoords:
|
|
130
|
-
searchByHotelId:
|
|
141
|
+
results: i,
|
|
142
|
+
loading: S === "pending" || v === "pending" || w || I,
|
|
143
|
+
isCoordsSearchError: _,
|
|
144
|
+
coordsSearchError: E,
|
|
145
|
+
isHotelIdSearchError: L,
|
|
146
|
+
hotelIdSearchError: q,
|
|
147
|
+
searchByCoords: D,
|
|
148
|
+
searchByHotelId: H
|
|
131
149
|
};
|
|
132
150
|
};
|
|
133
151
|
export {
|
|
134
152
|
Y as useHotelSearch,
|
|
135
153
|
A as validateSearchByCoordsArgs,
|
|
136
|
-
|
|
154
|
+
N as validateSearchByHotelIdArgs
|
|
137
155
|
};
|
|
@@ -2,7 +2,7 @@ import { useQuery as a } from "@tanstack/react-query";
|
|
|
2
2
|
import { HotelService as m } from "../../services/hotel/HotelService.js";
|
|
3
3
|
import "../../moment-BGjjqtLQ.js";
|
|
4
4
|
import "../../arrayExtensions-CFEBYUok.js";
|
|
5
|
-
import { E as u } from "../../enums-
|
|
5
|
+
import { E as u } from "../../enums-CEsj8R1d.js";
|
|
6
6
|
import { useState as l, useEffect as d } from "react";
|
|
7
7
|
import { defaultSimilarityThreshold as L, defaultLocationSortOrder as f } from "../../configs/defaults.js";
|
|
8
8
|
import { sortLocationResults as p } from "../../utilities/hotelUtils/hotelUtils.js";
|
|
@@ -3,7 +3,7 @@ import { IHotelDetails } from '../../components/HotelResult/HotelResult.types';
|
|
|
3
3
|
import { IRoom } from '../../services/booking/BookingService.types';
|
|
4
4
|
import { IPointsAsCash } from '../../utilities/pointsAsCashUtils';
|
|
5
5
|
import { IBestCheckout } from './useHotelDetails.types';
|
|
6
|
-
export declare const fetchTransferPartners: (hotelGroup: string) => Promise<
|
|
6
|
+
export declare const fetchTransferPartners: (hotelGroup: string) => Promise<import('../../services/hotel/HotelService.types').ITransferPartner[]>;
|
|
7
7
|
interface IPointsCheckResult {
|
|
8
8
|
pointsHotelDetails: IHotelDetails;
|
|
9
9
|
pointsRooms: IRoom[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IHotelDetails } from '../../components/HotelResult/HotelResult.types';
|
|
2
2
|
export declare const useHotelDetails: (hotel: IHotelDetails) => {
|
|
3
|
-
transferPartners:
|
|
3
|
+
transferPartners: import('../../services/hotel/HotelService.types').ITransferPartner[] | undefined;
|
|
4
4
|
loadingTransferPartners: boolean;
|
|
5
5
|
pointsRooms: import('../../main').IRoom[];
|
|
6
6
|
loadingLivePointsCheck: boolean;
|
|
@@ -34,15 +34,21 @@ export interface ISearchByCoordsParams extends ISearchByParams {
|
|
|
34
34
|
}
|
|
35
35
|
export interface ISearchByHotelIdParams extends ISearchByParams {
|
|
36
36
|
/**
|
|
37
|
-
* Required
|
|
38
|
-
* @type
|
|
37
|
+
* Required search coordinates
|
|
38
|
+
* @type ICoordinates
|
|
39
|
+
* @example { latitude: 123.456, longitude: 123.456 }
|
|
39
40
|
*/
|
|
40
|
-
|
|
41
|
+
coordinates: ICoordinates;
|
|
41
42
|
/**
|
|
42
43
|
* Required hotel group
|
|
43
44
|
* @type string
|
|
44
45
|
*/
|
|
45
46
|
hotelGroup: string;
|
|
47
|
+
/**
|
|
48
|
+
* Required hotel name
|
|
49
|
+
* @type string
|
|
50
|
+
*/
|
|
51
|
+
hotelName: string;
|
|
46
52
|
}
|
|
47
53
|
interface ISearchByParams {
|
|
48
54
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IHotelPointsCheckArgs, ISearchByHotelIdRequest, ISearchHotelsParams, ISearchLocation } from './HotelService.types';
|
|
1
|
+
import { IHotelPointsCheckArgs, ISearchByHotelIdRequest, ISearchHotelsParams, ISearchLocation, ITransferPartner } from './HotelService.types';
|
|
2
2
|
import { IHotelDetails, ILiveHotelCheck } from '../../components/HotelResult/HotelResult.types';
|
|
3
3
|
import { TServiceResponse } from '@type-op/shared';
|
|
4
4
|
import { IBestCheckout } from '../../hooks/useHotelDetails/useHotelDetails.types';
|
|
@@ -6,7 +6,7 @@ declare class _HotelService {
|
|
|
6
6
|
getLocations: (searchInputQuery: string) => Promise<TServiceResponse<ISearchLocation[]>>;
|
|
7
7
|
searchByCoords: (request: ISearchHotelsParams) => Promise<TServiceResponse<IHotelDetails[]>>;
|
|
8
8
|
searchByHotelId: (request: ISearchByHotelIdRequest) => Promise<TServiceResponse<IHotelDetails[]>>;
|
|
9
|
-
getTransferPartners: (program: string) => Promise<
|
|
9
|
+
getTransferPartners: (program: string) => Promise<ITransferPartner[]>;
|
|
10
10
|
hotelPointsCheck: (args: IHotelPointsCheckArgs) => Promise<{
|
|
11
11
|
success: any;
|
|
12
12
|
data: ILiveHotelCheck | null;
|
|
@@ -201,4 +201,32 @@ export interface IHotelPointsCheckArgs {
|
|
|
201
201
|
checkinDate: Moment;
|
|
202
202
|
checkoutDate: Moment;
|
|
203
203
|
}
|
|
204
|
+
export interface ITransferPartner {
|
|
205
|
+
partnerProgram: string;
|
|
206
|
+
ratio: number;
|
|
207
|
+
bonus: number;
|
|
208
|
+
transferMinutes: number;
|
|
209
|
+
minimumTransfer: number;
|
|
210
|
+
transferDenominator: number;
|
|
211
|
+
stepBonus: {
|
|
212
|
+
bonus: number;
|
|
213
|
+
stepThreshold: number;
|
|
214
|
+
};
|
|
215
|
+
steps: IStep[];
|
|
216
|
+
shortName: string;
|
|
217
|
+
program: string;
|
|
218
|
+
region: string;
|
|
219
|
+
partnerProgramCategory: string[];
|
|
220
|
+
transferTime: string;
|
|
221
|
+
}
|
|
222
|
+
export interface IStep {
|
|
223
|
+
text: string;
|
|
224
|
+
links: ITransferLink[];
|
|
225
|
+
id: string;
|
|
226
|
+
}
|
|
227
|
+
export interface ITransferLink {
|
|
228
|
+
text: string;
|
|
229
|
+
url: string;
|
|
230
|
+
id: string;
|
|
231
|
+
}
|
|
204
232
|
export {};
|
|
@@ -25,6 +25,10 @@ export declare const getBookingOptions: (searchResult: IHotelDetails) => {
|
|
|
25
25
|
};
|
|
26
26
|
points: number;
|
|
27
27
|
hasPoints: boolean;
|
|
28
|
+
cashAmount: number;
|
|
29
|
+
cashCurrency: string;
|
|
30
|
+
duffelCashBookingOffers: import('../../components/HotelResult/HotelResult.types').ICashBookingOffers | undefined;
|
|
31
|
+
isHotelChain: boolean;
|
|
28
32
|
};
|
|
29
33
|
/**
|
|
30
34
|
* Calculates the points value for a hotel search result based on the hotel group.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { HotelChains as
|
|
2
|
-
var h = class
|
|
3
|
-
static initParams(t,
|
|
4
|
-
return [t.replace(/\s+/g, "").toLowerCase(),
|
|
1
|
+
import { HotelChains as f } from "../../definitions/HotelChains.js";
|
|
2
|
+
var h = class y {
|
|
3
|
+
static initParams(t, o) {
|
|
4
|
+
return [t.replace(/\s+/g, "").toLowerCase(), o.replace(/\s+/g, "").toLowerCase()];
|
|
5
5
|
}
|
|
6
6
|
static checkThanosType(t) {
|
|
7
7
|
if (typeof t != "string") throw new Error("first argument should be a string");
|
|
@@ -11,77 +11,81 @@ var h = class f {
|
|
|
11
11
|
}
|
|
12
12
|
static checkAvengersType(t) {
|
|
13
13
|
if (!Array.isArray(t)) throw new Error("second argument should be an array of strings");
|
|
14
|
-
if (t.find((
|
|
14
|
+
if (t.find((o) => typeof o != "string")) throw new Error("second argument should be an array of strings");
|
|
15
15
|
}
|
|
16
|
-
sortMatch(t,
|
|
17
|
-
return
|
|
16
|
+
sortMatch(t, o) {
|
|
17
|
+
return y.checkThanosType(t), y.checkAvengersType(o), o.map((i, r) => ({ member: i, index: r, rating: this.similarity(t, i) })).sort((i, r) => i.rating - r.rating);
|
|
18
18
|
}
|
|
19
|
-
},
|
|
19
|
+
}, g = class extends h {
|
|
20
20
|
similarity(e, t) {
|
|
21
21
|
h.checkThanosType(e), h.checkRivalType(t);
|
|
22
|
-
let [
|
|
23
|
-
if (!
|
|
24
|
-
if (
|
|
25
|
-
let
|
|
26
|
-
for (let n = 0; n <
|
|
27
|
-
let s =
|
|
28
|
-
|
|
22
|
+
let [o, i] = h.initParams(e, t), [r, a] = [o.length, i.length];
|
|
23
|
+
if (!o.length && !i.length || o === i) return 1;
|
|
24
|
+
if (r < 2 || a < 2) return 0;
|
|
25
|
+
let c = /* @__PURE__ */ new Map();
|
|
26
|
+
for (let n = 0; n < r - 1; n++) {
|
|
27
|
+
let s = o.slice(n, n + 2), p = c.has(s) ? c.get(s) + 1 : 1;
|
|
28
|
+
c.set(s, p);
|
|
29
29
|
}
|
|
30
30
|
let l = 0;
|
|
31
|
-
for (let n = 0; n <
|
|
32
|
-
let s =
|
|
33
|
-
p > 0 && (
|
|
31
|
+
for (let n = 0; n < a - 1; n++) {
|
|
32
|
+
let s = i.slice(n, n + 2), p = c.has(s) ? c.get(s) : 0;
|
|
33
|
+
p > 0 && (c.set(s, p - 1), ++l);
|
|
34
34
|
}
|
|
35
|
-
return 2 * l / (
|
|
35
|
+
return 2 * l / (r + a - 2);
|
|
36
36
|
}
|
|
37
37
|
distance(e, t) {
|
|
38
38
|
return 1 - this.similarity(e, t);
|
|
39
39
|
}
|
|
40
|
-
},
|
|
41
|
-
const
|
|
42
|
-
var
|
|
43
|
-
const t = e.freeNight || e.nthNightFree !== 0 ? e.awardPoints : e.points,
|
|
40
|
+
}, m = new g(), w = { diceCoefficient: m }, d = w;
|
|
41
|
+
const b = (e) => {
|
|
42
|
+
var p;
|
|
43
|
+
const t = e.freeNight || e.nthNightFree !== 0 ? e.awardPoints : e.points, o = {
|
|
44
44
|
type: "",
|
|
45
45
|
value: -1
|
|
46
|
-
},
|
|
47
|
-
return e.bestValue === "cash" ? (
|
|
48
|
-
transferPartners: ((
|
|
49
|
-
...
|
|
50
|
-
value: t ? Math.ceil(t *
|
|
46
|
+
}, i = typeof e.cashValue.amount == "number" ? e.cashValue.amount : parseFloat(e.cashValue.amount), r = { ...o }, { cashBookingOffers: a } = e, { currency: c } = e.cashValue, l = a == null ? void 0 : a.cheapestRateTotalAmount, n = l && l > 0 ? l : i, s = f.isHotelChain(e.hotelGroup);
|
|
47
|
+
return e.bestValue === "cash" ? (o.type = "cash", o.value = n, r.type = "points", r.value = t || -1) : e.bestValue === "points" && (o.type = "points", o.value = t || -1, r.type = "cash", r.value = n), {
|
|
48
|
+
transferPartners: ((p = e.partners) == null ? void 0 : p.map((u) => ({
|
|
49
|
+
...u,
|
|
50
|
+
value: t ? Math.ceil(t * u.ratio) : -1
|
|
51
51
|
}))) || [],
|
|
52
|
-
bestBookingOption:
|
|
53
|
-
alternateBookingOption:
|
|
52
|
+
bestBookingOption: o,
|
|
53
|
+
alternateBookingOption: r,
|
|
54
54
|
points: t || -1,
|
|
55
|
-
hasPoints: typeof t == "number" && t > 0
|
|
55
|
+
hasPoints: typeof t == "number" && t > 0,
|
|
56
|
+
cashAmount: n,
|
|
57
|
+
cashCurrency: c,
|
|
58
|
+
duffelCashBookingOffers: a,
|
|
59
|
+
isHotelChain: s
|
|
56
60
|
};
|
|
57
|
-
},
|
|
61
|
+
}, C = (e) => (e == null ? void 0 : e.hotelGroup) === f.IHG ? e.freeNight || e.nthNightFree ? e.awardPoints : e.points : e.awardPoints;
|
|
58
62
|
function k(e) {
|
|
59
63
|
return !e || !Array.isArray(e) || e.length === 0 ? [] : e.map((t) => typeof t == "string" ? t : t && typeof t == "object" && "url" in t ? t.url : "").filter((t) => t !== "");
|
|
60
64
|
}
|
|
61
|
-
const
|
|
62
|
-
const
|
|
63
|
-
return
|
|
64
|
-
},
|
|
65
|
-
const
|
|
65
|
+
const v = (e, t) => {
|
|
66
|
+
const o = e.toLowerCase().trim(), i = t.toLowerCase().trim();
|
|
67
|
+
return d.diceCoefficient.similarity(o, i) * 100;
|
|
68
|
+
}, A = (e, t, o, i) => {
|
|
69
|
+
const r = e.toLowerCase().trim(), a = i.map((n) => {
|
|
66
70
|
const s = n.description.toLowerCase().trim();
|
|
67
71
|
return {
|
|
68
72
|
...n,
|
|
69
|
-
score:
|
|
73
|
+
score: v(e, n.description),
|
|
70
74
|
startsWithText: s
|
|
71
75
|
};
|
|
72
|
-
}),
|
|
73
|
-
(n) => n.startsWithText.startsWith(
|
|
74
|
-
), l =
|
|
76
|
+
}), c = a.filter(
|
|
77
|
+
(n) => n.startsWithText.startsWith(r) && n.score >= t
|
|
78
|
+
), l = a.filter(
|
|
75
79
|
(n) => n.score < t
|
|
76
80
|
);
|
|
77
|
-
return
|
|
78
|
-
(n, s) =>
|
|
79
|
-
), [...
|
|
81
|
+
return c.sort((n, s) => s.score - n.score), l.sort(
|
|
82
|
+
(n, s) => o[n.searchType] - o[s.searchType]
|
|
83
|
+
), [...c, ...l];
|
|
80
84
|
};
|
|
81
85
|
export {
|
|
82
|
-
|
|
83
|
-
|
|
86
|
+
v as calculateStringSimilarity,
|
|
87
|
+
b as getBookingOptions,
|
|
84
88
|
k as getHotelImageUrls,
|
|
85
|
-
|
|
86
|
-
|
|
89
|
+
C as getPointsValue,
|
|
90
|
+
A as sortLocationResults
|
|
87
91
|
};
|
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.24",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist"
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
]
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@odynn/awayz-core": "^0.2.
|
|
64
|
+
"@odynn/awayz-core": "^0.2.28",
|
|
65
65
|
"@tanstack/react-query": "^5.66.9",
|
|
66
66
|
"string-comparison": "^1.3.0"
|
|
67
67
|
}
|
package/dist/enums-Boat1JS-.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
var R = /* @__PURE__ */ ((C) => (C.LOCATIONS = "LOCATIONS", C.CHECK_USER = "CHECK_USER", C.USER_REGIONS = "USER_REGIONS", C.CONVERT_CURRENCY = "CONVERT_CURRENCY", C.CLIENT_COMPONENT_KEY = "CLIENT_COMPONENT_KEY", C.SEARCH_LIMIT = "SEARCH_LIMIT", C.PROGRAMS = "PROGRAMS", C.BANKS = "BANKS", C.CARDS = "CARDS", C))(R || {});
|
|
2
|
-
export {
|
|
3
|
-
R as E
|
|
4
|
-
};
|