@odynn/awayz-core 0.9.7 → 0.9.8
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,6 +1,6 @@
|
|
|
1
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 o } from "../../noRetryInstance-oiHCni_Z.js";
|
|
4
4
|
import "react";
|
|
5
5
|
import "react/jsx-runtime";
|
|
6
6
|
import "react-i18next";
|
|
@@ -10,41 +10,41 @@ import "../../_styles.flight-booking-DEUJthTJ.js";
|
|
|
10
10
|
import { awayzClient as k } from "../../configs/awayzClient.js";
|
|
11
11
|
/* empty css */
|
|
12
12
|
import "../../context/AwayzContext.js";
|
|
13
|
-
import { EBookingType as
|
|
13
|
+
import { EBookingType as n } from "../../services/trips/TripService.types.js";
|
|
14
14
|
/* empty css */
|
|
15
15
|
import { BookingService as e } from "../../services/bookings/BookingService.js";
|
|
16
16
|
const b = (r, t) => {
|
|
17
17
|
const {
|
|
18
18
|
data: s,
|
|
19
|
-
isError:
|
|
20
|
-
error:
|
|
19
|
+
isError: B,
|
|
20
|
+
error: p
|
|
21
21
|
} = u({
|
|
22
|
-
queryKey: [
|
|
22
|
+
queryKey: [o.BOOKING, r, n.HOTEL],
|
|
23
23
|
queryFn: () => e.getHotelBooking(r),
|
|
24
|
-
enabled: t ===
|
|
24
|
+
enabled: t === n.HOTEL && !!r
|
|
25
25
|
}), {
|
|
26
|
-
data:
|
|
27
|
-
isError:
|
|
28
|
-
error:
|
|
26
|
+
data: i,
|
|
27
|
+
isError: f,
|
|
28
|
+
error: F
|
|
29
29
|
} = u({
|
|
30
|
-
queryKey: [
|
|
30
|
+
queryKey: [o.BOOKING, r, n.FLIGHT],
|
|
31
31
|
queryFn: () => e.getFlightBooking(r),
|
|
32
|
-
enabled: t ===
|
|
33
|
-
}), { data:
|
|
34
|
-
queryKey: [
|
|
32
|
+
enabled: t === n.FLIGHT && !!r
|
|
33
|
+
}), { data: a, isLoading: O } = u({
|
|
34
|
+
queryKey: [o.BOOKING, r],
|
|
35
35
|
queryFn: () => e.getPointsAsCash(r),
|
|
36
36
|
enabled: !!r
|
|
37
37
|
}), {
|
|
38
|
-
mutate:
|
|
39
|
-
isPending:
|
|
40
|
-
isError:
|
|
41
|
-
error:
|
|
42
|
-
isSuccess:
|
|
38
|
+
mutate: d,
|
|
39
|
+
isPending: y,
|
|
40
|
+
isError: H,
|
|
41
|
+
error: A,
|
|
42
|
+
isSuccess: G
|
|
43
43
|
} = m({
|
|
44
44
|
mutationFn: async () => {
|
|
45
|
-
if (
|
|
45
|
+
if (a)
|
|
46
46
|
throw new Error("Not supported for bookings made with Points as Cash");
|
|
47
|
-
if (t ===
|
|
47
|
+
if (t === n.FLIGHT)
|
|
48
48
|
return e.initiateCancelFlightBooking(r);
|
|
49
49
|
throw new Error("Not supported for hotel bookings");
|
|
50
50
|
},
|
|
@@ -52,51 +52,37 @@ const b = (r, t) => {
|
|
|
52
52
|
c();
|
|
53
53
|
}
|
|
54
54
|
}), {
|
|
55
|
-
mutate:
|
|
56
|
-
isPending:
|
|
55
|
+
mutate: L,
|
|
56
|
+
isPending: E,
|
|
57
57
|
isError: S,
|
|
58
58
|
error: w,
|
|
59
|
-
isSuccess:
|
|
59
|
+
isSuccess: K
|
|
60
60
|
} = m({
|
|
61
61
|
mutationFn: async () => {
|
|
62
|
-
if (t ===
|
|
63
|
-
return
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
provider: i.provider,
|
|
67
|
-
type: o.FLIGHT,
|
|
68
|
-
pointsAmount: i.points,
|
|
69
|
-
cashAmount: i.cashValue.amount
|
|
70
|
-
}), e.confirmCancelFlightBooking(r);
|
|
71
|
-
if (t === o.HOTEL)
|
|
72
|
-
return i && s && await e.cancelPointsBooking({
|
|
73
|
-
confirmationCode: i.confirmationCode,
|
|
74
|
-
orderId: s.bookingId,
|
|
75
|
-
provider: i.provider,
|
|
76
|
-
type: o.HOTEL,
|
|
77
|
-
pointsAmount: i.points,
|
|
78
|
-
cashAmount: i.cashValue.amount
|
|
79
|
-
}), e.cancelHotelBooking(r);
|
|
62
|
+
if (t === n.FLIGHT)
|
|
63
|
+
return a && i && await e.cancelPointsBooking(i.id), e.confirmCancelFlightBooking(r);
|
|
64
|
+
if (t === n.HOTEL)
|
|
65
|
+
return a && s && await e.cancelPointsBooking(s.id), e.cancelHotelBooking(r);
|
|
80
66
|
},
|
|
81
67
|
onSuccess: () => {
|
|
82
68
|
c();
|
|
83
69
|
}
|
|
84
70
|
}), {
|
|
85
|
-
mutate:
|
|
86
|
-
isPending:
|
|
87
|
-
isError:
|
|
88
|
-
error:
|
|
71
|
+
mutate: P,
|
|
72
|
+
isPending: N,
|
|
73
|
+
isError: q,
|
|
74
|
+
error: T
|
|
89
75
|
} = m({
|
|
90
76
|
mutationFn: async (l) => {
|
|
91
|
-
var
|
|
92
|
-
const
|
|
77
|
+
var g, h;
|
|
78
|
+
const C = (h = (g = i == null ? void 0 : i.airlineInitiatedChanges) == null ? void 0 : g.filter(
|
|
93
79
|
(Q) => !Q.actionTaken
|
|
94
|
-
)) == null ? void 0 :
|
|
95
|
-
if (t ===
|
|
80
|
+
)) == null ? void 0 : h[0];
|
|
81
|
+
if (t === n.FLIGHT && (i != null && i.airlineInitiatedChanges) && C)
|
|
96
82
|
return e.actionAirlineChanges({
|
|
97
83
|
bookingId: r,
|
|
98
84
|
acceptChanges: l,
|
|
99
|
-
aicId:
|
|
85
|
+
aicId: C.id
|
|
100
86
|
});
|
|
101
87
|
throw new Error("Not supported for hotel bookings");
|
|
102
88
|
},
|
|
@@ -105,34 +91,34 @@ const b = (r, t) => {
|
|
|
105
91
|
}
|
|
106
92
|
}), c = () => {
|
|
107
93
|
[
|
|
108
|
-
[
|
|
109
|
-
[
|
|
110
|
-
[
|
|
94
|
+
[o.BOOKING, r, t],
|
|
95
|
+
[o.TRIPS],
|
|
96
|
+
[o.UNCATEGORISED_BOOKINGS]
|
|
111
97
|
].forEach((l) => {
|
|
112
98
|
k.invalidateQueries({ queryKey: l });
|
|
113
99
|
});
|
|
114
|
-
},
|
|
100
|
+
}, I = B || f, v = p || F;
|
|
115
101
|
return {
|
|
116
|
-
details: t ===
|
|
117
|
-
isError:
|
|
118
|
-
error:
|
|
119
|
-
initiateCancellation:
|
|
120
|
-
isInitiatingCancellation:
|
|
121
|
-
isInitiateCancellationError:
|
|
122
|
-
initiateCancellationError:
|
|
123
|
-
isInitiateCancellationSuccess:
|
|
124
|
-
cancelBooking:
|
|
125
|
-
isCancellingBooking:
|
|
126
|
-
isCancelingBooking:
|
|
102
|
+
details: t === n.HOTEL ? s : i,
|
|
103
|
+
isError: I,
|
|
104
|
+
error: v,
|
|
105
|
+
initiateCancellation: d,
|
|
106
|
+
isInitiatingCancellation: y,
|
|
107
|
+
isInitiateCancellationError: H,
|
|
108
|
+
initiateCancellationError: A,
|
|
109
|
+
isInitiateCancellationSuccess: G,
|
|
110
|
+
cancelBooking: L,
|
|
111
|
+
isCancellingBooking: E,
|
|
112
|
+
isCancelingBooking: E,
|
|
127
113
|
isCancelBookingError: S,
|
|
128
114
|
cancelBookingError: w,
|
|
129
|
-
isCancelBookingSuccess:
|
|
130
|
-
actionAirlineChanges:
|
|
131
|
-
isActionAirlineChangesPending:
|
|
132
|
-
isActionAirlineChangesError:
|
|
133
|
-
actionAirlineChangesError:
|
|
134
|
-
pointsAsCashDetails:
|
|
135
|
-
isLoadingPointsAsCash:
|
|
115
|
+
isCancelBookingSuccess: K,
|
|
116
|
+
actionAirlineChanges: P,
|
|
117
|
+
isActionAirlineChangesPending: N,
|
|
118
|
+
isActionAirlineChangesError: q,
|
|
119
|
+
actionAirlineChangesError: T,
|
|
120
|
+
pointsAsCashDetails: a,
|
|
121
|
+
isLoadingPointsAsCash: O
|
|
136
122
|
};
|
|
137
123
|
};
|
|
138
124
|
export {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IActionAirlineChangesRequest,
|
|
1
|
+
import { IActionAirlineChangesRequest, 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>;
|
|
@@ -6,7 +6,7 @@ declare class _BookingService {
|
|
|
6
6
|
confirmCancelFlightBooking: (bookingId: string) => Promise<any>;
|
|
7
7
|
cancelHotelBooking: (bookingId: string) => Promise<any>;
|
|
8
8
|
actionAirlineChanges: ({ bookingId, acceptChanges, aicId }: IActionAirlineChangesRequest) => Promise<any>;
|
|
9
|
-
cancelPointsBooking: (
|
|
9
|
+
cancelPointsBooking: (bookingId: string) => Promise<any>;
|
|
10
10
|
getPointsAsCash: (bookingId: string) => Promise<IPointsAsCash>;
|
|
11
11
|
}
|
|
12
12
|
export declare const BookingService: _BookingService;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { IAirport, ICoordinates, ISlice } from '@type-op/shared';
|
|
2
|
-
import { EBookingType } from '../trips/TripService.types';
|
|
3
2
|
export interface IGuest {
|
|
4
3
|
familyName: string;
|
|
5
4
|
givenName: string;
|
|
@@ -134,11 +133,3 @@ export interface IAirlineInitiatedChanges {
|
|
|
134
133
|
added: ISlice[];
|
|
135
134
|
removed: ISlice[];
|
|
136
135
|
}
|
|
137
|
-
export interface ICancelPointsBookingArgs {
|
|
138
|
-
confirmationCode: string;
|
|
139
|
-
orderId: string;
|
|
140
|
-
provider: string;
|
|
141
|
-
type: EBookingType;
|
|
142
|
-
pointsAmount: number;
|
|
143
|
-
cashAmount: number;
|
|
144
|
-
}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
var g = Object.defineProperty;
|
|
2
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
|
|
3
|
+
var c = (r, t, a) => y(r, typeof t != "symbol" ? t + "" : t, a);
|
|
4
4
|
import "../../arrayExtensions-DlcBOj5a.js";
|
|
5
|
-
import { c as d, b as
|
|
5
|
+
import { c as d, b as u, g as p } from "../../noRetryInstance-oiHCni_Z.js";
|
|
6
6
|
import "react";
|
|
7
|
-
import { EBookingEndpoints as
|
|
7
|
+
import { EBookingEndpoints as i } from "../../configs/endpoints.js";
|
|
8
8
|
const f = (r) => {
|
|
9
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 ` : "", l = a[6] ? `${a[6]}m` : "";
|
|
12
|
+
return `${o}${e}${l}`.trim();
|
|
13
13
|
} else
|
|
14
14
|
return r;
|
|
15
15
|
};
|
|
16
16
|
class h {
|
|
17
17
|
constructor() {
|
|
18
|
-
|
|
19
|
-
var
|
|
18
|
+
c(this, "getHotelBooking", async (t) => {
|
|
19
|
+
var l, _;
|
|
20
20
|
const { data: a } = await d.get(
|
|
21
|
-
`${
|
|
21
|
+
`${i.USER_HOTEL_BOOKINGS}/${t}`
|
|
22
22
|
), o = a.data.accommodation.rooms[0].rates[0];
|
|
23
23
|
return {
|
|
24
24
|
id: a.data._id,
|
|
@@ -54,15 +54,15 @@ class h {
|
|
|
54
54
|
longitude: a.data.accommodation.location.geographic_coordinates.longitude
|
|
55
55
|
},
|
|
56
56
|
images: a.data.accommodation.photos.map((n) => n.url),
|
|
57
|
-
guests: a.data.guests.map((n,
|
|
57
|
+
guests: a.data.guests.map((n, m) => {
|
|
58
58
|
var s;
|
|
59
59
|
return {
|
|
60
60
|
familyName: n.family_name,
|
|
61
61
|
givenName: n.given_name,
|
|
62
|
-
type: (s = a.data.guest_types[
|
|
62
|
+
type: (s = a.data.guest_types[m]) == null ? void 0 : s.type
|
|
63
63
|
};
|
|
64
64
|
}),
|
|
65
|
-
numberOfRooms: (
|
|
65
|
+
numberOfRooms: (l = a.data.rooms) == null ? void 0 : l.length,
|
|
66
66
|
cancellationTimeline: o.cancellation_timeline.map(
|
|
67
67
|
(n) => ({
|
|
68
68
|
refundAmount: parseFloat(n.refund_amount),
|
|
@@ -71,9 +71,9 @@ class h {
|
|
|
71
71
|
})
|
|
72
72
|
),
|
|
73
73
|
rooms: (_ = a.data.rooms) == null ? void 0 : _.map((n) => {
|
|
74
|
-
var
|
|
74
|
+
var m;
|
|
75
75
|
return {
|
|
76
|
-
beds: (
|
|
76
|
+
beds: (m = n.beds) == null ? void 0 : m.map((s) => ({
|
|
77
77
|
type: s.type,
|
|
78
78
|
count: s.count
|
|
79
79
|
})),
|
|
@@ -84,9 +84,9 @@ class h {
|
|
|
84
84
|
createdAt: a.data.created_at
|
|
85
85
|
};
|
|
86
86
|
});
|
|
87
|
-
|
|
87
|
+
c(this, "getFlightBooking", async (t) => {
|
|
88
88
|
const { data: a } = await d.get(
|
|
89
|
-
`${
|
|
89
|
+
`${i.USER_FLIGHT_BOOKINGS}/${t}`
|
|
90
90
|
);
|
|
91
91
|
return {
|
|
92
92
|
id: a.data._id,
|
|
@@ -137,38 +137,38 @@ class h {
|
|
|
137
137
|
numberOfStops: e.segments.length - 1,
|
|
138
138
|
reference: a.data.booking_reference,
|
|
139
139
|
durationInMinutes: f(e.duration),
|
|
140
|
-
origin:
|
|
141
|
-
destination:
|
|
140
|
+
origin: u(e.origin),
|
|
141
|
+
destination: u(e.destination)
|
|
142
142
|
})),
|
|
143
143
|
availableActions: a.data.available_actions,
|
|
144
|
-
airlineInitiatedChanges:
|
|
144
|
+
airlineInitiatedChanges: u(a.data.airline_initiated_changes) || []
|
|
145
145
|
};
|
|
146
146
|
});
|
|
147
|
-
|
|
147
|
+
c(this, "initiateCancelFlightBooking", async (t) => {
|
|
148
148
|
const { data: a } = await d.put(
|
|
149
|
-
`${
|
|
149
|
+
`${i.INITIATE_FLIGHT_CANCEL}/${t}`
|
|
150
150
|
);
|
|
151
151
|
return a.success;
|
|
152
152
|
});
|
|
153
|
-
|
|
153
|
+
c(this, "confirmCancelFlightBooking", async (t) => {
|
|
154
154
|
const { data: a } = await d.put(
|
|
155
|
-
`${
|
|
155
|
+
`${i.CONFIRM_FLIGHT_CANCEL}/${t}`
|
|
156
156
|
);
|
|
157
157
|
return a.success;
|
|
158
158
|
});
|
|
159
|
-
|
|
159
|
+
c(this, "cancelHotelBooking", async (t) => {
|
|
160
160
|
const { data: a } = await d.post(
|
|
161
|
-
`${
|
|
161
|
+
`${i.CANCEL_HOTEL_BOOKING}/${t}`
|
|
162
162
|
);
|
|
163
163
|
return a.success;
|
|
164
164
|
});
|
|
165
|
-
|
|
165
|
+
c(this, "actionAirlineChanges", async ({
|
|
166
166
|
bookingId: t,
|
|
167
167
|
acceptChanges: a,
|
|
168
168
|
aicId: o
|
|
169
169
|
}) => {
|
|
170
170
|
const { data: e } = await d.post(
|
|
171
|
-
|
|
171
|
+
i.ACTION_AIRLINE_CHANGES,
|
|
172
172
|
{
|
|
173
173
|
booking_id: t,
|
|
174
174
|
action_taken: a ? "accepted" : "cancelled",
|
|
@@ -177,23 +177,18 @@ class h {
|
|
|
177
177
|
);
|
|
178
178
|
return e.success;
|
|
179
179
|
});
|
|
180
|
-
|
|
180
|
+
c(this, "cancelPointsBooking", async (t) => {
|
|
181
181
|
const { data: a } = await p.post(
|
|
182
|
-
`${
|
|
182
|
+
`${i.REFUND_POINTS_BOOKING}`,
|
|
183
183
|
{
|
|
184
|
-
|
|
185
|
-
orderId: t.orderId,
|
|
186
|
-
provider: t.provider,
|
|
187
|
-
type: t.type,
|
|
188
|
-
pointsAmount: t.pointsAmount,
|
|
189
|
-
cashAmount: t.cashAmount
|
|
184
|
+
bookingId: t
|
|
190
185
|
}
|
|
191
186
|
);
|
|
192
187
|
return a.success;
|
|
193
188
|
});
|
|
194
|
-
|
|
189
|
+
c(this, "getPointsAsCash", async (t) => {
|
|
195
190
|
const { data: a } = await p.get(
|
|
196
|
-
`${
|
|
191
|
+
`${i.BOOKING_POINTS_AS_CASH}/${t}`
|
|
197
192
|
);
|
|
198
193
|
return {
|
|
199
194
|
...a.data,
|