@odynn/awayz-flights 0.2.20 → 0.2.21
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,5 +1,5 @@
|
|
|
1
1
|
import { jsxs as a, jsx as c, Fragment as E } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import h, { useMemo as q } from "react";
|
|
3
3
|
import { h as P } from "./moment-BGjjqtLQ.js";
|
|
4
4
|
import { a as $, b as z, d as k } from "./dateUtils-BJ6rnfY4.js";
|
|
5
5
|
import { l as J } from "./arrayExtensions-DFLvtO8l.js";
|
|
@@ -19,14 +19,14 @@ var y = /* @__PURE__ */ ((e) => (e.USStringDateFormat = "MMM DD, YYYY", e.USStri
|
|
|
19
19
|
className: void 0,
|
|
20
20
|
style: void 0,
|
|
21
21
|
attr: void 0
|
|
22
|
-
}, B =
|
|
22
|
+
}, B = h.createContext && /* @__PURE__ */ h.createContext(G), R = ["attr", "size", "title"];
|
|
23
23
|
function ee(e, t) {
|
|
24
24
|
if (e == null) return {};
|
|
25
25
|
var r = te(e, t), i, o;
|
|
26
26
|
if (Object.getOwnPropertySymbols) {
|
|
27
|
-
var
|
|
28
|
-
for (o = 0; o <
|
|
29
|
-
i =
|
|
27
|
+
var u = Object.getOwnPropertySymbols(e);
|
|
28
|
+
for (o = 0; o < u.length; o++)
|
|
29
|
+
i = u[o], !(t.indexOf(i) >= 0) && Object.prototype.propertyIsEnumerable.call(e, i) && (r[i] = e[i]);
|
|
30
30
|
}
|
|
31
31
|
return r;
|
|
32
32
|
}
|
|
@@ -89,12 +89,12 @@ function ne(e, t) {
|
|
|
89
89
|
return (t === "string" ? String : Number)(e);
|
|
90
90
|
}
|
|
91
91
|
function I(e) {
|
|
92
|
-
return e && e.map((t, r) => /* @__PURE__ */
|
|
92
|
+
return e && e.map((t, r) => /* @__PURE__ */ h.createElement(t.tag, F({
|
|
93
93
|
key: r
|
|
94
94
|
}, t.attr), I(t.child)));
|
|
95
95
|
}
|
|
96
96
|
function x(e) {
|
|
97
|
-
return (t) => /* @__PURE__ */
|
|
97
|
+
return (t) => /* @__PURE__ */ h.createElement(ae, Z({
|
|
98
98
|
attr: F({}, e.attr)
|
|
99
99
|
}, t), I(e.child));
|
|
100
100
|
}
|
|
@@ -103,23 +103,23 @@ function ae(e) {
|
|
|
103
103
|
var {
|
|
104
104
|
attr: i,
|
|
105
105
|
size: o,
|
|
106
|
-
title:
|
|
107
|
-
} = e,
|
|
108
|
-
return r.className && (l = r.className), e.className && (l = (l ? l + " " : "") + e.className), /* @__PURE__ */
|
|
106
|
+
title: u
|
|
107
|
+
} = e, f = ee(e, R), s = o || r.size || "1em", l;
|
|
108
|
+
return r.className && (l = r.className), e.className && (l = (l ? l + " " : "") + e.className), /* @__PURE__ */ h.createElement("svg", Z({
|
|
109
109
|
stroke: "currentColor",
|
|
110
110
|
fill: "currentColor",
|
|
111
111
|
strokeWidth: "0"
|
|
112
|
-
}, r.attr, i,
|
|
112
|
+
}, r.attr, i, f, {
|
|
113
113
|
className: l,
|
|
114
114
|
style: F(F({
|
|
115
115
|
color: e.color || r.color
|
|
116
116
|
}, r.style), e.style),
|
|
117
|
-
height:
|
|
118
|
-
width:
|
|
117
|
+
height: s,
|
|
118
|
+
width: s,
|
|
119
119
|
xmlns: "http://www.w3.org/2000/svg"
|
|
120
|
-
}),
|
|
120
|
+
}), u && /* @__PURE__ */ h.createElement("title", null, u), e.children);
|
|
121
121
|
};
|
|
122
|
-
return B !== void 0 ? /* @__PURE__ */
|
|
122
|
+
return B !== void 0 ? /* @__PURE__ */ h.createElement(B.Consumer, null, (r) => t(r)) : t(G);
|
|
123
123
|
}
|
|
124
124
|
function K(e) {
|
|
125
125
|
return x({ attr: { viewBox: "0 0 448 512" }, child: [{ tag: "path", attr: { d: "M12 192h424c6.6 0 12 5.4 12 12v260c0 26.5-21.5 48-48 48H48c-26.5 0-48-21.5-48-48V204c0-6.6 5.4-12 12-12zm436-44v-36c0-26.5-21.5-48-48-48h-48V12c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v52H160V12c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v52H48C21.5 64 0 85.5 0 112v36c0 6.6 5.4 12 12 12h424c6.6 0 12-5.4 12-12z" }, child: [] }] })(e);
|
|
@@ -137,38 +137,42 @@ const ge = ({
|
|
|
137
137
|
onDisableRenderItinerary: i,
|
|
138
138
|
isMultiDayFlight: o
|
|
139
139
|
}) => {
|
|
140
|
-
var
|
|
141
|
-
const
|
|
142
|
-
var
|
|
140
|
+
var s, l, v, D, w, A;
|
|
141
|
+
const u = () => {
|
|
142
|
+
var d, g;
|
|
143
|
+
const n = (g = (d = e[0]) == null ? void 0 : d.passengers) == null ? void 0 : g[0];
|
|
144
|
+
return (n == null ? void 0 : n.cabinClassMarketingName) ?? (n == null ? void 0 : n.cabinClass);
|
|
145
|
+
}, f = q(() => {
|
|
146
|
+
var d, g, b, C, O, T, M, N, Y, _, L;
|
|
143
147
|
const n = [];
|
|
144
148
|
for (let j = 0; j < e.length; j++) {
|
|
145
|
-
const
|
|
149
|
+
const p = e[j], m = e[j + 1];
|
|
146
150
|
if (!m)
|
|
147
151
|
break;
|
|
148
152
|
const H = {
|
|
149
153
|
arrival: {
|
|
150
|
-
airport: (
|
|
151
|
-
city: ((
|
|
152
|
-
country: S((O =
|
|
153
|
-
time:
|
|
154
|
-
arrivalTimeZone:
|
|
154
|
+
airport: (d = p.destination) == null ? void 0 : d.name,
|
|
155
|
+
city: ((g = p.destination) == null ? void 0 : g.cityName) ?? ((C = (b = p.destination) == null ? void 0 : b.city) == null ? void 0 : C.name),
|
|
156
|
+
country: S((O = p.destination) == null ? void 0 : O.iataCountryCode),
|
|
157
|
+
time: p.arrivingAt,
|
|
158
|
+
arrivalTimeZone: p.destination.timeZone
|
|
155
159
|
},
|
|
156
160
|
departure: {
|
|
157
161
|
airport: (T = m.origin) == null ? void 0 : T.name,
|
|
158
162
|
city: ((M = m.origin) == null ? void 0 : M.cityName) ?? ((Y = (N = m.origin) == null ? void 0 : N.city) == null ? void 0 : Y.name),
|
|
159
|
-
country: S((_ =
|
|
163
|
+
country: S((_ = p.destination) == null ? void 0 : _.iataCountryCode),
|
|
160
164
|
time: m.departingAt,
|
|
161
165
|
airline: m.operatingCarrier.name,
|
|
162
166
|
airlineCode: m.operatingCarrier.iataCode,
|
|
163
167
|
aircraft: (L = m.aircraft) == null ? void 0 : L.name,
|
|
164
168
|
flightNumber: m.operatingCarrierFlightNumber,
|
|
165
|
-
cabin: m.passengers[0].cabinClassMarketingName ??
|
|
169
|
+
cabin: m.passengers[0].cabinClassMarketingName ?? u(),
|
|
166
170
|
departureTimeZone: m.origin.timeZone
|
|
167
171
|
},
|
|
168
172
|
layoverTime: $({
|
|
169
173
|
// we need to swap around the departure and arrival times
|
|
170
|
-
departureAt:
|
|
171
|
-
departureTimeZone:
|
|
174
|
+
departureAt: p.arrivingAt,
|
|
175
|
+
departureTimeZone: p.destination.timeZone,
|
|
172
176
|
arrivalAt: m.departingAt,
|
|
173
177
|
arrivalTimeZone: m.origin.timeZone
|
|
174
178
|
})
|
|
@@ -190,15 +194,15 @@ const ge = ({
|
|
|
190
194
|
arrivalTimeZone: e[0].destination.timeZone,
|
|
191
195
|
airline: e[0].operatingCarrier.name,
|
|
192
196
|
airlineCode: e[0].operatingCarrier.iataCode,
|
|
193
|
-
aircraft: (
|
|
197
|
+
aircraft: (s = e[0].aircraft) == null ? void 0 : s.name,
|
|
194
198
|
flightNumber: e[0].operatingCarrierFlightNumber,
|
|
195
|
-
cabin:
|
|
199
|
+
cabin: u(),
|
|
196
200
|
isMultiDayFlight: o
|
|
197
201
|
}
|
|
198
202
|
),
|
|
199
|
-
|
|
200
|
-
var
|
|
201
|
-
return /* @__PURE__ */ a(
|
|
203
|
+
f.map((n, d) => {
|
|
204
|
+
var g, b, C, O, T, M, N, Y;
|
|
205
|
+
return /* @__PURE__ */ a(h.Fragment, { children: [
|
|
202
206
|
/* @__PURE__ */ c(
|
|
203
207
|
W,
|
|
204
208
|
{
|
|
@@ -217,13 +221,13 @@ const ge = ({
|
|
|
217
221
|
/* @__PURE__ */ c(
|
|
218
222
|
V,
|
|
219
223
|
{
|
|
220
|
-
airport: (
|
|
224
|
+
airport: (g = n.departure) == null ? void 0 : g.airport,
|
|
221
225
|
city: (b = n.departure) == null ? void 0 : b.city,
|
|
222
226
|
country: (C = n.departure) == null ? void 0 : C.country,
|
|
223
227
|
departureAt: n.departure.time,
|
|
224
228
|
departureTimeZone: n.departure.departureTimeZone,
|
|
225
|
-
arrivalAt: e[
|
|
226
|
-
arrivalTimeZone: e[
|
|
229
|
+
arrivalAt: e[d + 1].arrivingAt,
|
|
230
|
+
arrivalTimeZone: e[d + 1].destination.timeZone,
|
|
227
231
|
airline: (O = n.departure) == null ? void 0 : O.airline,
|
|
228
232
|
airlineCode: (T = n.departure) == null ? void 0 : T.airlineCode,
|
|
229
233
|
aircraft: (M = n.departure) == null ? void 0 : M.aircraft,
|
|
@@ -231,12 +235,12 @@ const ge = ({
|
|
|
231
235
|
cabin: (Y = n.departure) == null ? void 0 : Y.cabin
|
|
232
236
|
}
|
|
233
237
|
)
|
|
234
|
-
] }, n.departure.flightNumber ||
|
|
238
|
+
] }, n.departure.flightNumber || d);
|
|
235
239
|
}),
|
|
236
240
|
/* @__PURE__ */ c(
|
|
237
241
|
W,
|
|
238
242
|
{
|
|
239
|
-
airport: (
|
|
243
|
+
airport: (v = (l = e.getLast()) == null ? void 0 : l.destination) == null ? void 0 : v.name,
|
|
240
244
|
city: r.city,
|
|
241
245
|
country: S(r.country),
|
|
242
246
|
time: (D = e.getLast()) == null ? void 0 : D.arrivingAt,
|
|
@@ -254,18 +258,18 @@ const ge = ({
|
|
|
254
258
|
country: r,
|
|
255
259
|
airline: i,
|
|
256
260
|
airlineCode: o,
|
|
257
|
-
flightNumber:
|
|
258
|
-
aircraft:
|
|
259
|
-
cabin:
|
|
261
|
+
flightNumber: u,
|
|
262
|
+
aircraft: f,
|
|
263
|
+
cabin: s,
|
|
260
264
|
departureAt: l,
|
|
261
|
-
departureTimeZone:
|
|
265
|
+
departureTimeZone: v,
|
|
262
266
|
arrivalAt: D,
|
|
263
267
|
arrivalTimeZone: w,
|
|
264
268
|
isMultiDayFlight: A
|
|
265
269
|
}) => {
|
|
266
270
|
const n = $({
|
|
267
271
|
departureAt: l,
|
|
268
|
-
departureTimeZone:
|
|
272
|
+
departureTimeZone: v,
|
|
269
273
|
arrivalAt: D,
|
|
270
274
|
arrivalTimeZone: w
|
|
271
275
|
});
|
|
@@ -275,7 +279,7 @@ const ge = ({
|
|
|
275
279
|
" ",
|
|
276
280
|
/* @__PURE__ */ a("span", { className: "time-zone", children: [
|
|
277
281
|
"(",
|
|
278
|
-
z(
|
|
282
|
+
z(v, l),
|
|
279
283
|
")"
|
|
280
284
|
] }),
|
|
281
285
|
/* @__PURE__ */ c("br", {}),
|
|
@@ -308,19 +312,19 @@ const ge = ({
|
|
|
308
312
|
/* @__PURE__ */ a("p", { children: [
|
|
309
313
|
/* @__PURE__ */ c("strong", { children: "Aircraft:" }),
|
|
310
314
|
" ",
|
|
311
|
-
|
|
315
|
+
f
|
|
312
316
|
] }),
|
|
313
317
|
/* @__PURE__ */ a("p", { children: [
|
|
314
318
|
/* @__PURE__ */ c("strong", { children: "Flight:" }),
|
|
315
319
|
" ",
|
|
316
320
|
o,
|
|
317
321
|
" ",
|
|
318
|
-
|
|
322
|
+
u
|
|
319
323
|
] }),
|
|
320
324
|
/* @__PURE__ */ a("p", { children: [
|
|
321
325
|
/* @__PURE__ */ c("strong", { children: "Cabin:" }),
|
|
322
326
|
" ",
|
|
323
|
-
X(
|
|
327
|
+
X(s ?? "")
|
|
324
328
|
] })
|
|
325
329
|
] })
|
|
326
330
|
] });
|
|
@@ -330,19 +334,19 @@ const ge = ({
|
|
|
330
334
|
country: r,
|
|
331
335
|
time: i,
|
|
332
336
|
isLayover: o,
|
|
333
|
-
layoverTime:
|
|
334
|
-
arrivalTimeZone:
|
|
335
|
-
isMultiDayFlight:
|
|
337
|
+
layoverTime: u,
|
|
338
|
+
arrivalTimeZone: f,
|
|
339
|
+
isMultiDayFlight: s
|
|
336
340
|
}) => /* @__PURE__ */ a("div", { className: `arrival ${o ? "layover" : ""}`, children: [
|
|
337
341
|
/* @__PURE__ */ a("p", { children: [
|
|
338
342
|
P(i).format(y.FlightTime),
|
|
339
343
|
" ",
|
|
340
344
|
/* @__PURE__ */ a("span", { className: "time-zone", children: [
|
|
341
345
|
"(",
|
|
342
|
-
|
|
346
|
+
f,
|
|
343
347
|
")"
|
|
344
348
|
] }),
|
|
345
|
-
|
|
349
|
+
s && !o ? /* @__PURE__ */ a("div", { className: "travel-time", children: [
|
|
346
350
|
/* @__PURE__ */ c(K, {}),
|
|
347
351
|
/* @__PURE__ */ a("span", { children: [
|
|
348
352
|
"Arrival: ",
|
|
@@ -360,7 +364,7 @@ const ge = ({
|
|
|
360
364
|
", ",
|
|
361
365
|
r
|
|
362
366
|
] }),
|
|
363
|
-
/* @__PURE__ */ c("i", { children: o ?
|
|
367
|
+
/* @__PURE__ */ c("i", { children: o ? u : "" })
|
|
364
368
|
] })
|
|
365
369
|
] });
|
|
366
370
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "react/jsx-runtime";
|
|
2
2
|
import "react";
|
|
3
3
|
import "../../moment-BGjjqtLQ.js";
|
|
4
|
-
import { a as f } from "../../FlightItinerary-
|
|
4
|
+
import { a as f } from "../../FlightItinerary-lpSE4i3e.js";
|
|
5
5
|
import "../../dateUtils-BJ6rnfY4.js";
|
|
6
6
|
import "../../arrayExtensions-DFLvtO8l.js";
|
|
7
7
|
import "../../constants/constants.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as r, jsxs as e, Fragment as E } from "react/jsx-runtime";
|
|
2
2
|
import I, { useState as F, useMemo as L } from "react";
|
|
3
|
-
import { g as y, E as c, F as R, a as B } from "../../FlightItinerary-
|
|
3
|
+
import { g as y, E as c, F as R, a as B } from "../../FlightItinerary-lpSE4i3e.js";
|
|
4
4
|
import { DEFAULT_AIRLINE_PROGRAM as M, getFlightNumber as $, getLogoPath as x, getAirlineProgram as j } from "../../utils/flightUtils.js";
|
|
5
5
|
import { h } from "../../moment-BGjjqtLQ.js";
|
|
6
6
|
import { g as H } from "../../dateUtils-BJ6rnfY4.js";
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { useState as H, useRef as J } from "react";
|
|
2
2
|
import { useMutation as k } from "@tanstack/react-query";
|
|
3
3
|
import { ECabinClass as X, EFlightType as $, EFlightPaymentType as F } from "../../types/enums.js";
|
|
4
|
-
import { FlightService as
|
|
4
|
+
import { FlightService as D } from "../../services/flights/FlightsService.js";
|
|
5
5
|
import { mapDataToFlightDetails as Z, groupFlightResults as Q, buildFlightSearchQuery as ee } from "../../utils/flightUtils.js";
|
|
6
6
|
import "../../moment-BGjjqtLQ.js";
|
|
7
7
|
import "../../arrayExtensions-DFLvtO8l.js";
|
|
8
8
|
import { c as W } from "../../objectUtils-CyIaVmog.js";
|
|
9
9
|
import te from "../../stores/useFlightStore.js";
|
|
10
|
-
import { useAwayzContext as ne, awayzClient as
|
|
11
|
-
var I = /* @__PURE__ */ ((
|
|
12
|
-
async function oe(
|
|
13
|
-
const o =
|
|
10
|
+
import { useAwayzContext as ne, awayzClient as L, getBaseUrl as re } from "@odynn/awayz-core";
|
|
11
|
+
var I = /* @__PURE__ */ ((e) => (e.LOCATIONS = "LOCATIONS", e.CHECK_USER = "CHECK_USER", e.USER_REGIONS = "USER_REGIONS", e.CONVERT_CURRENCY = "CONVERT_CURRENCY", e.CLIENT_COMPONENT_KEY = "CLIENT_COMPONENT_KEY", e.SEARCH_LIMIT = "SEARCH_LIMIT", e.PROGRAMS = "PROGRAMS", e.BANKS = "BANKS", e.CARDS = "CARDS", e.USER_CARDS = "USER_CARDS", e))(I || {});
|
|
12
|
+
async function oe(e, n) {
|
|
13
|
+
const o = e.getReader();
|
|
14
14
|
let r;
|
|
15
15
|
for (; !(r = await o.read()).done; )
|
|
16
16
|
n(r.value);
|
|
17
17
|
}
|
|
18
|
-
function se(
|
|
18
|
+
function se(e) {
|
|
19
19
|
let n, o, r, s = !1;
|
|
20
20
|
return function(c) {
|
|
21
21
|
n === void 0 ? (n = c, o = 0, r = -1) : n = ie(n, c);
|
|
@@ -37,12 +37,12 @@ function se(t) {
|
|
|
37
37
|
}
|
|
38
38
|
if (l === -1)
|
|
39
39
|
break;
|
|
40
|
-
|
|
40
|
+
e(n.subarray(a, l), r), a = o, r = -1;
|
|
41
41
|
}
|
|
42
42
|
a === u ? n = void 0 : a !== 0 && (n = n.subarray(a), o -= a);
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
|
-
function ae(
|
|
45
|
+
function ae(e, n, o) {
|
|
46
46
|
let r = B();
|
|
47
47
|
const s = new TextDecoder();
|
|
48
48
|
return function(c, u) {
|
|
@@ -59,7 +59,7 @@ function ae(t, n, o) {
|
|
|
59
59
|
r.event = b;
|
|
60
60
|
break;
|
|
61
61
|
case "id":
|
|
62
|
-
|
|
62
|
+
e(r.id = b);
|
|
63
63
|
break;
|
|
64
64
|
case "retry":
|
|
65
65
|
const g = parseInt(b, 10);
|
|
@@ -69,9 +69,9 @@ function ae(t, n, o) {
|
|
|
69
69
|
}
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
|
-
function ie(
|
|
73
|
-
const o = new Uint8Array(
|
|
74
|
-
return o.set(
|
|
72
|
+
function ie(e, n) {
|
|
73
|
+
const o = new Uint8Array(e.length + n.length);
|
|
74
|
+
return o.set(e), o.set(n, e.length), o;
|
|
75
75
|
}
|
|
76
76
|
function B() {
|
|
77
77
|
return {
|
|
@@ -81,48 +81,48 @@ function B() {
|
|
|
81
81
|
retry: void 0
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
|
-
var ue = function(
|
|
84
|
+
var ue = function(e, n) {
|
|
85
85
|
var o = {};
|
|
86
|
-
for (var r in
|
|
87
|
-
if (
|
|
88
|
-
for (var s = 0, r = Object.getOwnPropertySymbols(
|
|
89
|
-
n.indexOf(r[s]) < 0 && Object.prototype.propertyIsEnumerable.call(
|
|
86
|
+
for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && n.indexOf(r) < 0 && (o[r] = e[r]);
|
|
87
|
+
if (e != null && typeof Object.getOwnPropertySymbols == "function")
|
|
88
|
+
for (var s = 0, r = Object.getOwnPropertySymbols(e); s < r.length; s++)
|
|
89
|
+
n.indexOf(r[s]) < 0 && Object.prototype.propertyIsEnumerable.call(e, r[s]) && (o[r[s]] = e[r[s]]);
|
|
90
90
|
return o;
|
|
91
91
|
};
|
|
92
92
|
const j = "text/event-stream", ce = 1e3, G = "last-event-id";
|
|
93
|
-
function de(
|
|
94
|
-
var { signal: o, headers: r, onopen: s, onmessage:
|
|
93
|
+
function de(e, n) {
|
|
94
|
+
var { signal: o, headers: r, onopen: s, onmessage: E, onclose: c, onerror: u, openWhenHidden: a, fetch: l } = n, b = ue(n, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
|
|
95
95
|
return new Promise((g, _) => {
|
|
96
96
|
const p = Object.assign({}, r);
|
|
97
97
|
p.accept || (p.accept = j);
|
|
98
98
|
let m;
|
|
99
|
-
function
|
|
99
|
+
function R() {
|
|
100
100
|
m.abort(), document.hidden || w();
|
|
101
101
|
}
|
|
102
|
-
a || document.addEventListener("visibilitychange",
|
|
103
|
-
let A = ce,
|
|
102
|
+
a || document.addEventListener("visibilitychange", R);
|
|
103
|
+
let A = ce, y = 0;
|
|
104
104
|
function v() {
|
|
105
|
-
document.removeEventListener("visibilitychange",
|
|
105
|
+
document.removeEventListener("visibilitychange", R), window.clearTimeout(y), m.abort();
|
|
106
106
|
}
|
|
107
107
|
o == null || o.addEventListener("abort", () => {
|
|
108
108
|
v(), g();
|
|
109
109
|
});
|
|
110
|
-
const
|
|
110
|
+
const q = l ?? window.fetch, P = s ?? le;
|
|
111
111
|
async function w() {
|
|
112
112
|
var T;
|
|
113
113
|
m = new AbortController();
|
|
114
114
|
try {
|
|
115
|
-
const
|
|
116
|
-
await P(
|
|
115
|
+
const O = await q(e, Object.assign(Object.assign({}, b), { headers: p, signal: m.signal }));
|
|
116
|
+
await P(O), await oe(O.body, se(ae((h) => {
|
|
117
117
|
h ? p[G] = h : delete p[G];
|
|
118
118
|
}, (h) => {
|
|
119
119
|
A = h;
|
|
120
|
-
},
|
|
121
|
-
} catch (
|
|
120
|
+
}, E))), c == null || c(), v(), g();
|
|
121
|
+
} catch (O) {
|
|
122
122
|
if (!m.signal.aborted)
|
|
123
123
|
try {
|
|
124
|
-
const h = (T = u == null ? void 0 : u(
|
|
125
|
-
window.clearTimeout(
|
|
124
|
+
const h = (T = u == null ? void 0 : u(O)) !== null && T !== void 0 ? T : A;
|
|
125
|
+
window.clearTimeout(y), y = window.setTimeout(w, h);
|
|
126
126
|
} catch (h) {
|
|
127
127
|
v(), _(h);
|
|
128
128
|
}
|
|
@@ -131,64 +131,64 @@ function de(t, n) {
|
|
|
131
131
|
w();
|
|
132
132
|
});
|
|
133
133
|
}
|
|
134
|
-
function le(
|
|
135
|
-
const n =
|
|
134
|
+
function le(e) {
|
|
135
|
+
const n = e.headers.get("content-type");
|
|
136
136
|
if (!(n != null && n.startsWith(j)))
|
|
137
137
|
throw new Error(`Expected content-type to be ${j}, Actual: ${n}`);
|
|
138
138
|
}
|
|
139
|
-
const z = 1,
|
|
139
|
+
const z = 1, V = X.ECONOMY;
|
|
140
140
|
let U = new AbortController();
|
|
141
|
-
const fe = 3 * 60 * 1e3,
|
|
142
|
-
if (!
|
|
141
|
+
const fe = 3 * 60 * 1e3, K = (e) => {
|
|
142
|
+
if (!e.origin || !e.destination)
|
|
143
143
|
throw new Error("Origin and destination are required.");
|
|
144
|
-
if (!
|
|
144
|
+
if (!e.departureDate)
|
|
145
145
|
throw new Error("Departure date is required.");
|
|
146
|
-
if (
|
|
146
|
+
if (e.flightType === $.ROUND_TRIP && !e.returnDate)
|
|
147
147
|
throw new Error("Return date is required for round-trip flights.");
|
|
148
148
|
}, we = () => {
|
|
149
|
-
const { token:
|
|
149
|
+
const { token: e, config: n } = ne(), [o, r] = H(""), [s, E] = H([]), [c, u] = H(!1), a = J(null), {
|
|
150
150
|
inboundResults: l,
|
|
151
151
|
outboundResults: b,
|
|
152
152
|
setInboundResults: g,
|
|
153
153
|
setOutboundResults: _,
|
|
154
154
|
partialOfferRequestId: p,
|
|
155
155
|
setPartialOfferRequestId: m
|
|
156
|
-
} = te(),
|
|
157
|
-
data:
|
|
156
|
+
} = te(), R = ({
|
|
157
|
+
data: t,
|
|
158
158
|
inbound: f
|
|
159
159
|
}) => {
|
|
160
|
-
const d = Z(
|
|
160
|
+
const d = Z(t);
|
|
161
161
|
return (f ? g : _)(Q(d)), d;
|
|
162
162
|
}, {
|
|
163
163
|
mutate: A,
|
|
164
|
-
status:
|
|
164
|
+
status: y,
|
|
165
165
|
error: v
|
|
166
166
|
} = k({
|
|
167
|
-
mutationFn: async (
|
|
168
|
-
|
|
167
|
+
mutationFn: async (t) => {
|
|
168
|
+
K(t);
|
|
169
169
|
const d = {
|
|
170
170
|
passengers: Array.from(
|
|
171
|
-
{ length:
|
|
171
|
+
{ length: t.passengers ?? z },
|
|
172
172
|
() => ({ type: "adult" })
|
|
173
173
|
),
|
|
174
|
-
origin:
|
|
175
|
-
destination:
|
|
176
|
-
cabin_class:
|
|
174
|
+
origin: t.origin || "",
|
|
175
|
+
destination: t.destination || "",
|
|
176
|
+
cabin_class: t.cabinClass || V
|
|
177
177
|
};
|
|
178
|
-
if (
|
|
179
|
-
const i = await
|
|
178
|
+
if (t.flightType === $.ONE_WAY) {
|
|
179
|
+
const i = await D.cashOnlySearch({
|
|
180
180
|
...d,
|
|
181
|
-
departure_date:
|
|
181
|
+
departure_date: t.departureDate
|
|
182
182
|
});
|
|
183
183
|
return {
|
|
184
184
|
success: i.success,
|
|
185
185
|
data: i.data
|
|
186
186
|
};
|
|
187
187
|
} else {
|
|
188
|
-
const i = await
|
|
188
|
+
const i = await D.roundTripOutboundSearch({
|
|
189
189
|
...d,
|
|
190
|
-
departure_date:
|
|
191
|
-
return_date:
|
|
190
|
+
departure_date: t.departureDate,
|
|
191
|
+
return_date: t.returnDate
|
|
192
192
|
});
|
|
193
193
|
return {
|
|
194
194
|
success: i.success,
|
|
@@ -197,81 +197,81 @@ const fe = 3 * 60 * 1e3, V = (t) => {
|
|
|
197
197
|
};
|
|
198
198
|
}
|
|
199
199
|
},
|
|
200
|
-
onSuccess: (
|
|
201
|
-
const { success: f, data: d, partialOfferRequestId: i } =
|
|
200
|
+
onSuccess: (t) => {
|
|
201
|
+
const { success: f, data: d, partialOfferRequestId: i } = t;
|
|
202
202
|
if (!f) {
|
|
203
203
|
console.log("oh lol, it didn't work");
|
|
204
204
|
return;
|
|
205
205
|
}
|
|
206
|
-
|
|
206
|
+
R({ data: d }), i && m(i);
|
|
207
207
|
},
|
|
208
|
-
onError: (
|
|
209
|
-
console.error("Error in outbound flight search:",
|
|
208
|
+
onError: (t) => {
|
|
209
|
+
console.error("Error in outbound flight search:", t);
|
|
210
210
|
},
|
|
211
211
|
onSettled: () => {
|
|
212
|
-
|
|
212
|
+
L.invalidateQueries({ queryKey: [I.SEARCH_LIMIT] });
|
|
213
213
|
}
|
|
214
214
|
}), {
|
|
215
|
-
mutate:
|
|
215
|
+
mutate: q,
|
|
216
216
|
status: P,
|
|
217
217
|
error: w
|
|
218
218
|
} = k({
|
|
219
|
-
mutationFn: async (
|
|
219
|
+
mutationFn: async (t) => {
|
|
220
220
|
if (!p)
|
|
221
221
|
throw new Error("No partialOfferRequestId found for inbound search.");
|
|
222
|
-
return r(
|
|
223
|
-
outboundOfferId:
|
|
222
|
+
return r(t), await D.roundTripInboundSearch({
|
|
223
|
+
outboundOfferId: t,
|
|
224
224
|
outboundOfferRequestId: p
|
|
225
225
|
});
|
|
226
226
|
},
|
|
227
|
-
onSuccess: (
|
|
228
|
-
const { success: f, data: d } =
|
|
229
|
-
f &&
|
|
227
|
+
onSuccess: (t) => {
|
|
228
|
+
const { success: f, data: d } = t;
|
|
229
|
+
f && R({
|
|
230
230
|
data: d.offers,
|
|
231
231
|
inbound: !0
|
|
232
232
|
});
|
|
233
233
|
},
|
|
234
|
-
onError: (
|
|
235
|
-
console.error("Error in inbound flight search:",
|
|
234
|
+
onError: (t) => {
|
|
235
|
+
console.error("Error in inbound flight search:", t);
|
|
236
236
|
},
|
|
237
237
|
onSettled: () => {
|
|
238
|
-
|
|
238
|
+
L.invalidateQueries({ queryKey: [I.SEARCH_LIMIT] });
|
|
239
239
|
}
|
|
240
240
|
}), {
|
|
241
241
|
mutate: T,
|
|
242
|
-
status:
|
|
242
|
+
status: O,
|
|
243
243
|
error: h
|
|
244
244
|
} = k({
|
|
245
|
-
mutationFn: async (
|
|
245
|
+
mutationFn: async (t) => {
|
|
246
246
|
if (!p)
|
|
247
247
|
throw new Error("No partialOfferRequestId found for round-trip fares.");
|
|
248
|
-
return await
|
|
248
|
+
return await D.getRoundTripFares({
|
|
249
249
|
outboundOfferId: o,
|
|
250
250
|
outboundOfferRequestId: p,
|
|
251
|
-
inboundOfferId:
|
|
251
|
+
inboundOfferId: t
|
|
252
252
|
});
|
|
253
253
|
},
|
|
254
|
-
onSuccess: (
|
|
255
|
-
const { success: f, data: d } =
|
|
254
|
+
onSuccess: (t) => {
|
|
255
|
+
const { success: f, data: d } = t;
|
|
256
256
|
if (!f) return;
|
|
257
257
|
const i = d.offers;
|
|
258
|
-
|
|
258
|
+
E(W(i));
|
|
259
259
|
},
|
|
260
|
-
onError: (
|
|
261
|
-
console.error("Error in round-trip fare search:",
|
|
260
|
+
onError: (t) => {
|
|
261
|
+
console.error("Error in round-trip fare search:", t);
|
|
262
262
|
},
|
|
263
263
|
onSettled: () => {
|
|
264
|
-
|
|
264
|
+
L.invalidateQueries({ queryKey: [I.SEARCH_LIMIT] });
|
|
265
265
|
}
|
|
266
|
-
}), x = async (
|
|
266
|
+
}), x = async (t) => {
|
|
267
267
|
var Y;
|
|
268
268
|
u(!0);
|
|
269
|
-
const f =
|
|
270
|
-
originCode:
|
|
271
|
-
destinationCode:
|
|
272
|
-
departureDate:
|
|
273
|
-
cabinClass:
|
|
274
|
-
passengerCount:
|
|
269
|
+
const f = t.paymentType === F.CASH_AND_MILES ? ['"cash"', '"points"'] : ['"points"'], d = ee({
|
|
270
|
+
originCode: t.origin,
|
|
271
|
+
destinationCode: t.destination,
|
|
272
|
+
departureDate: t.departureDate,
|
|
273
|
+
cabinClass: t.cabinClass || V,
|
|
274
|
+
passengerCount: t.passengers || z,
|
|
275
275
|
paymentType: f
|
|
276
276
|
});
|
|
277
277
|
let i = [], M = 0;
|
|
@@ -280,7 +280,7 @@ const fe = 3 * 60 * 1e3, V = (t) => {
|
|
|
280
280
|
}, (((Y = n == null ? void 0 : n.flightsConfig) == null ? void 0 : Y.streamTimeoutTotalSeconds) || fe) * 1e3), de(re() + d, {
|
|
281
281
|
headers: {
|
|
282
282
|
"Content-Type": "application/json",
|
|
283
|
-
Authorization:
|
|
283
|
+
Authorization: e || "",
|
|
284
284
|
"client-id": (n == null ? void 0 : n.clientId) || ""
|
|
285
285
|
},
|
|
286
286
|
openWhenHidden: !0,
|
|
@@ -294,7 +294,7 @@ const fe = 3 * 60 * 1e3, V = (t) => {
|
|
|
294
294
|
S();
|
|
295
295
|
return;
|
|
296
296
|
}
|
|
297
|
-
C.flights && (M = 0, i = [...i, ...C.flights],
|
|
297
|
+
C.flights && (M = 0, i = [...i, ...C.flights], R({
|
|
298
298
|
data: i
|
|
299
299
|
})), C.ping && (M++, M >= n.flightsConfig.streamTimeoutPingCount && S());
|
|
300
300
|
} catch (C) {
|
|
@@ -310,7 +310,7 @@ const fe = 3 * 60 * 1e3, V = (t) => {
|
|
|
310
310
|
keepalive: !1
|
|
311
311
|
});
|
|
312
312
|
}, S = () => {
|
|
313
|
-
U.abort(), a.current && (clearTimeout(a.current), a.current = null), u(!1),
|
|
313
|
+
U.abort(), a.current && (clearTimeout(a.current), a.current = null), u(!1), L.invalidateQueries({ queryKey: [I.SEARCH_LIMIT] });
|
|
314
314
|
};
|
|
315
315
|
return {
|
|
316
316
|
/**
|
|
@@ -318,13 +318,13 @@ const fe = 3 * 60 * 1e3, V = (t) => {
|
|
|
318
318
|
* @type {boolean}
|
|
319
319
|
* @default false
|
|
320
320
|
*/
|
|
321
|
-
loading:
|
|
321
|
+
loading: y === "pending" || P === "pending" || c,
|
|
322
322
|
/**
|
|
323
323
|
* Loading status for fares
|
|
324
324
|
* @type {boolean}
|
|
325
325
|
* @default false
|
|
326
326
|
*/
|
|
327
|
-
loadingFares:
|
|
327
|
+
loadingFares: O === "pending",
|
|
328
328
|
outboundError: v,
|
|
329
329
|
inboundError: w,
|
|
330
330
|
roundTripFaresError: h,
|
|
@@ -339,17 +339,17 @@ const fe = 3 * 60 * 1e3, V = (t) => {
|
|
|
339
339
|
*
|
|
340
340
|
* @param {ISearchFlightArgs} args - The search arguments
|
|
341
341
|
*/
|
|
342
|
-
searchOutboundFlights: async (
|
|
343
|
-
switch (
|
|
342
|
+
searchOutboundFlights: async (t) => {
|
|
343
|
+
switch (K(t), _([]), S(), t.paymentType) {
|
|
344
344
|
default:
|
|
345
345
|
case F.CASH_AND_MILES:
|
|
346
|
-
x(
|
|
346
|
+
x(t);
|
|
347
347
|
break;
|
|
348
348
|
case F.CASH:
|
|
349
|
-
A(
|
|
349
|
+
A(t);
|
|
350
350
|
break;
|
|
351
351
|
case F.MILES:
|
|
352
|
-
x(
|
|
352
|
+
x(t);
|
|
353
353
|
break;
|
|
354
354
|
}
|
|
355
355
|
},
|
|
@@ -359,7 +359,7 @@ const fe = 3 * 60 * 1e3, V = (t) => {
|
|
|
359
359
|
*
|
|
360
360
|
* @param {string} outboundOfferId - The ID of the outbound offer
|
|
361
361
|
*/
|
|
362
|
-
searchInboundFlights:
|
|
362
|
+
searchInboundFlights: q,
|
|
363
363
|
/**
|
|
364
364
|
* Used to get round-trip fares after selecting both outbound and inbound flights
|
|
365
365
|
* @type {function}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@odynn/awayz-flights",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.21",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
66
|
"@microsoft/fetch-event-source": "^2.0.1",
|
|
67
|
-
"@odynn/awayz-core": "^0.2.
|
|
67
|
+
"@odynn/awayz-core": "^0.2.33",
|
|
68
68
|
"@tanstack/react-query": "^5.67.1",
|
|
69
69
|
"country-code-lookup": "^0.1.3"
|
|
70
70
|
}
|