@odynn/awayz-hotels 0.13.0 → 0.13.2
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/hooks/useAvailabilityAlertNotifications/useAvailabilityAlertNotifications.js +17 -16
- package/dist/hooks/useAvailabilityAlerts/useAvailabilityAlerts.js +73 -71
- package/dist/lib/components/HotelResult/HotelResult.types.d.ts +1 -0
- package/dist/lib/main.d.ts +1 -0
- package/dist/lib/services/hotel/HotelService.types.d.ts +1 -0
- package/dist/main.js +28 -25
- package/dist/services/hotel/HotelService.mappers.js +8 -7
- package/package.json +1 -1
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
import { awayzClient as i } from "@odynn/awayz-core";
|
|
2
|
-
import { useQuery as
|
|
1
|
+
import { useAwayzContext as y, awayzClient as i } from "@odynn/awayz-core";
|
|
2
|
+
import { useQuery as c, useMutation as d } from "@tanstack/react-query";
|
|
3
3
|
import "react/jsx-runtime";
|
|
4
4
|
import "../../moment-BGjjqtLQ.js";
|
|
5
5
|
import "../../arrayExtensions-CFEBYUok.js";
|
|
6
6
|
import { E as e } from "../../enums-DPFgYLjY.js";
|
|
7
7
|
import "react";
|
|
8
8
|
import { AvailabilityAlertsService as r } from "../../services/availabilityAlerts/AvailabilityAlertsService.js";
|
|
9
|
-
const
|
|
10
|
-
const {
|
|
11
|
-
data:
|
|
9
|
+
const w = () => {
|
|
10
|
+
const { isAuthenticated: a } = y(), {
|
|
11
|
+
data: n = [],
|
|
12
12
|
error: o,
|
|
13
|
-
isPending:
|
|
14
|
-
} =
|
|
13
|
+
isPending: u
|
|
14
|
+
} = c({
|
|
15
15
|
queryKey: [e.ALERT_NOTIFICATIONS],
|
|
16
|
-
queryFn: () => r.getAlertNotifications()
|
|
16
|
+
queryFn: () => r.getAlertNotifications(),
|
|
17
|
+
enabled: a
|
|
17
18
|
}), {
|
|
18
|
-
mutate:
|
|
19
|
-
error:
|
|
19
|
+
mutate: l,
|
|
20
|
+
error: s,
|
|
20
21
|
isPending: A
|
|
21
|
-
} =
|
|
22
|
+
} = d({
|
|
22
23
|
mutationFn: async (t) => {
|
|
23
24
|
await r.updateAvailabilityAlert(t);
|
|
24
25
|
},
|
|
@@ -31,14 +32,14 @@ const N = () => {
|
|
|
31
32
|
}
|
|
32
33
|
});
|
|
33
34
|
return {
|
|
34
|
-
availabilityAlertNotifications:
|
|
35
|
-
updateAcknowledgement: (t,
|
|
36
|
-
mutateError:
|
|
35
|
+
availabilityAlertNotifications: n,
|
|
36
|
+
updateAcknowledgement: (t, m = !0) => l({ alertId: t, acknowledged: m }),
|
|
37
|
+
mutateError: s,
|
|
37
38
|
mutatePending: A,
|
|
38
39
|
fetchError: o,
|
|
39
|
-
fetchPending:
|
|
40
|
+
fetchPending: u
|
|
40
41
|
};
|
|
41
42
|
};
|
|
42
43
|
export {
|
|
43
|
-
|
|
44
|
+
w as useAvailabilityAlertNotifications
|
|
44
45
|
};
|
|
@@ -1,92 +1,94 @@
|
|
|
1
|
-
import { awayzClient as v } from "@odynn/awayz-core";
|
|
2
|
-
import { useQuery as
|
|
1
|
+
import { useAwayzContext as p, awayzClient as v } from "@odynn/awayz-core";
|
|
2
|
+
import { useQuery as E, useMutation as b } from "@tanstack/react-query";
|
|
3
3
|
import "react/jsx-runtime";
|
|
4
4
|
import "../../moment-BGjjqtLQ.js";
|
|
5
5
|
import "../../arrayExtensions-CFEBYUok.js";
|
|
6
6
|
import { E as u } from "../../enums-DPFgYLjY.js";
|
|
7
7
|
import "react";
|
|
8
|
-
import { AvailabilityAlertsService as
|
|
9
|
-
const
|
|
10
|
-
checkin:
|
|
8
|
+
import { AvailabilityAlertsService as w } from "../../services/availabilityAlerts/AvailabilityAlertsService.js";
|
|
9
|
+
const h = ({
|
|
10
|
+
checkin: e,
|
|
11
11
|
checkout: t,
|
|
12
|
-
hotelGroup:
|
|
13
|
-
hotelId:
|
|
14
|
-
name:
|
|
15
|
-
hotelImage:
|
|
16
|
-
hotelAddress:
|
|
17
|
-
hotelDescription:
|
|
18
|
-
hotelProgramName:
|
|
12
|
+
hotelGroup: o,
|
|
13
|
+
hotelId: n,
|
|
14
|
+
name: l,
|
|
15
|
+
hotelImage: s,
|
|
16
|
+
hotelAddress: A,
|
|
17
|
+
hotelDescription: i,
|
|
18
|
+
hotelProgramName: d
|
|
19
19
|
}) => {
|
|
20
|
-
if (!
|
|
20
|
+
if (!n)
|
|
21
21
|
throw new Error("Hotel ID is required");
|
|
22
|
-
if (!
|
|
22
|
+
if (!e)
|
|
23
23
|
throw new Error("Check-in date is required");
|
|
24
|
-
if (new Date(
|
|
24
|
+
if (new Date(e) <= /* @__PURE__ */ new Date())
|
|
25
25
|
throw new Error("Check-in date must be in the future");
|
|
26
26
|
if (!t)
|
|
27
27
|
throw new Error("Check-out date is required");
|
|
28
28
|
if (new Date(t) <= /* @__PURE__ */ new Date())
|
|
29
29
|
throw new Error("Check-out date must be in the future");
|
|
30
|
-
if (new Date(t) <= new Date(
|
|
30
|
+
if (new Date(t) <= new Date(e))
|
|
31
31
|
throw new Error("Check-out date must be after check-in date");
|
|
32
|
-
if (!
|
|
32
|
+
if (!l)
|
|
33
33
|
throw new Error("Hotel name is required");
|
|
34
|
-
if (!
|
|
34
|
+
if (!o)
|
|
35
35
|
throw new Error("Hotel group is required");
|
|
36
|
-
if (!
|
|
36
|
+
if (!s)
|
|
37
37
|
throw new Error("Hotel image is required");
|
|
38
|
-
if (!
|
|
38
|
+
if (!A)
|
|
39
39
|
throw new Error("Hotel address is required");
|
|
40
|
-
if (!
|
|
40
|
+
if (!i)
|
|
41
41
|
throw new Error("Hotel description is required");
|
|
42
|
-
if (!
|
|
42
|
+
if (!d)
|
|
43
43
|
throw new Error("Hotel program name is required");
|
|
44
|
-
},
|
|
45
|
-
alertId:
|
|
44
|
+
}, q = ({
|
|
45
|
+
alertId: e,
|
|
46
46
|
checkin: t,
|
|
47
|
-
checkout:
|
|
48
|
-
hotelGroup:
|
|
49
|
-
hotelId:
|
|
50
|
-
name:
|
|
51
|
-
hotelImage:
|
|
52
|
-
hotelAddress:
|
|
53
|
-
hotelDescription:
|
|
54
|
-
hotelProgramName:
|
|
55
|
-
archived:
|
|
56
|
-
acknowledged:
|
|
47
|
+
checkout: o,
|
|
48
|
+
hotelGroup: n,
|
|
49
|
+
hotelId: l,
|
|
50
|
+
name: s,
|
|
51
|
+
hotelImage: A,
|
|
52
|
+
hotelAddress: i,
|
|
53
|
+
hotelDescription: d,
|
|
54
|
+
hotelProgramName: y,
|
|
55
|
+
archived: c,
|
|
56
|
+
acknowledged: m
|
|
57
57
|
}) => {
|
|
58
|
-
if (!
|
|
58
|
+
if (!e)
|
|
59
59
|
throw new Error("Alert ID is required");
|
|
60
60
|
if (![
|
|
61
61
|
t,
|
|
62
|
-
a,
|
|
63
62
|
o,
|
|
64
63
|
n,
|
|
65
64
|
l,
|
|
66
|
-
i,
|
|
67
65
|
s,
|
|
68
66
|
A,
|
|
69
|
-
|
|
67
|
+
i,
|
|
68
|
+
d,
|
|
70
69
|
y,
|
|
71
|
-
|
|
70
|
+
c,
|
|
71
|
+
m
|
|
72
72
|
].some(
|
|
73
|
-
(
|
|
73
|
+
(a) => a != null && a !== ""
|
|
74
74
|
))
|
|
75
75
|
throw new Error("At least one field must be provided for update");
|
|
76
|
-
},
|
|
77
|
-
const { data:
|
|
76
|
+
}, D = () => {
|
|
77
|
+
const { isAuthenticated: e } = p(), { data: t = [] } = E({
|
|
78
78
|
queryKey: [u.AVAILABILITY_ALERTS],
|
|
79
|
-
queryFn: () =>
|
|
80
|
-
|
|
79
|
+
queryFn: () => w.getMyActiveAlerts(),
|
|
80
|
+
enabled: e
|
|
81
|
+
}), { data: o = [] } = E({
|
|
81
82
|
queryKey: [u.ALERT_NOTIFICATIONS],
|
|
82
|
-
queryFn: () =>
|
|
83
|
+
queryFn: () => w.getAlertNotifications(),
|
|
84
|
+
enabled: e
|
|
83
85
|
}), {
|
|
84
|
-
mutate:
|
|
85
|
-
isPending:
|
|
86
|
-
isError:
|
|
87
|
-
error:
|
|
88
|
-
} =
|
|
89
|
-
mutationFn: async (
|
|
86
|
+
mutate: n,
|
|
87
|
+
isPending: l,
|
|
88
|
+
isError: s,
|
|
89
|
+
error: A
|
|
90
|
+
} = b({
|
|
91
|
+
mutationFn: async (r) => (h(r), await w.createAvailabilityAlert(r)),
|
|
90
92
|
onSuccess: () => {
|
|
91
93
|
v.invalidateQueries({
|
|
92
94
|
queryKey: [u.AVAILABILITY_ALERTS]
|
|
@@ -94,12 +96,12 @@ const b = ({
|
|
|
94
96
|
}
|
|
95
97
|
}), {
|
|
96
98
|
mutate: i,
|
|
97
|
-
isPending:
|
|
98
|
-
isError:
|
|
99
|
-
error:
|
|
100
|
-
data:
|
|
101
|
-
} =
|
|
102
|
-
mutationFn: async (
|
|
99
|
+
isPending: d,
|
|
100
|
+
isError: y,
|
|
101
|
+
error: c,
|
|
102
|
+
data: m
|
|
103
|
+
} = b({
|
|
104
|
+
mutationFn: async (r) => (q(r), w.updateAvailabilityAlert(r)),
|
|
103
105
|
onSuccess: () => {
|
|
104
106
|
v.invalidateQueries({
|
|
105
107
|
queryKey: [u.AVAILABILITY_ALERTS]
|
|
@@ -109,25 +111,25 @@ const b = ({
|
|
|
109
111
|
}
|
|
110
112
|
});
|
|
111
113
|
return {
|
|
112
|
-
activeAlerts:
|
|
113
|
-
alertNotifications:
|
|
114
|
+
activeAlerts: t,
|
|
115
|
+
alertNotifications: o,
|
|
114
116
|
// Mutation for creating a new availability alert
|
|
115
|
-
createAvailabilityAlert:
|
|
116
|
-
isCreateAvailabilityAlertPending:
|
|
117
|
-
isCreateAvailabilityAlertError:
|
|
118
|
-
createAvailabilityAlertError:
|
|
117
|
+
createAvailabilityAlert: n,
|
|
118
|
+
isCreateAvailabilityAlertPending: l,
|
|
119
|
+
isCreateAvailabilityAlertError: s,
|
|
120
|
+
createAvailabilityAlertError: A,
|
|
119
121
|
// Mutation for updating/removing an existing alert
|
|
120
122
|
updateAvailabilityAlert: i,
|
|
121
|
-
isUpdateAvailabilityAlertPending:
|
|
122
|
-
isUpdateAvailabilityAlertError:
|
|
123
|
-
updateAvailabilityAlertError:
|
|
124
|
-
updatedAvailabilityAlert:
|
|
123
|
+
isUpdateAvailabilityAlertPending: d,
|
|
124
|
+
isUpdateAvailabilityAlertError: y,
|
|
125
|
+
updateAvailabilityAlertError: c,
|
|
126
|
+
updatedAvailabilityAlert: m,
|
|
125
127
|
// convenience function to update acknowledgment
|
|
126
|
-
updateAcknowledgement: (
|
|
128
|
+
updateAcknowledgement: (r, a = !0) => i({ alertId: r, acknowledged: a })
|
|
127
129
|
};
|
|
128
130
|
};
|
|
129
131
|
export {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
132
|
+
D as useAvailabilityAlerts,
|
|
133
|
+
h as validateCreateAvailabilityAlert,
|
|
134
|
+
q as validateUpdateAvailabilityAlert
|
|
133
135
|
};
|
package/dist/lib/main.d.ts
CHANGED
|
@@ -8,4 +8,5 @@ export * from './components';
|
|
|
8
8
|
export * from './configs';
|
|
9
9
|
export * from './enums';
|
|
10
10
|
export * from './hooks';
|
|
11
|
+
export { mapAccommodationResponse, mapRateResponse } from './services/booking/BookingService.mappers';
|
|
11
12
|
export type { checkNthNightFree, IAirlineProgram, IHotelDetails, IPointsAsCash, IRate, IRoom };
|
|
@@ -80,6 +80,7 @@ export interface IHotelResultResponse {
|
|
|
80
80
|
hotel_program?: IHotelProgramResponse & {
|
|
81
81
|
logo: string;
|
|
82
82
|
};
|
|
83
|
+
points_program_display?: string;
|
|
83
84
|
best_value: string;
|
|
84
85
|
points_as_cash?: IPointsAsCashResponse;
|
|
85
86
|
cash_booking_offers?: ICashBookingOffersResponse;
|
package/dist/main.js
CHANGED
|
@@ -1,33 +1,36 @@
|
|
|
1
|
-
import { ESearchType as
|
|
1
|
+
import { ESearchType as t } from "./services/hotel/HotelService.types.js";
|
|
2
2
|
import { HotelResult as l } from "./components/HotelResult/HotelResult.js";
|
|
3
|
-
import { HotelResults as
|
|
4
|
-
import { Legend as
|
|
5
|
-
import { Ratings as
|
|
6
|
-
import { defaultLocationSortOrder as u, defaultSimilarityThreshold as
|
|
7
|
-
import { EHotelSortOption as d, ESortingOrder as
|
|
8
|
-
import { useAvailabilityAlertNotifications as
|
|
9
|
-
import { useAvailabilityAlerts as
|
|
10
|
-
import { useHotelDetails as
|
|
11
|
-
import { useHotelSearch as
|
|
12
|
-
import { useHotelSort as
|
|
3
|
+
import { HotelResults as i } from "./components/HotelResults/HotelResults.js";
|
|
4
|
+
import { Legend as f } from "./components/Legend/Legend.js";
|
|
5
|
+
import { Ratings as s } from "./components/Banners/Ratings/Ratings.js";
|
|
6
|
+
import { defaultLocationSortOrder as u, defaultSimilarityThreshold as n, duffelTestHotelLocation as c } from "./configs/defaults.js";
|
|
7
|
+
import { EHotelSortOption as d, ESortingOrder as A } from "./enums/index.js";
|
|
8
|
+
import { useAvailabilityAlertNotifications as R } from "./hooks/useAvailabilityAlertNotifications/useAvailabilityAlertNotifications.js";
|
|
9
|
+
import { useAvailabilityAlerts as y } from "./hooks/useAvailabilityAlerts/useAvailabilityAlerts.js";
|
|
10
|
+
import { useHotelDetails as L } from "./hooks/useHotelDetails/useHotelDetails.js";
|
|
11
|
+
import { useHotelSearch as g } from "./hooks/useHotelSearch/useHotelSearch.js";
|
|
12
|
+
import { useHotelSort as O } from "./hooks/useHotelSort/useHotelSort.js";
|
|
13
13
|
import { useLocationSearch as D } from "./hooks/useLocationSearch/useLocationSearch.js";
|
|
14
|
-
import {
|
|
14
|
+
import { mapAccommodationResponse as j, mapRateResponse as k } from "./services/booking/BookingService.mappers.js";
|
|
15
|
+
import { EAvailabilityAlertStatus as w } from "./enums/EAvailabilityAlert.js";
|
|
15
16
|
export {
|
|
16
|
-
|
|
17
|
+
w as EAvailabilityAlertStatus,
|
|
17
18
|
d as EHotelSortOption,
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
t as ESearchType,
|
|
20
|
+
A as ESortingOrder,
|
|
20
21
|
l as HotelResult,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
i as HotelResults,
|
|
23
|
+
f as Legend,
|
|
24
|
+
s as Ratings,
|
|
24
25
|
u as defaultLocationSortOrder,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
n as defaultSimilarityThreshold,
|
|
27
|
+
c as duffelTestHotelLocation,
|
|
28
|
+
j as mapAccommodationResponse,
|
|
29
|
+
k as mapRateResponse,
|
|
30
|
+
R as useAvailabilityAlertNotifications,
|
|
31
|
+
y as useAvailabilityAlerts,
|
|
32
|
+
L as useHotelDetails,
|
|
33
|
+
g as useHotelSearch,
|
|
34
|
+
O as useHotelSort,
|
|
32
35
|
D as useLocationSearch
|
|
33
36
|
};
|
|
@@ -81,7 +81,7 @@ const n = (e) => {
|
|
|
81
81
|
beds: e.beds
|
|
82
82
|
};
|
|
83
83
|
}, T = (e) => {
|
|
84
|
-
var a, t, i, s, o, _, m, c, u, r, l, y, g, f, h, C, v, b, k,
|
|
84
|
+
var a, t, i, s, o, _, m, c, u, r, l, y, g, f, h, C, v, b, k, P;
|
|
85
85
|
if (e)
|
|
86
86
|
return {
|
|
87
87
|
searchRoomRateId: e.search_room_rate_id,
|
|
@@ -121,11 +121,11 @@ const n = (e) => {
|
|
|
121
121
|
cheapestRateTotalAmount: n(e.cheapest_rate_total_amount),
|
|
122
122
|
cheapestRateCurrency: e.cheapest_rate_currency ?? "",
|
|
123
123
|
chain: { name: ((k = e.chain) == null ? void 0 : k.name) ?? "" },
|
|
124
|
-
brand: { name: ((
|
|
124
|
+
brand: { name: ((P = e.brand) == null ? void 0 : P.name) ?? "" },
|
|
125
125
|
supportedLoyaltyProgramme: e.supported_loyalty_programme,
|
|
126
126
|
amenities: e.amenities ?? []
|
|
127
127
|
};
|
|
128
|
-
},
|
|
128
|
+
}, A = (e) => ({
|
|
129
129
|
bonus: (e == null ? void 0 : e.bonus) ?? 0,
|
|
130
130
|
stepThreshold: (e == null ? void 0 : e.step_threshold) ?? 0
|
|
131
131
|
}), R = (e) => ({
|
|
@@ -135,7 +135,7 @@ const n = (e) => {
|
|
|
135
135
|
transferMinutes: e.transfer_minutes,
|
|
136
136
|
minimumTransfer: e.minimum_transfer,
|
|
137
137
|
transferDenominator: e.transfer_denominator,
|
|
138
|
-
stepBonus:
|
|
138
|
+
stepBonus: A(e.step_bonus)
|
|
139
139
|
}), N = (e) => {
|
|
140
140
|
if (e)
|
|
141
141
|
return {
|
|
@@ -145,7 +145,7 @@ const n = (e) => {
|
|
|
145
145
|
transferMinutes: e.transfer_minutes,
|
|
146
146
|
minimumTransfer: e.minimum_transfer,
|
|
147
147
|
transferDenominator: e.transfer_denominator,
|
|
148
|
-
stepBonus:
|
|
148
|
+
stepBonus: A(e.step_bonus),
|
|
149
149
|
valueCent: e.value_cent,
|
|
150
150
|
logo: e.logo
|
|
151
151
|
};
|
|
@@ -214,6 +214,7 @@ const n = (e) => {
|
|
|
214
214
|
liveScrapingCheckNeeded: e.live_scraping_check_needed,
|
|
215
215
|
partners: ((u = e.partners) == null ? void 0 : u.map(R)) ?? [],
|
|
216
216
|
hotelProgram: N(e.hotel_program),
|
|
217
|
+
pointsProgramDisplay: e.points_program_display,
|
|
217
218
|
bestValue: e.best_value,
|
|
218
219
|
pointsAsCash: I(e.points_as_cash),
|
|
219
220
|
cashBookingOffers: T(e.cash_booking_offers),
|
|
@@ -239,7 +240,7 @@ const n = (e) => {
|
|
|
239
240
|
},
|
|
240
241
|
rooms: ((o = e.rooms) == null ? void 0 : o.map(p)) ?? []
|
|
241
242
|
};
|
|
242
|
-
},
|
|
243
|
+
}, D = (e) => {
|
|
243
244
|
var a, t;
|
|
244
245
|
return {
|
|
245
246
|
partnerProgram: e.partner_program,
|
|
@@ -267,5 +268,5 @@ export {
|
|
|
267
268
|
x as mapLiveHotelCheckResponse,
|
|
268
269
|
w as mapRateResponse,
|
|
269
270
|
p as mapRoomResponse,
|
|
270
|
-
|
|
271
|
+
D as mapTransferPartnerResponse
|
|
271
272
|
};
|