@odynn/awayz-flights 0.9.9 → 0.9.10
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.
|
@@ -6,9 +6,9 @@ import { g as X } from "../../dateUtils-Cb9VQiIL.js";
|
|
|
6
6
|
import "../../arrayExtensions-Ce8YopTP.js";
|
|
7
7
|
import { E as H } from "../../enums-tLvxh02p.js";
|
|
8
8
|
import { E as T, F as Z } from "../../FlightItinerary-C4KPpVcF.js";
|
|
9
|
-
import { useRef as
|
|
9
|
+
import { useRef as Ce, useState as A, useMemo as v, useEffect as k } from "react";
|
|
10
10
|
import { h as g } from "../../moment-BGjjqtLQ.js";
|
|
11
|
-
import { useTranslation as
|
|
11
|
+
import { useTranslation as be } from "react-i18next";
|
|
12
12
|
import { b as W, c as _e, d as Se, e as Ie, f as x } from "../../index-9LVJi5JO.js";
|
|
13
13
|
import { EPaymentType as d } from "../../enums/EPaymentType.js";
|
|
14
14
|
import { DEFAULT_AIRLINE_PROGRAM as B, getFlightNumber as Re, getLogoPath as Le, getAirlineProgram as ke } from "../../utils/flightUtils.js";
|
|
@@ -16,59 +16,59 @@ import ee from "../Dialog/Dialog.js";
|
|
|
16
16
|
import ie from "../HorizontalScroller/HorizontalScroller.js";
|
|
17
17
|
import '../../assets/_styles.css';/* empty css */
|
|
18
18
|
const xe = (...e) => e.join(" ");
|
|
19
|
-
async function re(e,
|
|
20
|
-
if (!e ||
|
|
21
|
-
const
|
|
22
|
-
queryKey: [H.CONVERT_CURRENCY,
|
|
19
|
+
async function re(e, p, l) {
|
|
20
|
+
if (!e || p === l) return e;
|
|
21
|
+
const c = await ne.ensureQueryData({
|
|
22
|
+
queryKey: [H.CONVERT_CURRENCY, p, l],
|
|
23
23
|
staleTime: 1e3 * 60 * 60,
|
|
24
24
|
// 1 hour
|
|
25
25
|
queryFn: () => Ae.convertCurrency({
|
|
26
|
-
baseCurrency:
|
|
26
|
+
baseCurrency: p,
|
|
27
27
|
targetCurrency: l
|
|
28
28
|
})
|
|
29
29
|
});
|
|
30
|
-
return e *
|
|
30
|
+
return e * c;
|
|
31
31
|
}
|
|
32
|
-
const
|
|
32
|
+
const ii = ({
|
|
33
33
|
details: e,
|
|
34
|
-
onClick:
|
|
34
|
+
onClick: p,
|
|
35
35
|
showBestValue: l = !1,
|
|
36
|
-
onShowBestValueCalculation:
|
|
36
|
+
onShowBestValueCalculation: c,
|
|
37
37
|
customStyling: se = !1,
|
|
38
38
|
customCashComponent: ae,
|
|
39
39
|
customPointsComponent: te,
|
|
40
40
|
onBookWithCash: D,
|
|
41
41
|
onBookWithPoints: O
|
|
42
42
|
}) => {
|
|
43
|
-
const { t: N } =
|
|
43
|
+
const { t: N } = be(), C = Ce(null), [U, ce] = A(!1), [F, le] = A(
|
|
44
44
|
"none"
|
|
45
45
|
/* NONE */
|
|
46
|
-
), [oe, me] = A(!1), { config:
|
|
46
|
+
), [oe, me] = A(!1), { config: b } = Fe(), he = e.origin, pe = e.destination, P = e.flightDetails, m = e.paymentOptions || [], { featureFlags: h } = Pe(), _ = v(
|
|
47
47
|
() => m.filter((i) => i.points === -1),
|
|
48
48
|
[m]
|
|
49
49
|
), S = v(
|
|
50
50
|
() => m.filter((i) => i.points > -1),
|
|
51
51
|
[m]
|
|
52
|
-
),
|
|
53
|
-
var i = m.filter((s) => s.points > -1).sort((s,
|
|
52
|
+
), V = m.filter((i) => i.points === -1).length === 1, ge = m.filter((i) => i.points > -1).length === 1, [fe, $] = A(B), a = v(() => {
|
|
53
|
+
var i = m.filter((s) => s.points > -1).sort((s, t) => s.points - t.points);
|
|
54
54
|
return i.find(
|
|
55
55
|
(s) => s.program === e.airlineProgram
|
|
56
56
|
) || i[0];
|
|
57
57
|
}, [m, e.airlineProgram]), ue = async () => {
|
|
58
|
-
if (!
|
|
59
|
-
|
|
58
|
+
if (!a) {
|
|
59
|
+
$(B);
|
|
60
60
|
return;
|
|
61
61
|
}
|
|
62
|
-
const i = await ke(
|
|
63
|
-
|
|
62
|
+
const i = await ke(a.program);
|
|
63
|
+
$(i);
|
|
64
64
|
};
|
|
65
65
|
k(() => {
|
|
66
66
|
ue();
|
|
67
|
-
}, [
|
|
67
|
+
}, [a]);
|
|
68
68
|
const { flightNumbers: de, airlines: y } = v(() => {
|
|
69
69
|
const i = [], s = [];
|
|
70
|
-
return e.flightDetails.slices.forEach((
|
|
71
|
-
|
|
70
|
+
return e.flightDetails.slices.forEach((t) => {
|
|
71
|
+
t.segments.forEach((o) => {
|
|
72
72
|
const f = Re(o);
|
|
73
73
|
i.includes(f) || i.push(f);
|
|
74
74
|
const E = o.operatingCarrier;
|
|
@@ -79,8 +79,8 @@ const Be = ({
|
|
|
79
79
|
});
|
|
80
80
|
}), { flightNumbers: i, airlines: s };
|
|
81
81
|
}, [e.flightDetails.slices]), Ne = () => {
|
|
82
|
-
|
|
83
|
-
}, I = e == null ? void 0 : e.airlineProgram, { data:
|
|
82
|
+
h.flightBookingOptionsDisplayFeature === G.SHEET || e.partial ? e.cash > 0 ? p(e, d.CASH) : p(e, d.POINTS) : K();
|
|
83
|
+
}, I = e == null ? void 0 : e.airlineProgram, { data: M } = De({
|
|
84
84
|
queryKey: [H.VALUE_CENTS, I, "test"],
|
|
85
85
|
queryFn: () => Y.getCentPerPoint(I),
|
|
86
86
|
staleTime: 1 / 0,
|
|
@@ -88,13 +88,13 @@ const Be = ({
|
|
|
88
88
|
}), q = v(() => {
|
|
89
89
|
var i, s;
|
|
90
90
|
return (s = (i = e.paymentOptions) == null ? void 0 : i.find(
|
|
91
|
-
(
|
|
91
|
+
(t) => {
|
|
92
92
|
var o;
|
|
93
|
-
return
|
|
93
|
+
return t.program === e.airlineProgram && ((o = t.cashFee) == null ? void 0 : o.amount) !== 0;
|
|
94
94
|
}
|
|
95
95
|
)) == null ? void 0 : s.cashFee;
|
|
96
96
|
}, [e.paymentOptions, e.airlineProgram]), ye = async () => {
|
|
97
|
-
if (!e || !
|
|
97
|
+
if (!e || !M || !e.points || !e.cash)
|
|
98
98
|
return;
|
|
99
99
|
const i = e.currency;
|
|
100
100
|
let s = {
|
|
@@ -115,13 +115,13 @@ const Be = ({
|
|
|
115
115
|
ve
|
|
116
116
|
);
|
|
117
117
|
}
|
|
118
|
-
const
|
|
118
|
+
const t = q ?? {
|
|
119
119
|
amount: 0,
|
|
120
120
|
currency: i
|
|
121
121
|
}, [o, f] = await Promise.all([
|
|
122
122
|
re(
|
|
123
|
-
|
|
124
|
-
|
|
123
|
+
t.amount,
|
|
124
|
+
t.currency,
|
|
125
125
|
i
|
|
126
126
|
),
|
|
127
127
|
re(
|
|
@@ -137,7 +137,7 @@ const Be = ({
|
|
|
137
137
|
};
|
|
138
138
|
k(() => {
|
|
139
139
|
ye();
|
|
140
|
-
}, [e,
|
|
140
|
+
}, [e, M, q]), k(() => {
|
|
141
141
|
const i = g(e.expiresAt), s = g();
|
|
142
142
|
if (!(i.year() === g(0).year()) && i.isAfter(s)) {
|
|
143
143
|
const o = i.diff(s), f = setTimeout(() => {
|
|
@@ -148,13 +148,13 @@ const Be = ({
|
|
|
148
148
|
};
|
|
149
149
|
}
|
|
150
150
|
}, [e.expiresAt]);
|
|
151
|
-
const z = (i, s,
|
|
152
|
-
i.stopPropagation(),
|
|
151
|
+
const z = (i, s, t) => {
|
|
152
|
+
i.stopPropagation(), h.flightBookingOptionsDisplayFeature === G.SHEET || t.partial ? p(t, s) : K();
|
|
153
153
|
}, K = () => {
|
|
154
154
|
const i = !U;
|
|
155
|
-
ce(i), i &&
|
|
155
|
+
ce(i), i && C.current && C.current.scrollIntoView({ behavior: "smooth" });
|
|
156
156
|
};
|
|
157
|
-
return /* @__PURE__ */ r(
|
|
157
|
+
return !(e.cash > 0) && !!!a ? null : /* @__PURE__ */ r(
|
|
158
158
|
"div",
|
|
159
159
|
{
|
|
160
160
|
className: `${se ? "" : "awayz-"}flight-result`,
|
|
@@ -168,7 +168,7 @@ const Be = ({
|
|
|
168
168
|
{
|
|
169
169
|
src: y[0].logo,
|
|
170
170
|
alt: y[0].airline,
|
|
171
|
-
onError: (i) => i.currentTarget.src = (
|
|
171
|
+
onError: (i) => i.currentTarget.src = (b == null ? void 0 : b.logoFallbackImageUrl) ?? ""
|
|
172
172
|
}
|
|
173
173
|
),
|
|
174
174
|
/* @__PURE__ */ n("div", { children: [
|
|
@@ -206,7 +206,7 @@ const Be = ({
|
|
|
206
206
|
] }),
|
|
207
207
|
/* @__PURE__ */ n("div", { className: "flight-location", children: [
|
|
208
208
|
/* @__PURE__ */ r("div", { className: "flight-location-icon", children: /* @__PURE__ */ r(_e, {}) }),
|
|
209
|
-
/* @__PURE__ */ r("p", { children:
|
|
209
|
+
/* @__PURE__ */ r("p", { children: he.airportCode })
|
|
210
210
|
] })
|
|
211
211
|
] }),
|
|
212
212
|
/* @__PURE__ */ n("div", { className: "flight-icon", children: [
|
|
@@ -241,7 +241,7 @@ const Be = ({
|
|
|
241
241
|
" "
|
|
242
242
|
] }),
|
|
243
243
|
/* @__PURE__ */ n("div", { className: "flight-location", children: [
|
|
244
|
-
/* @__PURE__ */ r("p", { children:
|
|
244
|
+
/* @__PURE__ */ r("p", { children: pe.airportCode }),
|
|
245
245
|
/* @__PURE__ */ r("div", { className: "flight-location-icon", children: /* @__PURE__ */ r(Ie, {}) })
|
|
246
246
|
] })
|
|
247
247
|
] })
|
|
@@ -266,15 +266,15 @@ const Be = ({
|
|
|
266
266
|
className: xe(
|
|
267
267
|
"amount-value",
|
|
268
268
|
F === "cash" && l ? "show-best-value-flag" : "",
|
|
269
|
-
|
|
269
|
+
h.amountsDisplayFeature !== u.CASH_AND_TRAVEL_PARTNER_POINTS ? "lg" : ""
|
|
270
270
|
),
|
|
271
271
|
onClick: (i) => {
|
|
272
272
|
z(i, d.CASH, e);
|
|
273
273
|
},
|
|
274
274
|
children: [
|
|
275
|
-
|
|
275
|
+
h.amountsDisplayFeature === u.CASH_AND_TRAVEL_PARTNER_POINTS ? /* @__PURE__ */ r("b", { children: "Cash" }) : /* @__PURE__ */ r("b", { children: V ? "Book For" : "From" }),
|
|
276
276
|
/* @__PURE__ */ n("div", { children: [
|
|
277
|
-
|
|
277
|
+
h.amountsDisplayFeature === u.CASH_AND_TRAVEL_PARTNER_POINTS && /* @__PURE__ */ r("label", { children: V ? "Book For" : "From" }),
|
|
278
278
|
/* @__PURE__ */ n("span", { className: "flight-cash-amount-value", children: [
|
|
279
279
|
/* @__PURE__ */ r(
|
|
280
280
|
Q,
|
|
@@ -284,7 +284,7 @@ const Be = ({
|
|
|
284
284
|
position: j.LEFT
|
|
285
285
|
}
|
|
286
286
|
),
|
|
287
|
-
|
|
287
|
+
h.amountsDisplayFeature === u.CASH_AND_CLIENT_POINTS && /* @__PURE__ */ n(L, { children: [
|
|
288
288
|
"/",
|
|
289
289
|
" ",
|
|
290
290
|
/* @__PURE__ */ r(
|
|
@@ -297,24 +297,24 @@ const Be = ({
|
|
|
297
297
|
] })
|
|
298
298
|
] })
|
|
299
299
|
] }),
|
|
300
|
-
F === "cash" &&
|
|
300
|
+
F === "cash" && h.amountsDisplayFeature === u.CASH_AND_TRAVEL_PARTNER_POINTS && l && /* @__PURE__ */ n(
|
|
301
301
|
"div",
|
|
302
302
|
{
|
|
303
303
|
className: "best-value-flag tip",
|
|
304
304
|
onClick: (i) => {
|
|
305
|
-
i.stopPropagation(),
|
|
305
|
+
i.stopPropagation(), c == null || c(e);
|
|
306
306
|
},
|
|
307
307
|
children: [
|
|
308
|
-
|
|
308
|
+
c && /* @__PURE__ */ r(x, {}),
|
|
309
309
|
/* @__PURE__ */ r("p", { children: "Best Value" }),
|
|
310
|
-
|
|
310
|
+
c && /* @__PURE__ */ r("span", { children: "Click to learn more" })
|
|
311
311
|
]
|
|
312
312
|
}
|
|
313
313
|
)
|
|
314
314
|
]
|
|
315
315
|
}
|
|
316
316
|
),
|
|
317
|
-
te || e.points > 0 &&
|
|
317
|
+
te || e.points > 0 && a && h.amountsDisplayFeature === u.CASH_AND_TRAVEL_PARTNER_POINTS && /* @__PURE__ */ n(
|
|
318
318
|
"div",
|
|
319
319
|
{
|
|
320
320
|
className: `amount-value ${F === "points" && l ? "show-best-value-flag" : ""}`,
|
|
@@ -327,12 +327,12 @@ const Be = ({
|
|
|
327
327
|
{
|
|
328
328
|
className: "best-value-flag tip",
|
|
329
329
|
onClick: (i) => {
|
|
330
|
-
i.stopPropagation(),
|
|
330
|
+
i.stopPropagation(), c == null || c(e);
|
|
331
331
|
},
|
|
332
332
|
children: [
|
|
333
|
-
|
|
333
|
+
c && /* @__PURE__ */ r(x, {}),
|
|
334
334
|
/* @__PURE__ */ r("p", { children: "Best Value" }),
|
|
335
|
-
|
|
335
|
+
c && /* @__PURE__ */ r("span", { children: "Click to learn more" })
|
|
336
336
|
]
|
|
337
337
|
}
|
|
338
338
|
),
|
|
@@ -341,15 +341,15 @@ const Be = ({
|
|
|
341
341
|
/* @__PURE__ */ r("label", { children: ge ? "Book For" : "From" }),
|
|
342
342
|
/* @__PURE__ */ n("p", { children: [
|
|
343
343
|
`${Oe(
|
|
344
|
-
|
|
344
|
+
a == null ? void 0 : a.points
|
|
345
345
|
)} ${N("miles")}`,
|
|
346
|
-
!!(
|
|
346
|
+
!!(a != null && a.cashFee) && /* @__PURE__ */ n(L, { children: [
|
|
347
347
|
" + ",
|
|
348
348
|
/* @__PURE__ */ r(
|
|
349
349
|
Q,
|
|
350
350
|
{
|
|
351
|
-
amount:
|
|
352
|
-
currency:
|
|
351
|
+
amount: a.cashFee.amount,
|
|
352
|
+
currency: a.cashFee.currency,
|
|
353
353
|
customDisplay: "No fee",
|
|
354
354
|
zeroDisplayOption: Te.CUSTOM,
|
|
355
355
|
position: j.LEFT
|
|
@@ -363,7 +363,7 @@ const Be = ({
|
|
|
363
363
|
)
|
|
364
364
|
] }) })
|
|
365
365
|
] }),
|
|
366
|
-
/* @__PURE__ */ r("div", { className: `flight-details ${U ? "is-open" : ""}`, children: /* @__PURE__ */ r("div", { ref:
|
|
366
|
+
/* @__PURE__ */ r("div", { className: `flight-details ${U ? "is-open" : ""}`, children: /* @__PURE__ */ r("div", { ref: C, className: "inner", children: /* @__PURE__ */ n("div", { className: "flight-booking-options", children: [
|
|
367
367
|
_.length > 0 && /* @__PURE__ */ n("div", { className: "booking-options-section", children: [
|
|
368
368
|
S.length > 0 && /* @__PURE__ */ r("p", { className: "booking-options-title", children: "Cash Options" }),
|
|
369
369
|
/* @__PURE__ */ r(ie, { children: _.map((i, s) => /* @__PURE__ */ r(
|
|
@@ -414,5 +414,5 @@ const Be = ({
|
|
|
414
414
|
);
|
|
415
415
|
};
|
|
416
416
|
export {
|
|
417
|
-
|
|
417
|
+
ii as FlightResult
|
|
418
418
|
};
|
|
@@ -37,4 +37,4 @@ export interface IFlightResultProps {
|
|
|
37
37
|
onBookWithCash?: (flightDetails: IFlightPaymentOption, flightResult?: IFlightResult) => void;
|
|
38
38
|
onBookWithPoints?: (flightDetails: IFlightPaymentOption) => void;
|
|
39
39
|
}
|
|
40
|
-
export declare const FlightResult: ({ details, onClick, showBestValue, onShowBestValueCalculation, customStyling, customCashComponent, customPointsComponent, onBookWithCash, onBookWithPoints }: IFlightResultProps) => import("react/jsx-runtime").JSX.Element;
|
|
40
|
+
export declare const FlightResult: ({ details, onClick, showBestValue, onShowBestValueCalculation, customStyling, customCashComponent, customPointsComponent, onBookWithCash, onBookWithPoints }: IFlightResultProps) => import("react/jsx-runtime").JSX.Element | null;
|