@odynn/awayz-flights 0.2.1 → 0.2.2
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,48 +1,42 @@
|
|
|
1
1
|
import { jsx as r, jsxs as e } from "react/jsx-runtime";
|
|
2
2
|
import k, { useState as d, useMemo as E } from "react";
|
|
3
|
-
import { g as f, E as N, F as I, a as
|
|
4
|
-
import { DEFAULT_AIRLINE_PROGRAM as
|
|
3
|
+
import { g as f, E as N, F as I, a as R } from "../../FlightItinerary-DgpK1LYF.js";
|
|
4
|
+
import { DEFAULT_AIRLINE_PROGRAM as T, getFlightNumber as B, getLogoPath as L, getAirlineProgram as $ } from "../../utils/flightUtils.js";
|
|
5
5
|
import { h as u } from "../../arrayExtensions-DWKenJCh.js";
|
|
6
|
-
import { g as
|
|
6
|
+
import { g as x } from "../../dateUtils-DeNLG5hw.js";
|
|
7
7
|
import { EPaymentType as v } from "../../enums/EPaymentType.js";
|
|
8
|
+
import { CashValue as M } from "@odynn/awayz-core";
|
|
8
9
|
import '../../assets/FlightResult.css';function b(i) {
|
|
9
10
|
if (!i || isNaN(i) || i < 0) return "N/A";
|
|
10
11
|
let n = i == null ? void 0 : i.toString().split(".")[0];
|
|
11
12
|
return n == null ? void 0 : n.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
12
13
|
}
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return i ? s.format(Math.round(i)).toString().split(".")[0] : s.format(0);
|
|
20
|
-
}, z = ({ details: i, onClick: n }) => {
|
|
21
|
-
const [s, y] = d(!1), o = i.origin, c = i.destination, g = i.flightDetails, D = !i.paymentOptions || i.paymentOptions.length === 1, [S, F] = d(R), C = async () => {
|
|
22
|
-
const t = await L(i.airlineProgram);
|
|
23
|
-
F(t);
|
|
24
|
-
}, { flightNumbers: h, airlines: P } = E(() => {
|
|
25
|
-
const t = [], a = [];
|
|
14
|
+
const z = ({ details: i, onClick: n }) => {
|
|
15
|
+
const [m, y] = d(!1), l = i.origin, o = i.destination, g = i.flightDetails, C = !i.paymentOptions || i.paymentOptions.length === 1, [D, F] = d(T), S = async () => {
|
|
16
|
+
const a = await $(i.airlineProgram);
|
|
17
|
+
F(a);
|
|
18
|
+
}, { flightNumbers: c, airlines: P } = E(() => {
|
|
19
|
+
const a = [], t = [];
|
|
26
20
|
return i.flightDetails.slices.forEach((A) => {
|
|
27
|
-
A.segments.forEach((
|
|
28
|
-
const p =
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
logo:
|
|
33
|
-
airline:
|
|
21
|
+
A.segments.forEach((s) => {
|
|
22
|
+
const p = B(s);
|
|
23
|
+
a.includes(p) || a.push(p);
|
|
24
|
+
const h = s.operatingCarrierFlightNumber ? s.operatingCarrier : s.marketingCarrier;
|
|
25
|
+
t.some((O) => O.airline === h.name) || t.push({
|
|
26
|
+
logo: L(h.iataCode),
|
|
27
|
+
airline: h.name
|
|
34
28
|
});
|
|
35
29
|
});
|
|
36
|
-
}),
|
|
30
|
+
}), S(), { flightNumbers: a, airlines: t };
|
|
37
31
|
}, [i.flightDetails.slices]);
|
|
38
32
|
return /* @__PURE__ */ r("div", { className: "flight-result", onClick: () => n(i), children: /* @__PURE__ */ e("div", { className: "content", children: [
|
|
39
33
|
/* @__PURE__ */ r("div", { className: "flight-info", children: /* @__PURE__ */ e("div", { className: "flight-locations", children: [
|
|
40
|
-
/* @__PURE__ */ r("div", { className: "airlines", children: P.map((
|
|
34
|
+
/* @__PURE__ */ r("div", { className: "airlines", children: P.map((a, t) => /* @__PURE__ */ r(k.Fragment, { children: /* @__PURE__ */ r("div", { className: "tip", children: /* @__PURE__ */ r("img", { src: a.logo, alt: a.airline }) }, t) }, t)) }),
|
|
41
35
|
/* @__PURE__ */ e("div", { className: "flight-location", children: [
|
|
42
36
|
/* @__PURE__ */ e("p", { children: [
|
|
43
|
-
|
|
37
|
+
l.city,
|
|
44
38
|
",",
|
|
45
|
-
f(
|
|
39
|
+
f(l.country)
|
|
46
40
|
] }),
|
|
47
41
|
/* @__PURE__ */ r("p", { children: u(i.departureTime).format(
|
|
48
42
|
// isMobile
|
|
@@ -54,7 +48,7 @@ const x = (i, n) => {
|
|
|
54
48
|
/* @__PURE__ */ e("div", { className: "flight-duration", children: [
|
|
55
49
|
/* @__PURE__ */ r("span", { className: "line" }),
|
|
56
50
|
/* @__PURE__ */ e("p", { children: [
|
|
57
|
-
|
|
51
|
+
x(g.slices[0].duration),
|
|
58
52
|
" ",
|
|
59
53
|
" - ",
|
|
60
54
|
i.numberOfStops > 0 ? `${i.numberOfStops} Stop${i.numberOfStops > 1 ? "s" : ""}` : "Direct"
|
|
@@ -63,9 +57,9 @@ const x = (i, n) => {
|
|
|
63
57
|
] }),
|
|
64
58
|
/* @__PURE__ */ e("div", { children: [
|
|
65
59
|
/* @__PURE__ */ e("p", { children: [
|
|
66
|
-
|
|
60
|
+
o.city,
|
|
67
61
|
", ",
|
|
68
|
-
f(
|
|
62
|
+
f(o.country)
|
|
69
63
|
] }),
|
|
70
64
|
/* @__PURE__ */ e("p", { children: [
|
|
71
65
|
u(i.arrivalTime).format(
|
|
@@ -84,18 +78,18 @@ const x = (i, n) => {
|
|
|
84
78
|
"div",
|
|
85
79
|
{
|
|
86
80
|
className: "flight-detail",
|
|
87
|
-
onClick: (
|
|
88
|
-
|
|
81
|
+
onClick: (a) => {
|
|
82
|
+
a.stopPropagation(), y(!m);
|
|
89
83
|
},
|
|
90
84
|
children: [
|
|
91
85
|
/* @__PURE__ */ r("p", { children: "Aircraft" }),
|
|
92
86
|
/* @__PURE__ */ e("p", { className: "chevron-text", children: [
|
|
93
87
|
/* @__PURE__ */ r(I, {}),
|
|
94
88
|
/* @__PURE__ */ e("span", { children: [
|
|
95
|
-
|
|
96
|
-
|
|
89
|
+
c[0],
|
|
90
|
+
c.length > 1 && /* @__PURE__ */ e("sup", { children: [
|
|
97
91
|
"+",
|
|
98
|
-
|
|
92
|
+
c.length - 1
|
|
99
93
|
] })
|
|
100
94
|
] })
|
|
101
95
|
] })
|
|
@@ -117,12 +111,18 @@ const x = (i, n) => {
|
|
|
117
111
|
"div",
|
|
118
112
|
{
|
|
119
113
|
className: "cash-value",
|
|
120
|
-
onClick: (
|
|
121
|
-
|
|
114
|
+
onClick: (a) => {
|
|
115
|
+
a.stopPropagation(), n(i, v.CASH);
|
|
122
116
|
},
|
|
123
117
|
children: [
|
|
124
|
-
/* @__PURE__ */ r("p", { children:
|
|
125
|
-
/* @__PURE__ */ r("p", { children:
|
|
118
|
+
/* @__PURE__ */ r("p", { children: C ? "Book For" : "From" }),
|
|
119
|
+
/* @__PURE__ */ r("p", { children: /* @__PURE__ */ r(
|
|
120
|
+
M,
|
|
121
|
+
{
|
|
122
|
+
amount: i.cash,
|
|
123
|
+
currency: i.currency
|
|
124
|
+
}
|
|
125
|
+
) })
|
|
126
126
|
]
|
|
127
127
|
}
|
|
128
128
|
),
|
|
@@ -130,23 +130,23 @@ const x = (i, n) => {
|
|
|
130
130
|
"div",
|
|
131
131
|
{
|
|
132
132
|
className: "points-value",
|
|
133
|
-
onClick: (
|
|
134
|
-
|
|
133
|
+
onClick: (a) => {
|
|
134
|
+
a.stopPropagation(), n(i, v.POINTS);
|
|
135
135
|
},
|
|
136
136
|
children: [
|
|
137
|
-
/* @__PURE__ */ r("img", { src:
|
|
137
|
+
/* @__PURE__ */ r("img", { src: D.programLogo }),
|
|
138
138
|
/* @__PURE__ */ r("p", { children: `${b(i.points)} miles` })
|
|
139
139
|
]
|
|
140
140
|
}
|
|
141
141
|
)
|
|
142
142
|
] })
|
|
143
143
|
] }),
|
|
144
|
-
/* @__PURE__ */ r("div", { className: `flight-details ${
|
|
145
|
-
|
|
144
|
+
/* @__PURE__ */ r("div", { className: `flight-details ${m ? "is-open" : ""}`, children: /* @__PURE__ */ r("div", { className: "inner", children: /* @__PURE__ */ r(
|
|
145
|
+
R,
|
|
146
146
|
{
|
|
147
147
|
itinerary: g.slices[0].segments,
|
|
148
|
-
origin:
|
|
149
|
-
destination:
|
|
148
|
+
origin: l,
|
|
149
|
+
destination: o
|
|
150
150
|
}
|
|
151
151
|
) }) })
|
|
152
152
|
] }) });
|
|
@@ -79,6 +79,7 @@ export interface IFlightPaymentOption {
|
|
|
79
79
|
cashFeeAmount: number;
|
|
80
80
|
baseCurrency: string;
|
|
81
81
|
fareBrandName: string;
|
|
82
|
+
program: string;
|
|
82
83
|
baggages?: {
|
|
83
84
|
type: EBaggage | null;
|
|
84
85
|
quantity: number;
|
|
@@ -110,6 +111,7 @@ export interface IFlightResult {
|
|
|
110
111
|
durationMinutes: number;
|
|
111
112
|
flightDetails: IFlightOffer;
|
|
112
113
|
paymentOptions: IFlightPaymentOption[];
|
|
114
|
+
currency: string;
|
|
113
115
|
}
|
|
114
116
|
export interface IAirportLocation {
|
|
115
117
|
city: string;
|
|
@@ -1,39 +1,40 @@
|
|
|
1
|
-
import { h as
|
|
2
|
-
import { c as
|
|
1
|
+
import { h as A } 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, h, g, M, P, N, L, F, w, d, p, c, y, C, b, l, u, D, k, O, f, z, v, _, $, 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 = (h = e.slices[0].segments[0].origin) == null ? void 0 : h.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: (L = (N = e.slices[0].segments[0].origin) == null ? void 0 : N.city) == null ? void 0 : L.longitude
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
destination: {
|
|
23
|
-
city: ((w = (
|
|
24
|
-
country: ((
|
|
25
|
-
airportCode: ((
|
|
23
|
+
city: ((w = (F = e.slices[0].segments.getLast()) == null ? void 0 : F.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 = (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) || ((z = (f = (O = e.slices[0].segments.getLast()) == null ? void 0 : O.destination) == null ? void 0 : f.city) == null ? void 0 : z.iataCode),
|
|
26
26
|
coordinates: {
|
|
27
|
-
latitude: (
|
|
28
|
-
longitude: (
|
|
27
|
+
latitude: ($ = (_ = (v = e.slices[0].segments.getLast()) == null ? void 0 : v.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
32
|
cash: parseFloat(e.totalAmount),
|
|
33
|
-
|
|
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: A(e.slices[0].segments[0].departingAt).toDate(),
|
|
37
|
+
arrivalTime: A(
|
|
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: A(e.slices[0].segments[0].departingAt),
|
|
47
|
+
arrivalTime: A(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
|
})
|
|
51
52
|
};
|
|
52
|
-
}),
|
|
53
|
+
}), ee = (s, e) => {
|
|
53
54
|
if (!(e != null && e.length))
|
|
54
|
-
return B(
|
|
55
|
-
const
|
|
56
|
-
for (const
|
|
57
|
-
const o =
|
|
58
|
-
iataCode:
|
|
59
|
-
flightNumber:
|
|
60
|
-
|
|
55
|
+
return B(s);
|
|
56
|
+
const r = [...e], t = [], a = {};
|
|
57
|
+
for (const i of s) {
|
|
58
|
+
const o = i.slices[0].segments, m = o[0], h = {
|
|
59
|
+
iataCode: m.operatingCarrier.iataCode,
|
|
60
|
+
flightNumber: T(
|
|
61
|
+
m.operatingCarrierFlightNumber
|
|
61
62
|
)
|
|
62
|
-
},
|
|
63
|
-
iataCode:
|
|
64
|
-
flightNumber:
|
|
65
|
-
|
|
63
|
+
}, g = {
|
|
64
|
+
iataCode: m.marketingCarrier.iataCode,
|
|
65
|
+
flightNumber: T(
|
|
66
|
+
m.marketingCarrierFlightNumber
|
|
66
67
|
)
|
|
67
|
-
},
|
|
68
|
-
const
|
|
69
|
-
!!
|
|
70
|
-
if (!(
|
|
71
|
-
(
|
|
68
|
+
}, M = i.awayzMatchId, P = `${h.iataCode}_${g.iataCode}-${g.flightNumber}`, N = i.awayzMarketerMatchId, L = !!h.flightNumber && h.flightNumber != "", F = !!g.flightNumber && g.flightNumber != "", w = r.filter((d, p) => {
|
|
69
|
+
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
|
|
70
|
+
!!y && y !== "";
|
|
71
|
+
if (!(c.slices[0].segments.length === (o == null ? void 0 : o.length) && !c.slices[0].segments.find(
|
|
72
|
+
(u, D) => u.departingAt !== o[D].departingAt || u.arrivingAt !== o[D].arrivingAt || u.duration !== o[D].duration
|
|
72
73
|
)))
|
|
73
74
|
return !1;
|
|
74
|
-
let
|
|
75
|
-
return (
|
|
75
|
+
let l = !1;
|
|
76
|
+
return (F && L && c.awayzMatchId === M || !C && c.awayzMatchId === P || L && !F && c.awayzMarketerMatchId === N) && (l = !0), l && (a[c.id] = p), l;
|
|
76
77
|
});
|
|
77
78
|
if (w.length) {
|
|
78
|
-
|
|
79
|
-
const
|
|
80
|
-
var
|
|
81
|
-
const
|
|
82
|
-
return
|
|
79
|
+
i.slices[0].comparisonKey = w[0].awayzGroupId;
|
|
80
|
+
const d = w.find((p) => {
|
|
81
|
+
var C, b, l, u;
|
|
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
|
+
return y === c || // Special Case for AC Only match on first word
|
|
83
84
|
// Due to differences in scraped points data and Duffel format
|
|
84
|
-
|
|
85
|
+
g.iataCode === "AC" && ((l = y.split(" ")) == null ? void 0 : l[0]) === ((u = c.split(" ")) == null ? void 0 : u[0]);
|
|
85
86
|
});
|
|
86
|
-
if (
|
|
87
|
-
const
|
|
88
|
-
...
|
|
89
|
-
...
|
|
90
|
-
points:
|
|
91
|
-
airlineProgram:
|
|
87
|
+
if (d) {
|
|
88
|
+
const p = a[d.id], c = {
|
|
89
|
+
...i,
|
|
90
|
+
...d,
|
|
91
|
+
points: i.points,
|
|
92
|
+
airlineProgram: i.airlineProgram,
|
|
92
93
|
flightDetails: {
|
|
93
|
-
...
|
|
94
|
-
...
|
|
95
|
-
points:
|
|
96
|
-
airlineProgram:
|
|
94
|
+
...i,
|
|
95
|
+
...d.flightDetails,
|
|
96
|
+
points: i.points,
|
|
97
|
+
airlineProgram: i.airlineProgram
|
|
97
98
|
}
|
|
98
99
|
};
|
|
99
|
-
|
|
100
|
+
r[p] = c;
|
|
100
101
|
} else
|
|
101
|
-
|
|
102
|
+
t.push(i);
|
|
102
103
|
} else
|
|
103
|
-
|
|
104
|
+
t.push(i);
|
|
104
105
|
}
|
|
105
106
|
return [
|
|
106
|
-
...
|
|
107
|
-
...B(
|
|
107
|
+
...r,
|
|
108
|
+
...B(t) ?? []
|
|
108
109
|
];
|
|
109
|
-
},
|
|
110
|
-
const e =
|
|
111
|
-
return e.iataCode + " " +
|
|
112
|
-
},
|
|
113
|
-
originCode:
|
|
110
|
+
}, j = (s) => {
|
|
111
|
+
const e = s.operatingCarrierFlightNumber ? s.operatingCarrier : s.marketingCarrier, r = s.operatingCarrierFlightNumber ?? s.marketingCarrierFlightNumber;
|
|
112
|
+
return e.iataCode + " " + T(r);
|
|
113
|
+
}, te = ({
|
|
114
|
+
originCode: s,
|
|
114
115
|
destinationCode: e,
|
|
115
|
-
departureDate:
|
|
116
|
-
cabinClass:
|
|
117
|
-
passengerCount:
|
|
116
|
+
departureDate: r,
|
|
117
|
+
cabinClass: t,
|
|
118
|
+
passengerCount: a,
|
|
118
119
|
paymentType: n
|
|
119
120
|
}) => {
|
|
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
|
|
121
|
+
let i = "/flights/search/one-way/points-cash?";
|
|
122
|
+
return i += `origin=${s}`, i += `&destination=${e}`, i += `&departure_date=${r}`, i += `&cabin_class=${t}`, i += `&adults=${a}`, i += `&cash_or_points=[${n}]`, i;
|
|
123
|
+
}, se = (s) => {
|
|
124
|
+
const e = {};
|
|
125
|
+
s.forEach((t) => {
|
|
126
|
+
const a = t.flightDetails.slices[0].segments.map((n) => j(n)).join("_");
|
|
127
|
+
if (e[a]) {
|
|
128
|
+
const n = U(t);
|
|
129
|
+
e[a].flight.paymentOptions.push(n);
|
|
130
|
+
const i = I(
|
|
131
|
+
e[a].flight.paymentOptions
|
|
132
|
+
);
|
|
133
|
+
e[a].flight.cash = i.lowestCash, e[a].flight.points = i.lowestPoints;
|
|
134
|
+
} else {
|
|
135
|
+
const { origin: n, destination: i } = t, o = [U(t)], m = I(o);
|
|
136
|
+
e[a] = {
|
|
137
|
+
programs: [],
|
|
138
|
+
flight: {
|
|
139
|
+
id: t.awayzGroupId,
|
|
140
|
+
partial: t.partial,
|
|
141
|
+
origin: {
|
|
142
|
+
city: n.city,
|
|
143
|
+
country: n.country,
|
|
144
|
+
airportCode: n.airportCode,
|
|
145
|
+
coordinates: n.coordinates
|
|
160
146
|
},
|
|
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
|
-
|
|
147
|
+
destination: {
|
|
148
|
+
city: i.city,
|
|
149
|
+
country: i.country,
|
|
150
|
+
airportCode: i.airportCode,
|
|
151
|
+
coordinates: i.coordinates
|
|
152
|
+
},
|
|
153
|
+
airline: t.airline,
|
|
154
|
+
flightNumber: t.flightNumber,
|
|
155
|
+
paymentOptions: o,
|
|
156
|
+
numberOfStops: t.numberOfStops,
|
|
157
|
+
departureTime: t.departureTime,
|
|
158
|
+
arrivalTime: t.arrivalTime,
|
|
159
|
+
awayzGroupId: t.awayzGroupId,
|
|
160
|
+
duration: t.duration,
|
|
161
|
+
airlineProgram: t.airlineProgram,
|
|
162
|
+
durationMinutes: K({
|
|
163
|
+
departureTime: A(
|
|
164
|
+
t.flightDetails.slices[0].segments[0].departingAt
|
|
165
|
+
),
|
|
166
|
+
arrivalTime: A(
|
|
167
|
+
t.flightDetails.slices[0].segments.getLast().arrivingAt
|
|
168
|
+
),
|
|
169
|
+
originTimeZone: t.flightDetails.slices[0].segments[0].origin.timeZone,
|
|
170
|
+
destinationTimeZone: t.flightDetails.slices[0].segments.getLast().destination.timeZone,
|
|
171
|
+
duration: t.flightDetails.slices[0].duration
|
|
172
|
+
}),
|
|
173
|
+
cash: m.lowestCash,
|
|
174
|
+
points: m.lowestPoints,
|
|
175
|
+
flightDetails: t.flightDetails,
|
|
176
|
+
currency: t.flightDetails.baseCurrency
|
|
177
|
+
}
|
|
186
178
|
};
|
|
187
179
|
}
|
|
188
|
-
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
|
|
180
|
+
t.airlineProgram && !e[a].programs.includes(t.airlineProgram) && e[a].programs.push(t.airlineProgram);
|
|
181
|
+
});
|
|
182
|
+
const r = [];
|
|
183
|
+
return Object.values(e).forEach((t) => {
|
|
184
|
+
t.programs.length > 0 ? t.programs.forEach((a) => {
|
|
185
|
+
const n = I(
|
|
186
|
+
t.flight.paymentOptions.filter(
|
|
187
|
+
(i) => i.program === a || i.cash > 0
|
|
188
|
+
)
|
|
189
|
+
);
|
|
190
|
+
r.push({
|
|
191
|
+
...t.flight,
|
|
192
|
+
airlineProgram: a,
|
|
193
|
+
cash: n.lowestCash,
|
|
194
|
+
points: n.lowestPoints
|
|
195
|
+
});
|
|
196
|
+
}) : r.push(t.flight);
|
|
197
|
+
}), r;
|
|
198
|
+
}, 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 = {
|
|
199
|
+
categoryLogo: R,
|
|
200
|
+
programLogo: R,
|
|
192
201
|
awayzActive: [],
|
|
193
202
|
mainProgram: "Unknown",
|
|
194
203
|
displayProgram: "Unknown",
|
|
195
204
|
id: "Unknown",
|
|
196
205
|
totalAccumulatedPoints: 0,
|
|
197
|
-
category:
|
|
206
|
+
category: V.Airline,
|
|
198
207
|
colour: "#fff",
|
|
199
208
|
// Using App Foreground Colour
|
|
200
209
|
url: "https://www.odynn.com"
|
|
201
|
-
},
|
|
202
|
-
const { airlines: e } = await
|
|
210
|
+
}, ae = async (s) => {
|
|
211
|
+
const { airlines: e } = await q.ensureQueryData({
|
|
203
212
|
queryKey: ["walletAwards"],
|
|
204
|
-
queryFn:
|
|
213
|
+
queryFn: Q.getAwards,
|
|
205
214
|
staleTime: 864e5
|
|
206
215
|
// 24 hours
|
|
207
216
|
});
|
|
208
|
-
let
|
|
209
|
-
(
|
|
210
|
-
var
|
|
211
|
-
return ((n = (
|
|
217
|
+
let r = e.find(
|
|
218
|
+
(t) => {
|
|
219
|
+
var a, n, i, o;
|
|
220
|
+
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
221
|
}
|
|
213
|
-
) ??
|
|
214
|
-
return
|
|
215
|
-
...
|
|
216
|
-
mainProgram:
|
|
217
|
-
displayProgram:
|
|
218
|
-
id:
|
|
219
|
-
}),
|
|
222
|
+
) ?? S;
|
|
223
|
+
return r || (r = {
|
|
224
|
+
...S,
|
|
225
|
+
mainProgram: s,
|
|
226
|
+
displayProgram: s,
|
|
227
|
+
id: s
|
|
228
|
+
}), r;
|
|
229
|
+
}, U = (s) => ({
|
|
230
|
+
id: s.id,
|
|
231
|
+
cash: s.cash,
|
|
232
|
+
points: s.points,
|
|
233
|
+
program: s.airlineProgram,
|
|
234
|
+
cashFeeCurrency: s.flightDetails.baseCurrency,
|
|
235
|
+
//TODO: Add Cash Fee Amount
|
|
236
|
+
cashFeeAmount: 0,
|
|
237
|
+
baseCurrency: s.flightDetails.baseCurrency,
|
|
238
|
+
fareBrandName: s.flightDetails.slices[0].fareBrandName,
|
|
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
|
};
|