@odynn/awayz-flights 0.2.6 → 0.2.7
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.
|
@@ -13,7 +13,7 @@ import '../../assets/FlightResult.css';function H(i) {
|
|
|
13
13
|
}
|
|
14
14
|
const Q = ({ details: i, onClick: a }) => {
|
|
15
15
|
var d;
|
|
16
|
-
const [g, C] = N(!1), c = i.origin, l = i.destination, p = i.flightDetails,
|
|
16
|
+
const [g, C] = N(!1), c = i.origin, l = i.destination, p = i.flightDetails, S = !i.paymentOptions || i.paymentOptions.length === 1, [D, P] = N($), A = async () => {
|
|
17
17
|
const n = await b(i.airlineProgram);
|
|
18
18
|
P(n);
|
|
19
19
|
}, { flightNumbers: h, airlines: O } = R(() => {
|
|
@@ -105,7 +105,7 @@ const Q = ({ details: i, onClick: a }) => {
|
|
|
105
105
|
] }),
|
|
106
106
|
/* @__PURE__ */ e("div", { className: "flight-detail", children: [
|
|
107
107
|
/* @__PURE__ */ r("p", { children: "Marketing Carrier" }),
|
|
108
|
-
/* @__PURE__ */ r("p", { children: i.
|
|
108
|
+
/* @__PURE__ */ r("p", { children: i.airline })
|
|
109
109
|
] })
|
|
110
110
|
] }),
|
|
111
111
|
/* @__PURE__ */ e("div", { className: "booking-options", children: [
|
|
@@ -118,7 +118,7 @@ const Q = ({ details: i, onClick: a }) => {
|
|
|
118
118
|
n.stopPropagation(), a(i, o.CASH);
|
|
119
119
|
},
|
|
120
120
|
children: [
|
|
121
|
-
/* @__PURE__ */ r("p", { children:
|
|
121
|
+
/* @__PURE__ */ r("p", { children: S ? "Book For" : "From" }),
|
|
122
122
|
/* @__PURE__ */ r("p", { children: /* @__PURE__ */ r(
|
|
123
123
|
y,
|
|
124
124
|
{
|
|
@@ -137,7 +137,7 @@ const Q = ({ details: i, onClick: a }) => {
|
|
|
137
137
|
n.stopPropagation(), a(i, o.POINTS);
|
|
138
138
|
},
|
|
139
139
|
children: [
|
|
140
|
-
/* @__PURE__ */ r("img", { src:
|
|
140
|
+
/* @__PURE__ */ r("img", { src: D.programLogo }),
|
|
141
141
|
/* @__PURE__ */ e("p", { children: [
|
|
142
142
|
`${H(i.points)} miles`,
|
|
143
143
|
((d = i.cashFee) == null ? void 0 : d.amount) > 0 && /* @__PURE__ */ e(I, { children: [
|
|
@@ -4,28 +4,28 @@ import "react";
|
|
|
4
4
|
import { awayzClient as q } from "@odynn/awayz-core";
|
|
5
5
|
import { WalletService as Q } from "../services/wallet/WalletService.js";
|
|
6
6
|
import { ERewardProgramCategories as V } from "../services/wallet/WalletService.types.js";
|
|
7
|
-
const
|
|
8
|
-
var
|
|
7
|
+
const S = (s) => s == null ? void 0 : s.map((e) => {
|
|
8
|
+
var n, t, r, a, i, o, l, h, g, M, P, N, A, L, w, d, p, c, y, C, b, m, u, D, O, T, z, f, v, E, _, $, Z, 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: ((
|
|
16
|
-
airportCode: ((
|
|
14
|
+
city: ((n = e.slices[0].segments[0].origin) == null ? void 0 : n.cityName) || ((r = (t = e.slices[0].segments[0].origin) == null ? void 0 : t.city) == null ? void 0 : r.name),
|
|
15
|
+
country: ((a = e.slices[0].segments[0].origin) == null ? void 0 : a.iataCountryCode) || ((o = (i = e.slices[0].segments[0].origin) == null ? void 0 : i.city) == null ? void 0 : o.iataCountryCode),
|
|
16
|
+
airportCode: ((l = e.slices[0].segments[0].origin) == null ? void 0 : l.iataCityCode) || ((g = (h = e.slices[0].segments[0].origin) == null ? void 0 : h.city) == null ? void 0 : g.iataCode),
|
|
17
17
|
coordinates: {
|
|
18
18
|
latitude: (P = (M = e.slices[0].segments[0].origin) == null ? void 0 : M.city) == null ? void 0 : P.latitude,
|
|
19
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: ((C = (y = e.slices[0].segments.getLast()) == null ? void 0 : y.destination) == null ? void 0 : C.iataCountryCode) || ((u = (
|
|
25
|
-
airportCode: ((
|
|
23
|
+
city: ((w = (L = e.slices[0].segments.getLast()) == null ? void 0 : L.destination) == null ? void 0 : w.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 = (m = (b = e.slices[0].segments.getLast()) == null ? void 0 : b.destination) == null ? void 0 : m.city) == null ? void 0 : u.iataCountryCode),
|
|
25
|
+
airportCode: ((O = (D = e.slices[0].segments.getLast()) == null ? void 0 : D.destination) == null ? void 0 : O.iataCityCode) || ((f = (z = (T = e.slices[0].segments.getLast()) == null ? void 0 : T.destination) == null ? void 0 : z.city) == null ? void 0 : f.iataCode),
|
|
26
26
|
coordinates: {
|
|
27
|
-
latitude: (
|
|
28
|
-
longitude: (G = (
|
|
27
|
+
latitude: (_ = (E = (v = e.slices[0].segments.getLast()) == null ? void 0 : v.destination) == null ? void 0 : E.city) == null ? void 0 : _.latitude,
|
|
28
|
+
longitude: (G = (Z = ($ = e.slices[0].segments.getLast()) == null ? void 0 : $.destination) == null ? void 0 : Z.city) == null ? void 0 : G.longitude
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
airline: e.owner.name,
|
|
@@ -53,39 +53,39 @@ const R = (s) => s == null ? void 0 : s.map((e) => {
|
|
|
53
53
|
};
|
|
54
54
|
}), ee = (s, e) => {
|
|
55
55
|
if (!(e != null && e.length))
|
|
56
|
-
return
|
|
57
|
-
const
|
|
56
|
+
return S(s);
|
|
57
|
+
const n = [...e], t = [], r = {};
|
|
58
58
|
for (const i of s) {
|
|
59
|
-
const o = i.slices[0].segments,
|
|
60
|
-
iataCode:
|
|
61
|
-
flightNumber:
|
|
62
|
-
|
|
59
|
+
const o = i.slices[0].segments, l = o[0], h = {
|
|
60
|
+
iataCode: l.operatingCarrier.iataCode,
|
|
61
|
+
flightNumber: k(
|
|
62
|
+
l.operatingCarrierFlightNumber
|
|
63
63
|
)
|
|
64
64
|
}, g = {
|
|
65
|
-
iataCode:
|
|
66
|
-
flightNumber:
|
|
67
|
-
|
|
65
|
+
iataCode: l.marketingCarrier.iataCode,
|
|
66
|
+
flightNumber: k(
|
|
67
|
+
l.marketingCarrierFlightNumber
|
|
68
68
|
)
|
|
69
|
-
}, M = i.awayzMatchId, P = `${
|
|
69
|
+
}, M = i.awayzMatchId, P = `${h.iataCode}_${g.iataCode}-${g.flightNumber}`, N = i.awayzMarketerMatchId, A = !!h.flightNumber && h.flightNumber != "", L = !!g.flightNumber && g.flightNumber != "", w = n.filter((d, p) => {
|
|
70
70
|
const c = d.flightDetails, y = d.flightDetails.slices[0].segments[0].operatingCarrierFlightNumber, C = c.id && !!y && y !== "";
|
|
71
71
|
if (!(c.slices[0].segments.length === (o == null ? void 0 : o.length) && !c.slices[0].segments.find(
|
|
72
72
|
(u, D) => u.departingAt !== o[D].departingAt || u.arrivingAt !== o[D].arrivingAt || u.duration !== o[D].duration
|
|
73
73
|
)))
|
|
74
74
|
return !1;
|
|
75
|
-
let
|
|
76
|
-
return (L && A && c.awayzMatchId === M || !C && c.awayzMatchId === P || A && !L && c.awayzMarketerMatchId === N) && (
|
|
75
|
+
let m = !1;
|
|
76
|
+
return (L && A && c.awayzMatchId === M || !C && c.awayzMatchId === P || A && !L && c.awayzMarketerMatchId === N) && (m = !0), m && (r[c.id] = p), m;
|
|
77
77
|
});
|
|
78
|
-
if (
|
|
79
|
-
i.slices[0].comparisonKey =
|
|
80
|
-
const d =
|
|
81
|
-
var C, b,
|
|
78
|
+
if (w.length) {
|
|
79
|
+
i.slices[0].comparisonKey = w[0].awayzGroupId;
|
|
80
|
+
const d = w.find((p) => {
|
|
81
|
+
var C, b, m, u;
|
|
82
82
|
const c = (C = p.flightDetails.slices[0].fareBrandName) == null ? void 0 : C.toLowerCase(), y = (b = i.slices[0].fareBrandName) == null ? void 0 : b.toLowerCase();
|
|
83
83
|
return y === c || // Special Case for AC Only match on first word
|
|
84
84
|
// Due to differences in scraped points data and Duffel format
|
|
85
|
-
g.iataCode === "AC" && ((
|
|
85
|
+
g.iataCode === "AC" && ((m = y.split(" ")) == null ? void 0 : m[0]) === ((u = c.split(" ")) == null ? void 0 : u[0]);
|
|
86
86
|
});
|
|
87
87
|
if (d) {
|
|
88
|
-
const p =
|
|
88
|
+
const p = r[d.id], c = {
|
|
89
89
|
...i,
|
|
90
90
|
...d,
|
|
91
91
|
points: i.points,
|
|
@@ -97,52 +97,52 @@ const R = (s) => s == null ? void 0 : s.map((e) => {
|
|
|
97
97
|
airlineProgram: i.airlineProgram
|
|
98
98
|
}
|
|
99
99
|
};
|
|
100
|
-
|
|
100
|
+
n[p] = c;
|
|
101
101
|
} else
|
|
102
102
|
t.push(i);
|
|
103
103
|
} else
|
|
104
104
|
t.push(i);
|
|
105
105
|
}
|
|
106
106
|
return [
|
|
107
|
-
...
|
|
108
|
-
...
|
|
107
|
+
...n,
|
|
108
|
+
...S(t) ?? []
|
|
109
109
|
];
|
|
110
110
|
}, j = (s) => {
|
|
111
|
-
const e = s.operatingCarrierFlightNumber ? s.operatingCarrier : s.marketingCarrier,
|
|
112
|
-
return e.iataCode + " " +
|
|
111
|
+
const e = s.operatingCarrierFlightNumber ? s.operatingCarrier : s.marketingCarrier, n = s.operatingCarrierFlightNumber ?? s.marketingCarrierFlightNumber;
|
|
112
|
+
return e.iataCode + " " + k(n);
|
|
113
113
|
}, te = ({
|
|
114
114
|
originCode: s,
|
|
115
115
|
destinationCode: e,
|
|
116
|
-
departureDate:
|
|
116
|
+
departureDate: n,
|
|
117
117
|
cabinClass: t,
|
|
118
|
-
passengerCount:
|
|
119
|
-
paymentType:
|
|
118
|
+
passengerCount: r,
|
|
119
|
+
paymentType: a
|
|
120
120
|
}) => {
|
|
121
121
|
let i = "/flights/search/one-way/points-cash?";
|
|
122
|
-
return i += `origin=${s}`, i += `&destination=${e}`, i += `&departure_date=${
|
|
122
|
+
return i += `origin=${s}`, i += `&destination=${e}`, i += `&departure_date=${n}`, i += `&cabin_class=${t}`, i += `&adults=${r}`, i += `&cash_or_points=[${a}]`, i;
|
|
123
123
|
}, se = (s) => {
|
|
124
124
|
const e = {};
|
|
125
125
|
s.forEach((t) => {
|
|
126
|
-
const
|
|
127
|
-
if (e[
|
|
128
|
-
const
|
|
129
|
-
e[
|
|
126
|
+
const r = t.flightDetails.slices[0].segments.map((a) => j(a)).join("_");
|
|
127
|
+
if (e[r]) {
|
|
128
|
+
const a = U(t);
|
|
129
|
+
e[r].flight.paymentOptions.push(a);
|
|
130
130
|
const i = I(
|
|
131
|
-
e[
|
|
131
|
+
e[r].flight.paymentOptions
|
|
132
132
|
);
|
|
133
|
-
e[
|
|
133
|
+
e[r].flight.cash = i.lowestCash, e[r].flight.points = i.lowestPoints;
|
|
134
134
|
} else {
|
|
135
|
-
const { origin:
|
|
136
|
-
e[
|
|
135
|
+
const { origin: a, destination: i } = t, o = [U(t)], l = I(o);
|
|
136
|
+
e[r] = {
|
|
137
137
|
programs: [],
|
|
138
138
|
flight: {
|
|
139
139
|
id: t.awayzGroupId,
|
|
140
140
|
partial: t.partial,
|
|
141
141
|
origin: {
|
|
142
|
-
city:
|
|
143
|
-
country:
|
|
144
|
-
airportCode:
|
|
145
|
-
coordinates:
|
|
142
|
+
city: a.city,
|
|
143
|
+
country: a.country,
|
|
144
|
+
airportCode: a.airportCode,
|
|
145
|
+
coordinates: a.coordinates
|
|
146
146
|
},
|
|
147
147
|
destination: {
|
|
148
148
|
city: i.city,
|
|
@@ -170,35 +170,54 @@ const R = (s) => s == null ? void 0 : s.map((e) => {
|
|
|
170
170
|
destinationTimeZone: t.flightDetails.slices[0].segments.getLast().destination.timeZone,
|
|
171
171
|
duration: t.flightDetails.slices[0].duration
|
|
172
172
|
}),
|
|
173
|
-
cash:
|
|
174
|
-
points:
|
|
173
|
+
cash: l.lowestCash,
|
|
174
|
+
points: l.lowestPoints,
|
|
175
175
|
flightDetails: t.flightDetails,
|
|
176
176
|
currency: t.flightDetails.baseCurrency,
|
|
177
177
|
cashFee: t.cashFee
|
|
178
178
|
}
|
|
179
179
|
};
|
|
180
180
|
}
|
|
181
|
-
t.airlineProgram && !e[
|
|
181
|
+
t.airlineProgram && !e[r].programs.includes(t.airlineProgram) && e[r].programs.push(t.airlineProgram);
|
|
182
182
|
});
|
|
183
|
-
const
|
|
183
|
+
const n = [];
|
|
184
184
|
return Object.values(e).forEach((t) => {
|
|
185
|
+
const r = [
|
|
186
|
+
...new Set(
|
|
187
|
+
t.flight.paymentOptions.map((a) => a.carrier.name)
|
|
188
|
+
)
|
|
189
|
+
];
|
|
185
190
|
t.programs.length > 0 ? t.programs.forEach((a) => {
|
|
186
|
-
|
|
191
|
+
r.forEach((i) => {
|
|
192
|
+
const o = I(
|
|
193
|
+
t.flight.paymentOptions.filter(
|
|
194
|
+
(l) => l.program === a || l.cash > 0 && l.carrier.name === i
|
|
195
|
+
)
|
|
196
|
+
);
|
|
197
|
+
n.push({
|
|
198
|
+
...t.flight,
|
|
199
|
+
airline: i,
|
|
200
|
+
airlineProgram: a,
|
|
201
|
+
cash: o.lowestCash,
|
|
202
|
+
points: o.lowestPoints
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
}) : r.forEach((a) => {
|
|
206
|
+
const { lowestCash: i } = I(
|
|
187
207
|
t.flight.paymentOptions.filter(
|
|
188
|
-
(
|
|
208
|
+
(o) => o.carrier.name === a
|
|
189
209
|
)
|
|
190
210
|
);
|
|
191
|
-
|
|
211
|
+
n.push({
|
|
192
212
|
...t.flight,
|
|
193
|
-
|
|
194
|
-
cash:
|
|
195
|
-
points: n.lowestPoints
|
|
213
|
+
airline: a,
|
|
214
|
+
cash: i
|
|
196
215
|
});
|
|
197
|
-
})
|
|
198
|
-
}),
|
|
199
|
-
},
|
|
200
|
-
categoryLogo:
|
|
201
|
-
programLogo:
|
|
216
|
+
});
|
|
217
|
+
}), n;
|
|
218
|
+
}, k = (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", B = {
|
|
219
|
+
categoryLogo: R,
|
|
220
|
+
programLogo: R,
|
|
202
221
|
awayzActive: [],
|
|
203
222
|
mainProgram: "Unknown",
|
|
204
223
|
displayProgram: "Unknown",
|
|
@@ -215,18 +234,18 @@ const R = (s) => s == null ? void 0 : s.map((e) => {
|
|
|
215
234
|
staleTime: 864e5
|
|
216
235
|
// 24 hours
|
|
217
236
|
});
|
|
218
|
-
let
|
|
237
|
+
let n = e.find(
|
|
219
238
|
(t) => {
|
|
220
|
-
var
|
|
221
|
-
return ((
|
|
239
|
+
var r, a, i, o;
|
|
240
|
+
return ((a = (r = t.mainProgram) == null ? void 0 : r.toLowerCase()) == null ? void 0 : a.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()));
|
|
222
241
|
}
|
|
223
242
|
) ?? B;
|
|
224
|
-
return
|
|
243
|
+
return n || (n = {
|
|
225
244
|
...B,
|
|
226
245
|
mainProgram: s,
|
|
227
246
|
displayProgram: s,
|
|
228
247
|
id: s
|
|
229
|
-
}),
|
|
248
|
+
}), n;
|
|
230
249
|
}, U = (s) => ({
|
|
231
250
|
id: s.id,
|
|
232
251
|
cash: s.cash,
|
|
@@ -243,12 +262,12 @@ const R = (s) => s == null ? void 0 : s.map((e) => {
|
|
|
243
262
|
}), I = (s) => {
|
|
244
263
|
const e = Math.min(
|
|
245
264
|
...s.filter((t) => t.cash > 0).map((t) => t.cash)
|
|
246
|
-
),
|
|
265
|
+
), n = Math.min(
|
|
247
266
|
...s.filter((t) => t.points > 0).map((t) => t.points)
|
|
248
267
|
);
|
|
249
268
|
return {
|
|
250
269
|
lowestCash: e === 1 / 0 ? -1 : e,
|
|
251
|
-
lowestPoints:
|
|
270
|
+
lowestPoints: n === 1 / 0 ? -1 : n
|
|
252
271
|
};
|
|
253
272
|
};
|
|
254
273
|
export {
|
|
@@ -258,7 +277,7 @@ export {
|
|
|
258
277
|
j as getFlightNumber,
|
|
259
278
|
ie as getLogoPath,
|
|
260
279
|
se as groupFlightResults,
|
|
261
|
-
|
|
280
|
+
S as mapFlightDetailsToResults,
|
|
262
281
|
ee as parseFlightDetails,
|
|
263
|
-
|
|
282
|
+
k as removeLeadingZeros
|
|
264
283
|
};
|