@odynn/awayz-hotels 0.1.18 → 0.1.20
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/useHotelDetails/useHotelDetails.api.js +1 -1
- package/dist/hooks/useHotelDetails/useHotelDetails.js +78 -72
- package/dist/lib/components/HotelResult/HotelResult.types.d.ts +15 -0
- package/dist/lib/hooks/useHotelDetails/useHotelDetails.d.ts +1 -0
- package/dist/lib/services/hotel/HotelService.d.ts +5 -2
- package/dist/services/hotel/HotelService.js +13 -10
- package/package.json +1 -1
|
@@ -24,7 +24,7 @@ const w = async (o) => await m.getTransferPartners(
|
|
|
24
24
|
checkoutDate: a
|
|
25
25
|
});
|
|
26
26
|
if (r.success) {
|
|
27
|
-
const e = r.data
|
|
27
|
+
const e = r.data, u = !(e.points.pointsValue > 0) && o.bestValue === l.POINTS;
|
|
28
28
|
n = {
|
|
29
29
|
...o,
|
|
30
30
|
awardPoints: e.points.awardPointsValue ?? e.points.pointsValue,
|
|
@@ -1,144 +1,150 @@
|
|
|
1
|
-
import { useMemo as
|
|
2
|
-
import { h as
|
|
1
|
+
import { useState as L, useMemo as Q } from "react";
|
|
2
|
+
import { h as i } from "../../moment-BGjjqtLQ.js";
|
|
3
3
|
import "../../arrayExtensions-cyilNkdJ.js";
|
|
4
|
-
import
|
|
5
|
-
import { fetchTransferPartners as
|
|
6
|
-
import { calculatePointsAsCash as
|
|
7
|
-
import { useQuery as
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
),
|
|
11
|
-
var
|
|
4
|
+
import U from "../../stores/useHotelsStore.js";
|
|
5
|
+
import { fetchTransferPartners as j, fetchPointsCheck as z, fetchAvailableRooms as J, fetchBestCheckout as V, combineUpdatedHotelData as O, fallbackBestCheckout as W } from "./useHotelDetails.api.js";
|
|
6
|
+
import { calculatePointsAsCash as X } from "../../utilities/pointsAsCashUtils.js";
|
|
7
|
+
import { useQuery as c } from "@tanstack/react-query";
|
|
8
|
+
const Y = (t, a) => Math.abs(
|
|
9
|
+
i(t.startOf("day")).diff(i(a.endOf("day")), "days")
|
|
10
|
+
), ae = (t) => {
|
|
11
|
+
var k, f, d, p, m, y, b, C, g, v, F;
|
|
12
12
|
if (!t)
|
|
13
13
|
throw new Error(
|
|
14
14
|
"Hotel is required in order to initiate the hotel details flow"
|
|
15
15
|
);
|
|
16
|
-
const { updateHotel:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
)
|
|
16
|
+
const { updateHotel: a, searchParams: o } = U(), [e, q] = L({
|
|
17
|
+
checkinDate: o == null ? void 0 : o.checkinDate,
|
|
18
|
+
checkoutDate: o == null ? void 0 : o.checkoutDate
|
|
19
|
+
}), s = Q(() => Y(e.checkinDate, e.checkoutDate), [e]), H = (x, E) => {
|
|
20
|
+
q({
|
|
21
|
+
checkinDate: i(x),
|
|
22
|
+
checkoutDate: i(E)
|
|
23
|
+
});
|
|
24
|
+
}, { data: R, isFetching: A } = c({
|
|
20
25
|
queryKey: ["transferPartners", t.hotelGroup],
|
|
21
|
-
queryFn: () =>
|
|
26
|
+
queryFn: () => j(t.hotelGroup),
|
|
22
27
|
enabled: !!t.hotelGroup,
|
|
23
28
|
placeholderData: []
|
|
24
29
|
}), {
|
|
25
|
-
data:
|
|
26
|
-
isFetching:
|
|
27
|
-
isFetched:
|
|
28
|
-
} =
|
|
30
|
+
data: B,
|
|
31
|
+
isFetching: n,
|
|
32
|
+
isFetched: G
|
|
33
|
+
} = c({
|
|
29
34
|
queryKey: [
|
|
30
35
|
"hotelPointsCheck",
|
|
31
36
|
t.hotelId,
|
|
32
37
|
t.hotelGroup,
|
|
33
|
-
(
|
|
34
|
-
(
|
|
38
|
+
(k = e == null ? void 0 : e.checkinDate) == null ? void 0 : k.valueOf(),
|
|
39
|
+
(f = e == null ? void 0 : e.checkoutDate) == null ? void 0 : f.valueOf()
|
|
35
40
|
],
|
|
36
|
-
queryFn: () =>
|
|
41
|
+
queryFn: () => z({
|
|
37
42
|
hotel: t,
|
|
38
43
|
checkinDate: e.checkinDate,
|
|
39
44
|
checkoutDate: e.checkoutDate,
|
|
40
|
-
updateHotel:
|
|
45
|
+
updateHotel: a
|
|
41
46
|
}),
|
|
42
|
-
enabled: !!e
|
|
47
|
+
enabled: !!e.checkinDate && !!e.checkoutDate && !!t.liveScrapingCheckNeeded,
|
|
43
48
|
// We don't throw an error on fail so we can gracefully handle fallback
|
|
44
49
|
retry: !1,
|
|
45
50
|
placeholderData: {
|
|
46
51
|
pointsHotelDetails: t,
|
|
47
52
|
pointsRooms: t.rooms ?? []
|
|
48
53
|
}
|
|
49
|
-
}), { pointsRooms:
|
|
54
|
+
}), { pointsRooms: I, pointsHotelDetails: r } = B || {
|
|
50
55
|
pointsHotelDetails: t,
|
|
51
56
|
pointsRooms: []
|
|
52
57
|
}, {
|
|
53
|
-
data:
|
|
54
|
-
isFetching:
|
|
55
|
-
isFetched:
|
|
56
|
-
} =
|
|
58
|
+
data: K,
|
|
59
|
+
isFetching: u,
|
|
60
|
+
isFetched: S
|
|
61
|
+
} = c({
|
|
57
62
|
queryKey: [
|
|
58
63
|
"fetchAvailableRooms",
|
|
59
|
-
(
|
|
60
|
-
(
|
|
61
|
-
(
|
|
62
|
-
|
|
63
|
-
|
|
64
|
+
(d = t.cashBookingOffers) == null ? void 0 : d.accommodationId,
|
|
65
|
+
(p = e == null ? void 0 : e.checkinDate) == null ? void 0 : p.valueOf(),
|
|
66
|
+
(m = e == null ? void 0 : e.checkoutDate) == null ? void 0 : m.valueOf(),
|
|
67
|
+
o == null ? void 0 : o.guests,
|
|
68
|
+
o == null ? void 0 : o.rooms
|
|
64
69
|
],
|
|
65
|
-
queryFn: () =>
|
|
70
|
+
queryFn: () => J({
|
|
66
71
|
hotel: t,
|
|
67
72
|
checkinDate: e.checkinDate,
|
|
68
73
|
checkoutDate: e.checkoutDate,
|
|
69
|
-
guests:
|
|
70
|
-
rooms:
|
|
71
|
-
updateHotel:
|
|
72
|
-
numberOfNights:
|
|
74
|
+
guests: o.guests,
|
|
75
|
+
rooms: o.rooms,
|
|
76
|
+
updateHotel: a,
|
|
77
|
+
numberOfNights: s
|
|
73
78
|
}),
|
|
74
|
-
enabled: !!e
|
|
79
|
+
enabled: !!e.checkinDate && !!e.checkoutDate && !!((y = t.cashBookingOffers) != null && y.accommodationId),
|
|
75
80
|
retry: !1,
|
|
76
81
|
placeholderData: {
|
|
77
82
|
cashHotelDetails: t,
|
|
78
83
|
cashRooms: []
|
|
79
84
|
}
|
|
80
|
-
}), { cashRooms:
|
|
85
|
+
}), { cashRooms: w, cashHotelDetails: h } = K || {
|
|
81
86
|
cashHotelDetails: t,
|
|
82
87
|
cashRooms: []
|
|
83
88
|
}, {
|
|
84
|
-
data:
|
|
85
|
-
isFetching:
|
|
86
|
-
isFetched:
|
|
87
|
-
} =
|
|
89
|
+
data: N,
|
|
90
|
+
isFetching: M,
|
|
91
|
+
isFetched: P
|
|
92
|
+
} = c({
|
|
88
93
|
queryKey: [
|
|
89
94
|
"bestCheckout",
|
|
90
95
|
t.hotelId,
|
|
91
96
|
t.hotelGroup,
|
|
92
|
-
(
|
|
93
|
-
(
|
|
97
|
+
(b = e == null ? void 0 : e.checkinDate) == null ? void 0 : b.valueOf(),
|
|
98
|
+
(C = e == null ? void 0 : e.checkoutDate) == null ? void 0 : C.valueOf()
|
|
94
99
|
],
|
|
95
|
-
queryFn: () =>
|
|
96
|
-
|
|
97
|
-
|
|
100
|
+
queryFn: () => V(
|
|
101
|
+
O(t, r, h),
|
|
102
|
+
s
|
|
98
103
|
),
|
|
99
|
-
enabled: !
|
|
104
|
+
enabled: !n && (t.liveScrapingCheckNeeded ? G : !0) && !u && ((g = t.cashBookingOffers) != null && g.accommodationId ? S : !0) && s > 0,
|
|
100
105
|
retry: !1,
|
|
101
106
|
placeholderData: {
|
|
102
|
-
bestCheckout:
|
|
107
|
+
bestCheckout: W(t, s),
|
|
103
108
|
isAvailable: !1
|
|
104
109
|
}
|
|
105
|
-
}), { bestCheckout: l, isAvailable:
|
|
110
|
+
}), { bestCheckout: l, isAvailable: D } = N || {
|
|
106
111
|
isAvailable: !1
|
|
107
|
-
}, { data:
|
|
112
|
+
}, { data: T } = c({
|
|
108
113
|
queryKey: [
|
|
109
114
|
"pointsAsCash",
|
|
110
115
|
t.hotelId,
|
|
111
116
|
t.hotelGroup,
|
|
112
|
-
(
|
|
113
|
-
(
|
|
117
|
+
(v = e == null ? void 0 : e.checkinDate) == null ? void 0 : v.valueOf(),
|
|
118
|
+
(F = e == null ? void 0 : e.checkoutDate) == null ? void 0 : F.valueOf()
|
|
114
119
|
],
|
|
115
|
-
queryFn: () =>
|
|
116
|
-
enabled:
|
|
120
|
+
queryFn: () => X(l.totalCashCost),
|
|
121
|
+
enabled: P && D,
|
|
117
122
|
retry: !1
|
|
118
123
|
});
|
|
119
124
|
return {
|
|
120
|
-
transferPartners:
|
|
121
|
-
loadingTransferPartners:
|
|
125
|
+
transferPartners: R,
|
|
126
|
+
loadingTransferPartners: A,
|
|
122
127
|
// Points Check
|
|
123
|
-
pointsRooms:
|
|
124
|
-
loadingLivePointsCheck:
|
|
128
|
+
pointsRooms: I,
|
|
129
|
+
loadingLivePointsCheck: n,
|
|
125
130
|
// Cash Rooms
|
|
126
|
-
cashRooms:
|
|
127
|
-
loadingCashRooms:
|
|
131
|
+
cashRooms: w,
|
|
132
|
+
loadingCashRooms: u,
|
|
128
133
|
// Best Checkout
|
|
129
134
|
bestCheckout: l,
|
|
130
|
-
loadingBestCheckout:
|
|
135
|
+
loadingBestCheckout: M,
|
|
131
136
|
// Combined availability
|
|
132
|
-
isAvailable:
|
|
137
|
+
isAvailable: D,
|
|
133
138
|
// Points as Cash
|
|
134
|
-
pointsAsCash:
|
|
135
|
-
hotelDetails:
|
|
139
|
+
pointsAsCash: T,
|
|
140
|
+
hotelDetails: O(
|
|
136
141
|
t,
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
)
|
|
142
|
+
r,
|
|
143
|
+
h
|
|
144
|
+
),
|
|
145
|
+
updateDates: H
|
|
140
146
|
};
|
|
141
147
|
};
|
|
142
148
|
export {
|
|
143
|
-
|
|
149
|
+
ae as useHotelDetails
|
|
144
150
|
};
|
|
@@ -141,3 +141,18 @@ export interface IStepBonus {
|
|
|
141
141
|
bonus: number;
|
|
142
142
|
stepThreshold: number;
|
|
143
143
|
}
|
|
144
|
+
export interface ILiveHotelCheck {
|
|
145
|
+
hotelName: string;
|
|
146
|
+
hotelNameKey: string;
|
|
147
|
+
country: string;
|
|
148
|
+
city: string;
|
|
149
|
+
state: string;
|
|
150
|
+
hotelId: string;
|
|
151
|
+
points: {
|
|
152
|
+
pointsType: string;
|
|
153
|
+
pointsValue: number;
|
|
154
|
+
awardPointsValue: number;
|
|
155
|
+
availability: boolean;
|
|
156
|
+
};
|
|
157
|
+
rooms: IRoom[];
|
|
158
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IHotelPointsCheckArgs, ISearchByHotelIdRequest, ISearchHotelsParams, ISearchLocation } from './HotelService.types';
|
|
2
|
-
import { IHotelDetails } from '../../components/HotelResult/HotelResult.types';
|
|
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';
|
|
5
5
|
declare class _HotelService {
|
|
@@ -7,7 +7,10 @@ declare class _HotelService {
|
|
|
7
7
|
searchByCoords: (request: ISearchHotelsParams) => Promise<TServiceResponse<IHotelDetails[]>>;
|
|
8
8
|
searchByHotelId: (request: ISearchByHotelIdRequest) => Promise<TServiceResponse<IHotelDetails[]>>;
|
|
9
9
|
getTransferPartners: (program: string) => Promise<any>;
|
|
10
|
-
hotelPointsCheck: (args: IHotelPointsCheckArgs) => Promise<
|
|
10
|
+
hotelPointsCheck: (args: IHotelPointsCheckArgs) => Promise<{
|
|
11
|
+
success: any;
|
|
12
|
+
data: ILiveHotelCheck;
|
|
13
|
+
}>;
|
|
11
14
|
getRecommendations: (args: any) => Promise<{
|
|
12
15
|
success: boolean;
|
|
13
16
|
data: IBestCheckout;
|
|
@@ -6,10 +6,10 @@ import { s as T } from "../../stringUtils-CvWpky85.js";
|
|
|
6
6
|
import "../../moment-BGjjqtLQ.js";
|
|
7
7
|
import "../../arrayExtensions-cyilNkdJ.js";
|
|
8
8
|
import { c as h } from "../../objectUtils-CyIaVmog.js";
|
|
9
|
-
import { E as
|
|
9
|
+
import { E as m } from "../../DateFormats-DZD30Nea.js";
|
|
10
10
|
import { EHotelEndpoints as i } from "../../configs/endpoints.js";
|
|
11
11
|
import { clientInstance as u } from "@odynn/awayz-auth";
|
|
12
|
-
import { EBestCheckoutType as
|
|
12
|
+
import { EBestCheckoutType as p } from "../../enums/EBestCheckoutType.js";
|
|
13
13
|
import { EBestValueType as S } from "../../enums/EBestValueType.js";
|
|
14
14
|
class H {
|
|
15
15
|
constructor() {
|
|
@@ -33,9 +33,9 @@ class H {
|
|
|
33
33
|
success: !0,
|
|
34
34
|
data: e.data.cities.map(
|
|
35
35
|
(o) => {
|
|
36
|
-
const { search_id:
|
|
37
|
-
searchId:
|
|
38
|
-
searchType:
|
|
36
|
+
const { search_id: _, search_type: l, description: d, coordinates: y, city: g } = o, n = {
|
|
37
|
+
searchId: _,
|
|
38
|
+
searchType: l,
|
|
39
39
|
description: d,
|
|
40
40
|
coordinates: y,
|
|
41
41
|
city: g
|
|
@@ -121,13 +121,16 @@ class H {
|
|
|
121
121
|
const e = {
|
|
122
122
|
hotel_group: a.hotelGroup,
|
|
123
123
|
hotel_id: a.hotelId,
|
|
124
|
-
check_in_date: a.checkinDate.format(
|
|
125
|
-
check_out_date: a.checkoutDate.format(
|
|
124
|
+
check_in_date: a.checkinDate.format(m.ServerDate),
|
|
125
|
+
check_out_date: a.checkoutDate.format(m.ServerDate)
|
|
126
126
|
}, { data: t } = await u.post(
|
|
127
127
|
i.HOTEL_POINTS_CHECK,
|
|
128
128
|
e
|
|
129
129
|
);
|
|
130
|
-
return
|
|
130
|
+
return {
|
|
131
|
+
success: t.success,
|
|
132
|
+
data: h(t.data[0])
|
|
133
|
+
};
|
|
131
134
|
});
|
|
132
135
|
r(this, "getRecommendations", async (a) => {
|
|
133
136
|
try {
|
|
@@ -146,7 +149,7 @@ class H {
|
|
|
146
149
|
cash_or_points: ["cash", "points"]
|
|
147
150
|
}
|
|
148
151
|
), t = e.data[0];
|
|
149
|
-
return
|
|
152
|
+
return {
|
|
150
153
|
success: !0,
|
|
151
154
|
data: {
|
|
152
155
|
totalPointsCost: t.total_hotel_points_cost,
|
|
@@ -157,7 +160,7 @@ class H {
|
|
|
157
160
|
sufficientPoints: t.user_has_sufficient_points,
|
|
158
161
|
awardPoints: t.award_points,
|
|
159
162
|
rewardsProgram: t.hotel_rewards_program,
|
|
160
|
-
bestCheckoutMethod: t.best_user_checkout_method === S.CASH ?
|
|
163
|
+
bestCheckoutMethod: t.best_user_checkout_method === S.CASH ? p.CASH : p.POINTS,
|
|
161
164
|
optimalProgram: {
|
|
162
165
|
remainingPointsBalance: t.optimal_user_program_checkout.primary_offer_remaining_points_balance,
|
|
163
166
|
programs: t.optimal_user_program_checkout.programs.map(
|