@odynn/awayz-flights 0.7.7 → 0.7.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.
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
import { jsx as r, jsxs as n, Fragment as S } from "react/jsx-runtime";
|
|
2
|
+
import { useAwayzContext as te, RewardsService as U, CashValue as _, EToolTipPosition as L, EInvalidAmountDisplayOption as se, awayzClient as q, CurrencyService as ae } from "@odynn/awayz-core";
|
|
3
|
+
import { useQuery as oe } from "@tanstack/react-query";
|
|
4
|
+
import { g as ce } from "./index-7zRjF0bU.js";
|
|
5
|
+
import { G as le, g as R, a as N, E as v, F as me, b as pe } from "./FlightItinerary-Dy-2zMYt.js";
|
|
6
|
+
import { E as b } from "./enums-D9aZqf8G.js";
|
|
7
|
+
import "./arrayExtensions-DFLvtO8l.js";
|
|
8
|
+
import he, { useState as P, useEffect as O, useMemo as $ } from "react";
|
|
9
|
+
import { h as m } from "./moment-BGjjqtLQ.js";
|
|
10
|
+
import { useTranslation as ge } from "react-i18next";
|
|
11
|
+
import { EPaymentType as E } from "./enums/EPaymentType.js";
|
|
12
|
+
import { isSameDayFlight as fe } from "./utils/flightDateUtils.js";
|
|
13
|
+
import { DEFAULT_AIRLINE_PROGRAM as ue, getFlightNumber as de, getLogoPath as ye, getAirlineProgram as Ne } from "./utils/flightUtils.js";
|
|
14
|
+
import './assets/FlightResult.css';const ve = (e, s, c = s + "s") => e === 1 ? s : c;
|
|
15
|
+
function Pe(e) {
|
|
16
|
+
if (!e || isNaN(e) || e < 0) return "N/A";
|
|
17
|
+
let s = e == null ? void 0 : e.toString().split(".")[0];
|
|
18
|
+
return s == null ? void 0 : s.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
19
|
+
}
|
|
20
|
+
function I(e) {
|
|
21
|
+
return le({ attr: { viewBox: "0 0 512 512" }, child: [{ tag: "path", attr: { d: "M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM216 336l24 0 0-64-24 0c-13.3 0-24-10.7-24-24s10.7-24 24-24l48 0c13.3 0 24 10.7 24 24l0 88 8 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-80 0c-13.3 0-24-10.7-24-24s10.7-24 24-24zm40-208a32 32 0 1 1 0 64 32 32 0 1 1 0-64z" }, child: [] }] })(e);
|
|
22
|
+
}
|
|
23
|
+
async function z(e, s, c) {
|
|
24
|
+
if (!e || s === c) return e;
|
|
25
|
+
const o = await q.ensureQueryData({
|
|
26
|
+
queryKey: [b.CONVERT_CURRENCY, s, c],
|
|
27
|
+
staleTime: 1e3 * 60 * 60,
|
|
28
|
+
// 1 hour
|
|
29
|
+
queryFn: () => ae.convertCurrency({
|
|
30
|
+
baseCurrency: s,
|
|
31
|
+
targetCurrency: c
|
|
32
|
+
})
|
|
33
|
+
});
|
|
34
|
+
return e * o;
|
|
35
|
+
}
|
|
36
|
+
const Ue = ({
|
|
37
|
+
details: e,
|
|
38
|
+
onClick: s,
|
|
39
|
+
showBestValue: c = !1,
|
|
40
|
+
onShowBestValueCalculation: o,
|
|
41
|
+
customStyling: w = !1,
|
|
42
|
+
customCashComponent: K,
|
|
43
|
+
customPointsComponent: Q
|
|
44
|
+
}) => {
|
|
45
|
+
const { t: h } = ge(), [x, G] = P(!1), [f, Y] = P(
|
|
46
|
+
"none"
|
|
47
|
+
/* NONE */
|
|
48
|
+
), [j, H] = P(!1), { config: F } = te(), u = e.origin, d = e.destination, k = e.flightDetails, T = e.paymentOptions || [], J = T.filter((i) => i.points === -1).length === 1, W = T.filter((i) => i.points > -1).length === 1, [X, Z] = P(ue), V = async () => {
|
|
49
|
+
const i = T.filter((a) => a.points > -1).sort((a, l) => a.points - l.points)[0], t = await Ne(i.program);
|
|
50
|
+
Z(t);
|
|
51
|
+
};
|
|
52
|
+
O(() => {
|
|
53
|
+
V();
|
|
54
|
+
}, [e.paymentOptions]);
|
|
55
|
+
const { flightNumbers: C, airlines: B } = $(() => {
|
|
56
|
+
const i = [], t = [];
|
|
57
|
+
return e.flightDetails.slices.forEach((a) => {
|
|
58
|
+
a.segments.forEach((l) => {
|
|
59
|
+
const p = de(l);
|
|
60
|
+
i.includes(p) || i.push(p);
|
|
61
|
+
const y = l.operatingCarrier;
|
|
62
|
+
t.some((A) => A.airline === y.name) || t.push({
|
|
63
|
+
logo: ye(y.iataCode),
|
|
64
|
+
airline: y.name
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
}), { flightNumbers: i, airlines: t };
|
|
68
|
+
}, [e.flightDetails.slices]), ee = () => {
|
|
69
|
+
e.cash > 0 ? s(e, E.CASH) : s(e, E.POINTS);
|
|
70
|
+
}, re = !fe(
|
|
71
|
+
e.departureTime,
|
|
72
|
+
e.arrivalTime
|
|
73
|
+
), D = e == null ? void 0 : e.airlineProgram, { data: M } = oe({
|
|
74
|
+
queryKey: [b.VALUE_CENTS, D, "test"],
|
|
75
|
+
queryFn: () => U.getCentPerPoint(D),
|
|
76
|
+
staleTime: 1 / 0,
|
|
77
|
+
enabled: !!D && c
|
|
78
|
+
}), g = $(() => {
|
|
79
|
+
var i, t;
|
|
80
|
+
return (t = (i = e.paymentOptions) == null ? void 0 : i.find(
|
|
81
|
+
(a) => {
|
|
82
|
+
var l;
|
|
83
|
+
return a.program === e.airlineProgram && ((l = a.cashFee) == null ? void 0 : l.amount) !== 0;
|
|
84
|
+
}
|
|
85
|
+
)) == null ? void 0 : t.cashFee;
|
|
86
|
+
}, [e.paymentOptions, e.airlineProgram]), ie = async () => {
|
|
87
|
+
if (!e || !M || !e.points || !e.cash)
|
|
88
|
+
return;
|
|
89
|
+
const i = e.currency;
|
|
90
|
+
let t = {
|
|
91
|
+
valueCents: 1,
|
|
92
|
+
currency: i
|
|
93
|
+
};
|
|
94
|
+
try {
|
|
95
|
+
t = await q.ensureQueryData({
|
|
96
|
+
queryKey: [b.VALUE_CENTS, e.airlineProgram],
|
|
97
|
+
staleTime: 1e3 * 60 * 60,
|
|
98
|
+
// 1 hour
|
|
99
|
+
queryFn: () => U.getCentPerPoint(e.airlineProgram)
|
|
100
|
+
});
|
|
101
|
+
} catch (ne) {
|
|
102
|
+
console.warn(
|
|
103
|
+
"Failed to fetch value cents for airline program:",
|
|
104
|
+
e.airlineProgram,
|
|
105
|
+
ne
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
const a = g ?? {
|
|
109
|
+
amount: 0,
|
|
110
|
+
currency: i
|
|
111
|
+
}, [l, p] = await Promise.all([
|
|
112
|
+
z(
|
|
113
|
+
a.amount,
|
|
114
|
+
a.currency,
|
|
115
|
+
i
|
|
116
|
+
),
|
|
117
|
+
z(
|
|
118
|
+
t.valueCents,
|
|
119
|
+
t.currency,
|
|
120
|
+
i
|
|
121
|
+
)
|
|
122
|
+
]), A = p * e.points / 100 + l < e.cash;
|
|
123
|
+
Y(
|
|
124
|
+
A ? "points" : "cash"
|
|
125
|
+
/* CASH */
|
|
126
|
+
);
|
|
127
|
+
};
|
|
128
|
+
return O(() => {
|
|
129
|
+
ie();
|
|
130
|
+
}, [e, M, g]), O(() => {
|
|
131
|
+
const i = m(e.expiresAt), t = m();
|
|
132
|
+
if (!(i.year() === m(0).year()) && i.isAfter(t)) {
|
|
133
|
+
const l = i.diff(t), p = setTimeout(() => {
|
|
134
|
+
H(!0);
|
|
135
|
+
}, l);
|
|
136
|
+
return () => {
|
|
137
|
+
clearTimeout(p);
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
}, [e.expiresAt]), /* @__PURE__ */ r(
|
|
141
|
+
"div",
|
|
142
|
+
{
|
|
143
|
+
className: `${w ? "" : "awayz-"}flight-result`,
|
|
144
|
+
onClick: ee,
|
|
145
|
+
children: /* @__PURE__ */ n("div", { className: "content", children: [
|
|
146
|
+
/* @__PURE__ */ r("div", { className: "flight-info", children: /* @__PURE__ */ n("div", { className: "flight-locations", children: [
|
|
147
|
+
/* @__PURE__ */ r("div", { className: "airlines", children: B.map((i, t) => /* @__PURE__ */ r(he.Fragment, { children: /* @__PURE__ */ n("div", { className: "tip", children: [
|
|
148
|
+
/* @__PURE__ */ r(
|
|
149
|
+
"img",
|
|
150
|
+
{
|
|
151
|
+
src: i.logo,
|
|
152
|
+
alt: i.airline,
|
|
153
|
+
onError: (a) => a.currentTarget.src = (F == null ? void 0 : F.logoFallbackImageUrl) ?? ""
|
|
154
|
+
}
|
|
155
|
+
),
|
|
156
|
+
/* @__PURE__ */ r("span", { className: "right", children: i.airline })
|
|
157
|
+
] }, t) }, t)) }),
|
|
158
|
+
/* @__PURE__ */ n("div", { className: "flight-location", children: [
|
|
159
|
+
/* @__PURE__ */ n("p", { className: "show-desktop", children: [
|
|
160
|
+
u.city,
|
|
161
|
+
",",
|
|
162
|
+
R(u.country)
|
|
163
|
+
] }),
|
|
164
|
+
/* @__PURE__ */ r("p", { className: "show-desktop", children: m(e.departureTime).format(
|
|
165
|
+
h(N.DATE_TIME_MEDIUM, v.FlightShortDate)
|
|
166
|
+
) }),
|
|
167
|
+
/* @__PURE__ */ r("p", { className: "show-mobile", children: u.airportCode }),
|
|
168
|
+
/* @__PURE__ */ r("p", { className: "show-mobile", children: m(e.departureTime).format(
|
|
169
|
+
h(N.TIME_ONLY, v.FlightTime)
|
|
170
|
+
) })
|
|
171
|
+
] }),
|
|
172
|
+
/* @__PURE__ */ n("div", { className: "flight-duration", children: [
|
|
173
|
+
/* @__PURE__ */ r("span", { className: "line" }),
|
|
174
|
+
/* @__PURE__ */ n("p", { children: [
|
|
175
|
+
ce(k.slices[0].duration),
|
|
176
|
+
" ",
|
|
177
|
+
" - ",
|
|
178
|
+
e.numberOfStops > 0 ? `${e.numberOfStops} ${ve(
|
|
179
|
+
e.numberOfStops,
|
|
180
|
+
"Stop"
|
|
181
|
+
)}` : "Direct"
|
|
182
|
+
] }),
|
|
183
|
+
/* @__PURE__ */ r("span", { className: "line" })
|
|
184
|
+
] }),
|
|
185
|
+
/* @__PURE__ */ n("div", { children: [
|
|
186
|
+
/* @__PURE__ */ n("p", { className: "show-desktop", children: [
|
|
187
|
+
d.city,
|
|
188
|
+
", ",
|
|
189
|
+
R(d.country)
|
|
190
|
+
] }),
|
|
191
|
+
/* @__PURE__ */ n("p", { className: "show-desktop", children: [
|
|
192
|
+
m(e.arrivalTime).format(
|
|
193
|
+
h(N.DATE_TIME_MEDIUM, v.FlightShortDate)
|
|
194
|
+
),
|
|
195
|
+
" "
|
|
196
|
+
] }),
|
|
197
|
+
/* @__PURE__ */ r("p", { className: "show-mobile", children: d.airportCode }),
|
|
198
|
+
/* @__PURE__ */ r("p", { className: "show-mobile", children: m(e.arrivalTime).format(
|
|
199
|
+
h(N.TIME_ONLY, v.FlightTime)
|
|
200
|
+
) })
|
|
201
|
+
] })
|
|
202
|
+
] }) }),
|
|
203
|
+
/* @__PURE__ */ n("div", { className: "flight-footer", children: [
|
|
204
|
+
/* @__PURE__ */ r("div", { className: "flight-detail-container", children: /* @__PURE__ */ n(
|
|
205
|
+
"div",
|
|
206
|
+
{
|
|
207
|
+
className: "flight-detail",
|
|
208
|
+
onClick: (i) => {
|
|
209
|
+
i.stopPropagation(), G(!x);
|
|
210
|
+
},
|
|
211
|
+
children: [
|
|
212
|
+
/* @__PURE__ */ r("p", { children: "Aircraft" }),
|
|
213
|
+
/* @__PURE__ */ n("p", { className: "chevron-text", children: [
|
|
214
|
+
/* @__PURE__ */ r(me, {}),
|
|
215
|
+
/* @__PURE__ */ n("span", { children: [
|
|
216
|
+
C[0],
|
|
217
|
+
C.length > 1 && /* @__PURE__ */ n("sup", { children: [
|
|
218
|
+
"+",
|
|
219
|
+
C.length - 1
|
|
220
|
+
] })
|
|
221
|
+
] })
|
|
222
|
+
] })
|
|
223
|
+
]
|
|
224
|
+
}
|
|
225
|
+
) }),
|
|
226
|
+
/* @__PURE__ */ r("div", { className: "booking-options ", children: j ? /* @__PURE__ */ n("div", { className: "offer-expiry", children: [
|
|
227
|
+
/* @__PURE__ */ r("span", { children: /* @__PURE__ */ r(I, {}) }),
|
|
228
|
+
/* @__PURE__ */ r("p", { className: "expired-tip", children: "Offer Expired" })
|
|
229
|
+
] }) : /* @__PURE__ */ n(S, { children: [
|
|
230
|
+
K || e.cash > 0 && /* @__PURE__ */ n(
|
|
231
|
+
"div",
|
|
232
|
+
{
|
|
233
|
+
className: `amount-value ${f === "cash" && c ? "show-best-value-flag" : ""}`,
|
|
234
|
+
onClick: (i) => {
|
|
235
|
+
i.stopPropagation(), s(e, E.CASH);
|
|
236
|
+
},
|
|
237
|
+
children: [
|
|
238
|
+
/* @__PURE__ */ r("b", { children: "Cash" }),
|
|
239
|
+
/* @__PURE__ */ n("div", { children: [
|
|
240
|
+
/* @__PURE__ */ r("label", { children: J ? "Book For" : "From" }),
|
|
241
|
+
/* @__PURE__ */ r(
|
|
242
|
+
_,
|
|
243
|
+
{
|
|
244
|
+
amount: e.cash,
|
|
245
|
+
currency: e.currency,
|
|
246
|
+
position: L.LEFT
|
|
247
|
+
}
|
|
248
|
+
)
|
|
249
|
+
] }),
|
|
250
|
+
f === "cash" && c && /* @__PURE__ */ n(
|
|
251
|
+
"div",
|
|
252
|
+
{
|
|
253
|
+
className: "best-value-flag tip",
|
|
254
|
+
onClick: (i) => {
|
|
255
|
+
i.stopPropagation(), o == null || o(e);
|
|
256
|
+
},
|
|
257
|
+
children: [
|
|
258
|
+
o && /* @__PURE__ */ r(I, {}),
|
|
259
|
+
/* @__PURE__ */ r("p", { children: "Best Value" }),
|
|
260
|
+
o && /* @__PURE__ */ r("span", { children: "Click to learn more" })
|
|
261
|
+
]
|
|
262
|
+
}
|
|
263
|
+
)
|
|
264
|
+
]
|
|
265
|
+
}
|
|
266
|
+
),
|
|
267
|
+
Q || e.points > 0 && /* @__PURE__ */ n(
|
|
268
|
+
"div",
|
|
269
|
+
{
|
|
270
|
+
className: `amount-value ${f === "points" && c ? "show-best-value-flag" : ""}`,
|
|
271
|
+
onClick: (i) => {
|
|
272
|
+
i.stopPropagation(), s(e, E.POINTS);
|
|
273
|
+
},
|
|
274
|
+
children: [
|
|
275
|
+
f === "points" && c && /* @__PURE__ */ n(
|
|
276
|
+
"div",
|
|
277
|
+
{
|
|
278
|
+
className: "best-value-flag tip",
|
|
279
|
+
onClick: (i) => {
|
|
280
|
+
i.stopPropagation(), o == null || o(e);
|
|
281
|
+
},
|
|
282
|
+
children: [
|
|
283
|
+
o && /* @__PURE__ */ r(I, {}),
|
|
284
|
+
/* @__PURE__ */ r("p", { children: "Best Value" }),
|
|
285
|
+
o && /* @__PURE__ */ r("span", { children: "Click to learn more" })
|
|
286
|
+
]
|
|
287
|
+
}
|
|
288
|
+
),
|
|
289
|
+
/* @__PURE__ */ r("div", { className: "amount-airline-logo", children: /* @__PURE__ */ r("img", { src: X.programLogo }) }),
|
|
290
|
+
/* @__PURE__ */ n("div", { children: [
|
|
291
|
+
/* @__PURE__ */ r("label", { children: W ? "Book For" : "From" }),
|
|
292
|
+
/* @__PURE__ */ n("p", { children: [
|
|
293
|
+
`${Pe(e.points)} ${h(
|
|
294
|
+
"miles"
|
|
295
|
+
)}`,
|
|
296
|
+
!!g && /* @__PURE__ */ n(S, { children: [
|
|
297
|
+
" + ",
|
|
298
|
+
/* @__PURE__ */ r(
|
|
299
|
+
_,
|
|
300
|
+
{
|
|
301
|
+
amount: g.amount,
|
|
302
|
+
currency: g.currency,
|
|
303
|
+
customDisplay: "No fee",
|
|
304
|
+
zeroDisplayOption: se.CUSTOM,
|
|
305
|
+
position: L.LEFT
|
|
306
|
+
}
|
|
307
|
+
)
|
|
308
|
+
] })
|
|
309
|
+
] })
|
|
310
|
+
] })
|
|
311
|
+
]
|
|
312
|
+
}
|
|
313
|
+
)
|
|
314
|
+
] }) })
|
|
315
|
+
] }),
|
|
316
|
+
/* @__PURE__ */ r("div", { className: `flight-details ${x ? "is-open" : ""}`, children: /* @__PURE__ */ r("div", { className: "inner", children: /* @__PURE__ */ r(
|
|
317
|
+
pe,
|
|
318
|
+
{
|
|
319
|
+
itinerary: k.slices[0].segments,
|
|
320
|
+
origin: u,
|
|
321
|
+
destination: d,
|
|
322
|
+
isMultiDayFlight: re
|
|
323
|
+
}
|
|
324
|
+
) }) })
|
|
325
|
+
] })
|
|
326
|
+
}
|
|
327
|
+
);
|
|
328
|
+
};
|
|
329
|
+
export {
|
|
330
|
+
Ue as F,
|
|
331
|
+
Pe as c
|
|
332
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "react/jsx-runtime";
|
|
2
2
|
import "@odynn/awayz-core";
|
|
3
3
|
import "@tanstack/react-query";
|
|
4
|
-
import { F as x } from "../../FlightResult-
|
|
4
|
+
import { F as x } from "../../FlightResult-KDQSMbR8.js";
|
|
5
5
|
import "../../index-7zRjF0bU.js";
|
|
6
6
|
import "../../FlightItinerary-Dy-2zMYt.js";
|
|
7
7
|
import "../../enums-D9aZqf8G.js";
|
package/dist/components/index.js
CHANGED
package/dist/main.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useFlightSearch as o } from "./hooks/useFlightSearch/useFlightSearch.js";
|
|
2
2
|
import { useAirportSearch as g } from "./hooks/useAirportSearch/useAirportSearch.js";
|
|
3
3
|
import { EBaggage as s } from "./hooks/useFlightSearch/useFlightSearch.types.js";
|
|
4
|
-
import { F as f, c as l } from "./FlightResult-
|
|
4
|
+
import { F as f, c as l } from "./FlightResult-KDQSMbR8.js";
|
|
5
5
|
import { EPaymentType as x } from "./enums/EPaymentType.js";
|
|
6
6
|
import { DEFAULT_AIRLINE_PROGRAM as C, getAirlineProgram as E, getFlightNumber as F, getLogoPath as c } from "./utils/flightUtils.js";
|
|
7
7
|
import { isSameDayFlight as y } from "./utils/flightDateUtils.js";
|
package/package.json
CHANGED
|
@@ -1,328 +0,0 @@
|
|
|
1
|
-
import { jsx as e, jsxs as n, Fragment as M } from "react/jsx-runtime";
|
|
2
|
-
import { useAwayzContext as tr, RewardsService as S, CashValue as U, EToolTipPosition as _, EInvalidAmountDisplayOption as sr, awayzClient as q, CurrencyService as ar } from "@odynn/awayz-core";
|
|
3
|
-
import { useQuery as or } from "@tanstack/react-query";
|
|
4
|
-
import { g as cr } from "./index-7zRjF0bU.js";
|
|
5
|
-
import { G as lr, g as L, a as N, E as v, F as mr, b as pr } from "./FlightItinerary-Dy-2zMYt.js";
|
|
6
|
-
import { E as O } from "./enums-D9aZqf8G.js";
|
|
7
|
-
import "./arrayExtensions-DFLvtO8l.js";
|
|
8
|
-
import hr, { useState as P, useMemo as R, useEffect as $ } from "react";
|
|
9
|
-
import { h as m } from "./moment-BGjjqtLQ.js";
|
|
10
|
-
import { useTranslation as gr } from "react-i18next";
|
|
11
|
-
import { EPaymentType as E } from "./enums/EPaymentType.js";
|
|
12
|
-
import { isSameDayFlight as fr } from "./utils/flightDateUtils.js";
|
|
13
|
-
import { DEFAULT_AIRLINE_PROGRAM as ur, getFlightNumber as dr, getLogoPath as yr, getAirlineProgram as Nr } from "./utils/flightUtils.js";
|
|
14
|
-
import './assets/FlightResult.css';const vr = (r, s, o = s + "s") => r === 1 ? s : o;
|
|
15
|
-
function Pr(r) {
|
|
16
|
-
if (!r || isNaN(r) || r < 0) return "N/A";
|
|
17
|
-
let s = r == null ? void 0 : r.toString().split(".")[0];
|
|
18
|
-
return s == null ? void 0 : s.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
19
|
-
}
|
|
20
|
-
function A(r) {
|
|
21
|
-
return lr({ attr: { viewBox: "0 0 512 512" }, child: [{ tag: "path", attr: { d: "M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM216 336l24 0 0-64-24 0c-13.3 0-24-10.7-24-24s10.7-24 24-24l48 0c13.3 0 24 10.7 24 24l0 88 8 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-80 0c-13.3 0-24-10.7-24-24s10.7-24 24-24zm40-208a32 32 0 1 1 0 64 32 32 0 1 1 0-64z" }, child: [] }] })(r);
|
|
22
|
-
}
|
|
23
|
-
async function z(r, s, o) {
|
|
24
|
-
if (!r || s === o) return r;
|
|
25
|
-
const a = await q.ensureQueryData({
|
|
26
|
-
queryKey: [O.CONVERT_CURRENCY, s, o],
|
|
27
|
-
staleTime: 1e3 * 60 * 60,
|
|
28
|
-
// 1 hour
|
|
29
|
-
queryFn: () => ar.convertCurrency({
|
|
30
|
-
baseCurrency: s,
|
|
31
|
-
targetCurrency: o
|
|
32
|
-
})
|
|
33
|
-
});
|
|
34
|
-
return r * a;
|
|
35
|
-
}
|
|
36
|
-
const Ur = ({
|
|
37
|
-
details: r,
|
|
38
|
-
onClick: s,
|
|
39
|
-
showBestValue: o = !1,
|
|
40
|
-
onShowBestValueCalculation: a,
|
|
41
|
-
customStyling: w = !1,
|
|
42
|
-
customCashComponent: K,
|
|
43
|
-
customPointsComponent: Q
|
|
44
|
-
}) => {
|
|
45
|
-
const { t: h } = gr(), [I, G] = P(!1), [f, Y] = P(
|
|
46
|
-
"none"
|
|
47
|
-
/* NONE */
|
|
48
|
-
), [j, H] = P(!1), { config: F } = tr(), u = r.origin, d = r.destination, b = r.flightDetails, x = r.paymentOptions || [], J = x.filter((i) => i.points === -1).length === 1, W = x.filter((i) => i.points > -1).length === 1, [X, Z] = P(ur), V = async () => {
|
|
49
|
-
const i = await Nr(r.airlineProgram);
|
|
50
|
-
Z(i);
|
|
51
|
-
}, { flightNumbers: T, airlines: B } = R(() => {
|
|
52
|
-
const i = [], t = [];
|
|
53
|
-
return r.flightDetails.slices.forEach((c) => {
|
|
54
|
-
c.segments.forEach((l) => {
|
|
55
|
-
const p = dr(l);
|
|
56
|
-
i.includes(p) || i.push(p);
|
|
57
|
-
const y = l.operatingCarrier;
|
|
58
|
-
t.some((D) => D.airline === y.name) || t.push({
|
|
59
|
-
logo: yr(y.iataCode),
|
|
60
|
-
airline: y.name
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
}), V(), { flightNumbers: i, airlines: t };
|
|
64
|
-
}, [r.flightDetails.slices]), rr = () => {
|
|
65
|
-
r.cash > 0 ? s(r, E.CASH) : s(r, E.POINTS);
|
|
66
|
-
}, er = !fr(
|
|
67
|
-
r.departureTime,
|
|
68
|
-
r.arrivalTime
|
|
69
|
-
), C = r == null ? void 0 : r.airlineProgram, { data: k } = or({
|
|
70
|
-
queryKey: [O.VALUE_CENTS, C, "test"],
|
|
71
|
-
queryFn: () => S.getCentPerPoint(C),
|
|
72
|
-
staleTime: 1 / 0,
|
|
73
|
-
enabled: !!C && o
|
|
74
|
-
}), g = R(() => {
|
|
75
|
-
var i, t;
|
|
76
|
-
return (t = (i = r.paymentOptions) == null ? void 0 : i.find(
|
|
77
|
-
(c) => {
|
|
78
|
-
var l;
|
|
79
|
-
return c.program === r.airlineProgram && ((l = c.cashFee) == null ? void 0 : l.amount) !== 0;
|
|
80
|
-
}
|
|
81
|
-
)) == null ? void 0 : t.cashFee;
|
|
82
|
-
}, [r.paymentOptions, r.airlineProgram]), ir = async () => {
|
|
83
|
-
if (!r || !k || !r.points || !r.cash)
|
|
84
|
-
return;
|
|
85
|
-
const i = r.currency;
|
|
86
|
-
let t = {
|
|
87
|
-
valueCents: 1,
|
|
88
|
-
currency: i
|
|
89
|
-
};
|
|
90
|
-
try {
|
|
91
|
-
t = await q.ensureQueryData({
|
|
92
|
-
queryKey: [O.VALUE_CENTS, r.airlineProgram],
|
|
93
|
-
staleTime: 1e3 * 60 * 60,
|
|
94
|
-
// 1 hour
|
|
95
|
-
queryFn: () => S.getCentPerPoint(r.airlineProgram)
|
|
96
|
-
});
|
|
97
|
-
} catch (nr) {
|
|
98
|
-
console.warn(
|
|
99
|
-
"Failed to fetch value cents for airline program:",
|
|
100
|
-
r.airlineProgram,
|
|
101
|
-
nr
|
|
102
|
-
);
|
|
103
|
-
}
|
|
104
|
-
const c = g ?? {
|
|
105
|
-
amount: 0,
|
|
106
|
-
currency: i
|
|
107
|
-
}, [l, p] = await Promise.all([
|
|
108
|
-
z(
|
|
109
|
-
c.amount,
|
|
110
|
-
c.currency,
|
|
111
|
-
i
|
|
112
|
-
),
|
|
113
|
-
z(
|
|
114
|
-
t.valueCents,
|
|
115
|
-
t.currency,
|
|
116
|
-
i
|
|
117
|
-
)
|
|
118
|
-
]), D = p * r.points / 100 + l < r.cash;
|
|
119
|
-
Y(
|
|
120
|
-
D ? "points" : "cash"
|
|
121
|
-
/* CASH */
|
|
122
|
-
);
|
|
123
|
-
};
|
|
124
|
-
return $(() => {
|
|
125
|
-
ir();
|
|
126
|
-
}, [r, k, g]), $(() => {
|
|
127
|
-
const i = m(r.expiresAt), t = m();
|
|
128
|
-
if (!(i.year() === m(0).year()) && i.isAfter(t)) {
|
|
129
|
-
const l = i.diff(t), p = setTimeout(() => {
|
|
130
|
-
H(!0);
|
|
131
|
-
}, l);
|
|
132
|
-
return () => {
|
|
133
|
-
clearTimeout(p);
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
}, [r.expiresAt]), /* @__PURE__ */ e(
|
|
137
|
-
"div",
|
|
138
|
-
{
|
|
139
|
-
className: `${w ? "" : "awayz-"}flight-result`,
|
|
140
|
-
onClick: rr,
|
|
141
|
-
children: /* @__PURE__ */ n("div", { className: "content", children: [
|
|
142
|
-
/* @__PURE__ */ e("div", { className: "flight-info", children: /* @__PURE__ */ n("div", { className: "flight-locations", children: [
|
|
143
|
-
/* @__PURE__ */ e("div", { className: "airlines", children: B.map((i, t) => /* @__PURE__ */ e(hr.Fragment, { children: /* @__PURE__ */ n("div", { className: "tip", children: [
|
|
144
|
-
/* @__PURE__ */ e(
|
|
145
|
-
"img",
|
|
146
|
-
{
|
|
147
|
-
src: i.logo,
|
|
148
|
-
alt: i.airline,
|
|
149
|
-
onError: (c) => c.currentTarget.src = (F == null ? void 0 : F.logoFallbackImageUrl) ?? ""
|
|
150
|
-
}
|
|
151
|
-
),
|
|
152
|
-
/* @__PURE__ */ e("span", { className: "right", children: i.airline })
|
|
153
|
-
] }, t) }, t)) }),
|
|
154
|
-
/* @__PURE__ */ n("div", { className: "flight-location", children: [
|
|
155
|
-
/* @__PURE__ */ n("p", { className: "show-desktop", children: [
|
|
156
|
-
u.city,
|
|
157
|
-
",",
|
|
158
|
-
L(u.country)
|
|
159
|
-
] }),
|
|
160
|
-
/* @__PURE__ */ e("p", { className: "show-desktop", children: m(r.departureTime).format(
|
|
161
|
-
h(N.DATE_TIME_MEDIUM, v.FlightShortDate)
|
|
162
|
-
) }),
|
|
163
|
-
/* @__PURE__ */ e("p", { className: "show-mobile", children: u.airportCode }),
|
|
164
|
-
/* @__PURE__ */ e("p", { className: "show-mobile", children: m(r.departureTime).format(
|
|
165
|
-
h(N.TIME_ONLY, v.FlightTime)
|
|
166
|
-
) })
|
|
167
|
-
] }),
|
|
168
|
-
/* @__PURE__ */ n("div", { className: "flight-duration", children: [
|
|
169
|
-
/* @__PURE__ */ e("span", { className: "line" }),
|
|
170
|
-
/* @__PURE__ */ n("p", { children: [
|
|
171
|
-
cr(b.slices[0].duration),
|
|
172
|
-
" ",
|
|
173
|
-
" - ",
|
|
174
|
-
r.numberOfStops > 0 ? `${r.numberOfStops} ${vr(
|
|
175
|
-
r.numberOfStops,
|
|
176
|
-
"Stop"
|
|
177
|
-
)}` : "Direct"
|
|
178
|
-
] }),
|
|
179
|
-
/* @__PURE__ */ e("span", { className: "line" })
|
|
180
|
-
] }),
|
|
181
|
-
/* @__PURE__ */ n("div", { children: [
|
|
182
|
-
/* @__PURE__ */ n("p", { className: "show-desktop", children: [
|
|
183
|
-
d.city,
|
|
184
|
-
", ",
|
|
185
|
-
L(d.country)
|
|
186
|
-
] }),
|
|
187
|
-
/* @__PURE__ */ n("p", { className: "show-desktop", children: [
|
|
188
|
-
m(r.arrivalTime).format(
|
|
189
|
-
h(N.DATE_TIME_MEDIUM, v.FlightShortDate)
|
|
190
|
-
),
|
|
191
|
-
" "
|
|
192
|
-
] }),
|
|
193
|
-
/* @__PURE__ */ e("p", { className: "show-mobile", children: d.airportCode }),
|
|
194
|
-
/* @__PURE__ */ e("p", { className: "show-mobile", children: m(r.arrivalTime).format(
|
|
195
|
-
h(N.TIME_ONLY, v.FlightTime)
|
|
196
|
-
) })
|
|
197
|
-
] })
|
|
198
|
-
] }) }),
|
|
199
|
-
/* @__PURE__ */ n("div", { className: "flight-footer", children: [
|
|
200
|
-
/* @__PURE__ */ e("div", { className: "flight-detail-container", children: /* @__PURE__ */ n(
|
|
201
|
-
"div",
|
|
202
|
-
{
|
|
203
|
-
className: "flight-detail",
|
|
204
|
-
onClick: (i) => {
|
|
205
|
-
i.stopPropagation(), G(!I);
|
|
206
|
-
},
|
|
207
|
-
children: [
|
|
208
|
-
/* @__PURE__ */ e("p", { children: "Aircraft" }),
|
|
209
|
-
/* @__PURE__ */ n("p", { className: "chevron-text", children: [
|
|
210
|
-
/* @__PURE__ */ e(mr, {}),
|
|
211
|
-
/* @__PURE__ */ n("span", { children: [
|
|
212
|
-
T[0],
|
|
213
|
-
T.length > 1 && /* @__PURE__ */ n("sup", { children: [
|
|
214
|
-
"+",
|
|
215
|
-
T.length - 1
|
|
216
|
-
] })
|
|
217
|
-
] })
|
|
218
|
-
] })
|
|
219
|
-
]
|
|
220
|
-
}
|
|
221
|
-
) }),
|
|
222
|
-
/* @__PURE__ */ e("div", { className: "booking-options ", children: j ? /* @__PURE__ */ n("div", { className: "offer-expiry", children: [
|
|
223
|
-
/* @__PURE__ */ e("span", { children: /* @__PURE__ */ e(A, {}) }),
|
|
224
|
-
/* @__PURE__ */ e("p", { className: "expired-tip", children: "Offer Expired" })
|
|
225
|
-
] }) : /* @__PURE__ */ n(M, { children: [
|
|
226
|
-
K || r.cash > 0 && /* @__PURE__ */ n(
|
|
227
|
-
"div",
|
|
228
|
-
{
|
|
229
|
-
className: `amount-value ${f === "cash" && o ? "show-best-value-flag" : ""}`,
|
|
230
|
-
onClick: (i) => {
|
|
231
|
-
i.stopPropagation(), s(r, E.CASH);
|
|
232
|
-
},
|
|
233
|
-
children: [
|
|
234
|
-
/* @__PURE__ */ e("b", { children: "Cash" }),
|
|
235
|
-
/* @__PURE__ */ n("div", { children: [
|
|
236
|
-
/* @__PURE__ */ e("label", { children: J ? "Book For" : "From" }),
|
|
237
|
-
/* @__PURE__ */ e(
|
|
238
|
-
U,
|
|
239
|
-
{
|
|
240
|
-
amount: r.cash,
|
|
241
|
-
currency: r.currency,
|
|
242
|
-
position: _.LEFT
|
|
243
|
-
}
|
|
244
|
-
)
|
|
245
|
-
] }),
|
|
246
|
-
f === "cash" && o && /* @__PURE__ */ n(
|
|
247
|
-
"div",
|
|
248
|
-
{
|
|
249
|
-
className: "best-value-flag tip",
|
|
250
|
-
onClick: (i) => {
|
|
251
|
-
i.stopPropagation(), a == null || a(r);
|
|
252
|
-
},
|
|
253
|
-
children: [
|
|
254
|
-
a && /* @__PURE__ */ e(A, {}),
|
|
255
|
-
/* @__PURE__ */ e("p", { children: "Best Value" }),
|
|
256
|
-
a && /* @__PURE__ */ e("span", { children: "Click to learn more" })
|
|
257
|
-
]
|
|
258
|
-
}
|
|
259
|
-
)
|
|
260
|
-
]
|
|
261
|
-
}
|
|
262
|
-
),
|
|
263
|
-
Q || r.points > 0 && /* @__PURE__ */ n(
|
|
264
|
-
"div",
|
|
265
|
-
{
|
|
266
|
-
className: `amount-value ${f === "points" && o ? "show-best-value-flag" : ""}`,
|
|
267
|
-
onClick: (i) => {
|
|
268
|
-
i.stopPropagation(), s(r, E.POINTS);
|
|
269
|
-
},
|
|
270
|
-
children: [
|
|
271
|
-
f === "points" && o && /* @__PURE__ */ n(
|
|
272
|
-
"div",
|
|
273
|
-
{
|
|
274
|
-
className: "best-value-flag tip",
|
|
275
|
-
onClick: (i) => {
|
|
276
|
-
i.stopPropagation(), a == null || a(r);
|
|
277
|
-
},
|
|
278
|
-
children: [
|
|
279
|
-
a && /* @__PURE__ */ e(A, {}),
|
|
280
|
-
/* @__PURE__ */ e("p", { children: "Best Value" }),
|
|
281
|
-
a && /* @__PURE__ */ e("span", { children: "Click to learn more" })
|
|
282
|
-
]
|
|
283
|
-
}
|
|
284
|
-
),
|
|
285
|
-
/* @__PURE__ */ e("div", { className: "amount-airline-logo", children: /* @__PURE__ */ e("img", { src: X.programLogo }) }),
|
|
286
|
-
/* @__PURE__ */ n("div", { children: [
|
|
287
|
-
/* @__PURE__ */ e("label", { children: W ? "Book For" : "From" }),
|
|
288
|
-
/* @__PURE__ */ n("p", { children: [
|
|
289
|
-
`${Pr(r.points)} ${h(
|
|
290
|
-
"miles"
|
|
291
|
-
)}`,
|
|
292
|
-
!!g && /* @__PURE__ */ n(M, { children: [
|
|
293
|
-
" + ",
|
|
294
|
-
/* @__PURE__ */ e(
|
|
295
|
-
U,
|
|
296
|
-
{
|
|
297
|
-
amount: g.amount,
|
|
298
|
-
currency: g.currency,
|
|
299
|
-
customDisplay: "No fee",
|
|
300
|
-
zeroDisplayOption: sr.CUSTOM,
|
|
301
|
-
position: _.LEFT
|
|
302
|
-
}
|
|
303
|
-
)
|
|
304
|
-
] })
|
|
305
|
-
] })
|
|
306
|
-
] })
|
|
307
|
-
]
|
|
308
|
-
}
|
|
309
|
-
)
|
|
310
|
-
] }) })
|
|
311
|
-
] }),
|
|
312
|
-
/* @__PURE__ */ e("div", { className: `flight-details ${I ? "is-open" : ""}`, children: /* @__PURE__ */ e("div", { className: "inner", children: /* @__PURE__ */ e(
|
|
313
|
-
pr,
|
|
314
|
-
{
|
|
315
|
-
itinerary: b.slices[0].segments,
|
|
316
|
-
origin: u,
|
|
317
|
-
destination: d,
|
|
318
|
-
isMultiDayFlight: er
|
|
319
|
-
}
|
|
320
|
-
) }) })
|
|
321
|
-
] })
|
|
322
|
-
}
|
|
323
|
-
);
|
|
324
|
-
};
|
|
325
|
-
export {
|
|
326
|
-
Ur as F,
|
|
327
|
-
Pr as c
|
|
328
|
-
};
|