@odynn/awayz-core 0.9.4 → 0.9.6
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/ClientPointsValue/ClientPointsValue.js +7 -7
- package/dist/configs/endpoints.js +4 -4
- package/dist/hooks/useBookingManagement/useBookingManagement.js +91 -85
- package/dist/lib/configs/endpoints.d.ts +2 -1
- package/dist/lib/hooks/useBookingManagement/useBookingManagement.types.d.ts +9 -1
- package/dist/lib/services/bookings/BookingService.d.ts +2 -1
- package/dist/lib/services/bookings/BookingService.types.d.ts +0 -2
- package/dist/services/bookings/BookingService.js +47 -54
- package/package.json +1 -1
|
@@ -2,18 +2,18 @@ import { jsxs as p } from "react/jsx-runtime";
|
|
|
2
2
|
import { useQuery as m } from "@tanstack/react-query";
|
|
3
3
|
import "../../arrayExtensions-DlcBOj5a.js";
|
|
4
4
|
import { E as u } from "../../noRetryInstance-oiHCni_Z.js";
|
|
5
|
-
import { useMemo as
|
|
6
|
-
import { useAwayzContext as
|
|
5
|
+
import { useMemo as y } from "react";
|
|
6
|
+
import { useAwayzContext as f } from "../../hooks/useAwayzContext.js";
|
|
7
7
|
import "react-i18next";
|
|
8
8
|
import '../../assets/_styles3.css';import '../../assets/_styles4.css';import '../../assets/_styles.css';import '../../assets/_styles2.css';/* empty css */
|
|
9
9
|
import "../../_styles.flight-booking-DEUJthTJ.js";
|
|
10
10
|
/* empty css */
|
|
11
|
-
import { CurrencyService as
|
|
11
|
+
import { CurrencyService as C } from "../../services/currency/CurrencyService.js";
|
|
12
12
|
/* empty css */
|
|
13
13
|
/* empty css */
|
|
14
14
|
import "../../configs/awayzClient.js";
|
|
15
15
|
import "../../context/AwayzContext.js";
|
|
16
|
-
import { useFeatureFlags as
|
|
16
|
+
import { useFeatureFlags as l } from "../../hooks/useFeatureFlags.js";
|
|
17
17
|
import { useWallet as d } from "../../hooks/useWallet/useWallet.js";
|
|
18
18
|
function g(t) {
|
|
19
19
|
if (!t || isNaN(t) || t < 0) return "N/A";
|
|
@@ -27,19 +27,19 @@ const v = (t, e) => {
|
|
|
27
27
|
cashAmount: t,
|
|
28
28
|
currency: e
|
|
29
29
|
}) => {
|
|
30
|
-
const { pointsAsCash: r } = d(), { user: o } =
|
|
30
|
+
const { pointsAsCash: r } = d(), { user: o } = f(), { featureFlags: i } = l(), n = y(
|
|
31
31
|
() => v(i.defaultCurrencyFeature, o),
|
|
32
32
|
[o]
|
|
33
33
|
), { data: c } = m({
|
|
34
34
|
queryKey: [u.CONVERT_CURRENCY, e, r.currency],
|
|
35
|
-
queryFn: () =>
|
|
35
|
+
queryFn: () => C.convertCurrency({
|
|
36
36
|
baseCurrency: e,
|
|
37
37
|
targetCurrency: r.currency
|
|
38
38
|
}),
|
|
39
39
|
staleTime: 1e3 * 60 * 60,
|
|
40
40
|
// 1 hour
|
|
41
41
|
enabled: !!e && !!n && e !== n && r.currency !== e && !!r.currency
|
|
42
|
-
}), s = t * (c ?? 1), a = Math.
|
|
42
|
+
}), s = t * (c ?? 1), a = Math.round(s / r.valuePerPoint);
|
|
43
43
|
return /* @__PURE__ */ p("p", { className: "client-points-amount", children: [
|
|
44
44
|
g(a),
|
|
45
45
|
" pts."
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
var r = /* @__PURE__ */ ((e) => (e.SIGN_IN = "auth/user-login", e.SIGN_UP = "auth/sign-up", e.GOOGLE_AUTH = "/auth/google-user", e.ME = "user", e.RESEND_VERIFICATION_EMAIL = "auth/resend-verification-email", e.UPDATE_USER_DETAILS = "account/update/user", e.CONFIRM_EMAIL = "account/verifyAccount", e.FORGOT_PASSWORD = "email/sendVeri", e.RESEND_OTP = "email/sendForgotPasswordVerification", e.RESET_PASSWORD = "account/updateUserPassword", e.REQUEST_LIMIT = "user/request-limit", e.APPLE_SOCIAL_SIGN_UP = "tp/apple/get/user", e.GOOGLE_SOCIAL_SIGN_UP = "tp/google/get/user", e.UPDATE_USER = "account/details/addUserDetails", e.ACKNOWLEDGEMENT = "account/update/userAcknowledgement", e.REGIONS = "user/region", e.UPDATE_USER_REGION = "/account/update/userRegion", e.UPDATE_PASSENGER_DETAILS = "/account/awayz", e.REFRESH_TOKEN = "auth/refresh-token", e.EXCHANGE_TOKEN = "user/exchange-token", e.REFRESH_EMBED_TOKEN = "user/refresh-token", e.OAUTH_INITIATE = "user/oauth2/initiate", e.OAUTH_CALLBACK = "user/oauth2/callback", e.FEATURES = "/user/features", e))(r || {}), a = /* @__PURE__ */ ((e) => (e.CURRENCY_CONVERSION = "currency/convert", e))(a || {}), _ = /* @__PURE__ */ ((e) => (e.USER_AWARDS = "user/rewards", e.LINKED_USER_AWARDS = "user/rewards/user-linked", e.USER_CARDS = "user/cards", e.ADD_USER_CARDS = "user/cards/add", e.REMOVE_USER_CARDS = "user/cards/remove", e.BANKS = "banks", e.CARDS = "cards", e.POINTS_AS_CASH = "/points-as-cash/available-points", e))(_ || {}), S = /* @__PURE__ */ ((e) => (e.TRIPS = "user/trips", e.ADD_BOOKING = "user/trips/add-booking-to-trip", e.REMOVE_BOOKING = "user/trips/remove-booking-from-trip", e.UNCATEGORISED_BOOKINGS = "/user/trips/get-uncategorized-bookings", e))(S || {}),
|
|
1
|
+
var r = /* @__PURE__ */ ((e) => (e.SIGN_IN = "auth/user-login", e.SIGN_UP = "auth/sign-up", e.GOOGLE_AUTH = "/auth/google-user", e.ME = "user", e.RESEND_VERIFICATION_EMAIL = "auth/resend-verification-email", e.UPDATE_USER_DETAILS = "account/update/user", e.CONFIRM_EMAIL = "account/verifyAccount", e.FORGOT_PASSWORD = "email/sendVeri", e.RESEND_OTP = "email/sendForgotPasswordVerification", e.RESET_PASSWORD = "account/updateUserPassword", e.REQUEST_LIMIT = "user/request-limit", e.APPLE_SOCIAL_SIGN_UP = "tp/apple/get/user", e.GOOGLE_SOCIAL_SIGN_UP = "tp/google/get/user", e.UPDATE_USER = "account/details/addUserDetails", e.ACKNOWLEDGEMENT = "account/update/userAcknowledgement", e.REGIONS = "user/region", e.UPDATE_USER_REGION = "/account/update/userRegion", e.UPDATE_PASSENGER_DETAILS = "/account/awayz", e.REFRESH_TOKEN = "auth/refresh-token", e.EXCHANGE_TOKEN = "user/exchange-token", e.REFRESH_EMBED_TOKEN = "user/refresh-token", e.OAUTH_INITIATE = "user/oauth2/initiate", e.OAUTH_CALLBACK = "user/oauth2/callback", e.FEATURES = "/user/features", e))(r || {}), a = /* @__PURE__ */ ((e) => (e.CURRENCY_CONVERSION = "currency/convert", e))(a || {}), _ = /* @__PURE__ */ ((e) => (e.USER_AWARDS = "user/rewards", e.LINKED_USER_AWARDS = "user/rewards/user-linked", e.USER_CARDS = "user/cards", e.ADD_USER_CARDS = "user/cards/add", e.REMOVE_USER_CARDS = "user/cards/remove", e.BANKS = "banks", e.CARDS = "cards", e.POINTS_AS_CASH = "/points-as-cash/available-points", e))(_ || {}), S = /* @__PURE__ */ ((e) => (e.TRIPS = "user/trips", e.ADD_BOOKING = "user/trips/add-booking-to-trip", e.REMOVE_BOOKING = "user/trips/remove-booking-from-trip", e.UNCATEGORISED_BOOKINGS = "/user/trips/get-uncategorized-bookings", e))(S || {}), O = /* @__PURE__ */ ((e) => (e.USER_HOTEL_BOOKINGS = "/user/bookings/hotels", e.USER_FLIGHT_BOOKINGS = "/user/bookings/flights", e.INITIATE_FLIGHT_CANCEL = "/duffel/flights/initiate-order-cancellation", e.CONFIRM_FLIGHT_CANCEL = "/duffel/flights/confirm-order-cancellation", e.CANCEL_HOTEL_BOOKING = "/duffel/hotels/cancel", e.ACTION_AIRLINE_CHANGES = "/user/bookings/flights/action-airline-initiated-changes", e.REFUND_POINTS_BOOKING = "/points-as-cash/refund-booking", e.BOOKING_POINTS_AS_CASH = "/points-as-cash", e))(O || {}), I = /* @__PURE__ */ ((e) => (e.POINTS_PER_CENT = "/user/rewards/points-per-cent", e))(I || {}), N = /* @__PURE__ */ ((e) => (e.USER_PREFERENCES = "/user/user-preferences", e))(N || {});
|
|
2
2
|
export {
|
|
3
3
|
r as EAuthEndpoints,
|
|
4
|
-
|
|
4
|
+
O as EBookingEndpoints,
|
|
5
5
|
a as ECurrencyEndpoints,
|
|
6
6
|
S as EMyTripsEndpoints,
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
N as EPreferencesEndpoints,
|
|
8
|
+
I as ERewardsEndpoints,
|
|
9
9
|
_ as EWalletEndpoints
|
|
10
10
|
};
|
|
@@ -1,134 +1,140 @@
|
|
|
1
|
-
import { useQuery as
|
|
1
|
+
import { useQuery as u, useMutation as m } from "@tanstack/react-query";
|
|
2
2
|
import "../../arrayExtensions-DlcBOj5a.js";
|
|
3
|
-
import { E as
|
|
3
|
+
import { E as a } from "../../noRetryInstance-oiHCni_Z.js";
|
|
4
4
|
import "react";
|
|
5
5
|
import "react/jsx-runtime";
|
|
6
6
|
import "react-i18next";
|
|
7
7
|
import '../../assets/_styles3.css';import '../../assets/_styles4.css';import '../../assets/_styles.css';import '../../assets/_styles2.css';/* empty css */
|
|
8
8
|
import "../../_styles.flight-booking-DEUJthTJ.js";
|
|
9
9
|
/* empty css */
|
|
10
|
-
import { awayzClient as
|
|
10
|
+
import { awayzClient as k } from "../../configs/awayzClient.js";
|
|
11
11
|
/* empty css */
|
|
12
12
|
import "../../context/AwayzContext.js";
|
|
13
13
|
import { EBookingType as o } from "../../services/trips/TripService.types.js";
|
|
14
14
|
/* empty css */
|
|
15
15
|
import { BookingService as e } from "../../services/bookings/BookingService.js";
|
|
16
|
-
const
|
|
16
|
+
const b = (r, t) => {
|
|
17
17
|
const {
|
|
18
|
-
data:
|
|
19
|
-
isError:
|
|
18
|
+
data: s,
|
|
19
|
+
isError: g,
|
|
20
20
|
error: d
|
|
21
|
-
} =
|
|
22
|
-
queryKey: [
|
|
23
|
-
queryFn: () => e.getHotelBooking(
|
|
24
|
-
enabled: t === o.HOTEL && !!
|
|
21
|
+
} = u({
|
|
22
|
+
queryKey: [a.BOOKING, r, o.HOTEL],
|
|
23
|
+
queryFn: () => e.getHotelBooking(r),
|
|
24
|
+
enabled: t === o.HOTEL && !!r
|
|
25
25
|
}), {
|
|
26
|
-
data:
|
|
27
|
-
isError:
|
|
26
|
+
data: n,
|
|
27
|
+
isError: B,
|
|
28
28
|
error: f
|
|
29
|
-
} =
|
|
30
|
-
queryKey: [
|
|
31
|
-
queryFn: () => e.getFlightBooking(
|
|
32
|
-
enabled: t === o.FLIGHT && !!
|
|
29
|
+
} = u({
|
|
30
|
+
queryKey: [a.BOOKING, r, o.FLIGHT],
|
|
31
|
+
queryFn: () => e.getFlightBooking(r),
|
|
32
|
+
enabled: t === o.FLIGHT && !!r
|
|
33
|
+
}), { data: i, isLoading: F } = u({
|
|
34
|
+
queryKey: [a.BOOKING, r],
|
|
35
|
+
queryFn: () => e.getPointsAsCash(r),
|
|
36
|
+
enabled: !!r
|
|
33
37
|
}), {
|
|
34
|
-
mutate:
|
|
35
|
-
isPending:
|
|
36
|
-
isError:
|
|
38
|
+
mutate: O,
|
|
39
|
+
isPending: A,
|
|
40
|
+
isError: y,
|
|
37
41
|
error: H,
|
|
38
|
-
isSuccess:
|
|
39
|
-
} =
|
|
42
|
+
isSuccess: L
|
|
43
|
+
} = m({
|
|
40
44
|
mutationFn: async () => {
|
|
41
|
-
if (i
|
|
45
|
+
if (i)
|
|
42
46
|
throw new Error("Not supported for bookings made with Points as Cash");
|
|
43
47
|
if (t === o.FLIGHT)
|
|
44
|
-
return e.initiateCancelFlightBooking(
|
|
48
|
+
return e.initiateCancelFlightBooking(r);
|
|
45
49
|
throw new Error("Not supported for hotel bookings");
|
|
46
50
|
},
|
|
47
51
|
onSuccess: () => {
|
|
48
|
-
|
|
52
|
+
c();
|
|
49
53
|
}
|
|
50
54
|
}), {
|
|
51
|
-
mutate:
|
|
52
|
-
isPending:
|
|
53
|
-
isError:
|
|
54
|
-
error:
|
|
55
|
-
isSuccess:
|
|
56
|
-
} =
|
|
55
|
+
mutate: G,
|
|
56
|
+
isPending: C,
|
|
57
|
+
isError: S,
|
|
58
|
+
error: w,
|
|
59
|
+
isSuccess: I
|
|
60
|
+
} = m({
|
|
57
61
|
mutationFn: async () => {
|
|
58
62
|
if (t === o.FLIGHT)
|
|
59
|
-
return
|
|
60
|
-
confirmationCode:
|
|
61
|
-
orderId:
|
|
62
|
-
provider:
|
|
63
|
+
return i && n && await e.cancelPointsBooking({
|
|
64
|
+
confirmationCode: i.confirmationCode,
|
|
65
|
+
orderId: n.orderId,
|
|
66
|
+
provider: i.provider,
|
|
63
67
|
type: o.FLIGHT,
|
|
64
|
-
pointsAmount:
|
|
65
|
-
cashAmount:
|
|
66
|
-
}), e.confirmCancelFlightBooking(
|
|
68
|
+
pointsAmount: i.points,
|
|
69
|
+
cashAmount: i.cashValue.amount
|
|
70
|
+
}), e.confirmCancelFlightBooking(r);
|
|
67
71
|
if (t === o.HOTEL)
|
|
68
|
-
return i
|
|
69
|
-
confirmationCode: i.
|
|
70
|
-
orderId:
|
|
71
|
-
provider: i.
|
|
72
|
+
return i && s && await e.cancelPointsBooking({
|
|
73
|
+
confirmationCode: i.confirmationCode,
|
|
74
|
+
orderId: s.bookingId,
|
|
75
|
+
provider: i.provider,
|
|
72
76
|
type: o.HOTEL,
|
|
73
|
-
pointsAmount: i.
|
|
74
|
-
cashAmount: i.
|
|
75
|
-
}), e.cancelHotelBooking(
|
|
77
|
+
pointsAmount: i.points,
|
|
78
|
+
cashAmount: i.cashValue.amount
|
|
79
|
+
}), e.cancelHotelBooking(r);
|
|
76
80
|
},
|
|
77
81
|
onSuccess: () => {
|
|
78
|
-
|
|
82
|
+
c();
|
|
79
83
|
}
|
|
80
84
|
}), {
|
|
81
|
-
mutate:
|
|
82
|
-
isPending:
|
|
83
|
-
isError:
|
|
84
|
-
error:
|
|
85
|
-
} =
|
|
86
|
-
mutationFn: async (
|
|
87
|
-
var
|
|
88
|
-
const
|
|
89
|
-
(
|
|
90
|
-
)) == null ? void 0 :
|
|
91
|
-
if (t === o.FLIGHT && (
|
|
85
|
+
mutate: K,
|
|
86
|
+
isPending: P,
|
|
87
|
+
isError: N,
|
|
88
|
+
error: v
|
|
89
|
+
} = m({
|
|
90
|
+
mutationFn: async (l) => {
|
|
91
|
+
var h, p;
|
|
92
|
+
const E = (p = (h = n == null ? void 0 : n.airlineInitiatedChanges) == null ? void 0 : h.filter(
|
|
93
|
+
(Q) => !Q.actionTaken
|
|
94
|
+
)) == null ? void 0 : p[0];
|
|
95
|
+
if (t === o.FLIGHT && (n != null && n.airlineInitiatedChanges) && E)
|
|
92
96
|
return e.actionAirlineChanges({
|
|
93
|
-
bookingId:
|
|
94
|
-
acceptChanges:
|
|
95
|
-
aicId:
|
|
97
|
+
bookingId: r,
|
|
98
|
+
acceptChanges: l,
|
|
99
|
+
aicId: E.id
|
|
96
100
|
});
|
|
97
101
|
throw new Error("Not supported for hotel bookings");
|
|
98
102
|
},
|
|
99
103
|
onSuccess: () => {
|
|
100
|
-
|
|
104
|
+
c();
|
|
101
105
|
}
|
|
102
|
-
}),
|
|
106
|
+
}), c = () => {
|
|
103
107
|
[
|
|
104
|
-
[
|
|
105
|
-
[
|
|
106
|
-
[
|
|
107
|
-
].forEach((
|
|
108
|
-
|
|
108
|
+
[a.BOOKING, r, t],
|
|
109
|
+
[a.TRIPS],
|
|
110
|
+
[a.UNCATEGORISED_BOOKINGS]
|
|
111
|
+
].forEach((l) => {
|
|
112
|
+
k.invalidateQueries({ queryKey: l });
|
|
109
113
|
});
|
|
110
|
-
},
|
|
114
|
+
}, T = g || B, q = d || f;
|
|
111
115
|
return {
|
|
112
|
-
details: t === o.HOTEL ?
|
|
113
|
-
isError:
|
|
114
|
-
error:
|
|
115
|
-
initiateCancellation:
|
|
116
|
-
isInitiatingCancellation:
|
|
117
|
-
isInitiateCancellationError:
|
|
116
|
+
details: t === o.HOTEL ? s : n,
|
|
117
|
+
isError: T,
|
|
118
|
+
error: q,
|
|
119
|
+
initiateCancellation: O,
|
|
120
|
+
isInitiatingCancellation: A,
|
|
121
|
+
isInitiateCancellationError: y,
|
|
118
122
|
initiateCancellationError: H,
|
|
119
|
-
isInitiateCancellationSuccess:
|
|
120
|
-
cancelBooking:
|
|
121
|
-
isCancellingBooking:
|
|
122
|
-
isCancelingBooking:
|
|
123
|
-
isCancelBookingError:
|
|
124
|
-
cancelBookingError:
|
|
125
|
-
isCancelBookingSuccess:
|
|
126
|
-
actionAirlineChanges:
|
|
127
|
-
isActionAirlineChangesPending:
|
|
128
|
-
isActionAirlineChangesError:
|
|
129
|
-
actionAirlineChangesError:
|
|
123
|
+
isInitiateCancellationSuccess: L,
|
|
124
|
+
cancelBooking: G,
|
|
125
|
+
isCancellingBooking: C,
|
|
126
|
+
isCancelingBooking: C,
|
|
127
|
+
isCancelBookingError: S,
|
|
128
|
+
cancelBookingError: w,
|
|
129
|
+
isCancelBookingSuccess: I,
|
|
130
|
+
actionAirlineChanges: K,
|
|
131
|
+
isActionAirlineChangesPending: P,
|
|
132
|
+
isActionAirlineChangesError: N,
|
|
133
|
+
actionAirlineChangesError: v,
|
|
134
|
+
pointsAsCashDetails: i,
|
|
135
|
+
isLoadingPointsAsCash: F
|
|
130
136
|
};
|
|
131
137
|
};
|
|
132
138
|
export {
|
|
133
|
-
|
|
139
|
+
b as useBookingManagement
|
|
134
140
|
};
|
|
@@ -50,7 +50,8 @@ export declare enum EBookingEndpoints {
|
|
|
50
50
|
CONFIRM_FLIGHT_CANCEL = "/duffel/flights/confirm-order-cancellation",
|
|
51
51
|
CANCEL_HOTEL_BOOKING = "/duffel/hotels/cancel",
|
|
52
52
|
ACTION_AIRLINE_CHANGES = "/user/bookings/flights/action-airline-initiated-changes",
|
|
53
|
-
REFUND_POINTS_BOOKING = "/points-as-cash/refund-booking"
|
|
53
|
+
REFUND_POINTS_BOOKING = "/points-as-cash/refund-booking",
|
|
54
|
+
BOOKING_POINTS_AS_CASH = "/points-as-cash"
|
|
54
55
|
}
|
|
55
56
|
export declare enum ERewardsEndpoints {
|
|
56
57
|
POINTS_PER_CENT = "/user/rewards/points-per-cent"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IFlightBookingDetails, IHotelBookingDetails } from '../../services/bookings/BookingService.types';
|
|
1
|
+
import { IFlightBookingDetails, IHotelBookingDetails, IPointsAsCash } from '../../services/bookings/BookingService.types';
|
|
2
2
|
export interface IUseBookingManagement {
|
|
3
3
|
/**
|
|
4
4
|
* The booking details, which can be either hotel or flight booking details
|
|
@@ -77,4 +77,12 @@ export interface IUseBookingManagement {
|
|
|
77
77
|
* The error object if there was an error while handling airline initiated changes
|
|
78
78
|
*/
|
|
79
79
|
actionAirlineChangesError: Error | null;
|
|
80
|
+
/**
|
|
81
|
+
* Points as cash details for the booking, if available
|
|
82
|
+
*/
|
|
83
|
+
pointsAsCashDetails: IPointsAsCash | undefined;
|
|
84
|
+
/**
|
|
85
|
+
* Indicates if the points as cash details are being loaded
|
|
86
|
+
*/
|
|
87
|
+
isLoadingPointsAsCash: boolean;
|
|
80
88
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IActionAirlineChangesRequest, ICancelPointsBookingArgs, IFlightBookingDetails, IHotelBookingDetails } from './BookingService.types';
|
|
1
|
+
import { IActionAirlineChangesRequest, ICancelPointsBookingArgs, IFlightBookingDetails, IHotelBookingDetails, IPointsAsCash } from './BookingService.types';
|
|
2
2
|
declare class _BookingService {
|
|
3
3
|
getHotelBooking: (bookingId: string) => Promise<IHotelBookingDetails>;
|
|
4
4
|
getFlightBooking: (bookingId: string) => Promise<IFlightBookingDetails>;
|
|
@@ -7,6 +7,7 @@ declare class _BookingService {
|
|
|
7
7
|
cancelHotelBooking: (bookingId: string) => Promise<any>;
|
|
8
8
|
actionAirlineChanges: ({ bookingId, acceptChanges, aicId }: IActionAirlineChangesRequest) => Promise<any>;
|
|
9
9
|
cancelPointsBooking: (args: ICancelPointsBookingArgs) => Promise<any>;
|
|
10
|
+
getPointsAsCash: (bookingId: string) => Promise<IPointsAsCash>;
|
|
10
11
|
}
|
|
11
12
|
export declare const BookingService: _BookingService;
|
|
12
13
|
export {};
|
|
@@ -40,7 +40,6 @@ export interface IHotelBookingDetails {
|
|
|
40
40
|
checkinAfterTime: string;
|
|
41
41
|
coordinates: ICoordinates;
|
|
42
42
|
cancellationTimeline: ICancellationTimeline[];
|
|
43
|
-
pointsAsCash?: IPointsAsCash;
|
|
44
43
|
rooms: {
|
|
45
44
|
beds: IBed[];
|
|
46
45
|
totalAmount: number;
|
|
@@ -108,7 +107,6 @@ export interface IFlightBookingDetails {
|
|
|
108
107
|
flights: IFlight[];
|
|
109
108
|
availableActions: string[];
|
|
110
109
|
airlineInitiatedChanges: IAirlineInitiatedChanges[];
|
|
111
|
-
pointsAsCash?: IPointsAsCash;
|
|
112
110
|
}
|
|
113
111
|
export interface IFlight {
|
|
114
112
|
origin: IAirport;
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
1
|
+
var g = Object.defineProperty;
|
|
2
|
+
var y = (r, t, a) => t in r ? g(r, t, { enumerable: !0, configurable: !0, writable: !0, value: a }) : r[t] = a;
|
|
3
|
+
var i = (r, t, a) => y(r, typeof t != "symbol" ? t + "" : t, a);
|
|
4
4
|
import "../../arrayExtensions-DlcBOj5a.js";
|
|
5
|
-
import { c as
|
|
5
|
+
import { c as d, b as l, g as p } from "../../noRetryInstance-oiHCni_Z.js";
|
|
6
6
|
import "react";
|
|
7
|
-
import { EBookingEndpoints as
|
|
8
|
-
const f = (
|
|
9
|
-
const t = /P((\d+)D)?T((\d+)H)?((\d+)M)?/, a =
|
|
7
|
+
import { EBookingEndpoints as c } from "../../configs/endpoints.js";
|
|
8
|
+
const f = (r) => {
|
|
9
|
+
const t = /P((\d+)D)?T((\d+)H)?((\d+)M)?/, a = r.match(t);
|
|
10
10
|
if (a) {
|
|
11
|
-
const o = a[2] ? `${a[2]}d ` : "", e = a[4] ? `${a[4]}h ` : "",
|
|
12
|
-
return `${o}${e}${
|
|
11
|
+
const o = a[2] ? `${a[2]}d ` : "", e = a[4] ? `${a[4]}h ` : "", m = a[6] ? `${a[6]}m` : "";
|
|
12
|
+
return `${o}${e}${m}`.trim();
|
|
13
13
|
} else
|
|
14
|
-
return
|
|
14
|
+
return r;
|
|
15
15
|
};
|
|
16
|
-
class
|
|
16
|
+
class h {
|
|
17
17
|
constructor() {
|
|
18
|
-
|
|
19
|
-
var
|
|
20
|
-
const { data: a } = await
|
|
21
|
-
`${
|
|
18
|
+
i(this, "getHotelBooking", async (t) => {
|
|
19
|
+
var m, _;
|
|
20
|
+
const { data: a } = await d.get(
|
|
21
|
+
`${c.USER_HOTEL_BOOKINGS}/${t}`
|
|
22
22
|
), o = a.data.accommodation.rooms[0].rates[0];
|
|
23
23
|
return {
|
|
24
24
|
id: a.data._id,
|
|
@@ -62,7 +62,7 @@ class y {
|
|
|
62
62
|
type: (s = a.data.guest_types[u]) == null ? void 0 : s.type
|
|
63
63
|
};
|
|
64
64
|
}),
|
|
65
|
-
numberOfRooms: (
|
|
65
|
+
numberOfRooms: (m = a.data.rooms) == null ? void 0 : m.length,
|
|
66
66
|
cancellationTimeline: o.cancellation_timeline.map(
|
|
67
67
|
(n) => ({
|
|
68
68
|
refundAmount: parseFloat(n.refund_amount),
|
|
@@ -70,15 +70,7 @@ class y {
|
|
|
70
70
|
before: n.before
|
|
71
71
|
})
|
|
72
72
|
),
|
|
73
|
-
|
|
74
|
-
authCode: a.data.points_as_cash.auth_code,
|
|
75
|
-
points: a.data.points_as_cash.points,
|
|
76
|
-
pointsValue: a.data.points_as_cash.points_value,
|
|
77
|
-
confirmationCode: a.data.points_as_cash.confirmation_code,
|
|
78
|
-
provider: a.data.points_as_cash.provider,
|
|
79
|
-
cashValue: a.data.points_as_cash.cash_value
|
|
80
|
-
} : void 0,
|
|
81
|
-
rooms: (m = a.data.rooms) == null ? void 0 : m.map((n) => {
|
|
73
|
+
rooms: (_ = a.data.rooms) == null ? void 0 : _.map((n) => {
|
|
82
74
|
var u;
|
|
83
75
|
return {
|
|
84
76
|
beds: (u = n.beds) == null ? void 0 : u.map((s) => ({
|
|
@@ -92,9 +84,9 @@ class y {
|
|
|
92
84
|
createdAt: a.data.created_at
|
|
93
85
|
};
|
|
94
86
|
});
|
|
95
|
-
|
|
96
|
-
const { data: a } = await
|
|
97
|
-
`${
|
|
87
|
+
i(this, "getFlightBooking", async (t) => {
|
|
88
|
+
const { data: a } = await d.get(
|
|
89
|
+
`${c.USER_FLIGHT_BOOKINGS}/${t}`
|
|
98
90
|
);
|
|
99
91
|
return {
|
|
100
92
|
id: a.data._id,
|
|
@@ -149,42 +141,34 @@ class y {
|
|
|
149
141
|
destination: l(e.destination)
|
|
150
142
|
})),
|
|
151
143
|
availableActions: a.data.available_actions,
|
|
152
|
-
airlineInitiatedChanges: l(a.data.airline_initiated_changes) || []
|
|
153
|
-
pointsAsCash: a.data.points_as_cash ? {
|
|
154
|
-
authCode: a.data.points_as_cash.auth_code,
|
|
155
|
-
points: a.data.points_as_cash.points,
|
|
156
|
-
pointsValue: a.data.points_as_cash.points_value,
|
|
157
|
-
confirmationCode: a.data.points_as_cash.confirmation_code,
|
|
158
|
-
provider: a.data.points_as_cash.provider,
|
|
159
|
-
cashValue: a.data.points_as_cash.cash_value
|
|
160
|
-
} : void 0
|
|
144
|
+
airlineInitiatedChanges: l(a.data.airline_initiated_changes) || []
|
|
161
145
|
};
|
|
162
146
|
});
|
|
163
|
-
|
|
164
|
-
const { data: a } = await
|
|
165
|
-
`${
|
|
147
|
+
i(this, "initiateCancelFlightBooking", async (t) => {
|
|
148
|
+
const { data: a } = await d.put(
|
|
149
|
+
`${c.INITIATE_FLIGHT_CANCEL}/${t}`
|
|
166
150
|
);
|
|
167
151
|
return a.success;
|
|
168
152
|
});
|
|
169
|
-
|
|
170
|
-
const { data: a } = await
|
|
171
|
-
`${
|
|
153
|
+
i(this, "confirmCancelFlightBooking", async (t) => {
|
|
154
|
+
const { data: a } = await d.put(
|
|
155
|
+
`${c.CONFIRM_FLIGHT_CANCEL}/${t}`
|
|
172
156
|
);
|
|
173
157
|
return a.success;
|
|
174
158
|
});
|
|
175
|
-
|
|
176
|
-
const { data: a } = await
|
|
177
|
-
`${
|
|
159
|
+
i(this, "cancelHotelBooking", async (t) => {
|
|
160
|
+
const { data: a } = await d.post(
|
|
161
|
+
`${c.CANCEL_HOTEL_BOOKING}/${t}`
|
|
178
162
|
);
|
|
179
163
|
return a.success;
|
|
180
164
|
});
|
|
181
|
-
|
|
165
|
+
i(this, "actionAirlineChanges", async ({
|
|
182
166
|
bookingId: t,
|
|
183
167
|
acceptChanges: a,
|
|
184
168
|
aicId: o
|
|
185
169
|
}) => {
|
|
186
|
-
const { data: e } = await
|
|
187
|
-
|
|
170
|
+
const { data: e } = await d.post(
|
|
171
|
+
c.ACTION_AIRLINE_CHANGES,
|
|
188
172
|
{
|
|
189
173
|
booking_id: t,
|
|
190
174
|
action_taken: a ? "accepted" : "cancelled",
|
|
@@ -193,9 +177,9 @@ class y {
|
|
|
193
177
|
);
|
|
194
178
|
return e.success;
|
|
195
179
|
});
|
|
196
|
-
|
|
197
|
-
const { data: a } = await
|
|
198
|
-
`${
|
|
180
|
+
i(this, "cancelPointsBooking", async (t) => {
|
|
181
|
+
const { data: a } = await p.post(
|
|
182
|
+
`${c.REFUND_POINTS_BOOKING}`,
|
|
199
183
|
{
|
|
200
184
|
confirmationCode: t.confirmationCode,
|
|
201
185
|
orderId: t.orderId,
|
|
@@ -207,9 +191,18 @@ class y {
|
|
|
207
191
|
);
|
|
208
192
|
return a.success;
|
|
209
193
|
});
|
|
194
|
+
i(this, "getPointsAsCash", async (t) => {
|
|
195
|
+
const { data: a } = await p.get(
|
|
196
|
+
`${c.BOOKING_POINTS_AS_CASH}/${t}`
|
|
197
|
+
);
|
|
198
|
+
return {
|
|
199
|
+
...a.data,
|
|
200
|
+
cashValue: a.data.cash
|
|
201
|
+
};
|
|
202
|
+
});
|
|
210
203
|
}
|
|
211
204
|
}
|
|
212
|
-
const
|
|
205
|
+
const N = new h();
|
|
213
206
|
export {
|
|
214
|
-
|
|
207
|
+
N as BookingService
|
|
215
208
|
};
|