@odynn/awayz-flights 0.2.21 → 0.3.1
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/{FlightItinerary-lpSE4i3e.js → FlightItinerary-COx1k-zp.js} +43 -44
- package/dist/components/FlightItinerary/FlightItinerary.js +3 -4
- package/dist/components/FlightResult/FlightResult.js +2 -2
- package/dist/hooks/useFlightSearch/useFlightSearch.js +64 -64
- package/dist/index-D0Heof44.js +58 -0
- package/dist/lib/components/FlightItinerary/FlightItinerary.d.ts +2 -1
- package/dist/lib/hooks/useFlightSearch/useFlightSearch.types.d.ts +1 -115
- package/dist/lib/main.d.ts +2 -0
- package/dist/lib/utils/flightUtils.d.ts +2 -1
- package/dist/utils/flightUtils.js +19 -20
- package/package.json +2 -2
- package/dist/constants/constants.js +0 -4
- package/dist/dateUtils-BJ6rnfY4.js +0 -57
- package/dist/lib/constants/constants.d.ts +0 -1
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import { jsxs as a, jsx as c, Fragment as E } from "react/jsx-runtime";
|
|
2
2
|
import h, { useMemo as q } from "react";
|
|
3
3
|
import { h as P } from "./moment-BGjjqtLQ.js";
|
|
4
|
-
import { a as $, b as z, d as k } from "./
|
|
5
|
-
import { l as
|
|
6
|
-
import { DUFFEL_ASSET_PATH as Q } from "./constants/constants.js";
|
|
4
|
+
import { a as $, b as z, d as k, D as J } from "./index-D0Heof44.js";
|
|
5
|
+
import { l as Q } from "./arrayExtensions-DFLvtO8l.js";
|
|
7
6
|
import './assets/FlightItinerary.css';const X = (e) => e ? e.charAt(0).toUpperCase() + e.slice(1).toLowerCase() : "", S = (e) => {
|
|
8
7
|
var t;
|
|
9
8
|
if (!e) return "";
|
|
10
9
|
try {
|
|
11
|
-
return (t =
|
|
10
|
+
return (t = Q.byIso(e)) == null ? void 0 : t.country;
|
|
12
11
|
} catch (r) {
|
|
13
12
|
return console.error(r), "";
|
|
14
13
|
}
|
|
15
14
|
};
|
|
16
|
-
var
|
|
15
|
+
var Y = /* @__PURE__ */ ((e) => (e.USStringDateFormat = "MMM DD, YYYY", e.USStringDateTimeFormat = "MMM DD, YYYY, h:mm A (z)", e.FlightShortDate = "MMM DD - h:mm A", e.FlightTime = "h:mm A", e.DateFormat = "MM/DD", e.StringDateFormat = "MMM DD", e.FullDateFormat = "MM/DD/YYYY", e.ServerDate = "YYYY-MM-DD", e.GoogleDateFormat = "YYYYMMDDTHHmmssZ", e.AppleDateFormat = "YYYYMMDDTHHmmss", e.USStringDateWithTimeFormat = "MMM DD, YYYY, h:mm A", e))(Y || {}), G = {
|
|
17
16
|
color: void 0,
|
|
18
17
|
size: void 0,
|
|
19
18
|
className: void 0,
|
|
@@ -24,9 +23,9 @@ function ee(e, t) {
|
|
|
24
23
|
if (e == null) return {};
|
|
25
24
|
var r = te(e, t), i, o;
|
|
26
25
|
if (Object.getOwnPropertySymbols) {
|
|
27
|
-
var
|
|
28
|
-
for (o = 0; o <
|
|
29
|
-
i =
|
|
26
|
+
var s = Object.getOwnPropertySymbols(e);
|
|
27
|
+
for (o = 0; o < s.length; o++)
|
|
28
|
+
i = s[o], !(t.indexOf(i) >= 0) && Object.prototype.propertyIsEnumerable.call(e, i) && (r[i] = e[i]);
|
|
30
29
|
}
|
|
31
30
|
return r;
|
|
32
31
|
}
|
|
@@ -103,8 +102,8 @@ function ae(e) {
|
|
|
103
102
|
var {
|
|
104
103
|
attr: i,
|
|
105
104
|
size: o,
|
|
106
|
-
title:
|
|
107
|
-
} = e, f = ee(e, R),
|
|
105
|
+
title: s
|
|
106
|
+
} = e, f = ee(e, R), u = o || r.size || "1em", l;
|
|
108
107
|
return r.className && (l = r.className), e.className && (l = (l ? l + " " : "") + e.className), /* @__PURE__ */ h.createElement("svg", Z({
|
|
109
108
|
stroke: "currentColor",
|
|
110
109
|
fill: "currentColor",
|
|
@@ -114,36 +113,36 @@ function ae(e) {
|
|
|
114
113
|
style: F(F({
|
|
115
114
|
color: e.color || r.color
|
|
116
115
|
}, r.style), e.style),
|
|
117
|
-
height:
|
|
118
|
-
width:
|
|
116
|
+
height: u,
|
|
117
|
+
width: u,
|
|
119
118
|
xmlns: "http://www.w3.org/2000/svg"
|
|
120
|
-
}),
|
|
119
|
+
}), s && /* @__PURE__ */ h.createElement("title", null, s), e.children);
|
|
121
120
|
};
|
|
122
121
|
return B !== void 0 ? /* @__PURE__ */ h.createElement(B.Consumer, null, (r) => t(r)) : t(G);
|
|
123
122
|
}
|
|
124
123
|
function K(e) {
|
|
125
124
|
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);
|
|
126
125
|
}
|
|
127
|
-
function
|
|
126
|
+
function de(e) {
|
|
128
127
|
return x({ attr: { viewBox: "0 0 448 512" }, child: [{ tag: "path", attr: { d: "M207.029 381.476L12.686 187.132c-9.373-9.373-9.373-24.569 0-33.941l22.667-22.667c9.357-9.357 24.522-9.375 33.901-.04L224 284.505l154.745-154.021c9.379-9.335 24.544-9.317 33.901.04l22.667 22.667c9.373 9.373 9.373 24.569 0 33.941L240.971 381.476c-9.373 9.372-24.569 9.372-33.942 0z" }, child: [] }] })(e);
|
|
129
128
|
}
|
|
130
129
|
function oe(e) {
|
|
131
130
|
return x({ attr: { viewBox: "0 0 512 512" }, child: [{ tag: "path", attr: { d: "M256,8C119,8,8,119,8,256S119,504,256,504,504,393,504,256,393,8,256,8Zm92.49,313h0l-20,25a16,16,0,0,1-22.49,2.5h0l-67-49.72a40,40,0,0,1-15-31.23V112a16,16,0,0,1,16-16h32a16,16,0,0,1,16,16V256l58,42.5A16,16,0,0,1,348.49,321Z" }, child: [] }] })(e);
|
|
132
131
|
}
|
|
133
|
-
const
|
|
132
|
+
const pe = ({
|
|
134
133
|
itinerary: e,
|
|
135
134
|
origin: t,
|
|
136
135
|
destination: r,
|
|
137
136
|
onDisableRenderItinerary: i,
|
|
138
137
|
isMultiDayFlight: o
|
|
139
138
|
}) => {
|
|
140
|
-
var
|
|
141
|
-
const
|
|
139
|
+
var u, l, v, y, w, A;
|
|
140
|
+
const s = () => {
|
|
142
141
|
var d, g;
|
|
143
142
|
const n = (g = (d = e[0]) == null ? void 0 : d.passengers) == null ? void 0 : g[0];
|
|
144
143
|
return (n == null ? void 0 : n.cabinClassMarketingName) ?? (n == null ? void 0 : n.cabinClass);
|
|
145
144
|
}, f = q(() => {
|
|
146
|
-
var d, g, b, C, O, T, M,
|
|
145
|
+
var d, g, b, C, O, T, M, D, N, _, L;
|
|
147
146
|
const n = [];
|
|
148
147
|
for (let j = 0; j < e.length; j++) {
|
|
149
148
|
const p = e[j], m = e[j + 1];
|
|
@@ -159,14 +158,14 @@ const ge = ({
|
|
|
159
158
|
},
|
|
160
159
|
departure: {
|
|
161
160
|
airport: (T = m.origin) == null ? void 0 : T.name,
|
|
162
|
-
city: ((M = m.origin) == null ? void 0 : M.cityName) ?? ((
|
|
161
|
+
city: ((M = m.origin) == null ? void 0 : M.cityName) ?? ((N = (D = m.origin) == null ? void 0 : D.city) == null ? void 0 : N.name),
|
|
163
162
|
country: S((_ = p.destination) == null ? void 0 : _.iataCountryCode),
|
|
164
163
|
time: m.departingAt,
|
|
165
164
|
airline: m.operatingCarrier.name,
|
|
166
165
|
airlineCode: m.operatingCarrier.iataCode,
|
|
167
166
|
aircraft: (L = m.aircraft) == null ? void 0 : L.name,
|
|
168
167
|
flightNumber: m.operatingCarrierFlightNumber,
|
|
169
|
-
cabin: m.passengers[0].cabinClassMarketingName ??
|
|
168
|
+
cabin: m.passengers[0].cabinClassMarketingName ?? s(),
|
|
170
169
|
departureTimeZone: m.origin.timeZone
|
|
171
170
|
},
|
|
172
171
|
layoverTime: $({
|
|
@@ -194,14 +193,14 @@ const ge = ({
|
|
|
194
193
|
arrivalTimeZone: e[0].destination.timeZone,
|
|
195
194
|
airline: e[0].operatingCarrier.name,
|
|
196
195
|
airlineCode: e[0].operatingCarrier.iataCode,
|
|
197
|
-
aircraft: (
|
|
196
|
+
aircraft: (u = e[0].aircraft) == null ? void 0 : u.name,
|
|
198
197
|
flightNumber: e[0].operatingCarrierFlightNumber,
|
|
199
|
-
cabin:
|
|
198
|
+
cabin: s(),
|
|
200
199
|
isMultiDayFlight: o
|
|
201
200
|
}
|
|
202
201
|
),
|
|
203
202
|
f.map((n, d) => {
|
|
204
|
-
var g, b, C, O, T, M,
|
|
203
|
+
var g, b, C, O, T, M, D, N;
|
|
205
204
|
return /* @__PURE__ */ a(h.Fragment, { children: [
|
|
206
205
|
/* @__PURE__ */ c(
|
|
207
206
|
W,
|
|
@@ -231,8 +230,8 @@ const ge = ({
|
|
|
231
230
|
airline: (O = n.departure) == null ? void 0 : O.airline,
|
|
232
231
|
airlineCode: (T = n.departure) == null ? void 0 : T.airlineCode,
|
|
233
232
|
aircraft: (M = n.departure) == null ? void 0 : M.aircraft,
|
|
234
|
-
flightNumber: (
|
|
235
|
-
cabin: (
|
|
233
|
+
flightNumber: (D = n.departure) == null ? void 0 : D.flightNumber,
|
|
234
|
+
cabin: (N = n.departure) == null ? void 0 : N.cabin
|
|
236
235
|
}
|
|
237
236
|
)
|
|
238
237
|
] }, n.departure.flightNumber || d);
|
|
@@ -243,7 +242,7 @@ const ge = ({
|
|
|
243
242
|
airport: (v = (l = e.getLast()) == null ? void 0 : l.destination) == null ? void 0 : v.name,
|
|
244
243
|
city: r.city,
|
|
245
244
|
country: S(r.country),
|
|
246
|
-
time: (
|
|
245
|
+
time: (y = e.getLast()) == null ? void 0 : y.arrivingAt,
|
|
247
246
|
arrivalTimeZone: z(
|
|
248
247
|
(w = e.getLast()) == null ? void 0 : w.destination.timeZone,
|
|
249
248
|
(A = e.getLast()) == null ? void 0 : A.arrivingAt
|
|
@@ -258,24 +257,24 @@ const ge = ({
|
|
|
258
257
|
country: r,
|
|
259
258
|
airline: i,
|
|
260
259
|
airlineCode: o,
|
|
261
|
-
flightNumber:
|
|
260
|
+
flightNumber: s,
|
|
262
261
|
aircraft: f,
|
|
263
|
-
cabin:
|
|
262
|
+
cabin: u,
|
|
264
263
|
departureAt: l,
|
|
265
264
|
departureTimeZone: v,
|
|
266
|
-
arrivalAt:
|
|
265
|
+
arrivalAt: y,
|
|
267
266
|
arrivalTimeZone: w,
|
|
268
267
|
isMultiDayFlight: A
|
|
269
268
|
}) => {
|
|
270
269
|
const n = $({
|
|
271
270
|
departureAt: l,
|
|
272
271
|
departureTimeZone: v,
|
|
273
|
-
arrivalAt:
|
|
272
|
+
arrivalAt: y,
|
|
274
273
|
arrivalTimeZone: w
|
|
275
274
|
});
|
|
276
275
|
return /* @__PURE__ */ a("div", { className: "departure", children: [
|
|
277
276
|
/* @__PURE__ */ a("p", { children: [
|
|
278
|
-
P(l).format(
|
|
277
|
+
P(l).format(Y.FlightTime),
|
|
279
278
|
" ",
|
|
280
279
|
/* @__PURE__ */ a("span", { className: "time-zone", children: [
|
|
281
280
|
"(",
|
|
@@ -289,7 +288,7 @@ const ge = ({
|
|
|
289
288
|
" ",
|
|
290
289
|
"Departure:",
|
|
291
290
|
" ",
|
|
292
|
-
P(l).format(
|
|
291
|
+
P(l).format(Y.StringDateFormat)
|
|
293
292
|
] })
|
|
294
293
|
] }) : /* @__PURE__ */ c(E, {}),
|
|
295
294
|
/* @__PURE__ */ a("div", { className: "travel-time", children: [
|
|
@@ -308,7 +307,7 @@ const ge = ({
|
|
|
308
307
|
", ",
|
|
309
308
|
r
|
|
310
309
|
] }),
|
|
311
|
-
/* @__PURE__ */ c("img", { src: `${
|
|
310
|
+
/* @__PURE__ */ c("img", { src: `${J}${o}.svg`, alt: i }),
|
|
312
311
|
/* @__PURE__ */ a("p", { children: [
|
|
313
312
|
/* @__PURE__ */ c("strong", { children: "Aircraft:" }),
|
|
314
313
|
" ",
|
|
@@ -319,12 +318,12 @@ const ge = ({
|
|
|
319
318
|
" ",
|
|
320
319
|
o,
|
|
321
320
|
" ",
|
|
322
|
-
|
|
321
|
+
s
|
|
323
322
|
] }),
|
|
324
323
|
/* @__PURE__ */ a("p", { children: [
|
|
325
324
|
/* @__PURE__ */ c("strong", { children: "Cabin:" }),
|
|
326
325
|
" ",
|
|
327
|
-
X(
|
|
326
|
+
X(u ?? "")
|
|
328
327
|
] })
|
|
329
328
|
] })
|
|
330
329
|
] });
|
|
@@ -334,23 +333,23 @@ const ge = ({
|
|
|
334
333
|
country: r,
|
|
335
334
|
time: i,
|
|
336
335
|
isLayover: o,
|
|
337
|
-
layoverTime:
|
|
336
|
+
layoverTime: s,
|
|
338
337
|
arrivalTimeZone: f,
|
|
339
|
-
isMultiDayFlight:
|
|
338
|
+
isMultiDayFlight: u
|
|
340
339
|
}) => /* @__PURE__ */ a("div", { className: `arrival ${o ? "layover" : ""}`, children: [
|
|
341
340
|
/* @__PURE__ */ a("p", { children: [
|
|
342
|
-
P(i).format(
|
|
341
|
+
P(i).format(Y.FlightTime),
|
|
343
342
|
" ",
|
|
344
343
|
/* @__PURE__ */ a("span", { className: "time-zone", children: [
|
|
345
344
|
"(",
|
|
346
345
|
f,
|
|
347
346
|
")"
|
|
348
347
|
] }),
|
|
349
|
-
|
|
348
|
+
u && !o ? /* @__PURE__ */ a("div", { className: "travel-time", children: [
|
|
350
349
|
/* @__PURE__ */ c(K, {}),
|
|
351
350
|
/* @__PURE__ */ a("span", { children: [
|
|
352
351
|
"Arrival: ",
|
|
353
|
-
P(i).format(
|
|
352
|
+
P(i).format(Y.StringDateFormat)
|
|
354
353
|
] })
|
|
355
354
|
] }) : /* @__PURE__ */ c(E, {})
|
|
356
355
|
] }),
|
|
@@ -364,12 +363,12 @@ const ge = ({
|
|
|
364
363
|
", ",
|
|
365
364
|
r
|
|
366
365
|
] }),
|
|
367
|
-
/* @__PURE__ */ c("i", { children: o ?
|
|
366
|
+
/* @__PURE__ */ c("i", { children: o ? s : "" })
|
|
368
367
|
] })
|
|
369
368
|
] });
|
|
370
369
|
export {
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
370
|
+
Y as E,
|
|
371
|
+
de as F,
|
|
372
|
+
pe as a,
|
|
374
373
|
S as g
|
|
375
374
|
};
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import "react/jsx-runtime";
|
|
2
2
|
import "react";
|
|
3
3
|
import "../../moment-BGjjqtLQ.js";
|
|
4
|
-
import { a as
|
|
5
|
-
import "../../
|
|
4
|
+
import { a as e } from "../../FlightItinerary-COx1k-zp.js";
|
|
5
|
+
import "../../index-D0Heof44.js";
|
|
6
6
|
import "../../arrayExtensions-DFLvtO8l.js";
|
|
7
|
-
import "../../constants/constants.js";
|
|
8
7
|
export {
|
|
9
|
-
|
|
8
|
+
e as default
|
|
10
9
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
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-COx1k-zp.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
|
-
import { g as H } from "../../
|
|
6
|
+
import { g as H } from "../../index-D0Heof44.js";
|
|
7
7
|
import "../../arrayExtensions-DFLvtO8l.js";
|
|
8
8
|
import { EPaymentType as m } from "../../enums/EPaymentType.js";
|
|
9
9
|
import { CashValue as C, EInvalidAmountDisplayOption as U } from "@odynn/awayz-core";
|
|
@@ -5,10 +5,10 @@ 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
|
-
import { c as
|
|
8
|
+
import { c as B } from "../../objectUtils-CyIaVmog.js";
|
|
9
9
|
import te from "../../stores/useFlightStore.js";
|
|
10
10
|
import { useAwayzContext as ne, awayzClient as L, getBaseUrl as re } from "@odynn/awayz-core";
|
|
11
|
-
var
|
|
11
|
+
var y = /* @__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.TRIPS = "TRIPS", e.UNCATEGORISED_BOOKINGS = "UNCATEGORISED_BOOKINGS", e.BOOKING = "BOOKING", e))(y || {});
|
|
12
12
|
async function oe(e, n) {
|
|
13
13
|
const o = e.getReader();
|
|
14
14
|
let r;
|
|
@@ -43,11 +43,11 @@ function se(e) {
|
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
45
|
function ae(e, n, o) {
|
|
46
|
-
let r =
|
|
46
|
+
let r = Y();
|
|
47
47
|
const s = new TextDecoder();
|
|
48
48
|
return function(c, u) {
|
|
49
49
|
if (c.length === 0)
|
|
50
|
-
o == null || o(r), r =
|
|
50
|
+
o == null || o(r), r = Y();
|
|
51
51
|
else if (u > 0) {
|
|
52
52
|
const a = s.decode(c.subarray(0, u)), l = u + (c[u + 1] === 32 ? 2 : 1), b = s.decode(c.subarray(l));
|
|
53
53
|
switch (a) {
|
|
@@ -73,7 +73,7 @@ function ie(e, n) {
|
|
|
73
73
|
const o = new Uint8Array(e.length + n.length);
|
|
74
74
|
return o.set(e), o.set(n, e.length), o;
|
|
75
75
|
}
|
|
76
|
-
function
|
|
76
|
+
function Y() {
|
|
77
77
|
return {
|
|
78
78
|
data: "",
|
|
79
79
|
event: "",
|
|
@@ -89,63 +89,63 @@ var ue = function(e, n) {
|
|
|
89
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
|
-
const
|
|
92
|
+
const G = "text/event-stream", ce = 1e3, W = "last-event-id";
|
|
93
93
|
function de(e, n) {
|
|
94
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
|
-
p.accept || (p.accept =
|
|
97
|
+
p.accept || (p.accept = G);
|
|
98
98
|
let m;
|
|
99
99
|
function R() {
|
|
100
|
-
m.abort(), document.hidden ||
|
|
100
|
+
m.abort(), document.hidden || v();
|
|
101
101
|
}
|
|
102
102
|
a || document.addEventListener("visibilitychange", R);
|
|
103
|
-
let A = ce,
|
|
104
|
-
function
|
|
105
|
-
document.removeEventListener("visibilitychange", R), window.clearTimeout(
|
|
103
|
+
let A = ce, I = 0;
|
|
104
|
+
function T() {
|
|
105
|
+
document.removeEventListener("visibilitychange", R), window.clearTimeout(I), m.abort();
|
|
106
106
|
}
|
|
107
107
|
o == null || o.addEventListener("abort", () => {
|
|
108
|
-
|
|
108
|
+
T(), g();
|
|
109
109
|
});
|
|
110
|
-
const
|
|
111
|
-
async function
|
|
112
|
-
var
|
|
110
|
+
const P = l ?? window.fetch, q = s ?? le;
|
|
111
|
+
async function v() {
|
|
112
|
+
var w;
|
|
113
113
|
m = new AbortController();
|
|
114
114
|
try {
|
|
115
|
-
const
|
|
116
|
-
await
|
|
117
|
-
h ? p[
|
|
115
|
+
const C = await P(e, Object.assign(Object.assign({}, b), { headers: p, signal: m.signal }));
|
|
116
|
+
await q(C), await oe(C.body, se(ae((h) => {
|
|
117
|
+
h ? p[W] = h : delete p[W];
|
|
118
118
|
}, (h) => {
|
|
119
119
|
A = h;
|
|
120
|
-
}, E))), c == null || c(),
|
|
121
|
-
} catch (
|
|
120
|
+
}, E))), c == null || c(), T(), g();
|
|
121
|
+
} catch (C) {
|
|
122
122
|
if (!m.signal.aborted)
|
|
123
123
|
try {
|
|
124
|
-
const h = (
|
|
125
|
-
window.clearTimeout(
|
|
124
|
+
const h = (w = u == null ? void 0 : u(C)) !== null && w !== void 0 ? w : A;
|
|
125
|
+
window.clearTimeout(I), I = window.setTimeout(v, h);
|
|
126
126
|
} catch (h) {
|
|
127
|
-
|
|
127
|
+
T(), _(h);
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
|
-
|
|
131
|
+
v();
|
|
132
132
|
});
|
|
133
133
|
}
|
|
134
134
|
function le(e) {
|
|
135
135
|
const n = e.headers.get("content-type");
|
|
136
|
-
if (!(n != null && n.startsWith(
|
|
137
|
-
throw new Error(`Expected content-type to be ${
|
|
136
|
+
if (!(n != null && n.startsWith(G)))
|
|
137
|
+
throw new Error(`Expected content-type to be ${G}, Actual: ${n}`);
|
|
138
138
|
}
|
|
139
|
-
const z = 1,
|
|
139
|
+
const z = 1, K = X.ECONOMY;
|
|
140
140
|
let U = new AbortController();
|
|
141
|
-
const fe = 3 * 60 * 1e3,
|
|
141
|
+
const fe = 3 * 60 * 1e3, V = (e) => {
|
|
142
142
|
if (!e.origin || !e.destination)
|
|
143
143
|
throw new Error("Origin and destination are required.");
|
|
144
144
|
if (!e.departureDate)
|
|
145
145
|
throw new Error("Departure date is required.");
|
|
146
146
|
if (e.flightType === $.ROUND_TRIP && !e.returnDate)
|
|
147
147
|
throw new Error("Return date is required for round-trip flights.");
|
|
148
|
-
},
|
|
148
|
+
}, ve = () => {
|
|
149
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,
|
|
@@ -161,11 +161,11 @@ const fe = 3 * 60 * 1e3, K = (e) => {
|
|
|
161
161
|
return (f ? g : _)(Q(d)), d;
|
|
162
162
|
}, {
|
|
163
163
|
mutate: A,
|
|
164
|
-
status:
|
|
165
|
-
error:
|
|
164
|
+
status: I,
|
|
165
|
+
error: T
|
|
166
166
|
} = k({
|
|
167
167
|
mutationFn: async (t) => {
|
|
168
|
-
|
|
168
|
+
V(t);
|
|
169
169
|
const d = {
|
|
170
170
|
passengers: Array.from(
|
|
171
171
|
{ length: t.passengers ?? z },
|
|
@@ -173,7 +173,7 @@ const fe = 3 * 60 * 1e3, K = (e) => {
|
|
|
173
173
|
),
|
|
174
174
|
origin: t.origin || "",
|
|
175
175
|
destination: t.destination || "",
|
|
176
|
-
cabin_class: t.cabinClass ||
|
|
176
|
+
cabin_class: t.cabinClass || K
|
|
177
177
|
};
|
|
178
178
|
if (t.flightType === $.ONE_WAY) {
|
|
179
179
|
const i = await D.cashOnlySearch({
|
|
@@ -209,12 +209,12 @@ const fe = 3 * 60 * 1e3, K = (e) => {
|
|
|
209
209
|
console.error("Error in outbound flight search:", t);
|
|
210
210
|
},
|
|
211
211
|
onSettled: () => {
|
|
212
|
-
L.invalidateQueries({ queryKey: [
|
|
212
|
+
L.invalidateQueries({ queryKey: [y.SEARCH_LIMIT] });
|
|
213
213
|
}
|
|
214
214
|
}), {
|
|
215
|
-
mutate:
|
|
216
|
-
status:
|
|
217
|
-
error:
|
|
215
|
+
mutate: P,
|
|
216
|
+
status: q,
|
|
217
|
+
error: v
|
|
218
218
|
} = k({
|
|
219
219
|
mutationFn: async (t) => {
|
|
220
220
|
if (!p)
|
|
@@ -235,11 +235,11 @@ const fe = 3 * 60 * 1e3, K = (e) => {
|
|
|
235
235
|
console.error("Error in inbound flight search:", t);
|
|
236
236
|
},
|
|
237
237
|
onSettled: () => {
|
|
238
|
-
L.invalidateQueries({ queryKey: [
|
|
238
|
+
L.invalidateQueries({ queryKey: [y.SEARCH_LIMIT] });
|
|
239
239
|
}
|
|
240
240
|
}), {
|
|
241
|
-
mutate:
|
|
242
|
-
status:
|
|
241
|
+
mutate: w,
|
|
242
|
+
status: C,
|
|
243
243
|
error: h
|
|
244
244
|
} = k({
|
|
245
245
|
mutationFn: async (t) => {
|
|
@@ -255,29 +255,29 @@ const fe = 3 * 60 * 1e3, K = (e) => {
|
|
|
255
255
|
const { success: f, data: d } = t;
|
|
256
256
|
if (!f) return;
|
|
257
257
|
const i = d.offers;
|
|
258
|
-
E(
|
|
258
|
+
E(B(i));
|
|
259
259
|
},
|
|
260
260
|
onError: (t) => {
|
|
261
261
|
console.error("Error in round-trip fare search:", t);
|
|
262
262
|
},
|
|
263
263
|
onSettled: () => {
|
|
264
|
-
L.invalidateQueries({ queryKey: [
|
|
264
|
+
L.invalidateQueries({ queryKey: [y.SEARCH_LIMIT] });
|
|
265
265
|
}
|
|
266
|
-
}),
|
|
267
|
-
var
|
|
266
|
+
}), j = async (t) => {
|
|
267
|
+
var x;
|
|
268
268
|
u(!0);
|
|
269
269
|
const f = t.paymentType === F.CASH_AND_MILES ? ['"cash"', '"points"'] : ['"points"'], d = ee({
|
|
270
270
|
originCode: t.origin,
|
|
271
271
|
destinationCode: t.destination,
|
|
272
272
|
departureDate: t.departureDate,
|
|
273
|
-
cabinClass: t.cabinClass ||
|
|
273
|
+
cabinClass: t.cabinClass || K,
|
|
274
274
|
passengerCount: t.passengers || z,
|
|
275
275
|
paymentType: f
|
|
276
276
|
});
|
|
277
277
|
let i = [], M = 0;
|
|
278
278
|
U = new AbortController(), a.current = setTimeout(() => {
|
|
279
279
|
S();
|
|
280
|
-
}, (((
|
|
280
|
+
}, (((x = n == null ? void 0 : n.flightsConfig) == null ? void 0 : x.streamTimeoutTotalSeconds) || fe) * 1e3), de(re() + d, {
|
|
281
281
|
headers: {
|
|
282
282
|
"Content-Type": "application/json",
|
|
283
283
|
Authorization: e || "",
|
|
@@ -287,18 +287,18 @@ const fe = 3 * 60 * 1e3, K = (e) => {
|
|
|
287
287
|
signal: U.signal,
|
|
288
288
|
onmessage(N) {
|
|
289
289
|
try {
|
|
290
|
-
const
|
|
291
|
-
if (
|
|
290
|
+
const O = B(JSON.parse(N.data));
|
|
291
|
+
if (O.success === !1)
|
|
292
292
|
return;
|
|
293
|
-
if (
|
|
293
|
+
if (O.close === !0) {
|
|
294
294
|
S();
|
|
295
295
|
return;
|
|
296
296
|
}
|
|
297
|
-
|
|
297
|
+
O.flights && (M = 0, i = [...i, ...O.flights], R({
|
|
298
298
|
data: i
|
|
299
|
-
})),
|
|
300
|
-
} catch (
|
|
301
|
-
console.error("Error parsing message:",
|
|
299
|
+
})), O.ping && (M++, M >= n.flightsConfig.streamTimeoutPingCount && S());
|
|
300
|
+
} catch (O) {
|
|
301
|
+
console.error("Error parsing message:", O), S();
|
|
302
302
|
}
|
|
303
303
|
},
|
|
304
304
|
onerror(N) {
|
|
@@ -310,7 +310,7 @@ const fe = 3 * 60 * 1e3, K = (e) => {
|
|
|
310
310
|
keepalive: !1
|
|
311
311
|
});
|
|
312
312
|
}, S = () => {
|
|
313
|
-
U.abort(), a.current && (clearTimeout(a.current), a.current = null), u(!1), L.invalidateQueries({ queryKey: [
|
|
313
|
+
U.abort(), a.current && (clearTimeout(a.current), a.current = null), u(!1), L.invalidateQueries({ queryKey: [y.SEARCH_LIMIT] });
|
|
314
314
|
};
|
|
315
315
|
return {
|
|
316
316
|
/**
|
|
@@ -318,15 +318,15 @@ const fe = 3 * 60 * 1e3, K = (e) => {
|
|
|
318
318
|
* @type {boolean}
|
|
319
319
|
* @default false
|
|
320
320
|
*/
|
|
321
|
-
loading:
|
|
321
|
+
loading: I === "pending" || q === "pending" || c,
|
|
322
322
|
/**
|
|
323
323
|
* Loading status for fares
|
|
324
324
|
* @type {boolean}
|
|
325
325
|
* @default false
|
|
326
326
|
*/
|
|
327
|
-
loadingFares:
|
|
328
|
-
outboundError:
|
|
329
|
-
inboundError:
|
|
327
|
+
loadingFares: C === "pending",
|
|
328
|
+
outboundError: T,
|
|
329
|
+
inboundError: v,
|
|
330
330
|
roundTripFaresError: h,
|
|
331
331
|
// Results
|
|
332
332
|
outboundResults: b,
|
|
@@ -340,16 +340,16 @@ const fe = 3 * 60 * 1e3, K = (e) => {
|
|
|
340
340
|
* @param {ISearchFlightArgs} args - The search arguments
|
|
341
341
|
*/
|
|
342
342
|
searchOutboundFlights: async (t) => {
|
|
343
|
-
switch (
|
|
343
|
+
switch (V(t), _([]), S(), t.paymentType) {
|
|
344
344
|
default:
|
|
345
345
|
case F.CASH_AND_MILES:
|
|
346
|
-
|
|
346
|
+
j(t);
|
|
347
347
|
break;
|
|
348
348
|
case F.CASH:
|
|
349
349
|
A(t);
|
|
350
350
|
break;
|
|
351
351
|
case F.MILES:
|
|
352
|
-
|
|
352
|
+
j(t);
|
|
353
353
|
break;
|
|
354
354
|
}
|
|
355
355
|
},
|
|
@@ -359,16 +359,16 @@ const fe = 3 * 60 * 1e3, K = (e) => {
|
|
|
359
359
|
*
|
|
360
360
|
* @param {string} outboundOfferId - The ID of the outbound offer
|
|
361
361
|
*/
|
|
362
|
-
searchInboundFlights:
|
|
362
|
+
searchInboundFlights: P,
|
|
363
363
|
/**
|
|
364
364
|
* Used to get round-trip fares after selecting both outbound and inbound flights
|
|
365
365
|
* @type {function}
|
|
366
366
|
*
|
|
367
367
|
* @param {string} inboundOfferId - The ID of the inbound offer
|
|
368
368
|
*/
|
|
369
|
-
getRoundTripFares:
|
|
369
|
+
getRoundTripFares: w
|
|
370
370
|
};
|
|
371
371
|
};
|
|
372
372
|
export {
|
|
373
|
-
|
|
373
|
+
ve as useFlightSearch
|
|
374
374
|
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { h as a } from "./moment-BGjjqtLQ.js";
|
|
2
|
+
import "./arrayExtensions-DFLvtO8l.js";
|
|
3
|
+
const M = (n) => {
|
|
4
|
+
const s = Math.floor(n / 1440);
|
|
5
|
+
let t = n % 1440;
|
|
6
|
+
const e = Math.floor(t / 60), o = Math.floor(t % 60);
|
|
7
|
+
return `${s ? `${s}d` : ""} ${e}h ${o}m`;
|
|
8
|
+
};
|
|
9
|
+
function T({
|
|
10
|
+
departureAt: n,
|
|
11
|
+
departureTimeZone: s,
|
|
12
|
+
arrivalAt: t,
|
|
13
|
+
arrivalTimeZone: e
|
|
14
|
+
}) {
|
|
15
|
+
const o = a.tz(n, s);
|
|
16
|
+
return a.tz(t, e).diff(o, "minutes");
|
|
17
|
+
}
|
|
18
|
+
const $ = (n, s) => {
|
|
19
|
+
if (!n)
|
|
20
|
+
return "";
|
|
21
|
+
const t = a(s).tz(n).format("z"), e = a(s).tz(n).format("Z");
|
|
22
|
+
return `${/^\s*[+\-]?\d+\s*$/.test(t) ? `${e} GMT` : t}`;
|
|
23
|
+
}, g = (n) => {
|
|
24
|
+
const s = /P((\d+)D)?T((\d+)H)?((\d+)M)?/, t = n.match(s);
|
|
25
|
+
if (t) {
|
|
26
|
+
const e = t[2] ? `${t[2]}d ` : "", o = t[4] ? `${t[4]}h ` : "", i = t[6] ? `${t[6]}m` : "";
|
|
27
|
+
return `${e}${o}${i}`.trim();
|
|
28
|
+
} else
|
|
29
|
+
return n;
|
|
30
|
+
}, p = ({
|
|
31
|
+
duration: n,
|
|
32
|
+
arrivalTime: s,
|
|
33
|
+
departureTime: t,
|
|
34
|
+
originTimeZone: e,
|
|
35
|
+
destinationTimeZone: o
|
|
36
|
+
}) => {
|
|
37
|
+
try {
|
|
38
|
+
if (n) {
|
|
39
|
+
const u = /P((\d+)D)?T((\d+)H)?((\d+)M)?/, r = n.match(u);
|
|
40
|
+
if (r) {
|
|
41
|
+
const d = r[2] ? parseInt(r[2]) : 0, f = r[4] ? parseInt(r[4]) : 0, m = r[6] ? parseInt(r[6]) : 0;
|
|
42
|
+
return d * 24 * 60 + f * 60 + m;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const i = t.tz(e);
|
|
46
|
+
return s.tz(o).diff(i, "minutes");
|
|
47
|
+
} catch {
|
|
48
|
+
return 0;
|
|
49
|
+
}
|
|
50
|
+
}, D = "https://assets.duffel.com/img/airlines/for-light-background/full-color-lockup/";
|
|
51
|
+
export {
|
|
52
|
+
D,
|
|
53
|
+
T as a,
|
|
54
|
+
$ as b,
|
|
55
|
+
p as c,
|
|
56
|
+
M as d,
|
|
57
|
+
g
|
|
58
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { IAirportLocation
|
|
1
|
+
import { IAirportLocation } from '../../hooks/useFlightSearch/useFlightSearch.types';
|
|
2
|
+
import { ISegment } from '@type-op/shared';
|
|
2
3
|
interface FlightItineraryProps {
|
|
3
4
|
origin: IAirportLocation;
|
|
4
5
|
destination: IAirportLocation;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ICoordinates } from '@type-op/shared';
|
|
1
|
+
import { IChangeCondition, ICoordinates, IPassenger, ISlice } from '@type-op/shared';
|
|
2
2
|
import { ECabinClass, EFlightPaymentType, EFlightType } from '../../types';
|
|
3
3
|
export interface ISearchFlightArgs {
|
|
4
4
|
/**
|
|
@@ -202,108 +202,10 @@ export interface IPaymentRequirements {
|
|
|
202
202
|
priceGuaranteeExpiresAt: string;
|
|
203
203
|
paymentRequiredBy: string;
|
|
204
204
|
}
|
|
205
|
-
export interface ISlice {
|
|
206
|
-
comparisonKey: string;
|
|
207
|
-
ngsShelf: number;
|
|
208
|
-
destinationType: string;
|
|
209
|
-
originType: string;
|
|
210
|
-
fareBrandName: string;
|
|
211
|
-
segments: ISegment[];
|
|
212
|
-
conditions: ISliceConditions;
|
|
213
|
-
duration: string;
|
|
214
|
-
destination: IAirport;
|
|
215
|
-
origin: IAirport;
|
|
216
|
-
id: string;
|
|
217
|
-
}
|
|
218
|
-
export interface ISegment {
|
|
219
|
-
originTerminal: string;
|
|
220
|
-
destinationTerminal: string;
|
|
221
|
-
aircraft: {
|
|
222
|
-
id: string;
|
|
223
|
-
iata_code: string;
|
|
224
|
-
name: string;
|
|
225
|
-
};
|
|
226
|
-
departingAt: string;
|
|
227
|
-
arrivingAt: string;
|
|
228
|
-
operatingCarrier: ICarrier;
|
|
229
|
-
marketingCarrier: ICarrier;
|
|
230
|
-
operatingCarrierFlightNumber: string;
|
|
231
|
-
stops: any[];
|
|
232
|
-
marketingCarrierFlightNumber: string;
|
|
233
|
-
distance: string;
|
|
234
|
-
passengers: ISegmentPassenger[];
|
|
235
|
-
media: any[];
|
|
236
|
-
duration: string;
|
|
237
|
-
destination: IAirport;
|
|
238
|
-
origin: IAirport;
|
|
239
|
-
id: string;
|
|
240
|
-
}
|
|
241
|
-
export interface ISegmentPassenger {
|
|
242
|
-
cabin: ICabin;
|
|
243
|
-
baggages: IBaggage[];
|
|
244
|
-
cabinClassMarketingName: string;
|
|
245
|
-
passengerId: string;
|
|
246
|
-
fareBasisCode: string;
|
|
247
|
-
cabinClass: string;
|
|
248
|
-
}
|
|
249
|
-
export interface ICabin {
|
|
250
|
-
amenities: IAmenities;
|
|
251
|
-
marketingName: string;
|
|
252
|
-
name: string;
|
|
253
|
-
}
|
|
254
|
-
export interface IAmenities {
|
|
255
|
-
wifi: IWifi;
|
|
256
|
-
seat: ISeat;
|
|
257
|
-
power: IPower;
|
|
258
|
-
}
|
|
259
|
-
export interface IWifi {
|
|
260
|
-
cost: string;
|
|
261
|
-
available: boolean;
|
|
262
|
-
}
|
|
263
|
-
export interface ISeat {
|
|
264
|
-
pitch: string;
|
|
265
|
-
legroom: string;
|
|
266
|
-
type: string | null;
|
|
267
|
-
}
|
|
268
|
-
export interface IPower {
|
|
269
|
-
available: boolean;
|
|
270
|
-
}
|
|
271
|
-
export interface IBaggage {
|
|
272
|
-
quantity: number;
|
|
273
|
-
type: string;
|
|
274
|
-
}
|
|
275
|
-
export interface ICarrier {
|
|
276
|
-
logoSymbolUrl: string;
|
|
277
|
-
logoLockupUrl: string;
|
|
278
|
-
conditionsOfCarriageUrl: string;
|
|
279
|
-
iataCode: string;
|
|
280
|
-
name: string;
|
|
281
|
-
id: string;
|
|
282
|
-
}
|
|
283
|
-
export interface ISliceConditions {
|
|
284
|
-
priorityCheckIn: any;
|
|
285
|
-
priorityBoarding: any;
|
|
286
|
-
advanceSeatSelection: any;
|
|
287
|
-
changeBeforeDeparture: IChangeCondition;
|
|
288
|
-
}
|
|
289
|
-
export interface IChangeCondition {
|
|
290
|
-
penaltyCurrency: string | null;
|
|
291
|
-
penaltyAmount: string | null;
|
|
292
|
-
allowed: boolean;
|
|
293
|
-
}
|
|
294
205
|
export interface IOfferConditions {
|
|
295
206
|
refundBeforeDeparture: IChangeCondition;
|
|
296
207
|
changeBeforeDeparture: IChangeCondition;
|
|
297
208
|
}
|
|
298
|
-
export interface IPassenger {
|
|
299
|
-
fareType: string | null;
|
|
300
|
-
loyaltyProgrammeAccounts: any[];
|
|
301
|
-
familyName: string | null;
|
|
302
|
-
givenName: string | null;
|
|
303
|
-
age: number | null;
|
|
304
|
-
type: string;
|
|
305
|
-
id: string;
|
|
306
|
-
}
|
|
307
209
|
export interface IOwner {
|
|
308
210
|
logoSymbolUrl: string;
|
|
309
211
|
logoLockupUrl: string;
|
|
@@ -312,19 +214,3 @@ export interface IOwner {
|
|
|
312
214
|
name: string;
|
|
313
215
|
id: string;
|
|
314
216
|
}
|
|
315
|
-
export interface ICity {
|
|
316
|
-
cityName: string;
|
|
317
|
-
icaoCode: string;
|
|
318
|
-
iataCityCode: string;
|
|
319
|
-
iataCountryCode: string;
|
|
320
|
-
iataCode: string;
|
|
321
|
-
latitude: number;
|
|
322
|
-
longitude: number;
|
|
323
|
-
timeZone: string;
|
|
324
|
-
type: string;
|
|
325
|
-
name: string;
|
|
326
|
-
id: string;
|
|
327
|
-
}
|
|
328
|
-
export interface IAirport extends ICity {
|
|
329
|
-
city: ICity;
|
|
330
|
-
}
|
package/dist/lib/main.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export * from './hooks';
|
|
2
2
|
export * from './components';
|
|
3
3
|
export * from './enums';
|
|
4
|
+
export type { ISlice, IBaggage, ICarrier, ISegment, IPassenger } from '@type-op/shared';
|
|
5
|
+
export type { IFlightResult } from './hooks/useFlightSearch/useFlightSearch.types';
|
|
4
6
|
export { getAirlineProgram, DEFAULT_AIRLINE_PROGRAM } from './utils/flightUtils';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { IFlightOffer, IFlightResult
|
|
1
|
+
import { IFlightOffer, IFlightResult } from '../hooks/useFlightSearch/useFlightSearch.types';
|
|
2
2
|
import { ECabinClass } from '../types';
|
|
3
|
+
import { ISegment } from '@type-op/shared';
|
|
3
4
|
import { IAirlineProgram } from '../services/wallet/WalletService.types';
|
|
4
5
|
/**
|
|
5
6
|
* @description - maps flight details into the flight result format, which is the expected format for Flight Components throughout the Awayz Application
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { mapBaggageType as Q } from "../hooks/useFlightSearch/useFlightSearch.types.js";
|
|
2
2
|
import { h as g } from "../moment-BGjjqtLQ.js";
|
|
3
|
-
import { c as K } from "../
|
|
3
|
+
import { c as K, D as V } from "../index-D0Heof44.js";
|
|
4
4
|
import "../arrayExtensions-DFLvtO8l.js";
|
|
5
5
|
import "react";
|
|
6
|
-
import { awayzClient as
|
|
7
|
-
import { WalletService as
|
|
8
|
-
import { ERewardProgramCategories as
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var i, n, l, m, s, a, r, c, o, d, u, C, w, b, F, L, D, A, T, P, k, h, O, v, R, E, I, _, N, z, M, S, Z, $, G;
|
|
6
|
+
import { awayzClient as Y } from "@odynn/awayz-core";
|
|
7
|
+
import { WalletService as x } from "../services/wallet/WalletService.js";
|
|
8
|
+
import { ERewardProgramCategories as H } from "../services/wallet/WalletService.types.js";
|
|
9
|
+
const re = (t) => t == null ? void 0 : t.map((e) => {
|
|
10
|
+
var i, n, l, m, s, a, r, c, o, d, u, C, w, b, D, F, L, A, T, P, k, h, O, v, R, E, I, _, N, z, M, S, Z, $, G;
|
|
12
11
|
return {
|
|
13
12
|
id: e.id,
|
|
14
13
|
points: (e == null ? void 0 : e.points) >= 0 ? e.points : -1,
|
|
@@ -23,7 +22,7 @@ const oe = (t) => t == null ? void 0 : t.map((e) => {
|
|
|
23
22
|
}
|
|
24
23
|
},
|
|
25
24
|
destination: {
|
|
26
|
-
city: ((
|
|
25
|
+
city: ((D = (b = e.slices[0].segments.getLast()) == null ? void 0 : b.destination) == null ? void 0 : D.cityName) || ((A = (L = (F = e.slices[0].segments.getLast()) == null ? void 0 : F.destination) == null ? void 0 : L.city) == null ? void 0 : A.name),
|
|
27
26
|
country: ((P = (T = e.slices[0].segments.getLast()) == null ? void 0 : T.destination) == null ? void 0 : P.iataCountryCode) || ((O = (h = (k = e.slices[0].segments.getLast()) == null ? void 0 : k.destination) == null ? void 0 : h.city) == null ? void 0 : O.iataCountryCode),
|
|
28
27
|
airportCode: ((R = (v = e.slices[0].segments.getLast()) == null ? void 0 : v.destination) == null ? void 0 : R.iataCityCode) || ((_ = (I = (E = e.slices[0].segments.getLast()) == null ? void 0 : E.destination) == null ? void 0 : I.city) == null ? void 0 : _.iataCode),
|
|
29
28
|
coordinates: {
|
|
@@ -61,7 +60,7 @@ const oe = (t) => t == null ? void 0 : t.map((e) => {
|
|
|
61
60
|
}), j = (t) => {
|
|
62
61
|
const e = t.operatingCarrierFlightNumber ? t.operatingCarrier : t.marketingCarrier, i = t.operatingCarrierFlightNumber ?? t.marketingCarrierFlightNumber;
|
|
63
62
|
return e.iataCode + " " + J(i);
|
|
64
|
-
},
|
|
63
|
+
}, oe = ({
|
|
65
64
|
originCode: t,
|
|
66
65
|
destinationCode: e,
|
|
67
66
|
departureDate: i,
|
|
@@ -71,7 +70,7 @@ const oe = (t) => t == null ? void 0 : t.map((e) => {
|
|
|
71
70
|
}) => {
|
|
72
71
|
let s = "/flights/search/one-way/points-cash?";
|
|
73
72
|
return s += `origin=${t}`, s += `&destination=${e}`, s += `&departure_date=${i}`, s += `&cabin_class=${n}`, s += `&adults=${l}`, s += `&cash_or_points=[${m}]`, s;
|
|
74
|
-
}, W = (t) => t.flightDetails.slices[0].segments.map((i) => j(i)).join("_"),
|
|
73
|
+
}, W = (t) => t.flightDetails.slices[0].segments.map((i) => j(i)).join("_"), ce = (t) => {
|
|
75
74
|
const e = {};
|
|
76
75
|
t.forEach((s) => {
|
|
77
76
|
var r;
|
|
@@ -192,7 +191,7 @@ const oe = (t) => t == null ? void 0 : t.map((e) => {
|
|
|
192
191
|
(r) => r.awayzGroupId === s.awayzGroupId
|
|
193
192
|
) || m.push(s);
|
|
194
193
|
}), m;
|
|
195
|
-
}, J = (t) => t ? t.replace(/^0+/, "") : "",
|
|
194
|
+
}, J = (t) => t ? t.replace(/^0+/, "") : "", me = (t) => `https://assets.duffel.com/img/airlines/for-light-background/full-color-logo/${t}.svg`, y = (t) => `${V}${t}.svg`, B = "/img/logo/odynn-eye.svg", q = {
|
|
196
195
|
categoryLogo: B,
|
|
197
196
|
programLogo: B,
|
|
198
197
|
awayzActive: [],
|
|
@@ -200,14 +199,14 @@ const oe = (t) => t == null ? void 0 : t.map((e) => {
|
|
|
200
199
|
displayProgram: "Unknown",
|
|
201
200
|
id: "Unknown",
|
|
202
201
|
totalAccumulatedPoints: 0,
|
|
203
|
-
category:
|
|
202
|
+
category: H.Airline,
|
|
204
203
|
colour: "#fff",
|
|
205
204
|
// Using App Foreground Colour
|
|
206
205
|
url: "https://www.odynn.com"
|
|
207
|
-
},
|
|
208
|
-
const { airlines: e } = await
|
|
206
|
+
}, le = async (t) => {
|
|
207
|
+
const { airlines: e } = await Y.ensureQueryData({
|
|
209
208
|
queryKey: ["walletAwards"],
|
|
210
|
-
queryFn:
|
|
209
|
+
queryFn: x.getAwards,
|
|
211
210
|
staleTime: 864e5
|
|
212
211
|
// 24 hours
|
|
213
212
|
});
|
|
@@ -259,12 +258,12 @@ const oe = (t) => t == null ? void 0 : t.map((e) => {
|
|
|
259
258
|
};
|
|
260
259
|
export {
|
|
261
260
|
q as DEFAULT_AIRLINE_PROGRAM,
|
|
262
|
-
|
|
263
|
-
|
|
261
|
+
oe as buildFlightSearchQuery,
|
|
262
|
+
le as getAirlineProgram,
|
|
264
263
|
j as getFlightNumber,
|
|
265
264
|
y as getFullLogoPath,
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
265
|
+
me as getLogoPath,
|
|
266
|
+
ce as groupFlightResults,
|
|
267
|
+
re as mapDataToFlightDetails,
|
|
269
268
|
J as removeLeadingZeros
|
|
270
269
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@odynn/awayz-flights",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
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.
|
|
67
|
+
"@odynn/awayz-core": "^0.3.1",
|
|
68
68
|
"@tanstack/react-query": "^5.67.1",
|
|
69
69
|
"country-code-lookup": "^0.1.3"
|
|
70
70
|
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { h as a } from "./moment-BGjjqtLQ.js";
|
|
2
|
-
import "./arrayExtensions-DFLvtO8l.js";
|
|
3
|
-
const M = (n) => {
|
|
4
|
-
const e = Math.floor(n / 1440);
|
|
5
|
-
let t = n % 1440;
|
|
6
|
-
const s = Math.floor(t / 60), r = Math.floor(t % 60);
|
|
7
|
-
return `${e ? `${e}d` : ""} ${s}h ${r}m`;
|
|
8
|
-
};
|
|
9
|
-
function $({
|
|
10
|
-
departureAt: n,
|
|
11
|
-
departureTimeZone: e,
|
|
12
|
-
arrivalAt: t,
|
|
13
|
-
arrivalTimeZone: s
|
|
14
|
-
}) {
|
|
15
|
-
const r = a.tz(n, e);
|
|
16
|
-
return a.tz(t, s).diff(r, "minutes");
|
|
17
|
-
}
|
|
18
|
-
const T = (n, e) => {
|
|
19
|
-
if (!n)
|
|
20
|
-
return "";
|
|
21
|
-
const t = a(e).tz(n).format("z"), s = a(e).tz(n).format("Z");
|
|
22
|
-
return `${/^\s*[+\-]?\d+\s*$/.test(t) ? `${s} GMT` : t}`;
|
|
23
|
-
}, g = (n) => {
|
|
24
|
-
const e = /P((\d+)D)?T((\d+)H)?((\d+)M)?/, t = n.match(e);
|
|
25
|
-
if (t) {
|
|
26
|
-
const s = t[2] ? `${t[2]}d ` : "", r = t[4] ? `${t[4]}h ` : "", i = t[6] ? `${t[6]}m` : "";
|
|
27
|
-
return `${s}${r}${i}`.trim();
|
|
28
|
-
} else
|
|
29
|
-
return n;
|
|
30
|
-
}, p = ({
|
|
31
|
-
duration: n,
|
|
32
|
-
arrivalTime: e,
|
|
33
|
-
departureTime: t,
|
|
34
|
-
originTimeZone: s,
|
|
35
|
-
destinationTimeZone: r
|
|
36
|
-
}) => {
|
|
37
|
-
try {
|
|
38
|
-
if (n) {
|
|
39
|
-
const d = /P((\d+)D)?T((\d+)H)?((\d+)M)?/, o = n.match(d);
|
|
40
|
-
if (o) {
|
|
41
|
-
const u = o[2] ? parseInt(o[2]) : 0, f = o[4] ? parseInt(o[4]) : 0, m = o[6] ? parseInt(o[6]) : 0;
|
|
42
|
-
return u * 24 * 60 + f * 60 + m;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
const i = t.tz(s);
|
|
46
|
-
return e.tz(r).diff(i, "minutes");
|
|
47
|
-
} catch {
|
|
48
|
-
return 0;
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
export {
|
|
52
|
-
$ as a,
|
|
53
|
-
T as b,
|
|
54
|
-
p as c,
|
|
55
|
-
M as d,
|
|
56
|
-
g
|
|
57
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const DUFFEL_ASSET_PATH = "https://assets.duffel.com/img/airlines/for-light-background/full-color-lockup/";
|