@odynn/awayz-hotels 0.1.23 → 0.1.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.
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { useMutation as
|
|
2
|
-
import { HotelService as
|
|
3
|
-
import { ESearchType as
|
|
1
|
+
import { useMutation as h } from "@tanstack/react-query";
|
|
2
|
+
import { HotelService as u } from "../../services/hotel/HotelService.js";
|
|
3
|
+
import { ESearchType as w } 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
|
-
|
|
6
|
+
import D from "../../stores/useHotelsStore.js";
|
|
7
|
+
import { useAwayzContext as S } from "@odynn/awayz-auth";
|
|
8
|
+
const _ = (o) => {
|
|
8
9
|
if (!o.checkinDate || !o.checkoutDate)
|
|
9
10
|
throw new Error("Checkin and checkout dates are required");
|
|
10
11
|
if (!o.coordinates)
|
|
@@ -17,7 +18,7 @@ const w = (o) => {
|
|
|
17
18
|
)}`
|
|
18
19
|
);
|
|
19
20
|
});
|
|
20
|
-
},
|
|
21
|
+
}, E = (o) => {
|
|
21
22
|
if (!o.checkinDate || !o.checkoutDate)
|
|
22
23
|
throw new Error("Checkin and checkout dates are required");
|
|
23
24
|
if (!o.hotelId)
|
|
@@ -28,15 +29,15 @@ const w = (o) => {
|
|
|
28
29
|
throw new Error(
|
|
29
30
|
`Invalid hotel group: ${o.hotelGroup}. Please use one of the following: ${t.toList().join(", ")}`
|
|
30
31
|
);
|
|
31
|
-
},
|
|
32
|
-
const { setHotels: o, hotels: r, setSearchParams:
|
|
33
|
-
mutate:
|
|
34
|
-
status:
|
|
35
|
-
isError:
|
|
36
|
-
error:
|
|
37
|
-
} =
|
|
32
|
+
}, L = () => {
|
|
33
|
+
const { setHotels: o, hotels: r, setSearchParams: i } = D(), { config: n } = S(), {
|
|
34
|
+
mutate: a,
|
|
35
|
+
status: l,
|
|
36
|
+
isError: d,
|
|
37
|
+
error: m
|
|
38
|
+
} = h({
|
|
38
39
|
mutationFn: async (e) => {
|
|
39
|
-
|
|
40
|
+
_(e), i({
|
|
40
41
|
checkinDate: c(e.checkinDate),
|
|
41
42
|
checkoutDate: c(e.checkoutDate),
|
|
42
43
|
guests: e.guests || 2,
|
|
@@ -54,21 +55,22 @@ const w = (o) => {
|
|
|
54
55
|
search_range: e.searchRange || 10,
|
|
55
56
|
range_type: e.rangeType || "mi",
|
|
56
57
|
hotel_groups: e.hotelGroups || t.toList(),
|
|
57
|
-
type: e.searchType ||
|
|
58
|
+
type: e.searchType || w.CITY,
|
|
59
|
+
external_inventory: (n == null ? void 0 : n.externalInventory) || !1
|
|
58
60
|
};
|
|
59
|
-
return await
|
|
61
|
+
return await u.searchByCoords(s);
|
|
60
62
|
},
|
|
61
63
|
onSuccess: (e) => {
|
|
62
64
|
e.success && o(e.data);
|
|
63
65
|
}
|
|
64
66
|
}), {
|
|
65
67
|
mutate: p,
|
|
66
|
-
status:
|
|
67
|
-
isError:
|
|
68
|
-
error:
|
|
69
|
-
} =
|
|
68
|
+
status: k,
|
|
69
|
+
isError: f,
|
|
70
|
+
error: y
|
|
71
|
+
} = h({
|
|
70
72
|
mutationFn: async (e) => {
|
|
71
|
-
|
|
73
|
+
E(e), i({
|
|
72
74
|
checkinDate: c(e.checkinDate),
|
|
73
75
|
checkoutDate: c(e.checkoutDate),
|
|
74
76
|
guests: e.guests || 2,
|
|
@@ -84,7 +86,7 @@ const w = (o) => {
|
|
|
84
86
|
cash_or_points: e.cashOrPoints || ["cash", "points"],
|
|
85
87
|
hotel_group: e.hotelGroup
|
|
86
88
|
};
|
|
87
|
-
return await
|
|
89
|
+
return await u.searchByHotelId(s);
|
|
88
90
|
},
|
|
89
91
|
onSuccess: (e) => {
|
|
90
92
|
e.success && o(e.data);
|
|
@@ -92,15 +94,15 @@ const w = (o) => {
|
|
|
92
94
|
});
|
|
93
95
|
return {
|
|
94
96
|
results: r,
|
|
95
|
-
loading:
|
|
96
|
-
isCoordsSearchError:
|
|
97
|
-
coordsSearchError:
|
|
98
|
-
isHotelIdSearchError:
|
|
99
|
-
hotelIdSearchError:
|
|
100
|
-
searchByCoords:
|
|
97
|
+
loading: l === "pending" || k === "pending",
|
|
98
|
+
isCoordsSearchError: d,
|
|
99
|
+
coordsSearchError: m,
|
|
100
|
+
isHotelIdSearchError: f,
|
|
101
|
+
hotelIdSearchError: y,
|
|
102
|
+
searchByCoords: a,
|
|
101
103
|
searchByHotelId: p
|
|
102
104
|
};
|
|
103
105
|
};
|
|
104
106
|
export {
|
|
105
|
-
|
|
107
|
+
L as useHotelSearch
|
|
106
108
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@odynn/awayz-hotels",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.24",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist"
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
]
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@odynn/awayz-auth": "^0.1.
|
|
68
|
+
"@odynn/awayz-auth": "^0.1.24",
|
|
69
69
|
"@tanstack/react-query": "^5.66.9"
|
|
70
70
|
}
|
|
71
71
|
}
|