@odynn/awayz-flights 0.3.9 → 0.4.0
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/{FlightItinerary-B_uX-d7I.js → FlightItinerary-VggJiPkC.js} +1 -1
- package/dist/FlightResult-DLe2iE7E.js +188 -0
- package/dist/components/FlightItinerary/FlightItinerary.js +2 -2
- package/dist/components/FlightResult/FlightResult.js +11 -184
- package/dist/components/index.js +1 -1
- package/dist/hooks/index.js +4 -2
- package/dist/hooks/useFlightSearch/useFlightSearch.js +68 -68
- package/dist/{index-D0Heof44.js → index-7zRjF0bU.js} +4 -4
- package/dist/lib/hooks/index.d.ts +2 -1
- package/dist/lib/main.d.ts +3 -2
- package/dist/lib/utils/flightUtils.d.ts +1 -1
- package/dist/main.js +35 -22
- package/dist/utils/flightUtils.js +98 -96
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsxs as a, jsx as c, Fragment as E } from "react/jsx-runtime";
|
|
2
2
|
import h, { useMemo as q } from "react";
|
|
3
3
|
import { h as P } from "./moment-BGjjqtLQ.js";
|
|
4
|
-
import {
|
|
4
|
+
import { c as $, a as z, b as k, D as J } from "./index-7zRjF0bU.js";
|
|
5
5
|
import { l as Q } from "./arrayExtensions-DFLvtO8l.js";
|
|
6
6
|
import './assets/FlightItinerary.css';const X = (e) => e ? e.charAt(0).toUpperCase() + e.slice(1).toLowerCase() : "", S = (e) => {
|
|
7
7
|
var t;
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { jsx as e, jsxs as a, Fragment as H } from "react/jsx-runtime";
|
|
2
|
+
import U, { useState as T, useMemo as _ } from "react";
|
|
3
|
+
import { g as k, E as c, F as z, a as G } from "./FlightItinerary-VggJiPkC.js";
|
|
4
|
+
import { DEFAULT_AIRLINE_PROGRAM as V, getFlightNumber as q, getLogoPath as J, getAirlineProgram as K } from "./utils/flightUtils.js";
|
|
5
|
+
import { h } from "./moment-BGjjqtLQ.js";
|
|
6
|
+
import { g as Q } from "./index-7zRjF0bU.js";
|
|
7
|
+
import "./arrayExtensions-DFLvtO8l.js";
|
|
8
|
+
import { EPaymentType as m } from "./enums/EPaymentType.js";
|
|
9
|
+
import { CashValue as A, EInvalidAmountDisplayOption as W } from "@odynn/awayz-core";
|
|
10
|
+
import { isSameDayFlight as X } from "./utils/flightDateUtils.js";
|
|
11
|
+
import './assets/FlightResult.css';function Y(i) {
|
|
12
|
+
if (!i || isNaN(i) || i < 0) return "N/A";
|
|
13
|
+
let o = i == null ? void 0 : i.toString().split(".")[0];
|
|
14
|
+
return o == null ? void 0 : o.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
15
|
+
}
|
|
16
|
+
const ci = ({ details: i, onClick: o }) => {
|
|
17
|
+
var u, v, F, y, C, D, S, O;
|
|
18
|
+
const [d, b] = T(!1), n = i.origin, t = i.destination, f = i.flightDetails, N = i.paymentOptions || [], w = N.filter((r) => r.points === -1).length === 1, E = N.filter((r) => r.points > -1).length === 1, [I, L] = T(V), R = async () => {
|
|
19
|
+
const r = await K(i.airlineProgram);
|
|
20
|
+
L(r);
|
|
21
|
+
}, { flightNumbers: p, airlines: B } = _(() => {
|
|
22
|
+
const r = [], s = [];
|
|
23
|
+
return i.flightDetails.slices.forEach((x) => {
|
|
24
|
+
x.segments.forEach((l) => {
|
|
25
|
+
const P = q(l);
|
|
26
|
+
r.includes(P) || r.push(P);
|
|
27
|
+
const g = l.operatingCarrierFlightNumber ? l.operatingCarrier : l.marketingCarrier;
|
|
28
|
+
s.some((j) => j.airline === g.name) || s.push({
|
|
29
|
+
logo: J(g.iataCode),
|
|
30
|
+
airline: g.name
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
}), R(), { flightNumbers: r, airlines: s };
|
|
34
|
+
}, [i.flightDetails.slices]), M = () => {
|
|
35
|
+
i.cash > 0 ? o(i, m.CASH) : o(i, m.POINTS);
|
|
36
|
+
}, $ = !X(
|
|
37
|
+
i.departureTime,
|
|
38
|
+
i.arrivalTime
|
|
39
|
+
);
|
|
40
|
+
return /* @__PURE__ */ e("div", { className: "flight-result", onClick: M, children: /* @__PURE__ */ a("div", { className: "content", children: [
|
|
41
|
+
/* @__PURE__ */ e("div", { className: "flight-info", children: /* @__PURE__ */ a("div", { className: "flight-locations", children: [
|
|
42
|
+
/* @__PURE__ */ e("div", { className: "airlines", children: B.map((r, s) => /* @__PURE__ */ e(U.Fragment, { children: /* @__PURE__ */ a("div", { className: "tip", children: [
|
|
43
|
+
/* @__PURE__ */ e("img", { src: r.logo, alt: r.airline }),
|
|
44
|
+
/* @__PURE__ */ e("span", { className: "right", children: r.airline })
|
|
45
|
+
] }, s) }, s)) }),
|
|
46
|
+
/* @__PURE__ */ a("div", { className: "flight-location", children: [
|
|
47
|
+
/* @__PURE__ */ a("p", { className: "show-desktop", children: [
|
|
48
|
+
n.city,
|
|
49
|
+
",",
|
|
50
|
+
k(n.country)
|
|
51
|
+
] }),
|
|
52
|
+
/* @__PURE__ */ e("p", { className: "show-desktop", children: h(i.departureTime).format(
|
|
53
|
+
c.FlightShortDate
|
|
54
|
+
) }),
|
|
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
|
+
] }),
|
|
58
|
+
/* @__PURE__ */ a("div", { className: "flight-duration", children: [
|
|
59
|
+
/* @__PURE__ */ e("span", { className: "line" }),
|
|
60
|
+
/* @__PURE__ */ a("p", { children: [
|
|
61
|
+
Q(f.slices[0].duration),
|
|
62
|
+
" ",
|
|
63
|
+
" - ",
|
|
64
|
+
i.numberOfStops > 0 ? `${i.numberOfStops} Stop${i.numberOfStops > 1 ? "s" : ""}` : "Direct"
|
|
65
|
+
] }),
|
|
66
|
+
/* @__PURE__ */ e("span", { className: "line" })
|
|
67
|
+
] }),
|
|
68
|
+
/* @__PURE__ */ a("div", { children: [
|
|
69
|
+
/* @__PURE__ */ a("p", { className: "show-desktop", children: [
|
|
70
|
+
t.city,
|
|
71
|
+
", ",
|
|
72
|
+
k(t.country)
|
|
73
|
+
] }),
|
|
74
|
+
/* @__PURE__ */ a("p", { className: "show-desktop", children: [
|
|
75
|
+
h(i.arrivalTime).format(
|
|
76
|
+
c.FlightShortDate
|
|
77
|
+
),
|
|
78
|
+
" "
|
|
79
|
+
] }),
|
|
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
|
+
] })
|
|
83
|
+
] }) }),
|
|
84
|
+
/* @__PURE__ */ a("div", { className: "flight-footer", children: [
|
|
85
|
+
/* @__PURE__ */ a("div", { className: "flight-detail-container", children: [
|
|
86
|
+
/* @__PURE__ */ a(
|
|
87
|
+
"div",
|
|
88
|
+
{
|
|
89
|
+
className: "flight-detail",
|
|
90
|
+
onClick: (r) => {
|
|
91
|
+
r.stopPropagation(), b(!d);
|
|
92
|
+
},
|
|
93
|
+
children: [
|
|
94
|
+
/* @__PURE__ */ e("p", { children: "Aircraft" }),
|
|
95
|
+
/* @__PURE__ */ a("p", { className: "chevron-text", children: [
|
|
96
|
+
/* @__PURE__ */ e(z, {}),
|
|
97
|
+
/* @__PURE__ */ a("span", { children: [
|
|
98
|
+
p[0],
|
|
99
|
+
p.length > 1 && /* @__PURE__ */ a("sup", { children: [
|
|
100
|
+
"+",
|
|
101
|
+
p.length - 1
|
|
102
|
+
] })
|
|
103
|
+
] })
|
|
104
|
+
] })
|
|
105
|
+
]
|
|
106
|
+
}
|
|
107
|
+
),
|
|
108
|
+
i.cabinClass && /* @__PURE__ */ a("div", { className: "flight-detail", children: [
|
|
109
|
+
/* @__PURE__ */ e("p", { children: "Class" }),
|
|
110
|
+
/* @__PURE__ */ e("p", { children: i.cabinClass })
|
|
111
|
+
] })
|
|
112
|
+
] }),
|
|
113
|
+
/* @__PURE__ */ a("div", { className: "booking-options", children: [
|
|
114
|
+
i.cash > 0 && /* @__PURE__ */ a(
|
|
115
|
+
"div",
|
|
116
|
+
{
|
|
117
|
+
className: "cash-value",
|
|
118
|
+
onClick: (r) => {
|
|
119
|
+
r.stopPropagation(), o(i, m.CASH);
|
|
120
|
+
},
|
|
121
|
+
children: [
|
|
122
|
+
/* @__PURE__ */ e("img", { src: i.airlineLogo }),
|
|
123
|
+
/* @__PURE__ */ a("div", { children: [
|
|
124
|
+
/* @__PURE__ */ e("label", { children: w ? "Book For" : "From" }),
|
|
125
|
+
/* @__PURE__ */ e(
|
|
126
|
+
A,
|
|
127
|
+
{
|
|
128
|
+
amount: i.cash,
|
|
129
|
+
currency: i.currency
|
|
130
|
+
}
|
|
131
|
+
)
|
|
132
|
+
] })
|
|
133
|
+
]
|
|
134
|
+
}
|
|
135
|
+
),
|
|
136
|
+
i.points > 0 && /* @__PURE__ */ a(
|
|
137
|
+
"div",
|
|
138
|
+
{
|
|
139
|
+
className: "points-value",
|
|
140
|
+
onClick: (r) => {
|
|
141
|
+
r.stopPropagation(), o(i, m.POINTS);
|
|
142
|
+
},
|
|
143
|
+
children: [
|
|
144
|
+
/* @__PURE__ */ e("img", { src: I.programLogo }),
|
|
145
|
+
/* @__PURE__ */ a("div", { children: [
|
|
146
|
+
/* @__PURE__ */ e("label", { children: E ? "Book For" : "From" }),
|
|
147
|
+
/* @__PURE__ */ a("p", { children: [
|
|
148
|
+
`${Y(i.points)} miles`,
|
|
149
|
+
((u = i.cashFee) == null ? void 0 : u.amount) > 0 || (((y = (F = (v = i.paymentOptions) == null ? void 0 : v.find(
|
|
150
|
+
(r) => r.points > -1
|
|
151
|
+
)) == null ? void 0 : F.cashFee) == null ? void 0 : y.amount) ?? 0) > 0 && /* @__PURE__ */ a(H, { children: [
|
|
152
|
+
" + ",
|
|
153
|
+
/* @__PURE__ */ e(
|
|
154
|
+
A,
|
|
155
|
+
{
|
|
156
|
+
amount: ((D = (C = i.paymentOptions.find(
|
|
157
|
+
(r) => r.points > -1
|
|
158
|
+
)) == null ? void 0 : C.cashFee) == null ? void 0 : D.amount) ?? 0,
|
|
159
|
+
currency: ((O = (S = i.paymentOptions.find(
|
|
160
|
+
(r) => r.points > -1
|
|
161
|
+
)) == null ? void 0 : S.cashFee) == null ? void 0 : O.currency) ?? "",
|
|
162
|
+
customDisplay: "No fee",
|
|
163
|
+
zeroDisplayOption: W.CUSTOM
|
|
164
|
+
}
|
|
165
|
+
)
|
|
166
|
+
] })
|
|
167
|
+
] })
|
|
168
|
+
] })
|
|
169
|
+
]
|
|
170
|
+
}
|
|
171
|
+
)
|
|
172
|
+
] })
|
|
173
|
+
] }),
|
|
174
|
+
/* @__PURE__ */ e("div", { className: `flight-details ${d ? "is-open" : ""}`, children: /* @__PURE__ */ e("div", { className: "inner", children: /* @__PURE__ */ e(
|
|
175
|
+
G,
|
|
176
|
+
{
|
|
177
|
+
itinerary: f.slices[0].segments,
|
|
178
|
+
origin: n,
|
|
179
|
+
destination: t,
|
|
180
|
+
isMultiDayFlight: $
|
|
181
|
+
}
|
|
182
|
+
) }) })
|
|
183
|
+
] }) });
|
|
184
|
+
};
|
|
185
|
+
export {
|
|
186
|
+
ci as F,
|
|
187
|
+
Y as c
|
|
188
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "react/jsx-runtime";
|
|
2
2
|
import "react";
|
|
3
3
|
import "../../moment-BGjjqtLQ.js";
|
|
4
|
-
import { a as e } from "../../FlightItinerary-
|
|
5
|
-
import "../../index-
|
|
4
|
+
import { a as e } from "../../FlightItinerary-VggJiPkC.js";
|
|
5
|
+
import "../../index-7zRjF0bU.js";
|
|
6
6
|
import "../../arrayExtensions-DFLvtO8l.js";
|
|
7
7
|
export {
|
|
8
8
|
e as default
|
|
@@ -1,187 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
1
|
+
import "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import { F as g } from "../../FlightResult-DLe2iE7E.js";
|
|
4
|
+
import "../../FlightItinerary-VggJiPkC.js";
|
|
5
|
+
import "../../utils/flightUtils.js";
|
|
6
|
+
import "../../moment-BGjjqtLQ.js";
|
|
7
|
+
import "../../index-7zRjF0bU.js";
|
|
7
8
|
import "../../arrayExtensions-DFLvtO8l.js";
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import '../../assets/FlightResult.css';function Y(i) {
|
|
12
|
-
if (!i || isNaN(i) || i < 0) return "N/A";
|
|
13
|
-
let o = i == null ? void 0 : i.toString().split(".")[0];
|
|
14
|
-
return o == null ? void 0 : o.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
15
|
-
}
|
|
16
|
-
const ci = ({ details: i, onClick: o }) => {
|
|
17
|
-
var u, v, F, y, C, D, S, O;
|
|
18
|
-
const [d, b] = T(!1), s = i.origin, t = i.destination, f = i.flightDetails, N = i.paymentOptions || [], w = N.filter((r) => r.points === -1).length === 1, E = N.filter((r) => r.points > -1).length === 1, [I, L] = T(V), R = async () => {
|
|
19
|
-
const r = await K(i.airlineProgram);
|
|
20
|
-
L(r);
|
|
21
|
-
}, { flightNumbers: p, airlines: B } = _(() => {
|
|
22
|
-
const r = [], n = [];
|
|
23
|
-
return i.flightDetails.slices.forEach((x) => {
|
|
24
|
-
x.segments.forEach((l) => {
|
|
25
|
-
const P = q(l);
|
|
26
|
-
r.includes(P) || r.push(P);
|
|
27
|
-
const g = l.operatingCarrierFlightNumber ? l.operatingCarrier : l.marketingCarrier;
|
|
28
|
-
n.some((j) => j.airline === g.name) || n.push({
|
|
29
|
-
logo: J(g.iataCode),
|
|
30
|
-
airline: g.name
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
}), R(), { flightNumbers: r, airlines: n };
|
|
34
|
-
}, [i.flightDetails.slices]), M = () => {
|
|
35
|
-
i.cash > 0 ? o(i, m.CASH) : o(i, m.POINTS);
|
|
36
|
-
}, $ = !X(
|
|
37
|
-
i.departureTime,
|
|
38
|
-
i.arrivalTime
|
|
39
|
-
);
|
|
40
|
-
return /* @__PURE__ */ e("div", { className: "flight-result", onClick: M, children: /* @__PURE__ */ a("div", { className: "content", children: [
|
|
41
|
-
/* @__PURE__ */ e("div", { className: "flight-info", children: /* @__PURE__ */ a("div", { className: "flight-locations", children: [
|
|
42
|
-
/* @__PURE__ */ e("div", { className: "airlines", children: B.map((r, n) => /* @__PURE__ */ e(U.Fragment, { children: /* @__PURE__ */ a("div", { className: "tip", children: [
|
|
43
|
-
/* @__PURE__ */ e("img", { src: r.logo, alt: r.airline }),
|
|
44
|
-
/* @__PURE__ */ e("span", { className: "right", children: r.airline })
|
|
45
|
-
] }, n) }, n)) }),
|
|
46
|
-
/* @__PURE__ */ a("div", { className: "flight-location", children: [
|
|
47
|
-
/* @__PURE__ */ a("p", { className: "show-desktop", children: [
|
|
48
|
-
s.city,
|
|
49
|
-
",",
|
|
50
|
-
k(s.country)
|
|
51
|
-
] }),
|
|
52
|
-
/* @__PURE__ */ e("p", { className: "show-desktop", children: h(i.departureTime).format(
|
|
53
|
-
c.FlightShortDate
|
|
54
|
-
) }),
|
|
55
|
-
/* @__PURE__ */ e("p", { className: "show-mobile", children: s.airportCode }),
|
|
56
|
-
/* @__PURE__ */ e("p", { className: "show-mobile", children: h(i.departureTime).format(c.FlightTime) })
|
|
57
|
-
] }),
|
|
58
|
-
/* @__PURE__ */ a("div", { className: "flight-duration", children: [
|
|
59
|
-
/* @__PURE__ */ e("span", { className: "line" }),
|
|
60
|
-
/* @__PURE__ */ a("p", { children: [
|
|
61
|
-
Q(f.slices[0].duration),
|
|
62
|
-
" ",
|
|
63
|
-
" - ",
|
|
64
|
-
i.numberOfStops > 0 ? `${i.numberOfStops} Stop${i.numberOfStops > 1 ? "s" : ""}` : "Direct"
|
|
65
|
-
] }),
|
|
66
|
-
/* @__PURE__ */ e("span", { className: "line" })
|
|
67
|
-
] }),
|
|
68
|
-
/* @__PURE__ */ a("div", { children: [
|
|
69
|
-
/* @__PURE__ */ a("p", { className: "show-desktop", children: [
|
|
70
|
-
t.city,
|
|
71
|
-
", ",
|
|
72
|
-
k(t.country)
|
|
73
|
-
] }),
|
|
74
|
-
/* @__PURE__ */ a("p", { className: "show-desktop", children: [
|
|
75
|
-
h(i.arrivalTime).format(
|
|
76
|
-
c.FlightShortDate
|
|
77
|
-
),
|
|
78
|
-
" "
|
|
79
|
-
] }),
|
|
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
|
-
] })
|
|
83
|
-
] }) }),
|
|
84
|
-
/* @__PURE__ */ a("div", { className: "flight-footer", children: [
|
|
85
|
-
/* @__PURE__ */ a("div", { className: "flight-detail-container", children: [
|
|
86
|
-
/* @__PURE__ */ a(
|
|
87
|
-
"div",
|
|
88
|
-
{
|
|
89
|
-
className: "flight-detail",
|
|
90
|
-
onClick: (r) => {
|
|
91
|
-
r.stopPropagation(), b(!d);
|
|
92
|
-
},
|
|
93
|
-
children: [
|
|
94
|
-
/* @__PURE__ */ e("p", { children: "Aircraft" }),
|
|
95
|
-
/* @__PURE__ */ a("p", { className: "chevron-text", children: [
|
|
96
|
-
/* @__PURE__ */ e(z, {}),
|
|
97
|
-
/* @__PURE__ */ a("span", { children: [
|
|
98
|
-
p[0],
|
|
99
|
-
p.length > 1 && /* @__PURE__ */ a("sup", { children: [
|
|
100
|
-
"+",
|
|
101
|
-
p.length - 1
|
|
102
|
-
] })
|
|
103
|
-
] })
|
|
104
|
-
] })
|
|
105
|
-
]
|
|
106
|
-
}
|
|
107
|
-
),
|
|
108
|
-
i.cabinClass && /* @__PURE__ */ a("div", { className: "flight-detail", children: [
|
|
109
|
-
/* @__PURE__ */ e("p", { children: "Class" }),
|
|
110
|
-
/* @__PURE__ */ e("p", { children: i.cabinClass })
|
|
111
|
-
] })
|
|
112
|
-
] }),
|
|
113
|
-
/* @__PURE__ */ a("div", { className: "booking-options", children: [
|
|
114
|
-
i.cash > 0 && /* @__PURE__ */ a(
|
|
115
|
-
"div",
|
|
116
|
-
{
|
|
117
|
-
className: "cash-value",
|
|
118
|
-
onClick: (r) => {
|
|
119
|
-
r.stopPropagation(), o(i, m.CASH);
|
|
120
|
-
},
|
|
121
|
-
children: [
|
|
122
|
-
/* @__PURE__ */ e("img", { src: i.airlineLogo }),
|
|
123
|
-
/* @__PURE__ */ a("div", { children: [
|
|
124
|
-
/* @__PURE__ */ e("label", { children: w ? "Book For" : "From" }),
|
|
125
|
-
/* @__PURE__ */ e(
|
|
126
|
-
A,
|
|
127
|
-
{
|
|
128
|
-
amount: i.cash,
|
|
129
|
-
currency: i.currency
|
|
130
|
-
}
|
|
131
|
-
)
|
|
132
|
-
] })
|
|
133
|
-
]
|
|
134
|
-
}
|
|
135
|
-
),
|
|
136
|
-
i.points > 0 && /* @__PURE__ */ a(
|
|
137
|
-
"div",
|
|
138
|
-
{
|
|
139
|
-
className: "points-value",
|
|
140
|
-
onClick: (r) => {
|
|
141
|
-
r.stopPropagation(), o(i, m.POINTS);
|
|
142
|
-
},
|
|
143
|
-
children: [
|
|
144
|
-
/* @__PURE__ */ e("img", { src: I.programLogo }),
|
|
145
|
-
/* @__PURE__ */ a("div", { children: [
|
|
146
|
-
/* @__PURE__ */ e("label", { children: E ? "Book For" : "From" }),
|
|
147
|
-
/* @__PURE__ */ a("p", { children: [
|
|
148
|
-
`${Y(i.points)} miles`,
|
|
149
|
-
((u = i.cashFee) == null ? void 0 : u.amount) > 0 || (((y = (F = (v = i.paymentOptions) == null ? void 0 : v.find(
|
|
150
|
-
(r) => r.points > -1
|
|
151
|
-
)) == null ? void 0 : F.cashFee) == null ? void 0 : y.amount) ?? 0) > 0 && /* @__PURE__ */ a(H, { children: [
|
|
152
|
-
" + ",
|
|
153
|
-
/* @__PURE__ */ e(
|
|
154
|
-
A,
|
|
155
|
-
{
|
|
156
|
-
amount: ((D = (C = i.paymentOptions.find(
|
|
157
|
-
(r) => r.points > -1
|
|
158
|
-
)) == null ? void 0 : C.cashFee) == null ? void 0 : D.amount) ?? 0,
|
|
159
|
-
currency: ((O = (S = i.paymentOptions.find(
|
|
160
|
-
(r) => r.points > -1
|
|
161
|
-
)) == null ? void 0 : S.cashFee) == null ? void 0 : O.currency) ?? "",
|
|
162
|
-
customDisplay: "No fee",
|
|
163
|
-
zeroDisplayOption: W.CUSTOM
|
|
164
|
-
}
|
|
165
|
-
)
|
|
166
|
-
] })
|
|
167
|
-
] })
|
|
168
|
-
] })
|
|
169
|
-
]
|
|
170
|
-
}
|
|
171
|
-
)
|
|
172
|
-
] })
|
|
173
|
-
] }),
|
|
174
|
-
/* @__PURE__ */ e("div", { className: `flight-details ${d ? "is-open" : ""}`, children: /* @__PURE__ */ e("div", { className: "inner", children: /* @__PURE__ */ e(
|
|
175
|
-
G,
|
|
176
|
-
{
|
|
177
|
-
itinerary: f.slices[0].segments,
|
|
178
|
-
origin: s,
|
|
179
|
-
destination: t,
|
|
180
|
-
isMultiDayFlight: $
|
|
181
|
-
}
|
|
182
|
-
) }) })
|
|
183
|
-
] }) });
|
|
184
|
-
};
|
|
9
|
+
import "../../enums/EPaymentType.js";
|
|
10
|
+
import "@odynn/awayz-core";
|
|
11
|
+
import "../../utils/flightDateUtils.js";
|
|
185
12
|
export {
|
|
186
|
-
|
|
13
|
+
g as FlightResult
|
|
187
14
|
};
|
package/dist/components/index.js
CHANGED
package/dist/hooks/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { useFlightSearch as o } from "./useFlightSearch/useFlightSearch.js";
|
|
2
|
-
import { useAirportSearch as
|
|
2
|
+
import { useAirportSearch as a } from "./useAirportSearch/useAirportSearch.js";
|
|
3
|
+
import { EBaggage as p } from "./useFlightSearch/useFlightSearch.types.js";
|
|
3
4
|
export {
|
|
4
|
-
|
|
5
|
+
p as EBaggage,
|
|
6
|
+
a as useAirportSearch,
|
|
5
7
|
o as useFlightSearch
|
|
6
8
|
};
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useMutation as
|
|
3
|
-
import { EFlightType as $, EFlightPaymentType as F } from "../../types/enums.js";
|
|
4
|
-
import { FlightService as D } from "../../services/flights/FlightsService.js";
|
|
5
|
-
import { mapDataToFlightDetails as X, groupFlightResults as Z, buildFlightSearchQuery as Q } from "../../utils/flightUtils.js";
|
|
1
|
+
import { useAwayzContext as J, awayzClient as F, getBaseUrl as X } from "@odynn/awayz-core";
|
|
2
|
+
import { useMutation as U } from "@tanstack/react-query";
|
|
6
3
|
import "../../moment-BGjjqtLQ.js";
|
|
7
4
|
import "../../arrayExtensions-DFLvtO8l.js";
|
|
8
5
|
import { c as B } from "../../objectUtils-CyIaVmog.js";
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
12
|
-
|
|
6
|
+
import { useState as H, useRef as Z } from "react";
|
|
7
|
+
import { FlightService as D } from "../../services/flights/FlightsService.js";
|
|
8
|
+
import Q from "../../stores/useFlightStore.js";
|
|
9
|
+
import { EFlightType as $, EFlightPaymentType as P } from "../../types/enums.js";
|
|
10
|
+
import { ECabinClass as ee } from "../../types/ECabinClass.js";
|
|
11
|
+
import { mapDataToFlightDetails as te, groupFlightResults as ne, buildFlightSearchQuery as re } from "../../utils/flightUtils.js";
|
|
13
12
|
async function oe(e, n) {
|
|
14
13
|
const o = e.getReader();
|
|
15
14
|
let r;
|
|
@@ -50,21 +49,21 @@ function ae(e, n, o) {
|
|
|
50
49
|
if (c.length === 0)
|
|
51
50
|
o == null || o(r), r = Y();
|
|
52
51
|
else if (u > 0) {
|
|
53
|
-
const a = s.decode(c.subarray(0, u)), d = u + (c[u + 1] === 32 ? 2 : 1),
|
|
52
|
+
const a = s.decode(c.subarray(0, u)), d = u + (c[u + 1] === 32 ? 2 : 1), S = s.decode(c.subarray(d));
|
|
54
53
|
switch (a) {
|
|
55
54
|
case "data":
|
|
56
55
|
r.data = r.data ? r.data + `
|
|
57
|
-
` +
|
|
56
|
+
` + S : S;
|
|
58
57
|
break;
|
|
59
58
|
case "event":
|
|
60
|
-
r.event =
|
|
59
|
+
r.event = S;
|
|
61
60
|
break;
|
|
62
61
|
case "id":
|
|
63
|
-
e(r.id =
|
|
62
|
+
e(r.id = S);
|
|
64
63
|
break;
|
|
65
64
|
case "retry":
|
|
66
|
-
const
|
|
67
|
-
isNaN(
|
|
65
|
+
const m = parseInt(S, 10);
|
|
66
|
+
isNaN(m) || n(r.retry = m);
|
|
68
67
|
break;
|
|
69
68
|
}
|
|
70
69
|
}
|
|
@@ -92,35 +91,35 @@ var ue = function(e, n) {
|
|
|
92
91
|
};
|
|
93
92
|
const G = "text/event-stream", ce = 1e3, W = "last-event-id";
|
|
94
93
|
function le(e, n) {
|
|
95
|
-
var { signal: o, headers: r, onopen: s, onmessage: E, onclose: c, onerror: u, openWhenHidden: a, fetch: d } = n,
|
|
96
|
-
return new Promise((
|
|
94
|
+
var { signal: o, headers: r, onopen: s, onmessage: E, onclose: c, onerror: u, openWhenHidden: a, fetch: d } = n, S = ue(n, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
|
|
95
|
+
return new Promise((m, _) => {
|
|
97
96
|
const p = Object.assign({}, r);
|
|
98
97
|
p.accept || (p.accept = G);
|
|
99
|
-
let
|
|
98
|
+
let b;
|
|
100
99
|
function R() {
|
|
101
|
-
|
|
100
|
+
b.abort(), document.hidden || v();
|
|
102
101
|
}
|
|
103
102
|
a || document.addEventListener("visibilitychange", R);
|
|
104
103
|
let A = ce, I = 0;
|
|
105
104
|
function T() {
|
|
106
|
-
document.removeEventListener("visibilitychange", R), window.clearTimeout(I),
|
|
105
|
+
document.removeEventListener("visibilitychange", R), window.clearTimeout(I), b.abort();
|
|
107
106
|
}
|
|
108
107
|
o == null || o.addEventListener("abort", () => {
|
|
109
|
-
T(),
|
|
108
|
+
T(), m();
|
|
110
109
|
});
|
|
111
|
-
const
|
|
110
|
+
const L = d ?? window.fetch, M = s ?? de;
|
|
112
111
|
async function v() {
|
|
113
112
|
var w;
|
|
114
|
-
|
|
113
|
+
b = new AbortController();
|
|
115
114
|
try {
|
|
116
|
-
const C = await
|
|
117
|
-
await
|
|
115
|
+
const C = await L(e, Object.assign(Object.assign({}, S), { headers: p, signal: b.signal }));
|
|
116
|
+
await M(C), await oe(C.body, se(ae((h) => {
|
|
118
117
|
h ? p[W] = h : delete p[W];
|
|
119
118
|
}, (h) => {
|
|
120
119
|
A = h;
|
|
121
|
-
}, E))), c == null || c(), T(),
|
|
120
|
+
}, E))), c == null || c(), T(), m();
|
|
122
121
|
} catch (C) {
|
|
123
|
-
if (!
|
|
122
|
+
if (!b.signal.aborted)
|
|
124
123
|
try {
|
|
125
124
|
const h = (w = u == null ? void 0 : u(C)) !== null && w !== void 0 ? w : A;
|
|
126
125
|
window.clearTimeout(I), I = window.setTimeout(v, h);
|
|
@@ -137,9 +136,10 @@ function de(e) {
|
|
|
137
136
|
if (!(n != null && n.startsWith(G)))
|
|
138
137
|
throw new Error(`Expected content-type to be ${G}, Actual: ${n}`);
|
|
139
138
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
139
|
+
var y = /* @__PURE__ */ ((e) => (e.LOCATIONS = "LOCATIONS", e.CHECK_USER = "CHECK_USER", e.USER_REGIONS = "USER_REGIONS", e.CONVERT_CURRENCY = "CONVERT_CURRENCY", e.CLIENT_COMPONENT_KEY = "CLIENT_COMPONENT_KEY", e.SEARCH_LIMIT = "SEARCH_LIMIT", e.PROGRAMS = "PROGRAMS", e.USER_PROGRAMS = "USER_PROGRAMS", e.BANKS = "BANKS", e.CARDS = "CARDS", e.USER_CARDS = "USER_CARDS", e.TRIPS = "TRIPS", e.UNCATEGORISED_BOOKINGS = "UNCATEGORISED_BOOKINGS", e.BOOKING = "BOOKING", e))(y || {});
|
|
140
|
+
const z = 1, V = ee.ECONOMY;
|
|
141
|
+
let k = new AbortController();
|
|
142
|
+
const fe = 3 * 60 * 1e3, K = (e) => {
|
|
143
143
|
if (!e.origin || !e.destination)
|
|
144
144
|
throw new Error("Origin and destination are required.");
|
|
145
145
|
if (!e.departureDate)
|
|
@@ -147,26 +147,26 @@ const fe = 3 * 60 * 1e3, V = (e) => {
|
|
|
147
147
|
if (e.flightType === $.ROUND_TRIP && !e.returnDate)
|
|
148
148
|
throw new Error("Return date is required for round-trip flights.");
|
|
149
149
|
}, we = () => {
|
|
150
|
-
const { token: e, config: n } =
|
|
150
|
+
const { token: e, config: n } = J(), [o, r] = H(""), [s, E] = H([]), [c, u] = H(!1), a = Z(null), {
|
|
151
151
|
inboundResults: d,
|
|
152
|
-
outboundResults:
|
|
153
|
-
setInboundResults:
|
|
152
|
+
outboundResults: S,
|
|
153
|
+
setInboundResults: m,
|
|
154
154
|
setOutboundResults: _,
|
|
155
155
|
partialOfferRequestId: p,
|
|
156
|
-
setPartialOfferRequestId:
|
|
157
|
-
} =
|
|
156
|
+
setPartialOfferRequestId: b
|
|
157
|
+
} = Q(), R = ({
|
|
158
158
|
data: t,
|
|
159
159
|
inbound: f
|
|
160
160
|
}) => {
|
|
161
|
-
const l =
|
|
162
|
-
return (f ?
|
|
161
|
+
const l = te(t);
|
|
162
|
+
return (f ? m : _)(ne(l)), l;
|
|
163
163
|
}, {
|
|
164
164
|
mutate: A,
|
|
165
165
|
status: I,
|
|
166
166
|
error: T
|
|
167
|
-
} =
|
|
167
|
+
} = U({
|
|
168
168
|
mutationFn: async (t) => {
|
|
169
|
-
|
|
169
|
+
K(t);
|
|
170
170
|
const l = {
|
|
171
171
|
passengers: Array.from(
|
|
172
172
|
{ length: t.passengers ?? z },
|
|
@@ -174,7 +174,7 @@ const fe = 3 * 60 * 1e3, V = (e) => {
|
|
|
174
174
|
),
|
|
175
175
|
origin: t.origin || "",
|
|
176
176
|
destination: t.destination || "",
|
|
177
|
-
cabin_class: t.cabinClass ??
|
|
177
|
+
cabin_class: t.cabinClass ?? V
|
|
178
178
|
};
|
|
179
179
|
if (t.flightType === $.ONE_WAY) {
|
|
180
180
|
const i = await D.cashOnlySearch({
|
|
@@ -204,19 +204,19 @@ const fe = 3 * 60 * 1e3, V = (e) => {
|
|
|
204
204
|
console.log("oh lol, it didn't work");
|
|
205
205
|
return;
|
|
206
206
|
}
|
|
207
|
-
R({ data: l }), i &&
|
|
207
|
+
R({ data: l }), i && b(i);
|
|
208
208
|
},
|
|
209
209
|
onError: (t) => {
|
|
210
210
|
console.error("Error in outbound flight search:", t);
|
|
211
211
|
},
|
|
212
212
|
onSettled: () => {
|
|
213
|
-
|
|
213
|
+
F.invalidateQueries({ queryKey: [y.SEARCH_LIMIT] });
|
|
214
214
|
}
|
|
215
215
|
}), {
|
|
216
|
-
mutate:
|
|
217
|
-
status:
|
|
216
|
+
mutate: L,
|
|
217
|
+
status: M,
|
|
218
218
|
error: v
|
|
219
|
-
} =
|
|
219
|
+
} = U({
|
|
220
220
|
mutationFn: async (t) => {
|
|
221
221
|
if (!p)
|
|
222
222
|
throw new Error("No partialOfferRequestId found for inbound search.");
|
|
@@ -236,13 +236,13 @@ const fe = 3 * 60 * 1e3, V = (e) => {
|
|
|
236
236
|
console.error("Error in inbound flight search:", t);
|
|
237
237
|
},
|
|
238
238
|
onSettled: () => {
|
|
239
|
-
|
|
239
|
+
F.invalidateQueries({ queryKey: [y.SEARCH_LIMIT] });
|
|
240
240
|
}
|
|
241
241
|
}), {
|
|
242
242
|
mutate: w,
|
|
243
243
|
status: C,
|
|
244
244
|
error: h
|
|
245
|
-
} =
|
|
245
|
+
} = U({
|
|
246
246
|
mutationFn: async (t) => {
|
|
247
247
|
if (!p)
|
|
248
248
|
throw new Error("No partialOfferRequestId found for round-trip fares.");
|
|
@@ -262,42 +262,42 @@ const fe = 3 * 60 * 1e3, V = (e) => {
|
|
|
262
262
|
console.error("Error in round-trip fare search:", t);
|
|
263
263
|
},
|
|
264
264
|
onSettled: () => {
|
|
265
|
-
|
|
265
|
+
F.invalidateQueries({ queryKey: [y.SEARCH_LIMIT] });
|
|
266
266
|
}
|
|
267
267
|
}), j = async (t) => {
|
|
268
268
|
var x;
|
|
269
269
|
u(!0);
|
|
270
|
-
const f = t.paymentType ===
|
|
270
|
+
const f = t.paymentType === P.CASH_AND_MILES ? ['"cash"', '"points"'] : ['"points"'], l = re({
|
|
271
271
|
originCode: t.origin,
|
|
272
272
|
destinationCode: t.destination,
|
|
273
273
|
departureDate: t.departureDate,
|
|
274
|
-
cabinClass: t.cabinClass ??
|
|
274
|
+
cabinClass: t.cabinClass ?? V,
|
|
275
275
|
passengerCount: t.passengers ?? z,
|
|
276
276
|
paymentType: f
|
|
277
277
|
});
|
|
278
|
-
let i = [],
|
|
279
|
-
|
|
278
|
+
let i = [], q = 0;
|
|
279
|
+
k = new AbortController(), a.current = setTimeout(() => {
|
|
280
280
|
O();
|
|
281
|
-
}, (((x = n == null ? void 0 : n.flightsConfig) == null ? void 0 : x.streamTimeoutTotalSeconds) ?? fe) * 1e3), le(
|
|
281
|
+
}, (((x = n == null ? void 0 : n.flightsConfig) == null ? void 0 : x.streamTimeoutTotalSeconds) ?? fe) * 1e3), le(X() + l, {
|
|
282
282
|
headers: {
|
|
283
283
|
"Content-Type": "application/json",
|
|
284
284
|
Authorization: e ?? "",
|
|
285
285
|
"client-id": (n == null ? void 0 : n.clientId) ?? ""
|
|
286
286
|
},
|
|
287
287
|
openWhenHidden: !0,
|
|
288
|
-
signal:
|
|
288
|
+
signal: k.signal,
|
|
289
289
|
onmessage(N) {
|
|
290
290
|
try {
|
|
291
|
-
const
|
|
292
|
-
if (
|
|
291
|
+
const g = B(JSON.parse(N.data));
|
|
292
|
+
if (g.success === !1)
|
|
293
293
|
return;
|
|
294
|
-
if (
|
|
294
|
+
if (g.close === !0) {
|
|
295
295
|
O();
|
|
296
296
|
return;
|
|
297
297
|
}
|
|
298
|
-
|
|
299
|
-
} catch (
|
|
300
|
-
console.error("Error parsing message:",
|
|
298
|
+
g.status === 200 && g.flights && g.flights.length > 0 && (q = 0, i = [...i, ...g.flights], R({ data: i })), g.ping && (q++, q >= n.flightsConfig.streamTimeoutPingCount && O());
|
|
299
|
+
} catch (g) {
|
|
300
|
+
console.error("Error parsing message:", g), O();
|
|
301
301
|
}
|
|
302
302
|
},
|
|
303
303
|
onerror(N) {
|
|
@@ -309,7 +309,7 @@ const fe = 3 * 60 * 1e3, V = (e) => {
|
|
|
309
309
|
keepalive: !1
|
|
310
310
|
});
|
|
311
311
|
}, O = () => {
|
|
312
|
-
|
|
312
|
+
k.abort(), a.current && (clearTimeout(a.current), a.current = null), u(!1), F.invalidateQueries({ queryKey: [y.SEARCH_LIMIT] });
|
|
313
313
|
};
|
|
314
314
|
return {
|
|
315
315
|
/**
|
|
@@ -317,7 +317,7 @@ const fe = 3 * 60 * 1e3, V = (e) => {
|
|
|
317
317
|
* @type {boolean}
|
|
318
318
|
* @default false
|
|
319
319
|
*/
|
|
320
|
-
loading: I === "pending" ||
|
|
320
|
+
loading: I === "pending" || M === "pending" || c,
|
|
321
321
|
/**
|
|
322
322
|
* Loading status for fares
|
|
323
323
|
* @type {boolean}
|
|
@@ -328,7 +328,7 @@ const fe = 3 * 60 * 1e3, V = (e) => {
|
|
|
328
328
|
inboundError: v,
|
|
329
329
|
roundTripFaresError: h,
|
|
330
330
|
// Results
|
|
331
|
-
outboundResults:
|
|
331
|
+
outboundResults: S,
|
|
332
332
|
inboundResults: d,
|
|
333
333
|
roundTripFares: s,
|
|
334
334
|
// Mutation triggers
|
|
@@ -339,14 +339,14 @@ const fe = 3 * 60 * 1e3, V = (e) => {
|
|
|
339
339
|
* @param {ISearchFlightArgs} args - The search arguments
|
|
340
340
|
*/
|
|
341
341
|
searchOutboundFlights: async (t) => {
|
|
342
|
-
switch (
|
|
343
|
-
case
|
|
342
|
+
switch (K(t), _([]), O(), t.paymentType) {
|
|
343
|
+
case P.CASH_AND_MILES:
|
|
344
344
|
j(t);
|
|
345
345
|
break;
|
|
346
|
-
case
|
|
346
|
+
case P.CASH:
|
|
347
347
|
A(t);
|
|
348
348
|
break;
|
|
349
|
-
case
|
|
349
|
+
case P.MILES:
|
|
350
350
|
j(t);
|
|
351
351
|
break;
|
|
352
352
|
}
|
|
@@ -357,7 +357,7 @@ const fe = 3 * 60 * 1e3, V = (e) => {
|
|
|
357
357
|
*
|
|
358
358
|
* @param {string} outboundOfferId - The ID of the outbound offer
|
|
359
359
|
*/
|
|
360
|
-
searchInboundFlights:
|
|
360
|
+
searchInboundFlights: L,
|
|
361
361
|
/**
|
|
362
362
|
* Used to get round-trip fares after selecting both outbound and inbound flights
|
|
363
363
|
* @type {function}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export * from './useFlightSearch/useFlightSearch';
|
|
2
2
|
export * from './useAirportSearch/useAirportSearch';
|
|
3
|
-
export type { IFlightResult, IFlightOffer, IFlightDetails,
|
|
3
|
+
export type { IFlightResult, IFlightOffer, IFlightDetails, IAirportLocation } from './useFlightSearch/useFlightSearch.types';
|
|
4
|
+
export { EBaggage } from './useFlightSearch/useFlightSearch.types';
|
package/dist/lib/main.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ISlice, IBaggage, ICarrier, ISegment, IPassenger, ICoordinates, commaSeparatedNumber, getDuration, getCountryNameByCode, getTimezoneOffsetOrCode, calculateTimeDifference, getTimeString, EDateFormats } from '@type-op/shared';
|
|
1
|
+
import { ISlice, IBaggage, ICarrier, ISegment, IPassenger, ICoordinates, commaSeparatedNumber, getDuration, getCountryNameByCode, getTimezoneOffsetOrCode, calculateTimeDifference, getTimeString, EDateFormats, DUFFEL_ASSET_PATH } from '@type-op/shared';
|
|
2
2
|
export * from './hooks';
|
|
3
3
|
export * from './components';
|
|
4
4
|
export * from './enums';
|
|
@@ -7,4 +7,5 @@ export { getLogoPath, getFlightNumber } from './utils/flightUtils';
|
|
|
7
7
|
export { isSameDayFlight } from './utils/flightDateUtils';
|
|
8
8
|
export { EFlightPaymentType, EFlightType } from './types/enums';
|
|
9
9
|
export { ECabinClass, getCabinClassLabel, getCabinClassList } from './types/ECabinClass';
|
|
10
|
-
export type { ISlice, IBaggage, ICarrier, ISegment, IPassenger, ICoordinates,
|
|
10
|
+
export type { ISlice, IBaggage, ICarrier, ISegment, IPassenger, ICoordinates, DUFFEL_ASSET_PATH };
|
|
11
|
+
export { commaSeparatedNumber, getDuration, getCountryNameByCode, getTimezoneOffsetOrCode, calculateTimeDifference, getTimeString, EDateFormats };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IFlightOffer, IFlightResult } from '../hooks/useFlightSearch/useFlightSearch.types';
|
|
2
1
|
import { ISegment } from '@type-op/shared';
|
|
2
|
+
import { IFlightOffer, IFlightResult } from '../hooks/useFlightSearch/useFlightSearch.types';
|
|
3
3
|
import { IAirlineProgram } from '../services/wallet/WalletService.types';
|
|
4
4
|
import { ECabinClass } from '../types/ECabinClass';
|
|
5
5
|
/**
|
package/dist/main.js
CHANGED
|
@@ -1,24 +1,37 @@
|
|
|
1
|
-
import { useFlightSearch as
|
|
2
|
-
import { useAirportSearch as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
1
|
+
import { useFlightSearch as o } from "./hooks/useFlightSearch/useFlightSearch.js";
|
|
2
|
+
import { useAirportSearch as g } from "./hooks/useAirportSearch/useAirportSearch.js";
|
|
3
|
+
import { EBaggage as s } from "./hooks/useFlightSearch/useFlightSearch.types.js";
|
|
4
|
+
import { F as f, c as l } from "./FlightResult-DLe2iE7E.js";
|
|
5
|
+
import { EPaymentType as x } from "./enums/EPaymentType.js";
|
|
6
|
+
import { DEFAULT_AIRLINE_PROGRAM as C, getAirlineProgram as E, getFlightNumber as F, getLogoPath as c } from "./utils/flightUtils.js";
|
|
7
|
+
import { isSameDayFlight as y } from "./utils/flightDateUtils.js";
|
|
8
|
+
import { EFlightPaymentType as T, EFlightType as A } from "./types/enums.js";
|
|
9
|
+
import { ECabinClass as L, getCabinClassLabel as P, getCabinClassList as S } from "./types/ECabinClass.js";
|
|
10
|
+
import { c as R, g as d, b as O, a as B } from "./index-7zRjF0bU.js";
|
|
11
|
+
import { E as _, g as z } from "./FlightItinerary-VggJiPkC.js";
|
|
12
|
+
import "./arrayExtensions-DFLvtO8l.js";
|
|
13
|
+
import "react";
|
|
9
14
|
export {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
15
|
+
C as DEFAULT_AIRLINE_PROGRAM,
|
|
16
|
+
s as EBaggage,
|
|
17
|
+
L as ECabinClass,
|
|
18
|
+
_ as EDateFormats,
|
|
19
|
+
T as EFlightPaymentType,
|
|
20
|
+
A as EFlightType,
|
|
21
|
+
x as EPaymentType,
|
|
22
|
+
f as FlightResult,
|
|
23
|
+
R as calculateTimeDifference,
|
|
24
|
+
l as commaSeparatedNumber,
|
|
25
|
+
E as getAirlineProgram,
|
|
26
|
+
P as getCabinClassLabel,
|
|
27
|
+
S as getCabinClassList,
|
|
28
|
+
z as getCountryNameByCode,
|
|
29
|
+
d as getDuration,
|
|
30
|
+
F as getFlightNumber,
|
|
31
|
+
c as getLogoPath,
|
|
32
|
+
O as getTimeString,
|
|
33
|
+
B as getTimezoneOffsetOrCode,
|
|
34
|
+
y as isSameDayFlight,
|
|
35
|
+
g as useAirportSearch,
|
|
36
|
+
o as useFlightSearch
|
|
24
37
|
};
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { c as K, D as V } from "../index-D0Heof44.js";
|
|
1
|
+
import { awayzClient as Q } from "@odynn/awayz-core";
|
|
2
|
+
import { d as K, D as V } from "../index-7zRjF0bU.js";
|
|
4
3
|
import "../arrayExtensions-DFLvtO8l.js";
|
|
5
4
|
import "react";
|
|
6
|
-
import {
|
|
5
|
+
import { h as g } from "../moment-BGjjqtLQ.js";
|
|
6
|
+
import { mapBaggageType as Y } from "../hooks/useFlightSearch/useFlightSearch.types.js";
|
|
7
7
|
import { WalletService as x } from "../services/wallet/WalletService.js";
|
|
8
8
|
import { ERewardProgramCategories as H } from "../services/wallet/WalletService.types.js";
|
|
9
9
|
const re = (t) => t == null ? void 0 : t.map((e) => {
|
|
10
|
-
var
|
|
10
|
+
var a, c, n, l, s, i, o, m, r, u, d, C, w, b, D, F, L, A, h, T, P, k, O, v, R, E, I, _, N, z, S, Z, $, G, M;
|
|
11
11
|
return {
|
|
12
12
|
id: e.id,
|
|
13
13
|
points: (e == null ? void 0 : e.points) >= 0 ? e.points : -1,
|
|
14
14
|
partial: e == null ? void 0 : e.partial,
|
|
15
15
|
origin: {
|
|
16
|
-
city: ((
|
|
17
|
-
country: ((
|
|
18
|
-
airportCode: ((
|
|
16
|
+
city: ((a = e.slices[0].segments[0].origin) == null ? void 0 : a.cityName) || ((n = (c = e.slices[0].segments[0].origin) == null ? void 0 : c.city) == null ? void 0 : n.name),
|
|
17
|
+
country: ((l = e.slices[0].segments[0].origin) == null ? void 0 : l.iataCountryCode) || ((i = (s = e.slices[0].segments[0].origin) == null ? void 0 : s.city) == null ? void 0 : i.iataCountryCode),
|
|
18
|
+
airportCode: ((o = e.slices[0].segments[0].origin) == null ? void 0 : o.iataCityCode) || ((r = (m = e.slices[0].segments[0].origin) == null ? void 0 : m.city) == null ? void 0 : r.iataCode),
|
|
19
19
|
coordinates: {
|
|
20
|
-
latitude: (
|
|
20
|
+
latitude: (d = (u = e.slices[0].segments[0].origin) == null ? void 0 : u.city) == null ? void 0 : d.latitude,
|
|
21
21
|
longitude: (w = (C = e.slices[0].segments[0].origin) == null ? void 0 : C.city) == null ? void 0 : w.longitude
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
destination: {
|
|
25
25
|
city: ((D = (b = e.slices[0].segments.getLast()) == null ? void 0 : b.destination) == null ? void 0 : D.cityName) || ((A = (L = (F = e.slices[0].segments.getLast()) == null ? void 0 : F.destination) == null ? void 0 : L.city) == null ? void 0 : A.name),
|
|
26
|
-
country: ((
|
|
26
|
+
country: ((T = (h = e.slices[0].segments.getLast()) == null ? void 0 : h.destination) == null ? void 0 : T.iataCountryCode) || ((O = (k = (P = e.slices[0].segments.getLast()) == null ? void 0 : P.destination) == null ? void 0 : k.city) == null ? void 0 : O.iataCountryCode),
|
|
27
27
|
airportCode: ((R = (v = e.slices[0].segments.getLast()) == null ? void 0 : v.destination) == null ? void 0 : R.iataCityCode) || ((_ = (I = (E = e.slices[0].segments.getLast()) == null ? void 0 : E.destination) == null ? void 0 : I.city) == null ? void 0 : _.iataCode),
|
|
28
28
|
coordinates: {
|
|
29
|
-
latitude: (
|
|
30
|
-
longitude: (
|
|
29
|
+
latitude: (S = (z = (N = e.slices[0].segments.getLast()) == null ? void 0 : N.destination) == null ? void 0 : z.city) == null ? void 0 : S.latitude,
|
|
30
|
+
longitude: (G = ($ = (Z = e.slices[0].segments.getLast()) == null ? void 0 : Z.destination) == null ? void 0 : $.city) == null ? void 0 : G.longitude
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
33
|
airline: e.owner.name,
|
|
@@ -55,62 +55,62 @@ const re = (t) => t == null ? void 0 : t.map((e) => {
|
|
|
55
55
|
duration: e.slices[0].duration
|
|
56
56
|
}),
|
|
57
57
|
cashFee: e.cashFee,
|
|
58
|
-
cabinClass: e.slices[0].fareBrandName || e.slices[0].segments[0].passengers[0].cabinClassMarketingName || ((
|
|
58
|
+
cabinClass: e.slices[0].fareBrandName || e.slices[0].segments[0].passengers[0].cabinClassMarketingName || ((M = e.slices[0].segments[0].passengers[0].cabin) == null ? void 0 : M.marketingName)
|
|
59
59
|
};
|
|
60
60
|
}), j = (t) => {
|
|
61
|
-
const e = t.operatingCarrierFlightNumber ? t.operatingCarrier : t.marketingCarrier,
|
|
62
|
-
return e.iataCode + " " + J(
|
|
61
|
+
const e = t.operatingCarrierFlightNumber ? t.operatingCarrier : t.marketingCarrier, a = t.operatingCarrierFlightNumber ?? t.marketingCarrierFlightNumber;
|
|
62
|
+
return e.iataCode + " " + J(a);
|
|
63
63
|
}, oe = ({
|
|
64
64
|
originCode: t,
|
|
65
65
|
destinationCode: e,
|
|
66
|
-
departureDate:
|
|
67
|
-
cabinClass:
|
|
68
|
-
passengerCount:
|
|
69
|
-
paymentType:
|
|
66
|
+
departureDate: a,
|
|
67
|
+
cabinClass: c,
|
|
68
|
+
passengerCount: n,
|
|
69
|
+
paymentType: l
|
|
70
70
|
}) => {
|
|
71
71
|
let s = "/flights/search/one-way/points-cash?";
|
|
72
|
-
return s += `origin=${t}`, s += `&destination=${e}`, s += `&departure_date=${
|
|
73
|
-
}, W = (t) => t.flightDetails.slices[0].segments.map((
|
|
72
|
+
return s += `origin=${t}`, s += `&destination=${e}`, s += `&departure_date=${a}`, s += `&cabin_class=${c}`, s += `&adults=${n}`, s += `&cash_or_points=[${l}]`, s;
|
|
73
|
+
}, W = (t) => t.flightDetails.slices[0].segments.map((a) => j(a)).join("_"), ce = (t) => {
|
|
74
74
|
const e = {};
|
|
75
75
|
t.forEach((s) => {
|
|
76
|
-
var
|
|
77
|
-
const
|
|
78
|
-
if (e[
|
|
79
|
-
const
|
|
80
|
-
e[
|
|
81
|
-
const
|
|
82
|
-
e[
|
|
76
|
+
var o;
|
|
77
|
+
const i = W(s);
|
|
78
|
+
if (e[i]) {
|
|
79
|
+
const m = U(s);
|
|
80
|
+
e[i].flight.paymentOptions.push(m);
|
|
81
|
+
const r = p(
|
|
82
|
+
e[i].flight.paymentOptions
|
|
83
83
|
);
|
|
84
|
-
e[
|
|
84
|
+
e[i].flight.cash = r.lowestCash, r.currency && (e[i].flight.flightDetails.baseCurrency = r.currency, e[i].flight.currency = r.currency), e[i].flight.points = r.lowestPoints;
|
|
85
85
|
} else {
|
|
86
|
-
const { origin:
|
|
87
|
-
e[
|
|
86
|
+
const { origin: m, destination: r } = s, u = [U(s)], d = p(u);
|
|
87
|
+
e[i] = {
|
|
88
88
|
programs: [],
|
|
89
89
|
flight: {
|
|
90
90
|
id: s.awayzGroupId,
|
|
91
91
|
partial: s.partial,
|
|
92
92
|
origin: {
|
|
93
|
-
city:
|
|
94
|
-
country:
|
|
95
|
-
airportCode:
|
|
96
|
-
coordinates:
|
|
93
|
+
city: m.city,
|
|
94
|
+
country: m.country,
|
|
95
|
+
airportCode: m.airportCode,
|
|
96
|
+
coordinates: m.coordinates
|
|
97
97
|
},
|
|
98
98
|
destination: {
|
|
99
|
-
city:
|
|
100
|
-
country:
|
|
101
|
-
airportCode:
|
|
102
|
-
coordinates:
|
|
99
|
+
city: r.city,
|
|
100
|
+
country: r.country,
|
|
101
|
+
airportCode: r.airportCode,
|
|
102
|
+
coordinates: r.coordinates
|
|
103
103
|
},
|
|
104
104
|
airline: s.airline,
|
|
105
105
|
airlineLogo: y(
|
|
106
106
|
s.flightDetails.slices[0].segments[0].marketingCarrier.iataCode
|
|
107
107
|
),
|
|
108
108
|
flightNumber: s.flightNumber,
|
|
109
|
-
paymentOptions:
|
|
109
|
+
paymentOptions: u,
|
|
110
110
|
numberOfStops: s.numberOfStops,
|
|
111
111
|
departureTime: s.departureTime,
|
|
112
112
|
arrivalTime: s.arrivalTime,
|
|
113
|
-
awayzGroupId:
|
|
113
|
+
awayzGroupId: i,
|
|
114
114
|
duration: s.duration,
|
|
115
115
|
airlineProgram: s.airlineProgram,
|
|
116
116
|
durationMinutes: K({
|
|
@@ -124,73 +124,73 @@ const re = (t) => t == null ? void 0 : t.map((e) => {
|
|
|
124
124
|
destinationTimeZone: s.flightDetails.slices[0].segments.getLast().destination.timeZone,
|
|
125
125
|
duration: s.flightDetails.slices[0].duration
|
|
126
126
|
}),
|
|
127
|
-
cash:
|
|
128
|
-
points:
|
|
127
|
+
cash: d.lowestCash,
|
|
128
|
+
points: d.lowestPoints,
|
|
129
129
|
flightDetails: s.flightDetails,
|
|
130
130
|
currency: s.flightDetails.baseCurrency,
|
|
131
131
|
cashFee: s.cashFee,
|
|
132
|
-
cabinClass: s.flightDetails.slices[0].fareBrandName || s.flightDetails.slices[0].segments[0].passengers[0].cabinClassMarketingName || ((
|
|
132
|
+
cabinClass: s.flightDetails.slices[0].fareBrandName || s.flightDetails.slices[0].segments[0].passengers[0].cabinClassMarketingName || ((o = s.flightDetails.slices[0].segments[0].passengers[0].cabin) == null ? void 0 : o.marketingName)
|
|
133
133
|
}
|
|
134
134
|
};
|
|
135
135
|
}
|
|
136
|
-
s.airlineProgram && !e[
|
|
136
|
+
s.airlineProgram && !e[i].programs.includes(s.airlineProgram) && e[i].programs.push(s.airlineProgram);
|
|
137
137
|
});
|
|
138
|
-
const
|
|
138
|
+
const a = [];
|
|
139
139
|
Object.values(e).forEach((s) => {
|
|
140
|
-
const
|
|
140
|
+
const i = [
|
|
141
141
|
...new Set(
|
|
142
|
-
s.flight.paymentOptions.map((
|
|
142
|
+
s.flight.paymentOptions.map((o) => o.carrier.name)
|
|
143
143
|
)
|
|
144
144
|
];
|
|
145
|
-
s.programs.length > 0 ? s.programs.forEach((
|
|
146
|
-
|
|
147
|
-
var
|
|
148
|
-
const
|
|
145
|
+
s.programs.length > 0 ? s.programs.forEach((o) => {
|
|
146
|
+
i.forEach((m) => {
|
|
147
|
+
var u;
|
|
148
|
+
const r = p(
|
|
149
149
|
s.flight.paymentOptions.filter(
|
|
150
|
-
(
|
|
150
|
+
(d) => d.program === o || d.cash > 0 && d.carrier.name === m
|
|
151
151
|
)
|
|
152
152
|
);
|
|
153
|
-
|
|
153
|
+
a.push({
|
|
154
154
|
...s.flight,
|
|
155
|
-
airline:
|
|
155
|
+
airline: m,
|
|
156
156
|
airlineLogo: y(
|
|
157
|
-
(
|
|
158
|
-
(
|
|
159
|
-
)) == null ? void 0 :
|
|
157
|
+
(u = s.flight.paymentOptions.find(
|
|
158
|
+
(d) => d.carrier.name === m
|
|
159
|
+
)) == null ? void 0 : u.carrier.iataCode
|
|
160
160
|
),
|
|
161
|
-
airlineProgram:
|
|
162
|
-
cash:
|
|
163
|
-
points:
|
|
161
|
+
airlineProgram: o,
|
|
162
|
+
cash: r.lowestCash,
|
|
163
|
+
points: r.lowestPoints
|
|
164
164
|
});
|
|
165
165
|
});
|
|
166
|
-
}) :
|
|
167
|
-
var
|
|
168
|
-
const { lowestCash:
|
|
166
|
+
}) : i.forEach((o) => {
|
|
167
|
+
var r;
|
|
168
|
+
const { lowestCash: m } = p(
|
|
169
169
|
s.flight.paymentOptions.filter(
|
|
170
|
-
(
|
|
170
|
+
(u) => u.carrier.name === o
|
|
171
171
|
)
|
|
172
172
|
);
|
|
173
|
-
|
|
173
|
+
a.push({
|
|
174
174
|
...s.flight,
|
|
175
|
-
airline:
|
|
175
|
+
airline: o,
|
|
176
176
|
airlineLogo: y(
|
|
177
|
-
(
|
|
178
|
-
(
|
|
179
|
-
)) == null ? void 0 :
|
|
177
|
+
(r = s.flight.paymentOptions.find(
|
|
178
|
+
(u) => u.carrier.name === o
|
|
179
|
+
)) == null ? void 0 : r.carrier.iataCode
|
|
180
180
|
),
|
|
181
|
-
cash:
|
|
181
|
+
cash: m
|
|
182
182
|
});
|
|
183
183
|
});
|
|
184
184
|
});
|
|
185
|
-
const { cashlessResults:
|
|
186
|
-
(s,
|
|
185
|
+
const { cashlessResults: c, otherResults: n } = a.reduce(
|
|
186
|
+
(s, i) => (i.cash <= 0 && i.points > 0 ? s.cashlessResults.push(i) : i.cash > 0 && s.otherResults.push(i), s),
|
|
187
187
|
{ cashlessResults: [], otherResults: [] }
|
|
188
|
-
),
|
|
189
|
-
return
|
|
190
|
-
|
|
191
|
-
(
|
|
192
|
-
) ||
|
|
193
|
-
}),
|
|
188
|
+
), l = n;
|
|
189
|
+
return c.forEach((s) => {
|
|
190
|
+
l.find(
|
|
191
|
+
(o) => o.awayzGroupId === s.awayzGroupId
|
|
192
|
+
) || l.push(s);
|
|
193
|
+
}), l;
|
|
194
194
|
}, J = (t) => t ? t.replace(/^0+/, "") : "", me = (t) => `https://assets.duffel.com/img/airlines/for-light-background/full-color-logo/${t}.svg`, y = (t) => `${V}${t}.svg`, B = "/img/logo/odynn-eye.svg", q = {
|
|
195
195
|
categoryLogo: B,
|
|
196
196
|
programLogo: B,
|
|
@@ -204,30 +204,30 @@ const re = (t) => t == null ? void 0 : t.map((e) => {
|
|
|
204
204
|
// Using App Foreground Colour
|
|
205
205
|
url: "https://www.odynn.com"
|
|
206
206
|
}, le = async (t) => {
|
|
207
|
-
const { airlines: e } = await
|
|
207
|
+
const { airlines: e } = await Q.ensureQueryData({
|
|
208
208
|
queryKey: ["walletAwards"],
|
|
209
209
|
queryFn: x.getAwards,
|
|
210
210
|
staleTime: 864e5
|
|
211
211
|
// 24 hours
|
|
212
212
|
});
|
|
213
|
-
let
|
|
214
|
-
(
|
|
215
|
-
var
|
|
216
|
-
return ((
|
|
213
|
+
let a = e.find(
|
|
214
|
+
(c) => {
|
|
215
|
+
var n, l, s, i;
|
|
216
|
+
return ((l = (n = c.mainProgram) == null ? void 0 : n.toLowerCase()) == null ? void 0 : l.includes(t == null ? void 0 : t.toLowerCase())) || ((i = (s = c.displayProgram) == null ? void 0 : s.toLowerCase()) == null ? void 0 : i.includes(t == null ? void 0 : t.toLowerCase()));
|
|
217
217
|
}
|
|
218
218
|
) ?? q;
|
|
219
|
-
return
|
|
219
|
+
return a || (a = {
|
|
220
220
|
...q,
|
|
221
221
|
mainProgram: t,
|
|
222
222
|
displayProgram: t,
|
|
223
223
|
id: t
|
|
224
|
-
}),
|
|
224
|
+
}), a;
|
|
225
225
|
}, U = (t) => {
|
|
226
|
-
var n, l,
|
|
227
|
-
const
|
|
228
|
-
(
|
|
229
|
-
type:
|
|
230
|
-
quantity:
|
|
226
|
+
var c, n, l, s;
|
|
227
|
+
const a = (((l = (n = (c = t.flightDetails.slices.getFirst()) == null ? void 0 : c.segments.getFirst()) == null ? void 0 : n.passengers.getFirst()) == null ? void 0 : l.baggages) ?? []).map(
|
|
228
|
+
(i) => ({
|
|
229
|
+
type: Y(i.type),
|
|
230
|
+
quantity: i.quantity
|
|
231
231
|
})
|
|
232
232
|
);
|
|
233
233
|
return {
|
|
@@ -239,21 +239,23 @@ const re = (t) => t == null ? void 0 : t.map((e) => {
|
|
|
239
239
|
fareBrandName: (s = t.flightDetails.slices.getFirst()) == null ? void 0 : s.fareBrandName,
|
|
240
240
|
cashFee: t.cashFee,
|
|
241
241
|
conditions: t.flightDetails.conditions,
|
|
242
|
-
baggages:
|
|
242
|
+
baggages: a,
|
|
243
243
|
carrier: {
|
|
244
244
|
iataCode: t.flightDetails.slices.getFirst().segments.getFirst().marketingCarrier.iataCode,
|
|
245
245
|
name: t.flightDetails.slices.getFirst().segments.getFirst().marketingCarrier.name
|
|
246
246
|
}
|
|
247
247
|
};
|
|
248
248
|
}, p = (t) => {
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
249
|
+
let e = 1 / 0, a = "";
|
|
250
|
+
for (const n of t)
|
|
251
|
+
n.cash > 0 && n.cash < e && (e = n.cash, a = n.baseCurrency);
|
|
252
|
+
const c = Math.min(
|
|
252
253
|
...t.filter((n) => n.points > 0).map((n) => n.points)
|
|
253
254
|
);
|
|
254
255
|
return {
|
|
255
256
|
lowestCash: e === 1 / 0 ? -1 : e,
|
|
256
|
-
lowestPoints:
|
|
257
|
+
lowestPoints: c === 1 / 0 ? -1 : c,
|
|
258
|
+
currency: a
|
|
257
259
|
};
|
|
258
260
|
};
|
|
259
261
|
export {
|