@odynn/awayz-flights 0.2.0 → 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.
- package/dist/components/FlightResult/FlightResult.js +46 -46
- package/dist/hooks/useFlightSearch/useFlightSearch.js +123 -130
- package/dist/lib/hooks/useFlightSearch/useFlightSearch.types.d.ts +2 -0
- package/dist/objectUtils-CyIaVmog.js +10 -0
- package/dist/services/flights/FlightsService.js +15 -16
- package/dist/services/wallet/WalletService.js +5 -6
- package/dist/utils/flightUtils.js +199 -163
- package/package.json +1 -1
- package/dist/AccountService-BjwUydb_-DRFWL3cC.js +0 -4840
|
@@ -1,48 +1,42 @@
|
|
|
1
1
|
import { jsx as r, jsxs as e } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import { g as f, E as N, F as I, a as
|
|
4
|
-
import { DEFAULT_AIRLINE_PROGRAM as
|
|
2
|
+
import k, { useState as d, useMemo as E } from "react";
|
|
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 ? l.format(Math.round(i)).toString().split(".")[0] : l.format(0);
|
|
20
|
-
}, z = ({ details: i, onClick: n }) => {
|
|
21
|
-
const [l, D] = d(!1), o = i.origin, c = i.destination, g = i.flightDetails, S = i.paymentOptions.length === 1, [y, 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
21
|
A.segments.forEach((s) => {
|
|
28
|
-
const p =
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
logo:
|
|
33
|
-
airline:
|
|
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
|
] }) });
|
|
@@ -1,85 +1,77 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useState as N, useRef as K } from "react";
|
|
2
2
|
import { useMutation as L } from "@tanstack/react-query";
|
|
3
|
-
import { ECabinClass as
|
|
3
|
+
import { ECabinClass as Q, EFlightType as J, EFlightPaymentType as k } from "../../types/enums.js";
|
|
4
4
|
import { FlightService as D } from "../../services/flights/FlightsService.js";
|
|
5
|
-
import { parseFlightDetails as
|
|
5
|
+
import { parseFlightDetails as V, groupFlightResults as G, buildFlightSearchQuery as X } from "../../utils/flightUtils.js";
|
|
6
6
|
import "../../arrayExtensions-DWKenJCh.js";
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import "
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
);
|
|
16
|
-
return n;
|
|
17
|
-
};
|
|
18
|
-
async function re(n, t) {
|
|
19
|
-
const o = n.getReader();
|
|
20
|
-
let r;
|
|
21
|
-
for (; !(r = await o.read()).done; )
|
|
22
|
-
t(r.value);
|
|
7
|
+
import { c as W } from "../../objectUtils-CyIaVmog.js";
|
|
8
|
+
import Z from "../../stores/useFlightStore.js";
|
|
9
|
+
import { useAwayzContext as ee, getBaseUrl as te } from "@odynn/awayz-core";
|
|
10
|
+
async function ne(o, t) {
|
|
11
|
+
const r = o.getReader();
|
|
12
|
+
let n;
|
|
13
|
+
for (; !(n = await r.read()).done; )
|
|
14
|
+
t(n.value);
|
|
23
15
|
}
|
|
24
|
-
function
|
|
25
|
-
let t,
|
|
16
|
+
function re(o) {
|
|
17
|
+
let t, r, n, s = !1;
|
|
26
18
|
return function(c) {
|
|
27
|
-
t === void 0 ? (t = c,
|
|
19
|
+
t === void 0 ? (t = c, r = 0, n = -1) : t = se(t, c);
|
|
28
20
|
const u = t.length;
|
|
29
21
|
let a = 0;
|
|
30
|
-
for (;
|
|
31
|
-
s && (t[
|
|
22
|
+
for (; r < u; ) {
|
|
23
|
+
s && (t[r] === 10 && (a = ++r), s = !1);
|
|
32
24
|
let d = -1;
|
|
33
|
-
for (;
|
|
34
|
-
switch (t[
|
|
25
|
+
for (; r < u && d === -1; ++r)
|
|
26
|
+
switch (t[r]) {
|
|
35
27
|
case 58:
|
|
36
|
-
|
|
28
|
+
n === -1 && (n = r - a);
|
|
37
29
|
break;
|
|
38
30
|
case 13:
|
|
39
31
|
s = !0;
|
|
40
32
|
case 10:
|
|
41
|
-
d =
|
|
33
|
+
d = r;
|
|
42
34
|
break;
|
|
43
35
|
}
|
|
44
36
|
if (d === -1)
|
|
45
37
|
break;
|
|
46
|
-
|
|
38
|
+
o(t.subarray(a, d), n), a = r, n = -1;
|
|
47
39
|
}
|
|
48
|
-
a === u ? t = void 0 : a !== 0 && (t = t.subarray(a),
|
|
40
|
+
a === u ? t = void 0 : a !== 0 && (t = t.subarray(a), r -= a);
|
|
49
41
|
};
|
|
50
42
|
}
|
|
51
|
-
function
|
|
52
|
-
let
|
|
43
|
+
function oe(o, t, r) {
|
|
44
|
+
let n = U();
|
|
53
45
|
const s = new TextDecoder();
|
|
54
46
|
return function(c, u) {
|
|
55
47
|
if (c.length === 0)
|
|
56
|
-
|
|
48
|
+
r == null || r(n), n = U();
|
|
57
49
|
else if (u > 0) {
|
|
58
|
-
const a = s.decode(c.subarray(0, u)), d = u + (c[u + 1] === 32 ? 2 : 1),
|
|
50
|
+
const a = s.decode(c.subarray(0, u)), d = u + (c[u + 1] === 32 ? 2 : 1), g = s.decode(c.subarray(d));
|
|
59
51
|
switch (a) {
|
|
60
52
|
case "data":
|
|
61
|
-
|
|
62
|
-
` +
|
|
53
|
+
n.data = n.data ? n.data + `
|
|
54
|
+
` + g : g;
|
|
63
55
|
break;
|
|
64
56
|
case "event":
|
|
65
|
-
|
|
57
|
+
n.event = g;
|
|
66
58
|
break;
|
|
67
59
|
case "id":
|
|
68
|
-
n
|
|
60
|
+
o(n.id = g);
|
|
69
61
|
break;
|
|
70
62
|
case "retry":
|
|
71
|
-
const
|
|
72
|
-
isNaN(
|
|
63
|
+
const b = parseInt(g, 10);
|
|
64
|
+
isNaN(b) || t(n.retry = b);
|
|
73
65
|
break;
|
|
74
66
|
}
|
|
75
67
|
}
|
|
76
68
|
};
|
|
77
69
|
}
|
|
78
|
-
function
|
|
79
|
-
const
|
|
80
|
-
return
|
|
70
|
+
function se(o, t) {
|
|
71
|
+
const r = new Uint8Array(o.length + t.length);
|
|
72
|
+
return r.set(o), r.set(t, o.length), r;
|
|
81
73
|
}
|
|
82
|
-
function
|
|
74
|
+
function U() {
|
|
83
75
|
return {
|
|
84
76
|
data: "",
|
|
85
77
|
event: "",
|
|
@@ -87,100 +79,102 @@ function M() {
|
|
|
87
79
|
retry: void 0
|
|
88
80
|
};
|
|
89
81
|
}
|
|
90
|
-
var
|
|
91
|
-
var
|
|
92
|
-
for (var
|
|
93
|
-
if (
|
|
94
|
-
for (var s = 0,
|
|
95
|
-
t.indexOf(
|
|
96
|
-
return
|
|
82
|
+
var ae = function(o, t) {
|
|
83
|
+
var r = {};
|
|
84
|
+
for (var n in o) Object.prototype.hasOwnProperty.call(o, n) && t.indexOf(n) < 0 && (r[n] = o[n]);
|
|
85
|
+
if (o != null && typeof Object.getOwnPropertySymbols == "function")
|
|
86
|
+
for (var s = 0, n = Object.getOwnPropertySymbols(o); s < n.length; s++)
|
|
87
|
+
t.indexOf(n[s]) < 0 && Object.prototype.propertyIsEnumerable.call(o, n[s]) && (r[n[s]] = o[n[s]]);
|
|
88
|
+
return r;
|
|
97
89
|
};
|
|
98
|
-
const
|
|
99
|
-
function
|
|
100
|
-
var { signal:
|
|
101
|
-
return new Promise((
|
|
102
|
-
const p = Object.assign({},
|
|
103
|
-
p.accept || (p.accept =
|
|
90
|
+
const x = "text/event-stream", ie = 1e3, z = "last-event-id";
|
|
91
|
+
function ue(o, t) {
|
|
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((b, _) => {
|
|
94
|
+
const p = Object.assign({}, n);
|
|
95
|
+
p.accept || (p.accept = x);
|
|
104
96
|
let m;
|
|
105
97
|
function w() {
|
|
106
|
-
m.abort(), document.hidden ||
|
|
98
|
+
m.abort(), document.hidden || T();
|
|
107
99
|
}
|
|
108
100
|
a || document.addEventListener("visibilitychange", w);
|
|
109
|
-
let F =
|
|
110
|
-
function
|
|
111
|
-
document.removeEventListener("visibilitychange", w), window.clearTimeout(
|
|
101
|
+
let F = ie, E = 0;
|
|
102
|
+
function S() {
|
|
103
|
+
document.removeEventListener("visibilitychange", w), window.clearTimeout(E), m.abort();
|
|
112
104
|
}
|
|
113
|
-
|
|
114
|
-
|
|
105
|
+
r == null || r.addEventListener("abort", () => {
|
|
106
|
+
S(), b();
|
|
115
107
|
});
|
|
116
|
-
const
|
|
117
|
-
async function
|
|
118
|
-
var
|
|
108
|
+
const q = d ?? window.fetch, P = s ?? ce;
|
|
109
|
+
async function T() {
|
|
110
|
+
var C;
|
|
119
111
|
m = new AbortController();
|
|
120
112
|
try {
|
|
121
|
-
const O = await
|
|
122
|
-
await
|
|
113
|
+
const O = await q(o, Object.assign(Object.assign({}, g), { headers: p, signal: m.signal }));
|
|
114
|
+
await P(O), await ne(O.body, re(oe((h) => {
|
|
123
115
|
h ? p[z] = h : delete p[z];
|
|
124
116
|
}, (h) => {
|
|
125
117
|
F = h;
|
|
126
|
-
},
|
|
118
|
+
}, v))), c == null || c(), S(), b();
|
|
127
119
|
} catch (O) {
|
|
128
120
|
if (!m.signal.aborted)
|
|
129
121
|
try {
|
|
130
|
-
const h = (
|
|
131
|
-
window.clearTimeout(
|
|
122
|
+
const h = (C = u == null ? void 0 : u(O)) !== null && C !== void 0 ? C : F;
|
|
123
|
+
window.clearTimeout(E), E = window.setTimeout(T, h);
|
|
132
124
|
} catch (h) {
|
|
133
|
-
|
|
125
|
+
S(), _(h);
|
|
134
126
|
}
|
|
135
127
|
}
|
|
136
128
|
}
|
|
137
|
-
|
|
129
|
+
T();
|
|
138
130
|
});
|
|
139
131
|
}
|
|
140
|
-
function
|
|
141
|
-
const t =
|
|
142
|
-
if (!(t != null && t.startsWith(
|
|
143
|
-
throw new Error(`Expected content-type to be ${
|
|
132
|
+
function ce(o) {
|
|
133
|
+
const t = o.headers.get("content-type");
|
|
134
|
+
if (!(t != null && t.startsWith(x)))
|
|
135
|
+
throw new Error(`Expected content-type to be ${x}, Actual: ${t}`);
|
|
144
136
|
}
|
|
145
|
-
const
|
|
146
|
-
|
|
137
|
+
const B = 1, Y = Q.ECONOMY;
|
|
138
|
+
let j = new AbortController();
|
|
139
|
+
const de = 3 * 60 * 1e3, $ = (o) => {
|
|
140
|
+
if (!o.origin || !o.destination)
|
|
147
141
|
throw new Error("Origin and destination are required.");
|
|
148
|
-
if (!
|
|
142
|
+
if (!o.departureDate)
|
|
149
143
|
throw new Error("Departure date is required.");
|
|
150
|
-
if (
|
|
144
|
+
if (o.flightType === J.ROUND_TRIP && !o.returnDate)
|
|
151
145
|
throw new Error("Return date is required for round-trip flights.");
|
|
152
|
-
},
|
|
153
|
-
const { token:
|
|
146
|
+
}, Ee = () => {
|
|
147
|
+
const { token: o, config: t } = ee(), [r, n] = N(""), [s, v] = N([]), [c, u] = N(!1), a = K(null), {
|
|
154
148
|
inboundResults: d,
|
|
155
|
-
outboundResults:
|
|
156
|
-
setInboundResults:
|
|
157
|
-
setOutboundResults:
|
|
149
|
+
outboundResults: g,
|
|
150
|
+
setInboundResults: b,
|
|
151
|
+
setOutboundResults: _,
|
|
158
152
|
partialOfferRequestId: p,
|
|
159
153
|
setPartialOfferRequestId: m
|
|
160
|
-
} =
|
|
154
|
+
} = Z(), w = ({
|
|
161
155
|
data: e,
|
|
162
156
|
previousResults: l,
|
|
163
157
|
inbound: f
|
|
164
158
|
}) => {
|
|
165
|
-
const i =
|
|
166
|
-
return (f ?
|
|
159
|
+
const i = V(e, l);
|
|
160
|
+
return (f ? b : _)(G(i)), i;
|
|
167
161
|
}, {
|
|
168
162
|
mutate: F,
|
|
169
|
-
status:
|
|
170
|
-
error:
|
|
163
|
+
status: E,
|
|
164
|
+
error: S
|
|
171
165
|
} = L({
|
|
172
166
|
mutationFn: async (e) => {
|
|
173
|
-
|
|
167
|
+
$(e);
|
|
174
168
|
const f = {
|
|
175
169
|
passengers: Array.from(
|
|
176
|
-
{ length: e.passengers ??
|
|
170
|
+
{ length: e.passengers ?? B },
|
|
177
171
|
() => ({ type: "adult" })
|
|
178
172
|
),
|
|
179
173
|
origin: e.origin || "",
|
|
180
174
|
destination: e.destination || "",
|
|
181
|
-
cabin_class: e.cabinClass ||
|
|
175
|
+
cabin_class: e.cabinClass || Y
|
|
182
176
|
};
|
|
183
|
-
if (e.flightType ===
|
|
177
|
+
if (e.flightType === J.ONE_WAY) {
|
|
184
178
|
const i = await D.cashOnlySearch({
|
|
185
179
|
...f,
|
|
186
180
|
departure_date: e.departureDate
|
|
@@ -215,14 +209,14 @@ const W = 1, U = K.ECONOMY, V = new AbortController(), le = 3 * 60 * 1e3, Y = (n
|
|
|
215
209
|
console.error("Error in outbound flight search:", e);
|
|
216
210
|
}
|
|
217
211
|
}), {
|
|
218
|
-
mutate:
|
|
219
|
-
status:
|
|
220
|
-
error:
|
|
212
|
+
mutate: q,
|
|
213
|
+
status: P,
|
|
214
|
+
error: T
|
|
221
215
|
} = L({
|
|
222
216
|
mutationFn: async (e) => {
|
|
223
217
|
if (!p)
|
|
224
218
|
throw new Error("No partialOfferRequestId found for inbound search.");
|
|
225
|
-
return
|
|
219
|
+
return n(e), await D.roundTripInboundSearch({
|
|
226
220
|
outboundOfferId: e,
|
|
227
221
|
outboundOfferRequestId: p
|
|
228
222
|
});
|
|
@@ -238,7 +232,7 @@ const W = 1, U = K.ECONOMY, V = new AbortController(), le = 3 * 60 * 1e3, Y = (n
|
|
|
238
232
|
console.error("Error in inbound flight search:", e);
|
|
239
233
|
}
|
|
240
234
|
}), {
|
|
241
|
-
mutate:
|
|
235
|
+
mutate: C,
|
|
242
236
|
status: O,
|
|
243
237
|
error: h
|
|
244
238
|
} = L({
|
|
@@ -246,7 +240,7 @@ const W = 1, U = K.ECONOMY, V = new AbortController(), le = 3 * 60 * 1e3, Y = (n
|
|
|
246
240
|
if (!p)
|
|
247
241
|
throw new Error("No partialOfferRequestId found for round-trip fares.");
|
|
248
242
|
return await D.getRoundTripFares({
|
|
249
|
-
outboundOfferId:
|
|
243
|
+
outboundOfferId: r,
|
|
250
244
|
outboundOfferRequestId: p,
|
|
251
245
|
inboundOfferId: e
|
|
252
246
|
});
|
|
@@ -255,61 +249,60 @@ const W = 1, U = K.ECONOMY, V = new AbortController(), le = 3 * 60 * 1e3, Y = (n
|
|
|
255
249
|
const { success: l, data: f } = e;
|
|
256
250
|
if (!l) return;
|
|
257
251
|
const i = f.offers;
|
|
258
|
-
|
|
252
|
+
v(W(i));
|
|
259
253
|
},
|
|
260
254
|
onError: (e) => {
|
|
261
255
|
console.error("Error in round-trip fare search:", e);
|
|
262
256
|
}
|
|
263
|
-
}),
|
|
257
|
+
}), H = async (e) => {
|
|
258
|
+
var M;
|
|
264
259
|
u(!0);
|
|
265
260
|
const l = e.paymentType === k.CASH_AND_MILES ? ['"cash"', '"points"'] : ['"points"'], f = X({
|
|
266
261
|
originCode: e.origin,
|
|
267
262
|
destinationCode: e.destination,
|
|
268
263
|
departureDate: e.departureDate,
|
|
269
|
-
cabinClass: e.cabinClass ||
|
|
270
|
-
passengerCount: e.passengers ||
|
|
264
|
+
cabinClass: e.cabinClass || Y,
|
|
265
|
+
passengerCount: e.passengers || B,
|
|
271
266
|
paymentType: l
|
|
272
267
|
});
|
|
273
268
|
let i = [], I = 0;
|
|
274
|
-
a.current = setTimeout(() => {
|
|
275
|
-
|
|
276
|
-
},
|
|
269
|
+
j = new AbortController(), a.current = setTimeout(() => {
|
|
270
|
+
R();
|
|
271
|
+
}, (((M = t == null ? void 0 : t.flightsConfig) == null ? void 0 : M.streamTimeoutTotalSeconds) || de) * 1e3), ue(te() + f, {
|
|
277
272
|
headers: {
|
|
278
273
|
"Content-Type": "application/json",
|
|
279
|
-
Authorization:
|
|
274
|
+
Authorization: o || "",
|
|
280
275
|
"client-id": (t == null ? void 0 : t.clientId) || ""
|
|
281
276
|
},
|
|
282
277
|
openWhenHidden: !0,
|
|
283
|
-
signal:
|
|
278
|
+
signal: j.signal,
|
|
284
279
|
onmessage(A) {
|
|
285
280
|
try {
|
|
286
|
-
const y =
|
|
287
|
-
if (y.success === !1)
|
|
288
|
-
v();
|
|
281
|
+
const y = W(JSON.parse(A.data));
|
|
282
|
+
if (y.success === !1)
|
|
289
283
|
return;
|
|
290
|
-
}
|
|
291
284
|
if (y.close === !0) {
|
|
292
|
-
|
|
285
|
+
R();
|
|
293
286
|
return;
|
|
294
287
|
}
|
|
295
288
|
y.flights && (I = 0, i = w({
|
|
296
289
|
data: y.flights,
|
|
297
290
|
previousResults: i
|
|
298
|
-
})), y.ping && (I++, I >= t.flightsConfig.streamTimeoutPingCount &&
|
|
291
|
+
})), y.ping && (I++, I >= t.flightsConfig.streamTimeoutPingCount && R());
|
|
299
292
|
} catch (y) {
|
|
300
|
-
console.error("Error parsing message:", y),
|
|
293
|
+
console.error("Error parsing message:", y), R();
|
|
301
294
|
}
|
|
302
295
|
},
|
|
303
296
|
onerror(A) {
|
|
304
|
-
throw console.error("EventSource error:", A),
|
|
297
|
+
throw console.error("EventSource error:", A), R(), A;
|
|
305
298
|
},
|
|
306
299
|
onclose() {
|
|
307
300
|
u(!1);
|
|
308
301
|
},
|
|
309
302
|
keepalive: !1
|
|
310
303
|
});
|
|
311
|
-
},
|
|
312
|
-
|
|
304
|
+
}, R = () => {
|
|
305
|
+
j.abort(), a.current && (clearTimeout(a.current), a.current = null), u(!1);
|
|
313
306
|
};
|
|
314
307
|
return {
|
|
315
308
|
/**
|
|
@@ -317,18 +310,18 @@ const W = 1, U = K.ECONOMY, V = new AbortController(), le = 3 * 60 * 1e3, Y = (n
|
|
|
317
310
|
* @type {boolean}
|
|
318
311
|
* @default false
|
|
319
312
|
*/
|
|
320
|
-
loading:
|
|
313
|
+
loading: E === "pending" || P === "pending" || c,
|
|
321
314
|
/**
|
|
322
315
|
* Loading status for fares
|
|
323
316
|
* @type {boolean}
|
|
324
317
|
* @default false
|
|
325
318
|
*/
|
|
326
319
|
loadingFares: O === "pending",
|
|
327
|
-
outboundError:
|
|
328
|
-
inboundError:
|
|
320
|
+
outboundError: S,
|
|
321
|
+
inboundError: T,
|
|
329
322
|
roundTripFaresError: h,
|
|
330
323
|
// Results
|
|
331
|
-
outboundResults:
|
|
324
|
+
outboundResults: g,
|
|
332
325
|
inboundResults: d,
|
|
333
326
|
roundTripFares: s,
|
|
334
327
|
// Mutation triggers
|
|
@@ -339,16 +332,16 @@ const W = 1, U = K.ECONOMY, V = new AbortController(), le = 3 * 60 * 1e3, Y = (n
|
|
|
339
332
|
* @param {ISearchFlightArgs} args - The search arguments
|
|
340
333
|
*/
|
|
341
334
|
searchOutboundFlights: async (e) => {
|
|
342
|
-
switch (
|
|
335
|
+
switch ($(e), e.paymentType) {
|
|
343
336
|
default:
|
|
344
337
|
case k.CASH_AND_MILES:
|
|
345
|
-
|
|
338
|
+
H(e);
|
|
346
339
|
break;
|
|
347
340
|
case k.CASH:
|
|
348
341
|
F(e);
|
|
349
342
|
break;
|
|
350
343
|
case k.MILES:
|
|
351
|
-
|
|
344
|
+
H(e);
|
|
352
345
|
break;
|
|
353
346
|
}
|
|
354
347
|
},
|
|
@@ -358,16 +351,16 @@ const W = 1, U = K.ECONOMY, V = new AbortController(), le = 3 * 60 * 1e3, Y = (n
|
|
|
358
351
|
*
|
|
359
352
|
* @param {string} outboundOfferId - The ID of the outbound offer
|
|
360
353
|
*/
|
|
361
|
-
searchInboundFlights:
|
|
354
|
+
searchInboundFlights: q,
|
|
362
355
|
/**
|
|
363
356
|
* Used to get round-trip fares after selecting both outbound and inbound flights
|
|
364
357
|
* @type {function}
|
|
365
358
|
*
|
|
366
359
|
* @param {string} inboundOfferId - The ID of the inbound offer
|
|
367
360
|
*/
|
|
368
|
-
getRoundTripFares:
|
|
361
|
+
getRoundTripFares: C
|
|
369
362
|
};
|
|
370
363
|
};
|
|
371
364
|
export {
|
|
372
|
-
|
|
365
|
+
Ee as useFlightSearch
|
|
373
366
|
};
|
|
@@ -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;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
function c(e) {
|
|
2
|
+
return e = e.replace(/^_+/, ""), e.replace(/_([a-z])/g, (r, a) => a.toUpperCase());
|
|
3
|
+
}
|
|
4
|
+
const t = (e) => Array.isArray(e) ? e.map((r) => t(r)) : typeof e == "object" && e !== null ? Object.keys(e).reduce((r, a) => {
|
|
5
|
+
const n = c(a);
|
|
6
|
+
return r[n] = t(e[a]), r;
|
|
7
|
+
}, {}) : e;
|
|
8
|
+
export {
|
|
9
|
+
t as c
|
|
10
|
+
};
|