@odynn/awayz-flights 0.9.6 → 0.9.8
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/BookingOption-V-FzaupW.js +196 -0
- package/dist/FlightItinerary-C4KPpVcF.js +94 -0
- package/dist/_commonjsHelpers-MdHo5S7N.js +26 -0
- package/dist/{arrayExtensions-DFLvtO8l.js → arrayExtensions-Ce8YopTP.js} +92 -113
- package/dist/assets/FlightItinerary.css +1 -1
- package/dist/assets/FlightItineraryDropdown.css +1 -1
- package/dist/assets/_styles.css +1 -1
- package/dist/assets/_styles2.css +1 -1
- package/dist/assets/_styles3.css +1 -0
- package/dist/assets/_styles4.css +1 -0
- package/dist/components/BookingOption/BookingOption.js +5 -6
- package/dist/components/Dialog/Dialog.js +20542 -0
- package/dist/components/FlightItinerary/FlightItinerary.js +5 -6
- package/dist/components/FlightItineraryDropdown/FlightItineraryDropdown.js +23 -29
- package/dist/components/FlightResult/FlightResult.js +318 -284
- package/dist/components/HorizontalScroller/HorizontalScroller.js +4 -4
- package/dist/components/MiniFlightItinerary/MiniFlightItinerary.js +90 -7
- package/dist/components/index.js +5 -5
- package/dist/constants/endpoints.js +1 -1
- package/dist/{dateUtils-CWDSSY2R.js → dateUtils-Cb9VQiIL.js} +1 -1
- package/dist/enums-tLvxh02p.js +4 -0
- package/dist/hooks/index.js +3 -3
- package/dist/hooks/useAirportSearch/useAirportSearch.js +1 -1
- package/dist/hooks/useFlightSearch/useFlightSearch.js +422 -12
- package/dist/{index-nOT-DH7g.js → index-9LVJi5JO.js} +12 -8
- package/dist/index-Kopwbl-x.js +19 -0
- package/dist/lib/components/Dialog/Dialog.d.ts +9 -0
- package/dist/lib/components/FlightItinerary/FlightItinerary.d.ts +1 -6
- package/dist/lib/components/FlightItineraryDropdown/FlightItineraryDropdown.d.ts +2 -4
- package/dist/lib/components/FlightResult/FlightResult.d.ts +1 -1
- package/dist/lib/constants/endpoints.d.ts +2 -1
- package/dist/lib/hooks/useFlightSearch/useFlightSearch.types.d.ts +3 -2
- package/dist/lib/services/flights/FlightsService.d.ts +1 -0
- package/dist/main.js +36 -35
- package/dist/services/flights/FlightsService.js +38 -29
- package/dist/services/wallet/WalletService.js +1 -1
- package/dist/utils/flightUtils.js +27 -28
- package/package.json +2 -1
- package/dist/BookingOption-Bf4d2RKS.js +0 -192
- package/dist/FlightItinerary-C2Jp2a9c.js +0 -262
- package/dist/MiniFlightItinerary-BEdrqoGh.js +0 -105
- package/dist/index-Gj4bRuCQ.js +0 -15
- package/dist/index-nI16-czT.js +0 -4
- package/dist/useFlightSearch-C0DEmnCL.js +0 -412
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsxs as L, jsx as o } from "react/jsx-runtime";
|
|
2
2
|
import { useRef as C, useState as n, useEffect as A } from "react";
|
|
3
|
-
import {
|
|
4
|
-
import '../../assets/
|
|
5
|
-
const
|
|
3
|
+
import { F as E, a as R } from "../../index-9LVJi5JO.js";
|
|
4
|
+
import '../../assets/_styles2.css';/* empty css */
|
|
5
|
+
const F = ({
|
|
6
6
|
children: i,
|
|
7
7
|
className: d = ""
|
|
8
8
|
}) => {
|
|
@@ -71,5 +71,5 @@ const N = ({
|
|
|
71
71
|
);
|
|
72
72
|
};
|
|
73
73
|
export {
|
|
74
|
-
|
|
74
|
+
F as default
|
|
75
75
|
};
|
|
@@ -1,9 +1,92 @@
|
|
|
1
|
-
import "react/jsx-runtime";
|
|
2
|
-
import "../../dateUtils-
|
|
3
|
-
import "../../arrayExtensions-
|
|
4
|
-
import "react";
|
|
5
|
-
import "../../index-
|
|
6
|
-
import {
|
|
1
|
+
import { jsxs as o, Fragment as b, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { c as v, b as f } from "../../dateUtils-Cb9VQiIL.js";
|
|
3
|
+
import "../../arrayExtensions-Ce8YopTP.js";
|
|
4
|
+
import { useMemo as y } from "react";
|
|
5
|
+
import { g as C, d as N } from "../../index-9LVJi5JO.js";
|
|
6
|
+
import { a as D, b as F, c as k } from "../../index-Kopwbl-x.js";
|
|
7
|
+
import '../../assets/MiniFlightItinerary.css';const I = ({
|
|
8
|
+
flightDetails: A
|
|
9
|
+
}) => {
|
|
10
|
+
const a = A.flightDetails.slices[0].segments, T = y(() => {
|
|
11
|
+
var t, l, n, s, p, h, g, u;
|
|
12
|
+
const i = [];
|
|
13
|
+
for (let m = 0; m < a.length; m++) {
|
|
14
|
+
const r = a[m], d = a[m + 1], L = v({
|
|
15
|
+
departureAt: r.departingAt,
|
|
16
|
+
departureTimeZone: r.origin.timeZone,
|
|
17
|
+
arrivalAt: r.arrivingAt,
|
|
18
|
+
arrivalTimeZone: r.destination.timeZone
|
|
19
|
+
});
|
|
20
|
+
if (i.push({
|
|
21
|
+
departure: {
|
|
22
|
+
code: (t = r.origin) == null ? void 0 : t.iataCode,
|
|
23
|
+
airport: (l = r.origin) == null ? void 0 : l.name
|
|
24
|
+
},
|
|
25
|
+
arrival: {
|
|
26
|
+
code: (n = r.destination) == null ? void 0 : n.iataCode,
|
|
27
|
+
airport: (s = r.destination) == null ? void 0 : s.name
|
|
28
|
+
},
|
|
29
|
+
time: L
|
|
30
|
+
}), !d)
|
|
31
|
+
break;
|
|
32
|
+
const Z = v({
|
|
33
|
+
departureAt: r.arrivingAt,
|
|
34
|
+
departureTimeZone: r.destination.timeZone,
|
|
35
|
+
arrivalAt: d.departingAt,
|
|
36
|
+
arrivalTimeZone: d.origin.timeZone
|
|
37
|
+
});
|
|
38
|
+
i.push({
|
|
39
|
+
departure: {
|
|
40
|
+
code: (p = r.destination) == null ? void 0 : p.iataCode,
|
|
41
|
+
airport: (h = r.destination) == null ? void 0 : h.name
|
|
42
|
+
},
|
|
43
|
+
arrival: {
|
|
44
|
+
code: (g = d.origin) == null ? void 0 : g.iataCode,
|
|
45
|
+
airport: (u = d.origin) == null ? void 0 : u.name
|
|
46
|
+
},
|
|
47
|
+
time: Z,
|
|
48
|
+
isLayover: !0
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return i;
|
|
52
|
+
}, [a]), c = y(() => {
|
|
53
|
+
var t, l;
|
|
54
|
+
const i = [];
|
|
55
|
+
for (let n = 0; n < a.length; n++) {
|
|
56
|
+
const s = a[n];
|
|
57
|
+
i.push(((t = s.origin) == null ? void 0 : t.iataCode) ?? "");
|
|
58
|
+
}
|
|
59
|
+
return i.push(((l = a.getLast().destination) == null ? void 0 : l.iataCode) ?? ""), i;
|
|
60
|
+
}, [a]);
|
|
61
|
+
return /* @__PURE__ */ o(b, { children: [
|
|
62
|
+
/* @__PURE__ */ e("div", { className: "mobile-mini-flight-itinerary", children: c.map((i, t) => /* @__PURE__ */ o("div", { children: [
|
|
63
|
+
/* @__PURE__ */ e("p", { children: i }),
|
|
64
|
+
t < c.length - 1 && /* @__PURE__ */ e(D, {})
|
|
65
|
+
] }, t)) }),
|
|
66
|
+
/* @__PURE__ */ e("div", { className: "mini-flight-itinerary", children: T.map(
|
|
67
|
+
(i, t) => i.isLayover ? /* @__PURE__ */ o("div", { className: "layover tip", children: [
|
|
68
|
+
/* @__PURE__ */ e(C, {}),
|
|
69
|
+
/* @__PURE__ */ e("p", { children: f(i.time) }),
|
|
70
|
+
/* @__PURE__ */ o("span", { className: "bottom", children: [
|
|
71
|
+
"Layover in ",
|
|
72
|
+
i.departure.code,
|
|
73
|
+
" (",
|
|
74
|
+
i.departure.airport,
|
|
75
|
+
")"
|
|
76
|
+
] })
|
|
77
|
+
] }) : /* @__PURE__ */ o("div", { className: "flight", children: [
|
|
78
|
+
/* @__PURE__ */ e(F, {}),
|
|
79
|
+
/* @__PURE__ */ e("p", { children: i.departure.code }),
|
|
80
|
+
/* @__PURE__ */ e("div", { className: "timeline", children: /* @__PURE__ */ o("div", { children: [
|
|
81
|
+
/* @__PURE__ */ e(N, {}),
|
|
82
|
+
/* @__PURE__ */ e("p", { children: f(i.time) })
|
|
83
|
+
] }) }),
|
|
84
|
+
/* @__PURE__ */ e(k, {}),
|
|
85
|
+
/* @__PURE__ */ e("p", { children: i.arrival.code })
|
|
86
|
+
] }, t)
|
|
87
|
+
) })
|
|
88
|
+
] });
|
|
89
|
+
};
|
|
7
90
|
export {
|
|
8
|
-
|
|
91
|
+
I as MiniFlightItinerary
|
|
9
92
|
};
|
package/dist/components/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { F as o } from "../FlightItinerary-
|
|
1
|
+
import { F as o } from "../FlightItinerary-C4KPpVcF.js";
|
|
2
2
|
import { FlightItineraryDropdown as e } from "./FlightItineraryDropdown/FlightItineraryDropdown.js";
|
|
3
|
-
import { FlightResult as
|
|
4
|
-
import {
|
|
3
|
+
import { FlightResult as n } from "./FlightResult/FlightResult.js";
|
|
4
|
+
import { MiniFlightItinerary as F } from "./MiniFlightItinerary/MiniFlightItinerary.js";
|
|
5
5
|
export {
|
|
6
6
|
o as FlightItinerary,
|
|
7
7
|
e as FlightItineraryDropdown,
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
n as FlightResult,
|
|
9
|
+
F as MiniFlightItinerary
|
|
10
10
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var s = /* @__PURE__ */ ((r) => (r.GET_AIRPORTS = "/flights/search/airports", r.CASH_FLIGHT_SEARCH = "/flights/search/multi/one-way/cash/", r.CASH_POINTS_FLIGHT_SEARCH = "/flights/search/multi/one-way/points-cash/", r.CASH_OUTBOUND_SEARCH = "/flights/search/multi/outbound", r.CASH_INBOUND_SEARCH = "/flights/search/multi/inbound", r.ROUND_TRIP_FARES = "/flights/search/multi/fares", r))(s || {}), a = /* @__PURE__ */ ((r) => (r.GET_AWARDS = "user/rewards", r.GET_USER_CARDS = "user/cards", r))(a || {});
|
|
1
|
+
var s = /* @__PURE__ */ ((r) => (r.GET_AIRPORTS = "/flights/search/airports", r.CASH_FLIGHT_SEARCH = "/flights/search/multi/one-way/cash/", r.CASH_POINTS_FLIGHT_SEARCH = "/flights/search/multi/one-way/points-cash/", r.CASH_OUTBOUND_SEARCH = "/flights/search/multi/outbound", r.CASH_INBOUND_SEARCH = "/flights/search/multi/inbound", r.ROUND_TRIP_FARES = "/flights/search/multi/fares", r.SUPPORTED_AIRLINE_PROGRAMS = "/flights/search/supported-airlines", r))(s || {}), a = /* @__PURE__ */ ((r) => (r.GET_AWARDS = "user/rewards", r.GET_USER_CARDS = "user/cards", r))(a || {});
|
|
2
2
|
export {
|
|
3
3
|
s as EFlightEndpoint,
|
|
4
4
|
a as EWalletEndpoints
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var S = /* @__PURE__ */ ((R) => (R.LOCATIONS = "LOCATIONS", R.CHECK_USER = "CHECK_USER", R.USER_REGIONS = "USER_REGIONS", R.CONVERT_CURRENCY = "CONVERT_CURRENCY", R.CLIENT_COMPONENT_KEY = "CLIENT_COMPONENT_KEY", R.SEARCH_LIMIT = "SEARCH_LIMIT", R.PROGRAMS = "PROGRAMS", R.USER_PROGRAMS = "USER_PROGRAMS", R.LINKED_USER_PROGRAMS = "LINKED_USER_PROGRAMS", R.BANKS = "BANKS", R.CARDS = "CARDS", R.USER_CARDS = "USER_CARDS", R.TRIPS = "TRIPS", R.UNCATEGORISED_BOOKINGS = "UNCATEGORISED_BOOKINGS", R.BOOKING = "BOOKING", R.VALUE_CENTS = "VALUE_CENTS", R.AVAILABILITY_ALERTS = "AVAILABILITY_ALERTS", R.ALERT_NOTIFICATIONS = "ALERT_NOTIFICATIONS", R.POINTS_AS_CASH = "POINTS_AS_CASH", R.GET_USER_REGION = "get_user_region", R.PRICING = "pricing", R.FAQS = "faqs", R.FEATURES = "features", R.AIRLINE_HEALTH = "airline_health", R.SUPPORTED_AIRLINE_PROGRAMS = "supported_airline_programs", R))(S || {});
|
|
2
|
+
export {
|
|
3
|
+
S as E
|
|
4
|
+
};
|
package/dist/hooks/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useAirportSearch as
|
|
1
|
+
import { useFlightSearch as o } from "./useFlightSearch/useFlightSearch.js";
|
|
2
|
+
import { useAirportSearch as a } from "./useAirportSearch/useAirportSearch.js";
|
|
3
3
|
import { EBaggage as p } from "./useFlightSearch/useFlightSearch.types.js";
|
|
4
4
|
export {
|
|
5
5
|
p as EBaggage,
|
|
6
|
-
|
|
6
|
+
a as useAirportSearch,
|
|
7
7
|
o as useFlightSearch
|
|
8
8
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useQuery as s } from "@tanstack/react-query";
|
|
2
2
|
import { FlightService as n } from "../../services/flights/FlightsService.js";
|
|
3
3
|
import "../../moment-BGjjqtLQ.js";
|
|
4
|
-
import "../../arrayExtensions-
|
|
4
|
+
import "../../arrayExtensions-Ce8YopTP.js";
|
|
5
5
|
import { useState as m, useEffect as a } from "react";
|
|
6
6
|
const c = 500, u = (t, r = c) => {
|
|
7
7
|
const [e, o] = m(t);
|
|
@@ -1,15 +1,425 @@
|
|
|
1
|
-
import "@odynn/awayz-core";
|
|
2
|
-
import "@tanstack/react-query";
|
|
1
|
+
import { useAwayzContext as te, awayzClient as q, getBaseUrl as ne } from "@odynn/awayz-core";
|
|
2
|
+
import { useQuery as re, useMutation as j } from "@tanstack/react-query";
|
|
3
3
|
import "../../moment-BGjjqtLQ.js";
|
|
4
|
-
import "../../arrayExtensions-
|
|
5
|
-
import "../../objectUtils-3IeCVocm.js";
|
|
6
|
-
import {
|
|
7
|
-
import "react";
|
|
8
|
-
import "../../services/flights/FlightsService.js";
|
|
9
|
-
import "../../stores/useFlightStore.js";
|
|
10
|
-
import "../../types/enums.js";
|
|
11
|
-
import "../../types/ECabinClass.js";
|
|
12
|
-
import "../../utils/flightUtils.js";
|
|
4
|
+
import "../../arrayExtensions-Ce8YopTP.js";
|
|
5
|
+
import { c as z } from "../../objectUtils-3IeCVocm.js";
|
|
6
|
+
import { E as A } from "../../enums-tLvxh02p.js";
|
|
7
|
+
import { useState as x, useRef as oe } from "react";
|
|
8
|
+
import { FlightService as P } from "../../services/flights/FlightsService.js";
|
|
9
|
+
import se from "../../stores/useFlightStore.js";
|
|
10
|
+
import { EFlightType as J, EFlightPaymentType as k } from "../../types/enums.js";
|
|
11
|
+
import { ECabinClass as ae } from "../../types/ECabinClass.js";
|
|
12
|
+
import { mapDataToFlightDetails as ie, groupFlightResults as ue, buildFlightSearchQuery as ce } from "../../utils/flightUtils.js";
|
|
13
|
+
async function le(o, t) {
|
|
14
|
+
const r = o.getReader();
|
|
15
|
+
let n;
|
|
16
|
+
for (; !(n = await r.read()).done; )
|
|
17
|
+
t(n.value);
|
|
18
|
+
}
|
|
19
|
+
function de(o) {
|
|
20
|
+
let t, r, n, s = !1;
|
|
21
|
+
return function(f) {
|
|
22
|
+
t === void 0 ? (t = f, r = 0, n = -1) : t = pe(t, f);
|
|
23
|
+
const d = t.length;
|
|
24
|
+
let u = 0;
|
|
25
|
+
for (; r < d; ) {
|
|
26
|
+
s && (t[r] === 10 && (u = ++r), s = !1);
|
|
27
|
+
let p = -1;
|
|
28
|
+
for (; r < d && p === -1; ++r)
|
|
29
|
+
switch (t[r]) {
|
|
30
|
+
case 58:
|
|
31
|
+
n === -1 && (n = r - u);
|
|
32
|
+
break;
|
|
33
|
+
case 13:
|
|
34
|
+
s = !0;
|
|
35
|
+
case 10:
|
|
36
|
+
p = r;
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
if (p === -1)
|
|
40
|
+
break;
|
|
41
|
+
o(t.subarray(u, p), n), u = r, n = -1;
|
|
42
|
+
}
|
|
43
|
+
u === d ? t = void 0 : u !== 0 && (t = t.subarray(u), r -= u);
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function fe(o, t, r) {
|
|
47
|
+
let n = B();
|
|
48
|
+
const s = new TextDecoder();
|
|
49
|
+
return function(f, d) {
|
|
50
|
+
if (f.length === 0)
|
|
51
|
+
r == null || r(n), n = B();
|
|
52
|
+
else if (d > 0) {
|
|
53
|
+
const u = s.decode(f.subarray(0, d)), p = d + (f[d + 1] === 32 ? 2 : 1), m = s.decode(f.subarray(p));
|
|
54
|
+
switch (u) {
|
|
55
|
+
case "data":
|
|
56
|
+
n.data = n.data ? n.data + `
|
|
57
|
+
` + m : m;
|
|
58
|
+
break;
|
|
59
|
+
case "event":
|
|
60
|
+
n.event = m;
|
|
61
|
+
break;
|
|
62
|
+
case "id":
|
|
63
|
+
o(n.id = m);
|
|
64
|
+
break;
|
|
65
|
+
case "retry":
|
|
66
|
+
const y = parseInt(m, 10);
|
|
67
|
+
isNaN(y) || t(n.retry = y);
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function pe(o, t) {
|
|
74
|
+
const r = new Uint8Array(o.length + t.length);
|
|
75
|
+
return r.set(o), r.set(t, o.length), r;
|
|
76
|
+
}
|
|
77
|
+
function B() {
|
|
78
|
+
return {
|
|
79
|
+
data: "",
|
|
80
|
+
event: "",
|
|
81
|
+
id: "",
|
|
82
|
+
retry: void 0
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
var he = function(o, t) {
|
|
86
|
+
var r = {};
|
|
87
|
+
for (var n in o) Object.prototype.hasOwnProperty.call(o, n) && t.indexOf(n) < 0 && (r[n] = o[n]);
|
|
88
|
+
if (o != null && typeof Object.getOwnPropertySymbols == "function")
|
|
89
|
+
for (var s = 0, n = Object.getOwnPropertySymbols(o); s < n.length; s++)
|
|
90
|
+
t.indexOf(n[s]) < 0 && Object.prototype.propertyIsEnumerable.call(o, n[s]) && (r[n[s]] = o[n[s]]);
|
|
91
|
+
return r;
|
|
92
|
+
};
|
|
93
|
+
const Q = "text/event-stream", ge = 1e3, Y = "last-event-id";
|
|
94
|
+
function me(o, t) {
|
|
95
|
+
var { signal: r, headers: n, onopen: s, onmessage: O, onclose: f, onerror: d, openWhenHidden: u, fetch: p } = t, m = he(t, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
|
|
96
|
+
return new Promise((y, T) => {
|
|
97
|
+
const h = Object.assign({}, n);
|
|
98
|
+
h.accept || (h.accept = Q);
|
|
99
|
+
let b;
|
|
100
|
+
function _() {
|
|
101
|
+
b.abort(), document.hidden || I();
|
|
102
|
+
}
|
|
103
|
+
u || document.addEventListener("visibilitychange", _);
|
|
104
|
+
let E = ge, R = 0;
|
|
105
|
+
function v() {
|
|
106
|
+
document.removeEventListener("visibilitychange", _), window.clearTimeout(R), b.abort();
|
|
107
|
+
}
|
|
108
|
+
r == null || r.addEventListener("abort", () => {
|
|
109
|
+
v(), y();
|
|
110
|
+
});
|
|
111
|
+
const N = p ?? window.fetch, H = s ?? ye;
|
|
112
|
+
async function I() {
|
|
113
|
+
var F;
|
|
114
|
+
b = new AbortController();
|
|
115
|
+
try {
|
|
116
|
+
const C = await N(o, Object.assign(Object.assign({}, m), { headers: h, signal: b.signal }));
|
|
117
|
+
await H(C), await le(C.body, de(fe((g) => {
|
|
118
|
+
g ? h[Y] = g : delete h[Y];
|
|
119
|
+
}, (g) => {
|
|
120
|
+
E = g;
|
|
121
|
+
}, O))), f == null || f(), v(), y();
|
|
122
|
+
} catch (C) {
|
|
123
|
+
if (!b.signal.aborted)
|
|
124
|
+
try {
|
|
125
|
+
const g = (F = d == null ? void 0 : d(C)) !== null && F !== void 0 ? F : E;
|
|
126
|
+
window.clearTimeout(R), R = window.setTimeout(I, g);
|
|
127
|
+
} catch (g) {
|
|
128
|
+
v(), T(g);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
I();
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
function ye(o) {
|
|
136
|
+
const t = o.headers.get("content-type");
|
|
137
|
+
if (!(t != null && t.startsWith(Q)))
|
|
138
|
+
throw new Error(`Expected content-type to be ${Q}, Actual: ${t}`);
|
|
139
|
+
}
|
|
140
|
+
const $ = 1, L = ae.ECONOMY;
|
|
141
|
+
let K = new AbortController();
|
|
142
|
+
const be = 3 * 60 * 1e3, G = (o) => {
|
|
143
|
+
if (!o.origin || !o.destination)
|
|
144
|
+
throw new Error("Origin and destination are required.");
|
|
145
|
+
if (!o.dates)
|
|
146
|
+
throw new Error("At least one date is required.");
|
|
147
|
+
if (o.flightType === J.ROUND_TRIP && o.dates.length != 2)
|
|
148
|
+
throw new Error(
|
|
149
|
+
"Two dates are required for round-trip flights: departure and return."
|
|
150
|
+
);
|
|
151
|
+
}, Le = () => {
|
|
152
|
+
const { token: o, config: t } = te(), [r, n] = x(""), [s, O] = x([]), [f, d] = x(!1), u = oe(null), {
|
|
153
|
+
inboundResults: p,
|
|
154
|
+
outboundResults: m,
|
|
155
|
+
setInboundResults: y,
|
|
156
|
+
setOutboundResults: T,
|
|
157
|
+
partialOfferRequestId: h,
|
|
158
|
+
setPartialOfferRequestId: b,
|
|
159
|
+
airlineStatuses: _,
|
|
160
|
+
setAirlineStatuses: E
|
|
161
|
+
} = se(), { data: R } = re({
|
|
162
|
+
queryKey: [A.SUPPORTED_AIRLINE_PROGRAMS],
|
|
163
|
+
queryFn: P.getSupportedAirlinePrograms,
|
|
164
|
+
initialData: []
|
|
165
|
+
}), v = ({
|
|
166
|
+
data: e,
|
|
167
|
+
inbound: c
|
|
168
|
+
}) => {
|
|
169
|
+
const i = ie(e);
|
|
170
|
+
return (c ? y : T)(ue(i)), i;
|
|
171
|
+
}, {
|
|
172
|
+
mutate: N,
|
|
173
|
+
status: H,
|
|
174
|
+
error: I
|
|
175
|
+
} = j({
|
|
176
|
+
mutationFn: async (e) => {
|
|
177
|
+
G(e);
|
|
178
|
+
const i = {
|
|
179
|
+
passengers: Array.from(
|
|
180
|
+
{ length: e.passengers ?? $ },
|
|
181
|
+
() => ({ type: "adult" })
|
|
182
|
+
),
|
|
183
|
+
origin: e.origin || "",
|
|
184
|
+
destination: e.destination || "",
|
|
185
|
+
cabin_class: e.cabinClass ?? L
|
|
186
|
+
};
|
|
187
|
+
if (e.flightType === J.ONE_WAY) {
|
|
188
|
+
const a = await P.cashOnlySearch({
|
|
189
|
+
...i,
|
|
190
|
+
departure_dates: e.dates
|
|
191
|
+
});
|
|
192
|
+
return {
|
|
193
|
+
success: a.success,
|
|
194
|
+
data: a.data
|
|
195
|
+
};
|
|
196
|
+
} else {
|
|
197
|
+
const a = await P.roundTripOutboundSearch({
|
|
198
|
+
...i,
|
|
199
|
+
departure_date: e.dates[0],
|
|
200
|
+
return_date: e.dates[1]
|
|
201
|
+
});
|
|
202
|
+
return {
|
|
203
|
+
success: a.success,
|
|
204
|
+
data: a.data.offers,
|
|
205
|
+
partialOfferRequestId: a.data.id
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
onSuccess: (e) => {
|
|
210
|
+
const { success: c, data: i, partialOfferRequestId: a } = e;
|
|
211
|
+
if (!c) {
|
|
212
|
+
console.log("oh lol, it didn't work");
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
v({ data: i }), a && b(a);
|
|
216
|
+
},
|
|
217
|
+
onError: (e) => {
|
|
218
|
+
console.error("Error in outbound flight search:", e);
|
|
219
|
+
},
|
|
220
|
+
onSettled: () => {
|
|
221
|
+
q.invalidateQueries({ queryKey: [A.SEARCH_LIMIT] });
|
|
222
|
+
}
|
|
223
|
+
}), {
|
|
224
|
+
mutate: F,
|
|
225
|
+
status: C,
|
|
226
|
+
error: g
|
|
227
|
+
} = j({
|
|
228
|
+
mutationFn: async ({
|
|
229
|
+
outboundOfferId: e,
|
|
230
|
+
cabinClass: c
|
|
231
|
+
}) => {
|
|
232
|
+
if (!h)
|
|
233
|
+
throw new Error("No partialOfferRequestId found for inbound search.");
|
|
234
|
+
return n(e), await P.roundTripInboundSearch({
|
|
235
|
+
outboundOfferId: e,
|
|
236
|
+
outboundOfferRequestId: h,
|
|
237
|
+
cabinClass: c || L
|
|
238
|
+
});
|
|
239
|
+
},
|
|
240
|
+
onSuccess: (e) => {
|
|
241
|
+
const { success: c, data: i } = e;
|
|
242
|
+
c && v({
|
|
243
|
+
data: i.offers,
|
|
244
|
+
inbound: !0
|
|
245
|
+
});
|
|
246
|
+
},
|
|
247
|
+
onError: (e) => {
|
|
248
|
+
console.error("Error in inbound flight search:", e);
|
|
249
|
+
},
|
|
250
|
+
onSettled: () => {
|
|
251
|
+
q.invalidateQueries({ queryKey: [A.SEARCH_LIMIT] });
|
|
252
|
+
}
|
|
253
|
+
}), {
|
|
254
|
+
mutate: V,
|
|
255
|
+
status: X,
|
|
256
|
+
error: Z
|
|
257
|
+
} = j({
|
|
258
|
+
mutationFn: async ({
|
|
259
|
+
inboundOfferId: e,
|
|
260
|
+
cabinClass: c
|
|
261
|
+
}) => {
|
|
262
|
+
if (!h)
|
|
263
|
+
throw new Error("No partialOfferRequestId found for round-trip fares.");
|
|
264
|
+
return await P.getRoundTripFares({
|
|
265
|
+
outboundOfferId: r,
|
|
266
|
+
outboundOfferRequestId: h,
|
|
267
|
+
inboundOfferId: e,
|
|
268
|
+
cabinClass: c || L
|
|
269
|
+
});
|
|
270
|
+
},
|
|
271
|
+
onSuccess: (e) => {
|
|
272
|
+
const { success: c, data: i } = e;
|
|
273
|
+
if (!c) return;
|
|
274
|
+
const a = i.offers;
|
|
275
|
+
O(z(a));
|
|
276
|
+
},
|
|
277
|
+
onError: (e) => {
|
|
278
|
+
console.error("Error in round-trip fare search:", e);
|
|
279
|
+
},
|
|
280
|
+
onSettled: () => {
|
|
281
|
+
q.invalidateQueries({ queryKey: [A.SEARCH_LIMIT] });
|
|
282
|
+
}
|
|
283
|
+
}), W = async (e) => {
|
|
284
|
+
var U;
|
|
285
|
+
E(() => ({
|
|
286
|
+
...R.reduce((S, l) => (S[l] = -1, S), {})
|
|
287
|
+
})), d(!0);
|
|
288
|
+
const c = e.paymentType === k.CASH_AND_MILES ? ['"cash"', '"points"'] : ['"points"'], i = ce({
|
|
289
|
+
originCode: e.origin,
|
|
290
|
+
destinationCode: e.destination,
|
|
291
|
+
dates: e.dates,
|
|
292
|
+
cabinClass: e.cabinClass ?? L,
|
|
293
|
+
passengerCount: e.passengers ?? $,
|
|
294
|
+
paymentType: c
|
|
295
|
+
});
|
|
296
|
+
let a = [], M = 0;
|
|
297
|
+
K = new AbortController(), u.current = setTimeout(
|
|
298
|
+
() => {
|
|
299
|
+
w();
|
|
300
|
+
},
|
|
301
|
+
(((U = t == null ? void 0 : t.flightsConfig) == null ? void 0 : U.streamTimeoutTotalSeconds) ?? be) * 1e3
|
|
302
|
+
), me(ne() + i, {
|
|
303
|
+
headers: {
|
|
304
|
+
"Content-Type": "application/json",
|
|
305
|
+
Authorization: o ?? "",
|
|
306
|
+
"client-id": (t == null ? void 0 : t.clientId) ?? ""
|
|
307
|
+
},
|
|
308
|
+
openWhenHidden: !0,
|
|
309
|
+
signal: K.signal,
|
|
310
|
+
onmessage(S) {
|
|
311
|
+
try {
|
|
312
|
+
const l = z(JSON.parse(S.data));
|
|
313
|
+
if (l.success === !1)
|
|
314
|
+
return;
|
|
315
|
+
if (l.close === !0) {
|
|
316
|
+
w();
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
if (l.airlineProgram && E((D) => ({
|
|
320
|
+
...D,
|
|
321
|
+
[l.airlineProgram]: l.status ?? l.statusCode ?? 300
|
|
322
|
+
})), l.status === 200 && l.flights && l.flights.length > 0) {
|
|
323
|
+
M = 0;
|
|
324
|
+
const D = l.flights.map((ee) => ({
|
|
325
|
+
...ee,
|
|
326
|
+
partners: l.partners ?? []
|
|
327
|
+
}));
|
|
328
|
+
a = [...a, ...D], v({ data: a });
|
|
329
|
+
}
|
|
330
|
+
l.ping && (M++, M >= t.flightsConfig.streamTimeoutPingCount && w());
|
|
331
|
+
} catch (l) {
|
|
332
|
+
console.error("Error parsing message:", l), w();
|
|
333
|
+
}
|
|
334
|
+
},
|
|
335
|
+
onerror(S) {
|
|
336
|
+
throw console.error("EventSource error:", S), w(), S;
|
|
337
|
+
},
|
|
338
|
+
onclose() {
|
|
339
|
+
w();
|
|
340
|
+
},
|
|
341
|
+
keepalive: !1
|
|
342
|
+
});
|
|
343
|
+
}, w = () => {
|
|
344
|
+
K.abort(), u.current && (clearTimeout(u.current), u.current = null), d(!1), q.invalidateQueries({ queryKey: [A.SEARCH_LIMIT] }), E((e) => {
|
|
345
|
+
const c = {};
|
|
346
|
+
for (const i in e) {
|
|
347
|
+
const a = e[i];
|
|
348
|
+
a !== -1 && (c[i] = a);
|
|
349
|
+
}
|
|
350
|
+
return c;
|
|
351
|
+
});
|
|
352
|
+
};
|
|
353
|
+
return {
|
|
354
|
+
/**
|
|
355
|
+
* Loading status for searching both outbound and inbound flights
|
|
356
|
+
* @type {boolean}
|
|
357
|
+
* @default false
|
|
358
|
+
*/
|
|
359
|
+
loading: H === "pending" || C === "pending" || f,
|
|
360
|
+
/**
|
|
361
|
+
* Loading status for fares
|
|
362
|
+
* @type {boolean}
|
|
363
|
+
* @default false
|
|
364
|
+
*/
|
|
365
|
+
loadingFares: X === "pending",
|
|
366
|
+
outboundError: I,
|
|
367
|
+
inboundError: g,
|
|
368
|
+
roundTripFaresError: Z,
|
|
369
|
+
// Results
|
|
370
|
+
outboundResults: m,
|
|
371
|
+
inboundResults: p,
|
|
372
|
+
roundTripFares: s,
|
|
373
|
+
// Mutation triggers
|
|
374
|
+
/**
|
|
375
|
+
* Used to search for outbound flights
|
|
376
|
+
* @type {function}
|
|
377
|
+
*
|
|
378
|
+
* @param {ISearchFlightArgs} args - The search arguments
|
|
379
|
+
*/
|
|
380
|
+
searchOutboundFlights: async (e) => {
|
|
381
|
+
switch (G(e), T([]), w(), e.paymentType) {
|
|
382
|
+
case k.CASH_AND_MILES:
|
|
383
|
+
W(e);
|
|
384
|
+
break;
|
|
385
|
+
case k.CASH:
|
|
386
|
+
N(e);
|
|
387
|
+
break;
|
|
388
|
+
case k.MILES:
|
|
389
|
+
W(e);
|
|
390
|
+
break;
|
|
391
|
+
}
|
|
392
|
+
},
|
|
393
|
+
/**
|
|
394
|
+
* Used to search for inbound flights after selecting an outbound flight
|
|
395
|
+
* @type {function}
|
|
396
|
+
*
|
|
397
|
+
* @param {{ outboundOfferId: string; cabinClass: ECabinClass }} args - The search arguments
|
|
398
|
+
*/
|
|
399
|
+
searchInboundFlights: F,
|
|
400
|
+
/**
|
|
401
|
+
* Used to get round-trip fares after selecting both outbound and inbound flights
|
|
402
|
+
* @type {function}
|
|
403
|
+
*
|
|
404
|
+
* @param {{ inboundOfferId: string; cabinClass: ECabinClass }} args - The fare search arguments
|
|
405
|
+
*/
|
|
406
|
+
getRoundTripFares: V,
|
|
407
|
+
/**
|
|
408
|
+
* Resets the flight search state, clearing all results and selections
|
|
409
|
+
* @type {function}
|
|
410
|
+
*
|
|
411
|
+
* @returns {void}
|
|
412
|
+
*/
|
|
413
|
+
reset: () => {
|
|
414
|
+
w(), T([]), y([]), O([]), b(""), n("");
|
|
415
|
+
},
|
|
416
|
+
/**
|
|
417
|
+
* Points search statuses of airlines during the flight search
|
|
418
|
+
* @type {IAirlineStatuses}
|
|
419
|
+
*/
|
|
420
|
+
airlineStatuses: _
|
|
421
|
+
};
|
|
422
|
+
};
|
|
13
423
|
export {
|
|
14
|
-
|
|
424
|
+
Le as useFlightSearch
|
|
15
425
|
};
|
|
@@ -33,19 +33,23 @@ function u(c) {
|
|
|
33
33
|
return t({ attr: { viewBox: "0 0 512 512" }, child: [{ tag: "path", attr: { d: "M176 56l0 40 160 0 0-40c0-4.4-3.6-8-8-8L184 48c-4.4 0-8 3.6-8 8zM128 96l0-40c0-30.9 25.1-56 56-56L328 0c30.9 0 56 25.1 56 56l0 40 0 32 0 352-256 0 0-352 0-32zM64 96l32 0 0 384-32 0c-35.3 0-64-28.7-64-64L0 160c0-35.3 28.7-64 64-64zM448 480l-32 0 0-384 32 0c35.3 0 64 28.7 64 64l0 256c0 35.3-28.7 64-64 64z" }, child: [] }] })(c);
|
|
34
34
|
}
|
|
35
35
|
function z(c) {
|
|
36
|
+
return t({ attr: { viewBox: "0 0 384 512" }, child: [{ tag: "path", attr: { d: "M376.6 84.5c11.3-13.6 9.5-33.8-4.1-45.1s-33.8-9.5-45.1 4.1L192 206 56.6 43.5C45.3 29.9 25.1 28.1 11.5 39.4S-3.9 70.9 7.4 84.5L150.3 256 7.4 427.5c-11.3 13.6-9.5 33.8 4.1 45.1s33.8 9.5 45.1-4.1L192 306 327.4 468.5c11.3 13.6 31.5 15.4 45.1 4.1s15.4-31.5 4.1-45.1L233.7 256 376.6 84.5z" }, child: [] }] })(c);
|
|
37
|
+
}
|
|
38
|
+
function M(c) {
|
|
36
39
|
return t({ attr: { viewBox: "0 0 512 512" }, child: [{ tag: "path", attr: { d: "M464 256A208 208 0 1 1 48 256a208 208 0 1 1 416 0zM0 256a256 256 0 1 0 512 0A256 256 0 1 0 0 256zM232 120l0 136c0 8 4 15.5 10.7 20l96 64c11 7.4 25.9 4.4 33.3-6.7s4.4-25.9-6.7-33.3L280 243.2 280 120c0-13.3-10.7-24-24-24s-24 10.7-24 24z" }, child: [] }] })(c);
|
|
37
40
|
}
|
|
38
41
|
export {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
i as F,
|
|
43
|
+
n as a,
|
|
44
|
+
M as b,
|
|
45
|
+
s as c,
|
|
46
|
+
L as d,
|
|
47
|
+
o as e,
|
|
48
|
+
e as f,
|
|
46
49
|
d as g,
|
|
47
50
|
u as h,
|
|
48
51
|
l as i,
|
|
49
52
|
h as j,
|
|
50
|
-
r as k
|
|
53
|
+
r as k,
|
|
54
|
+
z as l
|
|
51
55
|
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { G as r } from "./iconBase-DSKTHwal.js";
|
|
2
|
+
function n(t) {
|
|
3
|
+
return r({ attr: { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }, child: [{ tag: "path", attr: { d: "M5 12h14" }, child: [] }, { tag: "path", attr: { d: "m12 5 7 7-7 7" }, child: [] }] })(t);
|
|
4
|
+
}
|
|
5
|
+
function a(t) {
|
|
6
|
+
return r({ attr: { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }, child: [{ tag: "path", attr: { d: "m6 9 6 6 6-6" }, child: [] }] })(t);
|
|
7
|
+
}
|
|
8
|
+
function e(t) {
|
|
9
|
+
return r({ attr: { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }, child: [{ tag: "path", attr: { d: "M2 22h20" }, child: [] }, { tag: "path", attr: { d: "M3.77 10.77 2 9l2-4.5 1.1.55c.55.28.9.84.9 1.45s.35 1.17.9 1.45L8 8.5l3-6 1.05.53a2 2 0 0 1 1.09 1.52l.72 5.4a2 2 0 0 0 1.09 1.52l4.4 2.2c.42.22.78.55 1.01.96l.6 1.03c.49.88-.06 1.98-1.06 2.1l-1.18.15c-.47.06-.95-.02-1.37-.24L4.29 11.15a2 2 0 0 1-.52-.38Z" }, child: [] }] })(t);
|
|
10
|
+
}
|
|
11
|
+
function i(t) {
|
|
12
|
+
return r({ attr: { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }, child: [{ tag: "path", attr: { d: "M2 22h20" }, child: [] }, { tag: "path", attr: { d: "M6.36 17.4 4 17l-2-4 1.1-.55a2 2 0 0 1 1.8 0l.17.1a2 2 0 0 0 1.8 0L8 12 5 6l.9-.45a2 2 0 0 1 2.09.2l4.02 3a2 2 0 0 0 2.1.2l4.19-2.06a2.41 2.41 0 0 1 1.73-.17L21 7a1.4 1.4 0 0 1 .87 1.99l-.38.76c-.23.46-.6.84-1.07 1.08L7.58 17.2a2 2 0 0 1-1.22.18Z" }, child: [] }] })(t);
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
a as L,
|
|
16
|
+
n as a,
|
|
17
|
+
i as b,
|
|
18
|
+
e as c
|
|
19
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as RDialog from '@radix-ui/react-dialog';
|
|
2
|
+
interface IModalProps {
|
|
3
|
+
title: string;
|
|
4
|
+
trigger: React.ReactNode;
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
}
|
|
7
|
+
declare const Dialog: ({ trigger, children, title }: IModalProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare const DialogClose: import('react').ForwardRefExoticComponent<RDialog.DialogCloseProps & import('react').RefAttributes<HTMLButtonElement>>;
|
|
9
|
+
export default Dialog;
|