@odynn/awayz-flights 0.3.2 → 0.3.4
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,102 +1,102 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import { g as
|
|
4
|
-
import { DEFAULT_AIRLINE_PROGRAM as
|
|
1
|
+
import { jsx as e, jsxs as r, Fragment as $ } from "react/jsx-runtime";
|
|
2
|
+
import x, { useState as S, useMemo as j } from "react";
|
|
3
|
+
import { g as O, E as c, F as H, a as U } from "../../FlightItinerary-COx1k-zp.js";
|
|
4
|
+
import { DEFAULT_AIRLINE_PROGRAM as _, getFlightNumber as z, getLogoPath as G, getAirlineProgram as V } from "../../utils/flightUtils.js";
|
|
5
5
|
import { h } from "../../moment-BGjjqtLQ.js";
|
|
6
|
-
import { g as
|
|
6
|
+
import { g as q } from "../../index-D0Heof44.js";
|
|
7
7
|
import "../../arrayExtensions-DFLvtO8l.js";
|
|
8
8
|
import { EPaymentType as m } from "../../enums/EPaymentType.js";
|
|
9
|
-
import { CashValue as
|
|
10
|
-
import { isSameDayFlight as
|
|
11
|
-
import '../../assets/FlightResult.css';function
|
|
9
|
+
import { CashValue as P, EInvalidAmountDisplayOption as J } from "@odynn/awayz-core";
|
|
10
|
+
import { isSameDayFlight as K } from "../../utils/flightDateUtils.js";
|
|
11
|
+
import '../../assets/FlightResult.css';function Q(i) {
|
|
12
12
|
if (!i || isNaN(i) || i < 0) return "N/A";
|
|
13
13
|
let o = i == null ? void 0 : i.toString().split(".")[0];
|
|
14
14
|
return o == null ? void 0 : o.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
15
15
|
}
|
|
16
|
-
const
|
|
17
|
-
var u;
|
|
18
|
-
const [d,
|
|
19
|
-
const a = await
|
|
20
|
-
|
|
21
|
-
}, { flightNumbers: p, airlines:
|
|
16
|
+
const ni = ({ details: i, onClick: o }) => {
|
|
17
|
+
var u, v, F, y, C;
|
|
18
|
+
const [d, T] = S(!1), n = i.origin, t = i.destination, f = i.flightDetails, N = i.paymentOptions || [], k = N.filter((a) => a.cash).length === 1, A = N.filter((a) => a.points).length === 1, [b, w] = S(_), E = async () => {
|
|
19
|
+
const a = await V(i.airlineProgram);
|
|
20
|
+
w(a);
|
|
21
|
+
}, { flightNumbers: p, airlines: I } = j(() => {
|
|
22
22
|
const a = [], s = [];
|
|
23
|
-
return i.flightDetails.slices.forEach((
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
a.includes(
|
|
23
|
+
return i.flightDetails.slices.forEach((B) => {
|
|
24
|
+
B.segments.forEach((l) => {
|
|
25
|
+
const D = z(l);
|
|
26
|
+
a.includes(D) || a.push(D);
|
|
27
27
|
const g = l.operatingCarrierFlightNumber ? l.operatingCarrier : l.marketingCarrier;
|
|
28
|
-
s.some((
|
|
29
|
-
logo:
|
|
28
|
+
s.some((M) => M.airline === g.name) || s.push({
|
|
29
|
+
logo: G(g.iataCode),
|
|
30
30
|
airline: g.name
|
|
31
31
|
});
|
|
32
32
|
});
|
|
33
|
-
}),
|
|
34
|
-
}, [i.flightDetails.slices]),
|
|
33
|
+
}), E(), { flightNumbers: a, airlines: s };
|
|
34
|
+
}, [i.flightDetails.slices]), L = () => {
|
|
35
35
|
i.cash > 0 ? o(i, m.CASH) : o(i, m.POINTS);
|
|
36
|
-
},
|
|
36
|
+
}, R = !K(
|
|
37
37
|
i.departureTime,
|
|
38
38
|
i.arrivalTime
|
|
39
39
|
);
|
|
40
|
-
return /* @__PURE__ */
|
|
41
|
-
/* @__PURE__ */
|
|
42
|
-
/* @__PURE__ */
|
|
43
|
-
/* @__PURE__ */
|
|
44
|
-
/* @__PURE__ */
|
|
40
|
+
return /* @__PURE__ */ e("div", { className: "flight-result", onClick: L, children: /* @__PURE__ */ r("div", { className: "content", children: [
|
|
41
|
+
/* @__PURE__ */ e("div", { className: "flight-info", children: /* @__PURE__ */ r("div", { className: "flight-locations", children: [
|
|
42
|
+
/* @__PURE__ */ e("div", { className: "airlines", children: I.map((a, s) => /* @__PURE__ */ e(x.Fragment, { children: /* @__PURE__ */ r("div", { className: "tip", children: [
|
|
43
|
+
/* @__PURE__ */ e("img", { src: a.logo, alt: a.airline }),
|
|
44
|
+
/* @__PURE__ */ e("span", { className: "right", children: a.airline })
|
|
45
45
|
] }, s) }, s)) }),
|
|
46
|
-
/* @__PURE__ */
|
|
47
|
-
/* @__PURE__ */
|
|
46
|
+
/* @__PURE__ */ r("div", { className: "flight-location", children: [
|
|
47
|
+
/* @__PURE__ */ r("p", { className: "show-desktop", children: [
|
|
48
48
|
n.city,
|
|
49
49
|
",",
|
|
50
|
-
|
|
50
|
+
O(n.country)
|
|
51
51
|
] }),
|
|
52
|
-
/* @__PURE__ */
|
|
52
|
+
/* @__PURE__ */ e("p", { className: "show-desktop", children: h(i.departureTime).format(
|
|
53
53
|
c.FlightShortDate
|
|
54
54
|
) }),
|
|
55
|
-
/* @__PURE__ */
|
|
56
|
-
/* @__PURE__ */
|
|
55
|
+
/* @__PURE__ */ e("p", { className: "show-mobile", children: n.airportCode }),
|
|
56
|
+
/* @__PURE__ */ e("p", { className: "show-mobile", children: h(i.departureTime).format(c.FlightTime) })
|
|
57
57
|
] }),
|
|
58
|
-
/* @__PURE__ */
|
|
59
|
-
/* @__PURE__ */
|
|
60
|
-
/* @__PURE__ */
|
|
61
|
-
|
|
58
|
+
/* @__PURE__ */ r("div", { className: "flight-duration", children: [
|
|
59
|
+
/* @__PURE__ */ e("span", { className: "line" }),
|
|
60
|
+
/* @__PURE__ */ r("p", { children: [
|
|
61
|
+
q(f.slices[0].duration),
|
|
62
62
|
" ",
|
|
63
63
|
" - ",
|
|
64
64
|
i.numberOfStops > 0 ? `${i.numberOfStops} Stop${i.numberOfStops > 1 ? "s" : ""}` : "Direct"
|
|
65
65
|
] }),
|
|
66
|
-
/* @__PURE__ */
|
|
66
|
+
/* @__PURE__ */ e("span", { className: "line" })
|
|
67
67
|
] }),
|
|
68
|
-
/* @__PURE__ */
|
|
69
|
-
/* @__PURE__ */
|
|
68
|
+
/* @__PURE__ */ r("div", { children: [
|
|
69
|
+
/* @__PURE__ */ r("p", { className: "show-desktop", children: [
|
|
70
70
|
t.city,
|
|
71
71
|
", ",
|
|
72
|
-
|
|
72
|
+
O(t.country)
|
|
73
73
|
] }),
|
|
74
|
-
/* @__PURE__ */
|
|
74
|
+
/* @__PURE__ */ r("p", { className: "show-desktop", children: [
|
|
75
75
|
h(i.arrivalTime).format(
|
|
76
76
|
c.FlightShortDate
|
|
77
77
|
),
|
|
78
78
|
" "
|
|
79
79
|
] }),
|
|
80
|
-
/* @__PURE__ */
|
|
81
|
-
/* @__PURE__ */
|
|
80
|
+
/* @__PURE__ */ e("p", { className: "show-mobile", children: t.airportCode }),
|
|
81
|
+
/* @__PURE__ */ e("p", { className: "show-mobile", children: h(i.arrivalTime).format(c.FlightTime) })
|
|
82
82
|
] })
|
|
83
83
|
] }) }),
|
|
84
|
-
/* @__PURE__ */
|
|
85
|
-
/* @__PURE__ */
|
|
86
|
-
/* @__PURE__ */
|
|
84
|
+
/* @__PURE__ */ r("div", { className: "flight-footer", children: [
|
|
85
|
+
/* @__PURE__ */ r("div", { className: "flight-detail-container", children: [
|
|
86
|
+
/* @__PURE__ */ r(
|
|
87
87
|
"div",
|
|
88
88
|
{
|
|
89
89
|
className: "flight-detail",
|
|
90
90
|
onClick: (a) => {
|
|
91
|
-
a.stopPropagation(),
|
|
91
|
+
a.stopPropagation(), T(!d);
|
|
92
92
|
},
|
|
93
93
|
children: [
|
|
94
|
-
/* @__PURE__ */
|
|
95
|
-
/* @__PURE__ */
|
|
96
|
-
/* @__PURE__ */
|
|
97
|
-
/* @__PURE__ */
|
|
94
|
+
/* @__PURE__ */ e("p", { children: "Aircraft" }),
|
|
95
|
+
/* @__PURE__ */ r("p", { className: "chevron-text", children: [
|
|
96
|
+
/* @__PURE__ */ e(H, {}),
|
|
97
|
+
/* @__PURE__ */ r("span", { children: [
|
|
98
98
|
p[0],
|
|
99
|
-
p.length > 1 && /* @__PURE__ */
|
|
99
|
+
p.length > 1 && /* @__PURE__ */ r("sup", { children: [
|
|
100
100
|
"+",
|
|
101
101
|
p.length - 1
|
|
102
102
|
] })
|
|
@@ -105,13 +105,13 @@ const ii = ({ details: i, onClick: o }) => {
|
|
|
105
105
|
]
|
|
106
106
|
}
|
|
107
107
|
),
|
|
108
|
-
i.cabinClass && /* @__PURE__ */
|
|
109
|
-
/* @__PURE__ */
|
|
110
|
-
/* @__PURE__ */
|
|
108
|
+
i.cabinClass && /* @__PURE__ */ r("div", { className: "flight-detail", children: [
|
|
109
|
+
/* @__PURE__ */ e("p", { children: "Class" }),
|
|
110
|
+
/* @__PURE__ */ e("p", { children: i.cabinClass })
|
|
111
111
|
] })
|
|
112
112
|
] }),
|
|
113
|
-
/* @__PURE__ */
|
|
114
|
-
i.cash > 0 && /* @__PURE__ */
|
|
113
|
+
/* @__PURE__ */ r("div", { className: "booking-options", children: [
|
|
114
|
+
i.cash > 0 && /* @__PURE__ */ r(
|
|
115
115
|
"div",
|
|
116
116
|
{
|
|
117
117
|
className: "cash-value",
|
|
@@ -119,11 +119,11 @@ const ii = ({ details: i, onClick: o }) => {
|
|
|
119
119
|
a.stopPropagation(), o(i, m.CASH);
|
|
120
120
|
},
|
|
121
121
|
children: [
|
|
122
|
-
/* @__PURE__ */
|
|
123
|
-
/* @__PURE__ */
|
|
124
|
-
/* @__PURE__ */
|
|
125
|
-
/* @__PURE__ */
|
|
126
|
-
|
|
122
|
+
/* @__PURE__ */ e("img", { src: i.airlineLogo }),
|
|
123
|
+
/* @__PURE__ */ r("div", { children: [
|
|
124
|
+
/* @__PURE__ */ e("label", { children: k ? "Book For" : "From" }),
|
|
125
|
+
/* @__PURE__ */ e(
|
|
126
|
+
P,
|
|
127
127
|
{
|
|
128
128
|
amount: i.cash,
|
|
129
129
|
currency: i.currency
|
|
@@ -133,7 +133,7 @@ const ii = ({ details: i, onClick: o }) => {
|
|
|
133
133
|
]
|
|
134
134
|
}
|
|
135
135
|
),
|
|
136
|
-
i.points > 0 && /* @__PURE__ */
|
|
136
|
+
i.points > 0 && /* @__PURE__ */ r(
|
|
137
137
|
"div",
|
|
138
138
|
{
|
|
139
139
|
className: "points-value",
|
|
@@ -141,20 +141,20 @@ const ii = ({ details: i, onClick: o }) => {
|
|
|
141
141
|
a.stopPropagation(), o(i, m.POINTS);
|
|
142
142
|
},
|
|
143
143
|
children: [
|
|
144
|
-
/* @__PURE__ */
|
|
145
|
-
/* @__PURE__ */
|
|
146
|
-
/* @__PURE__ */
|
|
147
|
-
/* @__PURE__ */
|
|
148
|
-
`${
|
|
149
|
-
((u = i.cashFee) == null ? void 0 : u.amount) > 0 && /* @__PURE__ */
|
|
144
|
+
/* @__PURE__ */ e("img", { src: b.programLogo }),
|
|
145
|
+
/* @__PURE__ */ r("div", { children: [
|
|
146
|
+
/* @__PURE__ */ e("label", { children: A ? "Book For" : "From" }),
|
|
147
|
+
/* @__PURE__ */ r("p", { children: [
|
|
148
|
+
`${Q(i.points)} miles`,
|
|
149
|
+
((u = i.cashFee) == null ? void 0 : u.amount) > 0 && /* @__PURE__ */ r($, { children: [
|
|
150
150
|
" + ",
|
|
151
|
-
/* @__PURE__ */
|
|
152
|
-
|
|
151
|
+
/* @__PURE__ */ e(
|
|
152
|
+
P,
|
|
153
153
|
{
|
|
154
|
-
amount: i.cashFee.amount,
|
|
155
|
-
currency: i.cashFee.currency,
|
|
154
|
+
amount: (F = (v = i.paymentOptions[0]) == null ? void 0 : v.cashFee) == null ? void 0 : F.amount,
|
|
155
|
+
currency: (C = (y = i.paymentOptions[0]) == null ? void 0 : y.cashFee) == null ? void 0 : C.currency,
|
|
156
156
|
customDisplay: "No fee",
|
|
157
|
-
zeroDisplayOption:
|
|
157
|
+
zeroDisplayOption: J.CUSTOM
|
|
158
158
|
}
|
|
159
159
|
)
|
|
160
160
|
] })
|
|
@@ -165,17 +165,17 @@ const ii = ({ details: i, onClick: o }) => {
|
|
|
165
165
|
)
|
|
166
166
|
] })
|
|
167
167
|
] }),
|
|
168
|
-
/* @__PURE__ */
|
|
169
|
-
|
|
168
|
+
/* @__PURE__ */ e("div", { className: `flight-details ${d ? "is-open" : ""}`, children: /* @__PURE__ */ e("div", { className: "inner", children: /* @__PURE__ */ e(
|
|
169
|
+
U,
|
|
170
170
|
{
|
|
171
171
|
itinerary: f.slices[0].segments,
|
|
172
172
|
origin: n,
|
|
173
173
|
destination: t,
|
|
174
|
-
isMultiDayFlight:
|
|
174
|
+
isMultiDayFlight: R
|
|
175
175
|
}
|
|
176
176
|
) }) })
|
|
177
177
|
] }) });
|
|
178
178
|
};
|
|
179
179
|
export {
|
|
180
|
-
|
|
180
|
+
ni as FlightResult
|
|
181
181
|
};
|
|
@@ -23,8 +23,8 @@ function se(e) {
|
|
|
23
23
|
let a = 0;
|
|
24
24
|
for (; o < u; ) {
|
|
25
25
|
s && (n[o] === 10 && (a = ++o), s = !1);
|
|
26
|
-
let
|
|
27
|
-
for (; o < u &&
|
|
26
|
+
let d = -1;
|
|
27
|
+
for (; o < u && d === -1; ++o)
|
|
28
28
|
switch (n[o]) {
|
|
29
29
|
case 58:
|
|
30
30
|
r === -1 && (r = o - a);
|
|
@@ -32,12 +32,12 @@ function se(e) {
|
|
|
32
32
|
case 13:
|
|
33
33
|
s = !0;
|
|
34
34
|
case 10:
|
|
35
|
-
|
|
35
|
+
d = o;
|
|
36
36
|
break;
|
|
37
37
|
}
|
|
38
|
-
if (
|
|
38
|
+
if (d === -1)
|
|
39
39
|
break;
|
|
40
|
-
e(n.subarray(a,
|
|
40
|
+
e(n.subarray(a, d), r), a = o, r = -1;
|
|
41
41
|
}
|
|
42
42
|
a === u ? n = void 0 : a !== 0 && (n = n.subarray(a), o -= a);
|
|
43
43
|
};
|
|
@@ -49,21 +49,21 @@ function ae(e, n, o) {
|
|
|
49
49
|
if (c.length === 0)
|
|
50
50
|
o == null || o(r), r = Y();
|
|
51
51
|
else if (u > 0) {
|
|
52
|
-
const a = s.decode(c.subarray(0, u)),
|
|
52
|
+
const a = s.decode(c.subarray(0, u)), d = u + (c[u + 1] === 32 ? 2 : 1), g = s.decode(c.subarray(d));
|
|
53
53
|
switch (a) {
|
|
54
54
|
case "data":
|
|
55
55
|
r.data = r.data ? r.data + `
|
|
56
|
-
` +
|
|
56
|
+
` + g : g;
|
|
57
57
|
break;
|
|
58
58
|
case "event":
|
|
59
|
-
r.event =
|
|
59
|
+
r.event = g;
|
|
60
60
|
break;
|
|
61
61
|
case "id":
|
|
62
|
-
e(r.id =
|
|
62
|
+
e(r.id = g);
|
|
63
63
|
break;
|
|
64
64
|
case "retry":
|
|
65
|
-
const
|
|
66
|
-
isNaN(
|
|
65
|
+
const m = parseInt(g, 10);
|
|
66
|
+
isNaN(m) || n(r.retry = m);
|
|
67
67
|
break;
|
|
68
68
|
}
|
|
69
69
|
}
|
|
@@ -90,36 +90,36 @@ var ue = function(e, n) {
|
|
|
90
90
|
return o;
|
|
91
91
|
};
|
|
92
92
|
const G = "text/event-stream", ce = 1e3, W = "last-event-id";
|
|
93
|
-
function
|
|
94
|
-
var { signal: o, headers: r, onopen: s, onmessage: E, onclose: c, onerror: u, openWhenHidden: a, fetch:
|
|
95
|
-
return new Promise((
|
|
93
|
+
function le(e, n) {
|
|
94
|
+
var { signal: o, headers: r, onopen: s, onmessage: E, onclose: c, onerror: u, openWhenHidden: a, fetch: d } = n, g = ue(n, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
|
|
95
|
+
return new Promise((m, _) => {
|
|
96
96
|
const p = Object.assign({}, r);
|
|
97
97
|
p.accept || (p.accept = G);
|
|
98
|
-
let
|
|
98
|
+
let S;
|
|
99
99
|
function R() {
|
|
100
|
-
|
|
100
|
+
S.abort(), document.hidden || v();
|
|
101
101
|
}
|
|
102
102
|
a || document.addEventListener("visibilitychange", R);
|
|
103
103
|
let A = ce, I = 0;
|
|
104
104
|
function T() {
|
|
105
|
-
document.removeEventListener("visibilitychange", R), window.clearTimeout(I),
|
|
105
|
+
document.removeEventListener("visibilitychange", R), window.clearTimeout(I), S.abort();
|
|
106
106
|
}
|
|
107
107
|
o == null || o.addEventListener("abort", () => {
|
|
108
|
-
T(),
|
|
108
|
+
T(), m();
|
|
109
109
|
});
|
|
110
|
-
const P =
|
|
110
|
+
const P = d ?? window.fetch, q = s ?? de;
|
|
111
111
|
async function v() {
|
|
112
112
|
var w;
|
|
113
|
-
|
|
113
|
+
S = new AbortController();
|
|
114
114
|
try {
|
|
115
|
-
const C = await P(e, Object.assign(Object.assign({},
|
|
115
|
+
const C = await P(e, Object.assign(Object.assign({}, g), { headers: p, signal: S.signal }));
|
|
116
116
|
await q(C), await oe(C.body, se(ae((h) => {
|
|
117
117
|
h ? p[W] = h : delete p[W];
|
|
118
118
|
}, (h) => {
|
|
119
119
|
A = h;
|
|
120
|
-
}, E))), c == null || c(), T(),
|
|
120
|
+
}, E))), c == null || c(), T(), m();
|
|
121
121
|
} catch (C) {
|
|
122
|
-
if (!
|
|
122
|
+
if (!S.signal.aborted)
|
|
123
123
|
try {
|
|
124
124
|
const h = (w = u == null ? void 0 : u(C)) !== null && w !== void 0 ? w : A;
|
|
125
125
|
window.clearTimeout(I), I = window.setTimeout(v, h);
|
|
@@ -131,7 +131,7 @@ function de(e, n) {
|
|
|
131
131
|
v();
|
|
132
132
|
});
|
|
133
133
|
}
|
|
134
|
-
function
|
|
134
|
+
function de(e) {
|
|
135
135
|
const n = e.headers.get("content-type");
|
|
136
136
|
if (!(n != null && n.startsWith(G)))
|
|
137
137
|
throw new Error(`Expected content-type to be ${G}, Actual: ${n}`);
|
|
@@ -147,18 +147,18 @@ const fe = 3 * 60 * 1e3, V = (e) => {
|
|
|
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
|
-
inboundResults:
|
|
151
|
-
outboundResults:
|
|
152
|
-
setInboundResults:
|
|
150
|
+
inboundResults: d,
|
|
151
|
+
outboundResults: g,
|
|
152
|
+
setInboundResults: m,
|
|
153
153
|
setOutboundResults: _,
|
|
154
154
|
partialOfferRequestId: p,
|
|
155
|
-
setPartialOfferRequestId:
|
|
155
|
+
setPartialOfferRequestId: S
|
|
156
156
|
} = te(), R = ({
|
|
157
157
|
data: t,
|
|
158
158
|
inbound: f
|
|
159
159
|
}) => {
|
|
160
|
-
const
|
|
161
|
-
return (f ?
|
|
160
|
+
const l = Z(t);
|
|
161
|
+
return (f ? m : _)(Q(l)), l;
|
|
162
162
|
}, {
|
|
163
163
|
mutate: A,
|
|
164
164
|
status: I,
|
|
@@ -166,7 +166,7 @@ const fe = 3 * 60 * 1e3, V = (e) => {
|
|
|
166
166
|
} = k({
|
|
167
167
|
mutationFn: async (t) => {
|
|
168
168
|
V(t);
|
|
169
|
-
const
|
|
169
|
+
const l = {
|
|
170
170
|
passengers: Array.from(
|
|
171
171
|
{ length: t.passengers ?? z },
|
|
172
172
|
() => ({ type: "adult" })
|
|
@@ -177,7 +177,7 @@ const fe = 3 * 60 * 1e3, V = (e) => {
|
|
|
177
177
|
};
|
|
178
178
|
if (t.flightType === $.ONE_WAY) {
|
|
179
179
|
const i = await D.cashOnlySearch({
|
|
180
|
-
...
|
|
180
|
+
...l,
|
|
181
181
|
departure_date: t.departureDate
|
|
182
182
|
});
|
|
183
183
|
return {
|
|
@@ -186,7 +186,7 @@ const fe = 3 * 60 * 1e3, V = (e) => {
|
|
|
186
186
|
};
|
|
187
187
|
} else {
|
|
188
188
|
const i = await D.roundTripOutboundSearch({
|
|
189
|
-
...
|
|
189
|
+
...l,
|
|
190
190
|
departure_date: t.departureDate,
|
|
191
191
|
return_date: t.returnDate
|
|
192
192
|
});
|
|
@@ -198,12 +198,12 @@ const fe = 3 * 60 * 1e3, V = (e) => {
|
|
|
198
198
|
}
|
|
199
199
|
},
|
|
200
200
|
onSuccess: (t) => {
|
|
201
|
-
const { success: f, data:
|
|
201
|
+
const { success: f, data: l, partialOfferRequestId: i } = t;
|
|
202
202
|
if (!f) {
|
|
203
203
|
console.log("oh lol, it didn't work");
|
|
204
204
|
return;
|
|
205
205
|
}
|
|
206
|
-
R({ data:
|
|
206
|
+
R({ data: l }), i && S(i);
|
|
207
207
|
},
|
|
208
208
|
onError: (t) => {
|
|
209
209
|
console.error("Error in outbound flight search:", t);
|
|
@@ -225,9 +225,9 @@ const fe = 3 * 60 * 1e3, V = (e) => {
|
|
|
225
225
|
});
|
|
226
226
|
},
|
|
227
227
|
onSuccess: (t) => {
|
|
228
|
-
const { success: f, data:
|
|
228
|
+
const { success: f, data: l } = t;
|
|
229
229
|
f && R({
|
|
230
|
-
data:
|
|
230
|
+
data: l.offers,
|
|
231
231
|
inbound: !0
|
|
232
232
|
});
|
|
233
233
|
},
|
|
@@ -252,9 +252,9 @@ const fe = 3 * 60 * 1e3, V = (e) => {
|
|
|
252
252
|
});
|
|
253
253
|
},
|
|
254
254
|
onSuccess: (t) => {
|
|
255
|
-
const { success: f, data:
|
|
255
|
+
const { success: f, data: l } = t;
|
|
256
256
|
if (!f) return;
|
|
257
|
-
const i =
|
|
257
|
+
const i = l.offers;
|
|
258
258
|
E(B(i));
|
|
259
259
|
},
|
|
260
260
|
onError: (t) => {
|
|
@@ -266,7 +266,7 @@ const fe = 3 * 60 * 1e3, V = (e) => {
|
|
|
266
266
|
}), j = async (t) => {
|
|
267
267
|
var x;
|
|
268
268
|
u(!0);
|
|
269
|
-
const f = t.paymentType === F.CASH_AND_MILES ? ['"cash"', '"points"'] : ['"points"'],
|
|
269
|
+
const f = t.paymentType === F.CASH_AND_MILES ? ['"cash"', '"points"'] : ['"points"'], l = ee({
|
|
270
270
|
originCode: t.origin,
|
|
271
271
|
destinationCode: t.destination,
|
|
272
272
|
departureDate: t.departureDate,
|
|
@@ -276,8 +276,8 @@ const fe = 3 * 60 * 1e3, V = (e) => {
|
|
|
276
276
|
});
|
|
277
277
|
let i = [], M = 0;
|
|
278
278
|
U = new AbortController(), a.current = setTimeout(() => {
|
|
279
|
-
|
|
280
|
-
}, (((x = n == null ? void 0 : n.flightsConfig) == null ? void 0 : x.streamTimeoutTotalSeconds) || fe) * 1e3),
|
|
279
|
+
O();
|
|
280
|
+
}, (((x = n == null ? void 0 : n.flightsConfig) == null ? void 0 : x.streamTimeoutTotalSeconds) || fe) * 1e3), le(re() + l, {
|
|
281
281
|
headers: {
|
|
282
282
|
"Content-Type": "application/json",
|
|
283
283
|
Authorization: e || "",
|
|
@@ -287,29 +287,27 @@ const fe = 3 * 60 * 1e3, V = (e) => {
|
|
|
287
287
|
signal: U.signal,
|
|
288
288
|
onmessage(N) {
|
|
289
289
|
try {
|
|
290
|
-
const
|
|
291
|
-
if (
|
|
290
|
+
const b = B(JSON.parse(N.data));
|
|
291
|
+
if (b.success === !1)
|
|
292
292
|
return;
|
|
293
|
-
if (
|
|
294
|
-
|
|
293
|
+
if (b.close === !0) {
|
|
294
|
+
O();
|
|
295
295
|
return;
|
|
296
296
|
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
} catch (O) {
|
|
301
|
-
console.error("Error parsing message:", O), S();
|
|
297
|
+
b.status === 200 && b.flights && b.flights.length > 0 && (M = 0, i = [...i, ...b.flights], R({ data: i })), b.ping && (M++, M >= n.flightsConfig.streamTimeoutPingCount && O());
|
|
298
|
+
} catch (b) {
|
|
299
|
+
console.error("Error parsing message:", b), O();
|
|
302
300
|
}
|
|
303
301
|
},
|
|
304
302
|
onerror(N) {
|
|
305
|
-
throw console.error("EventSource error:", N),
|
|
303
|
+
throw console.error("EventSource error:", N), O(), N;
|
|
306
304
|
},
|
|
307
305
|
onclose() {
|
|
308
|
-
|
|
306
|
+
O();
|
|
309
307
|
},
|
|
310
308
|
keepalive: !1
|
|
311
309
|
});
|
|
312
|
-
},
|
|
310
|
+
}, O = () => {
|
|
313
311
|
U.abort(), a.current && (clearTimeout(a.current), a.current = null), u(!1), L.invalidateQueries({ queryKey: [y.SEARCH_LIMIT] });
|
|
314
312
|
};
|
|
315
313
|
return {
|
|
@@ -329,8 +327,8 @@ const fe = 3 * 60 * 1e3, V = (e) => {
|
|
|
329
327
|
inboundError: v,
|
|
330
328
|
roundTripFaresError: h,
|
|
331
329
|
// Results
|
|
332
|
-
outboundResults:
|
|
333
|
-
inboundResults:
|
|
330
|
+
outboundResults: g,
|
|
331
|
+
inboundResults: d,
|
|
334
332
|
roundTripFares: s,
|
|
335
333
|
// Mutation triggers
|
|
336
334
|
/**
|
|
@@ -340,7 +338,7 @@ const fe = 3 * 60 * 1e3, V = (e) => {
|
|
|
340
338
|
* @param {ISearchFlightArgs} args - The search arguments
|
|
341
339
|
*/
|
|
342
340
|
searchOutboundFlights: async (t) => {
|
|
343
|
-
switch (V(t), _([]),
|
|
341
|
+
switch (V(t), _([]), O(), t.paymentType) {
|
|
344
342
|
default:
|
|
345
343
|
case F.CASH_AND_MILES:
|
|
346
344
|
j(t);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@odynn/awayz-flights",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
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.3.
|
|
67
|
+
"@odynn/awayz-core": "^0.3.14",
|
|
68
68
|
"@tanstack/react-query": "^5.67.1",
|
|
69
69
|
"country-code-lookup": "^0.1.3"
|
|
70
70
|
}
|