@odynn/awayz-flights 0.2.1 → 0.2.3
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,60 +1,56 @@
|
|
|
1
|
-
import { jsx as r, jsxs as e } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import { g as
|
|
4
|
-
import { DEFAULT_AIRLINE_PROGRAM as
|
|
5
|
-
import { h as
|
|
6
|
-
import { g as
|
|
7
|
-
import { EPaymentType as
|
|
8
|
-
import
|
|
1
|
+
import { jsx as r, jsxs as e, Fragment as E } from "react/jsx-runtime";
|
|
2
|
+
import I, { useState as f, useMemo as T } from "react";
|
|
3
|
+
import { g as N, E as u, F as R, a as B } from "../../FlightItinerary-DgpK1LYF.js";
|
|
4
|
+
import { DEFAULT_AIRLINE_PROGRAM as L, getFlightNumber as $, getLogoPath as x, getAirlineProgram as M } from "../../utils/flightUtils.js";
|
|
5
|
+
import { h as v } from "../../arrayExtensions-DWKenJCh.js";
|
|
6
|
+
import { g as b } from "../../dateUtils-DeNLG5hw.js";
|
|
7
|
+
import { EPaymentType as o } from "../../enums/EPaymentType.js";
|
|
8
|
+
import { CashValue as F } from "@odynn/awayz-core";
|
|
9
|
+
import '../../assets/FlightResult.css';function j(i) {
|
|
9
10
|
if (!i || isNaN(i) || i < 0) return "N/A";
|
|
10
|
-
let
|
|
11
|
-
return
|
|
11
|
+
let a = i == null ? void 0 : i.toString().split(".")[0];
|
|
12
|
+
return a == null ? void 0 : a.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
12
13
|
}
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return i.flightDetails.slices.forEach((A) => {
|
|
27
|
-
A.segments.forEach((l) => {
|
|
28
|
-
const p = T(l);
|
|
29
|
-
t.includes(p) || t.push(p);
|
|
30
|
-
const m = l.operatingCarrierFlightNumber ? l.operatingCarrier : l.marketingCarrier;
|
|
31
|
-
a.some((O) => O.airline === m.name) || a.push({
|
|
32
|
-
logo: B(m.iataCode),
|
|
14
|
+
const K = ({ details: i, onClick: a }) => {
|
|
15
|
+
const [g, y] = f(!1), c = i.origin, l = i.destination, p = i.flightDetails, C = !i.paymentOptions || i.paymentOptions.length === 1, [D, S] = f(L), P = async () => {
|
|
16
|
+
const n = await M(i.airlineProgram);
|
|
17
|
+
S(n);
|
|
18
|
+
}, { flightNumbers: h, airlines: A } = T(() => {
|
|
19
|
+
const n = [], t = [];
|
|
20
|
+
return i.flightDetails.slices.forEach((O) => {
|
|
21
|
+
O.segments.forEach((s) => {
|
|
22
|
+
const d = $(s);
|
|
23
|
+
n.includes(d) || n.push(d);
|
|
24
|
+
const m = s.operatingCarrierFlightNumber ? s.operatingCarrier : s.marketingCarrier;
|
|
25
|
+
t.some((k) => k.airline === m.name) || t.push({
|
|
26
|
+
logo: x(m.iataCode),
|
|
33
27
|
airline: m.name
|
|
34
28
|
});
|
|
35
29
|
});
|
|
36
|
-
}),
|
|
30
|
+
}), P(), { flightNumbers: n, airlines: t };
|
|
37
31
|
}, [i.flightDetails.slices]);
|
|
38
|
-
return /* @__PURE__ */ r("div", { className: "flight-result", onClick: () =>
|
|
32
|
+
return /* @__PURE__ */ r("div", { className: "flight-result", onClick: () => {
|
|
33
|
+
i.cash > 0 ? a(i, o.CASH) : a(i, o.POINTS);
|
|
34
|
+
}, children: /* @__PURE__ */ e("div", { className: "content", children: [
|
|
39
35
|
/* @__PURE__ */ r("div", { className: "flight-info", children: /* @__PURE__ */ e("div", { className: "flight-locations", children: [
|
|
40
|
-
/* @__PURE__ */ r("div", { className: "airlines", children:
|
|
36
|
+
/* @__PURE__ */ r("div", { className: "airlines", children: A.map((n, t) => /* @__PURE__ */ r(I.Fragment, { children: /* @__PURE__ */ r("div", { className: "tip", children: /* @__PURE__ */ r("img", { src: n.logo, alt: n.airline }) }, t) }, t)) }),
|
|
41
37
|
/* @__PURE__ */ e("div", { className: "flight-location", children: [
|
|
42
38
|
/* @__PURE__ */ e("p", { children: [
|
|
43
|
-
|
|
39
|
+
c.city,
|
|
44
40
|
",",
|
|
45
|
-
|
|
41
|
+
N(c.country)
|
|
46
42
|
] }),
|
|
47
|
-
/* @__PURE__ */ r("p", { children:
|
|
43
|
+
/* @__PURE__ */ r("p", { children: v(i.departureTime).format(
|
|
48
44
|
// isMobile
|
|
49
45
|
// ? EDateFormats.FlightTime
|
|
50
46
|
// :
|
|
51
|
-
|
|
47
|
+
u.FlightShortDate
|
|
52
48
|
) })
|
|
53
49
|
] }),
|
|
54
50
|
/* @__PURE__ */ e("div", { className: "flight-duration", children: [
|
|
55
51
|
/* @__PURE__ */ r("span", { className: "line" }),
|
|
56
52
|
/* @__PURE__ */ e("p", { children: [
|
|
57
|
-
|
|
53
|
+
b(p.slices[0].duration),
|
|
58
54
|
" ",
|
|
59
55
|
" - ",
|
|
60
56
|
i.numberOfStops > 0 ? `${i.numberOfStops} Stop${i.numberOfStops > 1 ? "s" : ""}` : "Direct"
|
|
@@ -63,16 +59,16 @@ const x = (i, n) => {
|
|
|
63
59
|
] }),
|
|
64
60
|
/* @__PURE__ */ e("div", { children: [
|
|
65
61
|
/* @__PURE__ */ e("p", { children: [
|
|
66
|
-
|
|
62
|
+
l.city,
|
|
67
63
|
", ",
|
|
68
|
-
|
|
64
|
+
N(l.country)
|
|
69
65
|
] }),
|
|
70
66
|
/* @__PURE__ */ e("p", { children: [
|
|
71
|
-
|
|
67
|
+
v(i.arrivalTime).format(
|
|
72
68
|
// isMobile
|
|
73
69
|
// ? EDateFormats.FlightTime
|
|
74
70
|
// :
|
|
75
|
-
|
|
71
|
+
u.FlightShortDate
|
|
76
72
|
),
|
|
77
73
|
" "
|
|
78
74
|
] })
|
|
@@ -84,13 +80,13 @@ const x = (i, n) => {
|
|
|
84
80
|
"div",
|
|
85
81
|
{
|
|
86
82
|
className: "flight-detail",
|
|
87
|
-
onClick: (
|
|
88
|
-
|
|
83
|
+
onClick: (n) => {
|
|
84
|
+
n.stopPropagation(), y(!g);
|
|
89
85
|
},
|
|
90
86
|
children: [
|
|
91
87
|
/* @__PURE__ */ r("p", { children: "Aircraft" }),
|
|
92
88
|
/* @__PURE__ */ e("p", { className: "chevron-text", children: [
|
|
93
|
-
/* @__PURE__ */ r(
|
|
89
|
+
/* @__PURE__ */ r(R, {}),
|
|
94
90
|
/* @__PURE__ */ e("span", { children: [
|
|
95
91
|
h[0],
|
|
96
92
|
h.length > 1 && /* @__PURE__ */ e("sup", { children: [
|
|
@@ -117,12 +113,18 @@ const x = (i, n) => {
|
|
|
117
113
|
"div",
|
|
118
114
|
{
|
|
119
115
|
className: "cash-value",
|
|
120
|
-
onClick: (
|
|
121
|
-
|
|
116
|
+
onClick: (n) => {
|
|
117
|
+
n.stopPropagation(), a(i, o.CASH);
|
|
122
118
|
},
|
|
123
119
|
children: [
|
|
124
|
-
/* @__PURE__ */ r("p", { children:
|
|
125
|
-
/* @__PURE__ */ r("p", { children:
|
|
120
|
+
/* @__PURE__ */ r("p", { children: C ? "Book For" : "From" }),
|
|
121
|
+
/* @__PURE__ */ r("p", { children: /* @__PURE__ */ r(
|
|
122
|
+
F,
|
|
123
|
+
{
|
|
124
|
+
amount: i.cash,
|
|
125
|
+
currency: i.currency
|
|
126
|
+
}
|
|
127
|
+
) })
|
|
126
128
|
]
|
|
127
129
|
}
|
|
128
130
|
),
|
|
@@ -130,27 +132,39 @@ const x = (i, n) => {
|
|
|
130
132
|
"div",
|
|
131
133
|
{
|
|
132
134
|
className: "points-value",
|
|
133
|
-
onClick: (
|
|
134
|
-
|
|
135
|
+
onClick: (n) => {
|
|
136
|
+
n.stopPropagation(), a(i, o.POINTS);
|
|
135
137
|
},
|
|
136
138
|
children: [
|
|
137
|
-
/* @__PURE__ */ r("img", { src:
|
|
138
|
-
/* @__PURE__ */
|
|
139
|
+
/* @__PURE__ */ r("img", { src: D.programLogo }),
|
|
140
|
+
/* @__PURE__ */ e("p", { children: [
|
|
141
|
+
`${j(i.points)} miles`,
|
|
142
|
+
i.cashFee.amount > 0 && /* @__PURE__ */ e(E, { children: [
|
|
143
|
+
" + ",
|
|
144
|
+
/* @__PURE__ */ r(
|
|
145
|
+
F,
|
|
146
|
+
{
|
|
147
|
+
amount: i.cashFee.amount,
|
|
148
|
+
currency: i.cashFee.currency
|
|
149
|
+
}
|
|
150
|
+
)
|
|
151
|
+
] })
|
|
152
|
+
] })
|
|
139
153
|
]
|
|
140
154
|
}
|
|
141
155
|
)
|
|
142
156
|
] })
|
|
143
157
|
] }),
|
|
144
|
-
/* @__PURE__ */ r("div", { className: `flight-details ${
|
|
145
|
-
|
|
158
|
+
/* @__PURE__ */ r("div", { className: `flight-details ${g ? "is-open" : ""}`, children: /* @__PURE__ */ r("div", { className: "inner", children: /* @__PURE__ */ r(
|
|
159
|
+
B,
|
|
146
160
|
{
|
|
147
|
-
itinerary:
|
|
148
|
-
origin:
|
|
149
|
-
destination:
|
|
161
|
+
itinerary: p.slices[0].segments,
|
|
162
|
+
origin: c,
|
|
163
|
+
destination: l
|
|
150
164
|
}
|
|
151
165
|
) }) })
|
|
152
166
|
] }) });
|
|
153
167
|
};
|
|
154
168
|
export {
|
|
155
|
-
|
|
169
|
+
K as FlightResult
|
|
156
170
|
};
|
|
@@ -60,8 +60,8 @@ function oe(o, t, r) {
|
|
|
60
60
|
o(n.id = g);
|
|
61
61
|
break;
|
|
62
62
|
case "retry":
|
|
63
|
-
const
|
|
64
|
-
isNaN(
|
|
63
|
+
const m = parseInt(g, 10);
|
|
64
|
+
isNaN(m) || t(n.retry = m);
|
|
65
65
|
break;
|
|
66
66
|
}
|
|
67
67
|
}
|
|
@@ -90,34 +90,34 @@ var ae = function(o, t) {
|
|
|
90
90
|
const x = "text/event-stream", ie = 1e3, z = "last-event-id";
|
|
91
91
|
function ue(o, t) {
|
|
92
92
|
var { signal: r, headers: n, onopen: s, onmessage: v, onclose: c, onerror: u, openWhenHidden: a, fetch: d } = t, g = ae(t, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
|
|
93
|
-
return new Promise((
|
|
93
|
+
return new Promise((m, _) => {
|
|
94
94
|
const p = Object.assign({}, n);
|
|
95
95
|
p.accept || (p.accept = x);
|
|
96
|
-
let
|
|
96
|
+
let y;
|
|
97
97
|
function w() {
|
|
98
|
-
|
|
98
|
+
y.abort(), document.hidden || T();
|
|
99
99
|
}
|
|
100
100
|
a || document.addEventListener("visibilitychange", w);
|
|
101
101
|
let F = ie, E = 0;
|
|
102
102
|
function S() {
|
|
103
|
-
document.removeEventListener("visibilitychange", w), window.clearTimeout(E),
|
|
103
|
+
document.removeEventListener("visibilitychange", w), window.clearTimeout(E), y.abort();
|
|
104
104
|
}
|
|
105
105
|
r == null || r.addEventListener("abort", () => {
|
|
106
|
-
S(),
|
|
106
|
+
S(), m();
|
|
107
107
|
});
|
|
108
108
|
const q = d ?? window.fetch, P = s ?? ce;
|
|
109
109
|
async function T() {
|
|
110
110
|
var C;
|
|
111
|
-
|
|
111
|
+
y = new AbortController();
|
|
112
112
|
try {
|
|
113
|
-
const O = await q(o, Object.assign(Object.assign({}, g), { headers: p, signal:
|
|
113
|
+
const O = await q(o, Object.assign(Object.assign({}, g), { headers: p, signal: y.signal }));
|
|
114
114
|
await P(O), await ne(O.body, re(oe((h) => {
|
|
115
115
|
h ? p[z] = h : delete p[z];
|
|
116
116
|
}, (h) => {
|
|
117
117
|
F = h;
|
|
118
|
-
}, v))), c == null || c(), S(),
|
|
118
|
+
}, v))), c == null || c(), S(), m();
|
|
119
119
|
} catch (O) {
|
|
120
|
-
if (!
|
|
120
|
+
if (!y.signal.aborted)
|
|
121
121
|
try {
|
|
122
122
|
const h = (C = u == null ? void 0 : u(O)) !== null && C !== void 0 ? C : F;
|
|
123
123
|
window.clearTimeout(E), E = window.setTimeout(T, h);
|
|
@@ -147,17 +147,17 @@ const de = 3 * 60 * 1e3, $ = (o) => {
|
|
|
147
147
|
const { token: o, config: t } = ee(), [r, n] = N(""), [s, v] = N([]), [c, u] = N(!1), a = K(null), {
|
|
148
148
|
inboundResults: d,
|
|
149
149
|
outboundResults: g,
|
|
150
|
-
setInboundResults:
|
|
150
|
+
setInboundResults: m,
|
|
151
151
|
setOutboundResults: _,
|
|
152
152
|
partialOfferRequestId: p,
|
|
153
|
-
setPartialOfferRequestId:
|
|
153
|
+
setPartialOfferRequestId: y
|
|
154
154
|
} = Z(), w = ({
|
|
155
155
|
data: e,
|
|
156
156
|
previousResults: l,
|
|
157
157
|
inbound: f
|
|
158
158
|
}) => {
|
|
159
159
|
const i = V(e, l);
|
|
160
|
-
return (f ?
|
|
160
|
+
return (f ? m : _)(G(i)), i;
|
|
161
161
|
}, {
|
|
162
162
|
mutate: F,
|
|
163
163
|
status: E,
|
|
@@ -197,13 +197,12 @@ const de = 3 * 60 * 1e3, $ = (o) => {
|
|
|
197
197
|
}
|
|
198
198
|
},
|
|
199
199
|
onSuccess: (e) => {
|
|
200
|
-
console.log({ result: e });
|
|
201
200
|
const { success: l, data: f, partialOfferRequestId: i } = e;
|
|
202
201
|
if (!l) {
|
|
203
202
|
console.log("oh lol, it didn't work");
|
|
204
203
|
return;
|
|
205
204
|
}
|
|
206
|
-
w({ data: f }), i &&
|
|
205
|
+
w({ data: f }), i && y(i);
|
|
207
206
|
},
|
|
208
207
|
onError: (e) => {
|
|
209
208
|
console.error("Error in outbound flight search:", e);
|
|
@@ -278,19 +277,19 @@ const de = 3 * 60 * 1e3, $ = (o) => {
|
|
|
278
277
|
signal: j.signal,
|
|
279
278
|
onmessage(A) {
|
|
280
279
|
try {
|
|
281
|
-
const
|
|
282
|
-
if (
|
|
280
|
+
const b = W(JSON.parse(A.data));
|
|
281
|
+
if (b.success === !1)
|
|
283
282
|
return;
|
|
284
|
-
if (
|
|
283
|
+
if (b.close === !0) {
|
|
285
284
|
R();
|
|
286
285
|
return;
|
|
287
286
|
}
|
|
288
|
-
|
|
289
|
-
data:
|
|
287
|
+
b.flights && (console.log({ parsed: b.flights }), I = 0, i = w({
|
|
288
|
+
data: b.flights,
|
|
290
289
|
previousResults: i
|
|
291
|
-
})),
|
|
292
|
-
} catch (
|
|
293
|
-
console.error("Error parsing message:",
|
|
290
|
+
})), b.ping && (I++, I >= t.flightsConfig.streamTimeoutPingCount && R());
|
|
291
|
+
} catch (b) {
|
|
292
|
+
console.error("Error parsing message:", b), R();
|
|
294
293
|
}
|
|
295
294
|
},
|
|
296
295
|
onerror(A) {
|
|
@@ -75,10 +75,13 @@ export interface IFlightPaymentOption {
|
|
|
75
75
|
id: string;
|
|
76
76
|
cash: number;
|
|
77
77
|
points: number;
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
cashFee: {
|
|
79
|
+
amount: number;
|
|
80
|
+
currency: string;
|
|
81
|
+
};
|
|
80
82
|
baseCurrency: string;
|
|
81
83
|
fareBrandName: string;
|
|
84
|
+
program: string;
|
|
82
85
|
baggages?: {
|
|
83
86
|
type: EBaggage | null;
|
|
84
87
|
quantity: number;
|
|
@@ -101,6 +104,10 @@ export interface IFlightResult {
|
|
|
101
104
|
destination: IAirportLocation;
|
|
102
105
|
cash: number;
|
|
103
106
|
points: number;
|
|
107
|
+
cashFee: {
|
|
108
|
+
amount: number;
|
|
109
|
+
currency: string;
|
|
110
|
+
};
|
|
104
111
|
numberOfStops: number;
|
|
105
112
|
departureTime: Date;
|
|
106
113
|
arrivalTime: Date;
|
|
@@ -110,6 +117,7 @@ export interface IFlightResult {
|
|
|
110
117
|
durationMinutes: number;
|
|
111
118
|
flightDetails: IFlightOffer;
|
|
112
119
|
paymentOptions: IFlightPaymentOption[];
|
|
120
|
+
currency: string;
|
|
113
121
|
}
|
|
114
122
|
export interface IAirportLocation {
|
|
115
123
|
city: string;
|
|
@@ -149,6 +157,10 @@ export interface IFlightOffer {
|
|
|
149
157
|
partial: boolean;
|
|
150
158
|
owner: IOwner;
|
|
151
159
|
id: string;
|
|
160
|
+
cashFee: {
|
|
161
|
+
amount: number;
|
|
162
|
+
currency: string;
|
|
163
|
+
};
|
|
152
164
|
}
|
|
153
165
|
export interface IPaymentRequirements {
|
|
154
166
|
requiresInstantPayment: boolean;
|
|
@@ -1,39 +1,40 @@
|
|
|
1
|
-
import { h as
|
|
2
|
-
import { c as
|
|
1
|
+
import { h as F } from "../arrayExtensions-DWKenJCh.js";
|
|
2
|
+
import { c as K } from "../dateUtils-DeNLG5hw.js";
|
|
3
3
|
import "react";
|
|
4
|
-
import { awayzClient as
|
|
5
|
-
import { WalletService as
|
|
6
|
-
import { ERewardProgramCategories as
|
|
7
|
-
const B = (
|
|
8
|
-
var
|
|
4
|
+
import { awayzClient as q } from "@odynn/awayz-core";
|
|
5
|
+
import { WalletService as Q } from "../services/wallet/WalletService.js";
|
|
6
|
+
import { ERewardProgramCategories as V } from "../services/wallet/WalletService.types.js";
|
|
7
|
+
const B = (s) => s == null ? void 0 : s.map((e) => {
|
|
8
|
+
var r, t, a, n, i, o, m, w, g, M, P, N, A, L, h, d, p, c, y, C, b, l, u, D, k, O, z, v, f, _, $, Z, E, G;
|
|
9
9
|
return {
|
|
10
10
|
id: e.id,
|
|
11
11
|
points: (e == null ? void 0 : e.points) >= 0 ? e.points : -1,
|
|
12
12
|
partial: e == null ? void 0 : e.partial,
|
|
13
13
|
origin: {
|
|
14
|
-
city: ((
|
|
15
|
-
country: ((n = e.slices[0].segments[0].origin) == null ? void 0 : n.iataCountryCode) || ((o = (
|
|
16
|
-
airportCode: ((
|
|
14
|
+
city: ((r = e.slices[0].segments[0].origin) == null ? void 0 : r.cityName) || ((a = (t = e.slices[0].segments[0].origin) == null ? void 0 : t.city) == null ? void 0 : a.name),
|
|
15
|
+
country: ((n = e.slices[0].segments[0].origin) == null ? void 0 : n.iataCountryCode) || ((o = (i = e.slices[0].segments[0].origin) == null ? void 0 : i.city) == null ? void 0 : o.iataCountryCode),
|
|
16
|
+
airportCode: ((m = e.slices[0].segments[0].origin) == null ? void 0 : m.iataCityCode) || ((g = (w = e.slices[0].segments[0].origin) == null ? void 0 : w.city) == null ? void 0 : g.iataCode),
|
|
17
17
|
coordinates: {
|
|
18
|
-
latitude: (
|
|
19
|
-
longitude: (
|
|
18
|
+
latitude: (P = (M = e.slices[0].segments[0].origin) == null ? void 0 : M.city) == null ? void 0 : P.latitude,
|
|
19
|
+
longitude: (A = (N = e.slices[0].segments[0].origin) == null ? void 0 : N.city) == null ? void 0 : A.longitude
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
destination: {
|
|
23
|
-
city: ((
|
|
24
|
-
country: ((
|
|
25
|
-
airportCode: ((
|
|
23
|
+
city: ((h = (L = e.slices[0].segments.getLast()) == null ? void 0 : L.destination) == null ? void 0 : h.cityName) || ((c = (p = (d = e.slices[0].segments.getLast()) == null ? void 0 : d.destination) == null ? void 0 : p.city) == null ? void 0 : c.name),
|
|
24
|
+
country: ((C = (y = e.slices[0].segments.getLast()) == null ? void 0 : y.destination) == null ? void 0 : C.iataCountryCode) || ((u = (l = (b = e.slices[0].segments.getLast()) == null ? void 0 : b.destination) == null ? void 0 : l.city) == null ? void 0 : u.iataCountryCode),
|
|
25
|
+
airportCode: ((k = (D = e.slices[0].segments.getLast()) == null ? void 0 : D.destination) == null ? void 0 : k.iataCityCode) || ((v = (z = (O = e.slices[0].segments.getLast()) == null ? void 0 : O.destination) == null ? void 0 : z.city) == null ? void 0 : v.iataCode),
|
|
26
26
|
coordinates: {
|
|
27
|
-
latitude: (
|
|
28
|
-
longitude: (
|
|
27
|
+
latitude: ($ = (_ = (f = e.slices[0].segments.getLast()) == null ? void 0 : f.destination) == null ? void 0 : _.city) == null ? void 0 : $.latitude,
|
|
28
|
+
longitude: (G = (E = (Z = e.slices[0].segments.getLast()) == null ? void 0 : Z.destination) == null ? void 0 : E.city) == null ? void 0 : G.longitude
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
airline: e.owner.name,
|
|
32
|
-
cash: parseFloat(e.totalAmount),
|
|
33
|
-
|
|
32
|
+
cash: e.totalAmount ? parseFloat(e.totalAmount) : 0,
|
|
33
|
+
currency: e.baseCurrency,
|
|
34
|
+
flightNumber: j(e.slices[0].segments[0]),
|
|
34
35
|
awayzGroupId: e.slices[0].comparisonKey || e.awayzRouteId || e.awayzGroupId || e.id,
|
|
35
|
-
departureTime:
|
|
36
|
-
arrivalTime:
|
|
36
|
+
departureTime: F(e.slices[0].segments[0].departingAt).toDate(),
|
|
37
|
+
arrivalTime: F(
|
|
37
38
|
e.slices[0].segments[e.slices[0].segments.length - 1].arrivingAt
|
|
38
39
|
).toDate(),
|
|
39
40
|
numberOfStops: e.slices[0].segments.length - 1,
|
|
@@ -41,191 +42,228 @@ const B = (i) => i == null ? void 0 : i.map((e) => {
|
|
|
41
42
|
duration: e.slices[0].duration,
|
|
42
43
|
airlineProgram: e.airlineProgram,
|
|
43
44
|
paymentOptions: [],
|
|
44
|
-
durationMinutes:
|
|
45
|
-
departureTime:
|
|
46
|
-
arrivalTime:
|
|
45
|
+
durationMinutes: K({
|
|
46
|
+
departureTime: F(e.slices[0].segments[0].departingAt),
|
|
47
|
+
arrivalTime: F(e.slices[0].segments.getLast().arrivingAt),
|
|
47
48
|
originTimeZone: e.slices[0].segments[0].origin.timeZone,
|
|
48
49
|
destinationTimeZone: e.slices[0].segments.getLast().destination.timeZone,
|
|
49
50
|
duration: e.slices[0].duration
|
|
50
|
-
})
|
|
51
|
+
}),
|
|
52
|
+
cashFee: e.cashFee
|
|
51
53
|
};
|
|
52
|
-
}),
|
|
54
|
+
}), ee = (s, e) => {
|
|
53
55
|
if (!(e != null && e.length))
|
|
54
|
-
return B(
|
|
55
|
-
const
|
|
56
|
-
for (const
|
|
57
|
-
const o =
|
|
58
|
-
iataCode:
|
|
59
|
-
flightNumber:
|
|
60
|
-
|
|
56
|
+
return B(s);
|
|
57
|
+
const r = [...e], t = [], a = {};
|
|
58
|
+
for (const i of s) {
|
|
59
|
+
const o = i.slices[0].segments, m = o[0], w = {
|
|
60
|
+
iataCode: m.operatingCarrier.iataCode,
|
|
61
|
+
flightNumber: T(
|
|
62
|
+
m.operatingCarrierFlightNumber
|
|
61
63
|
)
|
|
62
|
-
},
|
|
63
|
-
iataCode:
|
|
64
|
-
flightNumber:
|
|
65
|
-
|
|
64
|
+
}, g = {
|
|
65
|
+
iataCode: m.marketingCarrier.iataCode,
|
|
66
|
+
flightNumber: T(
|
|
67
|
+
m.marketingCarrierFlightNumber
|
|
66
68
|
)
|
|
67
|
-
},
|
|
68
|
-
const
|
|
69
|
-
!!
|
|
70
|
-
if (!(
|
|
71
|
-
(
|
|
69
|
+
}, M = i.awayzMatchId, P = `${w.iataCode}_${g.iataCode}-${g.flightNumber}`, N = i.awayzMarketerMatchId, A = !!w.flightNumber && w.flightNumber != "", L = !!g.flightNumber && g.flightNumber != "", h = r.filter((d, p) => {
|
|
70
|
+
const c = d.flightDetails, y = d.flightDetails.slices[0].segments[0].operatingCarrierFlightNumber, C = c.id && // TODO: Maybe expand on this - Id check ensures it is a duffel flight
|
|
71
|
+
!!y && y !== "";
|
|
72
|
+
if (!(c.slices[0].segments.length === (o == null ? void 0 : o.length) && !c.slices[0].segments.find(
|
|
73
|
+
(u, D) => u.departingAt !== o[D].departingAt || u.arrivingAt !== o[D].arrivingAt || u.duration !== o[D].duration
|
|
72
74
|
)))
|
|
73
75
|
return !1;
|
|
74
|
-
let
|
|
75
|
-
return (L &&
|
|
76
|
+
let l = !1;
|
|
77
|
+
return (L && A && c.awayzMatchId === M || !C && c.awayzMatchId === P || A && !L && c.awayzMarketerMatchId === N) && (l = !0), l && (a[c.id] = p), l;
|
|
76
78
|
});
|
|
77
|
-
if (
|
|
78
|
-
|
|
79
|
-
const
|
|
80
|
-
var
|
|
81
|
-
const
|
|
82
|
-
return
|
|
79
|
+
if (h.length) {
|
|
80
|
+
i.slices[0].comparisonKey = h[0].awayzGroupId;
|
|
81
|
+
const d = h.find((p) => {
|
|
82
|
+
var C, b, l, u;
|
|
83
|
+
const c = (C = p.flightDetails.slices[0].fareBrandName) == null ? void 0 : C.toLowerCase(), y = (b = i.slices[0].fareBrandName) == null ? void 0 : b.toLowerCase();
|
|
84
|
+
return y === c || // Special Case for AC Only match on first word
|
|
83
85
|
// Due to differences in scraped points data and Duffel format
|
|
84
|
-
|
|
86
|
+
g.iataCode === "AC" && ((l = y.split(" ")) == null ? void 0 : l[0]) === ((u = c.split(" ")) == null ? void 0 : u[0]);
|
|
85
87
|
});
|
|
86
|
-
if (
|
|
87
|
-
const
|
|
88
|
-
...
|
|
89
|
-
...
|
|
90
|
-
points:
|
|
91
|
-
airlineProgram:
|
|
88
|
+
if (d) {
|
|
89
|
+
const p = a[d.id], c = {
|
|
90
|
+
...i,
|
|
91
|
+
...d,
|
|
92
|
+
points: i.points,
|
|
93
|
+
airlineProgram: i.airlineProgram,
|
|
92
94
|
flightDetails: {
|
|
93
|
-
...
|
|
94
|
-
...
|
|
95
|
-
points:
|
|
96
|
-
airlineProgram:
|
|
95
|
+
...i,
|
|
96
|
+
...d.flightDetails,
|
|
97
|
+
points: i.points,
|
|
98
|
+
airlineProgram: i.airlineProgram
|
|
97
99
|
}
|
|
98
100
|
};
|
|
99
|
-
|
|
101
|
+
r[p] = c;
|
|
100
102
|
} else
|
|
101
|
-
|
|
103
|
+
t.push(i);
|
|
102
104
|
} else
|
|
103
|
-
|
|
105
|
+
t.push(i);
|
|
104
106
|
}
|
|
105
107
|
return [
|
|
106
|
-
...
|
|
107
|
-
...B(
|
|
108
|
+
...r,
|
|
109
|
+
...B(t) ?? []
|
|
108
110
|
];
|
|
109
|
-
},
|
|
110
|
-
const e =
|
|
111
|
-
return e.iataCode + " " +
|
|
112
|
-
},
|
|
113
|
-
originCode:
|
|
111
|
+
}, j = (s) => {
|
|
112
|
+
const e = s.operatingCarrierFlightNumber ? s.operatingCarrier : s.marketingCarrier, r = s.operatingCarrierFlightNumber ?? s.marketingCarrierFlightNumber;
|
|
113
|
+
return e.iataCode + " " + T(r);
|
|
114
|
+
}, te = ({
|
|
115
|
+
originCode: s,
|
|
114
116
|
destinationCode: e,
|
|
115
|
-
departureDate:
|
|
116
|
-
cabinClass:
|
|
117
|
-
passengerCount:
|
|
117
|
+
departureDate: r,
|
|
118
|
+
cabinClass: t,
|
|
119
|
+
passengerCount: a,
|
|
118
120
|
paymentType: n
|
|
119
121
|
}) => {
|
|
120
|
-
let
|
|
121
|
-
return
|
|
122
|
-
},
|
|
123
|
-
const e =
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
airline: s.airline,
|
|
146
|
-
flightNumber: s.flightNumber,
|
|
147
|
-
paymentOptions: a.map((r) => ({
|
|
148
|
-
id: r.id,
|
|
149
|
-
cash: r.cash,
|
|
150
|
-
points: r.points,
|
|
151
|
-
cashFeeCurrency: r.flightDetails.baseCurrency,
|
|
152
|
-
//TODO: Add Cash Fee Amount
|
|
153
|
-
cashFeeAmount: 0,
|
|
154
|
-
baseCurrency: r.flightDetails.baseCurrency,
|
|
155
|
-
fareBrandName: r.flightDetails.slices[0].fareBrandName,
|
|
156
|
-
conditions: {
|
|
157
|
-
//TODO: Add Refund and Change Conditions
|
|
158
|
-
refundBeforeDeparture: !0,
|
|
159
|
-
changeBeforeDeparture: !0
|
|
122
|
+
let i = "/flights/search/one-way/points-cash?";
|
|
123
|
+
return i += `origin=${s}`, i += `&destination=${e}`, i += `&departure_date=${r}`, i += `&cabin_class=${t}`, i += `&adults=${a}`, i += `&cash_or_points=[${n}]`, i;
|
|
124
|
+
}, se = (s) => {
|
|
125
|
+
const e = {};
|
|
126
|
+
s.forEach((t) => {
|
|
127
|
+
const a = t.flightDetails.slices[0].segments.map((n) => j(n)).join("_");
|
|
128
|
+
if (e[a]) {
|
|
129
|
+
const n = U(t);
|
|
130
|
+
e[a].flight.paymentOptions.push(n);
|
|
131
|
+
const i = I(
|
|
132
|
+
e[a].flight.paymentOptions
|
|
133
|
+
);
|
|
134
|
+
e[a].flight.cash = i.lowestCash, e[a].flight.points = i.lowestPoints;
|
|
135
|
+
} else {
|
|
136
|
+
const { origin: n, destination: i } = t, o = [U(t)], m = I(o);
|
|
137
|
+
e[a] = {
|
|
138
|
+
programs: [],
|
|
139
|
+
flight: {
|
|
140
|
+
id: t.awayzGroupId,
|
|
141
|
+
partial: t.partial,
|
|
142
|
+
origin: {
|
|
143
|
+
city: n.city,
|
|
144
|
+
country: n.country,
|
|
145
|
+
airportCode: n.airportCode,
|
|
146
|
+
coordinates: n.coordinates
|
|
160
147
|
},
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
148
|
+
destination: {
|
|
149
|
+
city: i.city,
|
|
150
|
+
country: i.country,
|
|
151
|
+
airportCode: i.airportCode,
|
|
152
|
+
coordinates: i.coordinates
|
|
153
|
+
},
|
|
154
|
+
airline: t.airline,
|
|
155
|
+
flightNumber: t.flightNumber,
|
|
156
|
+
paymentOptions: o,
|
|
157
|
+
numberOfStops: t.numberOfStops,
|
|
158
|
+
departureTime: t.departureTime,
|
|
159
|
+
arrivalTime: t.arrivalTime,
|
|
160
|
+
awayzGroupId: t.awayzGroupId,
|
|
161
|
+
duration: t.duration,
|
|
162
|
+
airlineProgram: t.airlineProgram,
|
|
163
|
+
durationMinutes: K({
|
|
164
|
+
departureTime: F(
|
|
165
|
+
t.flightDetails.slices[0].segments[0].departingAt
|
|
166
|
+
),
|
|
167
|
+
arrivalTime: F(
|
|
168
|
+
t.flightDetails.slices[0].segments.getLast().arrivingAt
|
|
169
|
+
),
|
|
170
|
+
originTimeZone: t.flightDetails.slices[0].segments[0].origin.timeZone,
|
|
171
|
+
destinationTimeZone: t.flightDetails.slices[0].segments.getLast().destination.timeZone,
|
|
172
|
+
duration: t.flightDetails.slices[0].duration
|
|
173
|
+
}),
|
|
174
|
+
cash: m.lowestCash,
|
|
175
|
+
points: m.lowestPoints,
|
|
176
|
+
flightDetails: t.flightDetails,
|
|
177
|
+
currency: t.flightDetails.baseCurrency,
|
|
178
|
+
cashFee: t.cashFee
|
|
179
|
+
}
|
|
186
180
|
};
|
|
187
181
|
}
|
|
188
|
-
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
|
|
182
|
+
t.airlineProgram && !e[a].programs.includes(t.airlineProgram) && e[a].programs.push(t.airlineProgram);
|
|
183
|
+
});
|
|
184
|
+
const r = [];
|
|
185
|
+
return Object.values(e).forEach((t) => {
|
|
186
|
+
t.programs.length > 0 ? t.programs.forEach((a) => {
|
|
187
|
+
const n = I(
|
|
188
|
+
t.flight.paymentOptions.filter(
|
|
189
|
+
(i) => i.program === a || i.cash > 0
|
|
190
|
+
)
|
|
191
|
+
);
|
|
192
|
+
r.push({
|
|
193
|
+
...t.flight,
|
|
194
|
+
airlineProgram: a,
|
|
195
|
+
cash: n.lowestCash,
|
|
196
|
+
points: n.lowestPoints
|
|
197
|
+
});
|
|
198
|
+
}) : r.push(t.flight);
|
|
199
|
+
}), r;
|
|
200
|
+
}, T = (s) => s ? s.replace(/^0+/, "") : "", ie = (s) => `https://assets.duffel.com/img/airlines/for-light-background/full-color-logo/${s}.svg`, R = "/img/logo/odynn-eye.svg", S = {
|
|
201
|
+
categoryLogo: R,
|
|
202
|
+
programLogo: R,
|
|
192
203
|
awayzActive: [],
|
|
193
204
|
mainProgram: "Unknown",
|
|
194
205
|
displayProgram: "Unknown",
|
|
195
206
|
id: "Unknown",
|
|
196
207
|
totalAccumulatedPoints: 0,
|
|
197
|
-
category:
|
|
208
|
+
category: V.Airline,
|
|
198
209
|
colour: "#fff",
|
|
199
210
|
// Using App Foreground Colour
|
|
200
211
|
url: "https://www.odynn.com"
|
|
201
|
-
},
|
|
202
|
-
const { airlines: e } = await
|
|
212
|
+
}, ae = async (s) => {
|
|
213
|
+
const { airlines: e } = await q.ensureQueryData({
|
|
203
214
|
queryKey: ["walletAwards"],
|
|
204
|
-
queryFn:
|
|
215
|
+
queryFn: Q.getAwards,
|
|
205
216
|
staleTime: 864e5
|
|
206
217
|
// 24 hours
|
|
207
218
|
});
|
|
208
|
-
let
|
|
209
|
-
(
|
|
210
|
-
var
|
|
211
|
-
return ((n = (
|
|
219
|
+
let r = e.find(
|
|
220
|
+
(t) => {
|
|
221
|
+
var a, n, i, o;
|
|
222
|
+
return ((n = (a = t.mainProgram) == null ? void 0 : a.toLowerCase()) == null ? void 0 : n.includes(s == null ? void 0 : s.toLowerCase())) || ((o = (i = t.displayProgram) == null ? void 0 : i.toLowerCase()) == null ? void 0 : o.includes(s == null ? void 0 : s.toLowerCase()));
|
|
212
223
|
}
|
|
213
|
-
) ??
|
|
214
|
-
return
|
|
215
|
-
...
|
|
216
|
-
mainProgram:
|
|
217
|
-
displayProgram:
|
|
218
|
-
id:
|
|
219
|
-
}),
|
|
224
|
+
) ?? S;
|
|
225
|
+
return r || (r = {
|
|
226
|
+
...S,
|
|
227
|
+
mainProgram: s,
|
|
228
|
+
displayProgram: s,
|
|
229
|
+
id: s
|
|
230
|
+
}), r;
|
|
231
|
+
}, U = (s) => (console.log({ flight: s }), {
|
|
232
|
+
id: s.id,
|
|
233
|
+
cash: s.cash,
|
|
234
|
+
points: s.points,
|
|
235
|
+
program: s.airlineProgram,
|
|
236
|
+
baseCurrency: s.flightDetails.baseCurrency,
|
|
237
|
+
fareBrandName: s.flightDetails.slices[0].fareBrandName,
|
|
238
|
+
cashFee: s.cashFee,
|
|
239
|
+
conditions: {
|
|
240
|
+
//TODO: Add Refund and Change Conditions
|
|
241
|
+
refundBeforeDeparture: !0,
|
|
242
|
+
changeBeforeDeparture: !0
|
|
243
|
+
},
|
|
244
|
+
carrier: {
|
|
245
|
+
iataCode: s.flightDetails.slices[0].segments[0].marketingCarrier.iataCode,
|
|
246
|
+
name: s.flightDetails.slices[0].segments[0].marketingCarrier.name
|
|
247
|
+
}
|
|
248
|
+
}), I = (s) => {
|
|
249
|
+
const e = Math.min(
|
|
250
|
+
...s.filter((t) => t.cash > 0).map((t) => t.cash)
|
|
251
|
+
), r = Math.min(
|
|
252
|
+
...s.filter((t) => t.points > 0).map((t) => t.points)
|
|
253
|
+
);
|
|
254
|
+
return {
|
|
255
|
+
lowestCash: e === 1 / 0 ? -1 : e,
|
|
256
|
+
lowestPoints: r === 1 / 0 ? -1 : r
|
|
257
|
+
};
|
|
220
258
|
};
|
|
221
259
|
export {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
260
|
+
S as DEFAULT_AIRLINE_PROGRAM,
|
|
261
|
+
te as buildFlightSearchQuery,
|
|
262
|
+
ae as getAirlineProgram,
|
|
263
|
+
j as getFlightNumber,
|
|
264
|
+
ie as getLogoPath,
|
|
265
|
+
se as groupFlightResults,
|
|
228
266
|
B as mapFlightDetailsToResults,
|
|
229
|
-
|
|
230
|
-
|
|
267
|
+
ee as parseFlightDetails,
|
|
268
|
+
T as removeLeadingZeros
|
|
231
269
|
};
|