@odynn/awayz-flights 0.7.8 → 0.7.9
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/FlightResult-5gEbjZT0.js +335 -0
- package/dist/components/FlightResult/FlightResult.js +2 -2
- package/dist/components/index.js +1 -1
- package/dist/enums-Bmg_7eKJ.js +4 -0
- package/dist/hooks/useFlightSearch/useFlightSearch.js +2 -2
- package/dist/lib/hooks/useFlightSearch/useFlightSearch.types.d.ts +2 -1
- package/dist/main.js +1 -1
- package/dist/{objectUtils-CyIaVmog.js → objectUtils-3IeCVocm.js} +2 -5
- package/dist/services/flights/FlightsService.js +1 -1
- package/dist/services/wallet/WalletService.js +1 -1
- package/dist/utils/flightUtils.js +45 -43
- package/package.json +1 -1
- package/dist/FlightResult-KDQSMbR8.js +0 -332
- package/dist/enums-D9aZqf8G.js +0 -4
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
import { jsx as i, jsxs as n, Fragment as S } from "react/jsx-runtime";
|
|
2
|
+
import { useAwayzContext as tr, RewardsService as U, CashValue as _, EToolTipPosition as L, 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 R, a as N, E as v, F as mr, b as pr } from "./FlightItinerary-Dy-2zMYt.js";
|
|
6
|
+
import { E as b } from "./enums-Bmg_7eKJ.js";
|
|
7
|
+
import "./arrayExtensions-DFLvtO8l.js";
|
|
8
|
+
import hr, { useState as P, useEffect as A, useMemo as $ } from "react";
|
|
9
|
+
import { h as p } 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, l = s + "s") => r === 1 ? s : l;
|
|
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 I(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, l) {
|
|
24
|
+
if (!r || s === l) return r;
|
|
25
|
+
const o = await q.ensureQueryData({
|
|
26
|
+
queryKey: [b.CONVERT_CURRENCY, s, l],
|
|
27
|
+
staleTime: 1e3 * 60 * 60,
|
|
28
|
+
// 1 hour
|
|
29
|
+
queryFn: () => ar.convertCurrency({
|
|
30
|
+
baseCurrency: s,
|
|
31
|
+
targetCurrency: l
|
|
32
|
+
})
|
|
33
|
+
});
|
|
34
|
+
return r * o;
|
|
35
|
+
}
|
|
36
|
+
const Ur = ({
|
|
37
|
+
details: r,
|
|
38
|
+
onClick: s,
|
|
39
|
+
showBestValue: l = !1,
|
|
40
|
+
onShowBestValueCalculation: o,
|
|
41
|
+
customStyling: w = !1,
|
|
42
|
+
customCashComponent: K,
|
|
43
|
+
customPointsComponent: Q
|
|
44
|
+
}) => {
|
|
45
|
+
const { t: h } = gr(), [x, G] = P(!1), [f, Y] = P(
|
|
46
|
+
"none"
|
|
47
|
+
/* NONE */
|
|
48
|
+
), [j, H] = P(!1), { config: F } = tr(), u = r.origin, d = r.destination, k = r.flightDetails, T = r.paymentOptions || [], J = T.filter((e) => e.points === -1).length === 1, W = T.filter((e) => e.points > -1).length === 1, [X, Z] = P(ur), V = async () => {
|
|
49
|
+
var e = T.filter((a) => a.points > -1).sort((a, m) => a.points - m.points);
|
|
50
|
+
const t = e.find(
|
|
51
|
+
(a) => a.program === r.airlineProgram
|
|
52
|
+
) || e[0], c = await Nr(t.program);
|
|
53
|
+
Z(c);
|
|
54
|
+
};
|
|
55
|
+
A(() => {
|
|
56
|
+
V();
|
|
57
|
+
}, [r.paymentOptions]);
|
|
58
|
+
const { flightNumbers: C, airlines: B } = $(() => {
|
|
59
|
+
const e = [], t = [];
|
|
60
|
+
return r.flightDetails.slices.forEach((c) => {
|
|
61
|
+
c.segments.forEach((a) => {
|
|
62
|
+
const m = dr(a);
|
|
63
|
+
e.includes(m) || e.push(m);
|
|
64
|
+
const y = a.operatingCarrier;
|
|
65
|
+
t.some((O) => O.airline === y.name) || t.push({
|
|
66
|
+
logo: yr(y.iataCode),
|
|
67
|
+
airline: y.name
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
}), { flightNumbers: e, airlines: t };
|
|
71
|
+
}, [r.flightDetails.slices]), rr = () => {
|
|
72
|
+
r.cash > 0 ? s(r, E.CASH) : s(r, E.POINTS);
|
|
73
|
+
}, er = !fr(
|
|
74
|
+
r.departureTime,
|
|
75
|
+
r.arrivalTime
|
|
76
|
+
), D = r == null ? void 0 : r.airlineProgram, { data: M } = or({
|
|
77
|
+
queryKey: [b.VALUE_CENTS, D, "test"],
|
|
78
|
+
queryFn: () => U.getCentPerPoint(D),
|
|
79
|
+
staleTime: 1 / 0,
|
|
80
|
+
enabled: !!D && l
|
|
81
|
+
}), g = $(() => {
|
|
82
|
+
var e, t;
|
|
83
|
+
return (t = (e = r.paymentOptions) == null ? void 0 : e.find(
|
|
84
|
+
(c) => {
|
|
85
|
+
var a;
|
|
86
|
+
return c.program === r.airlineProgram && ((a = c.cashFee) == null ? void 0 : a.amount) !== 0;
|
|
87
|
+
}
|
|
88
|
+
)) == null ? void 0 : t.cashFee;
|
|
89
|
+
}, [r.paymentOptions, r.airlineProgram]), ir = async () => {
|
|
90
|
+
if (!r || !M || !r.points || !r.cash)
|
|
91
|
+
return;
|
|
92
|
+
const e = r.currency;
|
|
93
|
+
let t = {
|
|
94
|
+
valueCents: 1,
|
|
95
|
+
currency: e
|
|
96
|
+
};
|
|
97
|
+
try {
|
|
98
|
+
t = await q.ensureQueryData({
|
|
99
|
+
queryKey: [b.VALUE_CENTS, r.airlineProgram],
|
|
100
|
+
staleTime: 1e3 * 60 * 60,
|
|
101
|
+
// 1 hour
|
|
102
|
+
queryFn: () => U.getCentPerPoint(r.airlineProgram)
|
|
103
|
+
});
|
|
104
|
+
} catch (nr) {
|
|
105
|
+
console.warn(
|
|
106
|
+
"Failed to fetch value cents for airline program:",
|
|
107
|
+
r.airlineProgram,
|
|
108
|
+
nr
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
const c = g ?? {
|
|
112
|
+
amount: 0,
|
|
113
|
+
currency: e
|
|
114
|
+
}, [a, m] = await Promise.all([
|
|
115
|
+
z(
|
|
116
|
+
c.amount,
|
|
117
|
+
c.currency,
|
|
118
|
+
e
|
|
119
|
+
),
|
|
120
|
+
z(
|
|
121
|
+
t.valueCents,
|
|
122
|
+
t.currency,
|
|
123
|
+
e
|
|
124
|
+
)
|
|
125
|
+
]), O = m * r.points / 100 + a < r.cash;
|
|
126
|
+
Y(
|
|
127
|
+
O ? "points" : "cash"
|
|
128
|
+
/* CASH */
|
|
129
|
+
);
|
|
130
|
+
};
|
|
131
|
+
return A(() => {
|
|
132
|
+
ir();
|
|
133
|
+
}, [r, M, g]), A(() => {
|
|
134
|
+
const e = p(r.expiresAt), t = p();
|
|
135
|
+
if (!(e.year() === p(0).year()) && e.isAfter(t)) {
|
|
136
|
+
const a = e.diff(t), m = setTimeout(() => {
|
|
137
|
+
H(!0);
|
|
138
|
+
}, a);
|
|
139
|
+
return () => {
|
|
140
|
+
clearTimeout(m);
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
}, [r.expiresAt]), /* @__PURE__ */ i(
|
|
144
|
+
"div",
|
|
145
|
+
{
|
|
146
|
+
className: `${w ? "" : "awayz-"}flight-result`,
|
|
147
|
+
onClick: rr,
|
|
148
|
+
children: /* @__PURE__ */ n("div", { className: "content", children: [
|
|
149
|
+
/* @__PURE__ */ i("div", { className: "flight-info", children: /* @__PURE__ */ n("div", { className: "flight-locations", children: [
|
|
150
|
+
/* @__PURE__ */ i("div", { className: "airlines", children: B.map((e, t) => /* @__PURE__ */ i(hr.Fragment, { children: /* @__PURE__ */ n("div", { className: "tip", children: [
|
|
151
|
+
/* @__PURE__ */ i(
|
|
152
|
+
"img",
|
|
153
|
+
{
|
|
154
|
+
src: e.logo,
|
|
155
|
+
alt: e.airline,
|
|
156
|
+
onError: (c) => c.currentTarget.src = (F == null ? void 0 : F.logoFallbackImageUrl) ?? ""
|
|
157
|
+
}
|
|
158
|
+
),
|
|
159
|
+
/* @__PURE__ */ i("span", { className: "right", children: e.airline })
|
|
160
|
+
] }, t) }, t)) }),
|
|
161
|
+
/* @__PURE__ */ n("div", { className: "flight-location", children: [
|
|
162
|
+
/* @__PURE__ */ n("p", { className: "show-desktop", children: [
|
|
163
|
+
u.city,
|
|
164
|
+
",",
|
|
165
|
+
R(u.country)
|
|
166
|
+
] }),
|
|
167
|
+
/* @__PURE__ */ i("p", { className: "show-desktop", children: p(r.departureTime).format(
|
|
168
|
+
h(N.DATE_TIME_MEDIUM, v.FlightShortDate)
|
|
169
|
+
) }),
|
|
170
|
+
/* @__PURE__ */ i("p", { className: "show-mobile", children: u.airportCode }),
|
|
171
|
+
/* @__PURE__ */ i("p", { className: "show-mobile", children: p(r.departureTime).format(
|
|
172
|
+
h(N.TIME_ONLY, v.FlightTime)
|
|
173
|
+
) })
|
|
174
|
+
] }),
|
|
175
|
+
/* @__PURE__ */ n("div", { className: "flight-duration", children: [
|
|
176
|
+
/* @__PURE__ */ i("span", { className: "line" }),
|
|
177
|
+
/* @__PURE__ */ n("p", { children: [
|
|
178
|
+
cr(k.slices[0].duration),
|
|
179
|
+
" ",
|
|
180
|
+
" - ",
|
|
181
|
+
r.numberOfStops > 0 ? `${r.numberOfStops} ${vr(
|
|
182
|
+
r.numberOfStops,
|
|
183
|
+
"Stop"
|
|
184
|
+
)}` : "Direct"
|
|
185
|
+
] }),
|
|
186
|
+
/* @__PURE__ */ i("span", { className: "line" })
|
|
187
|
+
] }),
|
|
188
|
+
/* @__PURE__ */ n("div", { children: [
|
|
189
|
+
/* @__PURE__ */ n("p", { className: "show-desktop", children: [
|
|
190
|
+
d.city,
|
|
191
|
+
", ",
|
|
192
|
+
R(d.country)
|
|
193
|
+
] }),
|
|
194
|
+
/* @__PURE__ */ n("p", { className: "show-desktop", children: [
|
|
195
|
+
p(r.arrivalTime).format(
|
|
196
|
+
h(N.DATE_TIME_MEDIUM, v.FlightShortDate)
|
|
197
|
+
),
|
|
198
|
+
" "
|
|
199
|
+
] }),
|
|
200
|
+
/* @__PURE__ */ i("p", { className: "show-mobile", children: d.airportCode }),
|
|
201
|
+
/* @__PURE__ */ i("p", { className: "show-mobile", children: p(r.arrivalTime).format(
|
|
202
|
+
h(N.TIME_ONLY, v.FlightTime)
|
|
203
|
+
) })
|
|
204
|
+
] })
|
|
205
|
+
] }) }),
|
|
206
|
+
/* @__PURE__ */ n("div", { className: "flight-footer", children: [
|
|
207
|
+
/* @__PURE__ */ i("div", { className: "flight-detail-container", children: /* @__PURE__ */ n(
|
|
208
|
+
"div",
|
|
209
|
+
{
|
|
210
|
+
className: "flight-detail",
|
|
211
|
+
onClick: (e) => {
|
|
212
|
+
e.stopPropagation(), G(!x);
|
|
213
|
+
},
|
|
214
|
+
children: [
|
|
215
|
+
/* @__PURE__ */ i("p", { children: "Aircraft" }),
|
|
216
|
+
/* @__PURE__ */ n("p", { className: "chevron-text", children: [
|
|
217
|
+
/* @__PURE__ */ i(mr, {}),
|
|
218
|
+
/* @__PURE__ */ n("span", { children: [
|
|
219
|
+
C[0],
|
|
220
|
+
C.length > 1 && /* @__PURE__ */ n("sup", { children: [
|
|
221
|
+
"+",
|
|
222
|
+
C.length - 1
|
|
223
|
+
] })
|
|
224
|
+
] })
|
|
225
|
+
] })
|
|
226
|
+
]
|
|
227
|
+
}
|
|
228
|
+
) }),
|
|
229
|
+
/* @__PURE__ */ i("div", { className: "booking-options ", children: j ? /* @__PURE__ */ n("div", { className: "offer-expiry", children: [
|
|
230
|
+
/* @__PURE__ */ i("span", { children: /* @__PURE__ */ i(I, {}) }),
|
|
231
|
+
/* @__PURE__ */ i("p", { className: "expired-tip", children: "Offer Expired" })
|
|
232
|
+
] }) : /* @__PURE__ */ n(S, { children: [
|
|
233
|
+
K || r.cash > 0 && /* @__PURE__ */ n(
|
|
234
|
+
"div",
|
|
235
|
+
{
|
|
236
|
+
className: `amount-value ${f === "cash" && l ? "show-best-value-flag" : ""}`,
|
|
237
|
+
onClick: (e) => {
|
|
238
|
+
e.stopPropagation(), s(r, E.CASH);
|
|
239
|
+
},
|
|
240
|
+
children: [
|
|
241
|
+
/* @__PURE__ */ i("b", { children: "Cash" }),
|
|
242
|
+
/* @__PURE__ */ n("div", { children: [
|
|
243
|
+
/* @__PURE__ */ i("label", { children: J ? "Book For" : "From" }),
|
|
244
|
+
/* @__PURE__ */ i(
|
|
245
|
+
_,
|
|
246
|
+
{
|
|
247
|
+
amount: r.cash,
|
|
248
|
+
currency: r.currency,
|
|
249
|
+
position: L.LEFT
|
|
250
|
+
}
|
|
251
|
+
)
|
|
252
|
+
] }),
|
|
253
|
+
f === "cash" && l && /* @__PURE__ */ n(
|
|
254
|
+
"div",
|
|
255
|
+
{
|
|
256
|
+
className: "best-value-flag tip",
|
|
257
|
+
onClick: (e) => {
|
|
258
|
+
e.stopPropagation(), o == null || o(r);
|
|
259
|
+
},
|
|
260
|
+
children: [
|
|
261
|
+
o && /* @__PURE__ */ i(I, {}),
|
|
262
|
+
/* @__PURE__ */ i("p", { children: "Best Value" }),
|
|
263
|
+
o && /* @__PURE__ */ i("span", { children: "Click to learn more" })
|
|
264
|
+
]
|
|
265
|
+
}
|
|
266
|
+
)
|
|
267
|
+
]
|
|
268
|
+
}
|
|
269
|
+
),
|
|
270
|
+
Q || r.points > 0 && /* @__PURE__ */ n(
|
|
271
|
+
"div",
|
|
272
|
+
{
|
|
273
|
+
className: `amount-value ${f === "points" && l ? "show-best-value-flag" : ""}`,
|
|
274
|
+
onClick: (e) => {
|
|
275
|
+
e.stopPropagation(), s(r, E.POINTS);
|
|
276
|
+
},
|
|
277
|
+
children: [
|
|
278
|
+
f === "points" && l && /* @__PURE__ */ n(
|
|
279
|
+
"div",
|
|
280
|
+
{
|
|
281
|
+
className: "best-value-flag tip",
|
|
282
|
+
onClick: (e) => {
|
|
283
|
+
e.stopPropagation(), o == null || o(r);
|
|
284
|
+
},
|
|
285
|
+
children: [
|
|
286
|
+
o && /* @__PURE__ */ i(I, {}),
|
|
287
|
+
/* @__PURE__ */ i("p", { children: "Best Value" }),
|
|
288
|
+
o && /* @__PURE__ */ i("span", { children: "Click to learn more" })
|
|
289
|
+
]
|
|
290
|
+
}
|
|
291
|
+
),
|
|
292
|
+
/* @__PURE__ */ i("div", { className: "amount-airline-logo", children: /* @__PURE__ */ i("img", { src: X.programLogo }) }),
|
|
293
|
+
/* @__PURE__ */ n("div", { children: [
|
|
294
|
+
/* @__PURE__ */ i("label", { children: W ? "Book For" : "From" }),
|
|
295
|
+
/* @__PURE__ */ n("p", { children: [
|
|
296
|
+
`${Pr(r.points)} ${h(
|
|
297
|
+
"miles"
|
|
298
|
+
)}`,
|
|
299
|
+
!!g && /* @__PURE__ */ n(S, { children: [
|
|
300
|
+
" + ",
|
|
301
|
+
/* @__PURE__ */ i(
|
|
302
|
+
_,
|
|
303
|
+
{
|
|
304
|
+
amount: g.amount,
|
|
305
|
+
currency: g.currency,
|
|
306
|
+
customDisplay: "No fee",
|
|
307
|
+
zeroDisplayOption: sr.CUSTOM,
|
|
308
|
+
position: L.LEFT
|
|
309
|
+
}
|
|
310
|
+
)
|
|
311
|
+
] })
|
|
312
|
+
] })
|
|
313
|
+
] })
|
|
314
|
+
]
|
|
315
|
+
}
|
|
316
|
+
)
|
|
317
|
+
] }) })
|
|
318
|
+
] }),
|
|
319
|
+
/* @__PURE__ */ i("div", { className: `flight-details ${x ? "is-open" : ""}`, children: /* @__PURE__ */ i("div", { className: "inner", children: /* @__PURE__ */ i(
|
|
320
|
+
pr,
|
|
321
|
+
{
|
|
322
|
+
itinerary: k.slices[0].segments,
|
|
323
|
+
origin: u,
|
|
324
|
+
destination: d,
|
|
325
|
+
isMultiDayFlight: er
|
|
326
|
+
}
|
|
327
|
+
) }) })
|
|
328
|
+
] })
|
|
329
|
+
}
|
|
330
|
+
);
|
|
331
|
+
};
|
|
332
|
+
export {
|
|
333
|
+
Ur as F,
|
|
334
|
+
Pr as c
|
|
335
|
+
};
|
|
@@ -1,10 +1,10 @@
|
|
|
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-5gEbjZT0.js";
|
|
5
5
|
import "../../index-7zRjF0bU.js";
|
|
6
6
|
import "../../FlightItinerary-Dy-2zMYt.js";
|
|
7
|
-
import "../../enums-
|
|
7
|
+
import "../../enums-Bmg_7eKJ.js";
|
|
8
8
|
import "../../arrayExtensions-DFLvtO8l.js";
|
|
9
9
|
import "react";
|
|
10
10
|
import "../../moment-BGjjqtLQ.js";
|
package/dist/components/index.js
CHANGED
|
@@ -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))(S || {});
|
|
2
|
+
export {
|
|
3
|
+
S as E
|
|
4
|
+
};
|
|
@@ -2,8 +2,8 @@ import { useAwayzContext as V, awayzClient as _, getBaseUrl as G } from "@odynn/
|
|
|
2
2
|
import { useMutation as j } from "@tanstack/react-query";
|
|
3
3
|
import "../../moment-BGjjqtLQ.js";
|
|
4
4
|
import "../../arrayExtensions-DFLvtO8l.js";
|
|
5
|
-
import { c as U } from "../../objectUtils-
|
|
6
|
-
import { E as q } from "../../enums-
|
|
5
|
+
import { c as U } from "../../objectUtils-3IeCVocm.js";
|
|
6
|
+
import { E as q } from "../../enums-Bmg_7eKJ.js";
|
|
7
7
|
import { useState as x, useRef as X } from "react";
|
|
8
8
|
import { FlightService as k } from "../../services/flights/FlightsService.js";
|
|
9
9
|
import Z from "../../stores/useFlightStore.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IChangeCondition, ICoordinates, IPassenger, ISlice } from '@type-op/shared';
|
|
1
|
+
import { IChangeCondition, ICoordinates, IPassenger, ISlice, ITransferPartner } from '@type-op/shared';
|
|
2
2
|
import { EFlightPaymentType, EFlightType } from '../../types';
|
|
3
3
|
import { ECabinClass } from '../../types/ECabinClass';
|
|
4
4
|
export interface ISearchFlightArgs {
|
|
@@ -150,6 +150,7 @@ export interface IFlightResult {
|
|
|
150
150
|
currency: string;
|
|
151
151
|
cabinClass: string;
|
|
152
152
|
expiresAt: string;
|
|
153
|
+
transferPartners: ITransferPartner[];
|
|
153
154
|
}
|
|
154
155
|
export interface IAirportLocation {
|
|
155
156
|
city: string;
|
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-5gEbjZT0.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";
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
function c(e) {
|
|
2
|
-
return e = e.replace(/^_+/, ""), e.replace(/_([a-z])/g, (r, a) => a.toUpperCase());
|
|
3
|
-
}
|
|
4
1
|
const t = (e) => Array.isArray(e) ? e.map((r) => t(r)) : typeof e == "object" && e !== null ? Object.keys(e).reduce((r, a) => {
|
|
5
|
-
const n =
|
|
2
|
+
const n = s(a);
|
|
6
3
|
return r[n] = t(e[a]), r;
|
|
7
|
-
}, {}) : e;
|
|
4
|
+
}, {}) : e, s = (e) => (e = e.replace(/^_+/, ""), e.replace(/_([a-z])/gi, (r, a) => a.toUpperCase()));
|
|
8
5
|
export {
|
|
9
6
|
t as c
|
|
10
7
|
};
|
|
@@ -4,7 +4,7 @@ var o = (c, s, a) => p(c, typeof s != "symbol" ? s + "" : s, a);
|
|
|
4
4
|
import { clientInstance as d } from "@odynn/awayz-core";
|
|
5
5
|
import "../../moment-BGjjqtLQ.js";
|
|
6
6
|
import "../../arrayExtensions-DFLvtO8l.js";
|
|
7
|
-
import { c as f } from "../../objectUtils-
|
|
7
|
+
import { c as f } from "../../objectUtils-3IeCVocm.js";
|
|
8
8
|
import "react";
|
|
9
9
|
import { EFlightEndpoint as i } from "../../constants/endpoints.js";
|
|
10
10
|
class y {
|
|
@@ -5,7 +5,7 @@ import { ERewardProgramCategories as o } from "./WalletService.types.js";
|
|
|
5
5
|
import { clientInstance as n } from "@odynn/awayz-core";
|
|
6
6
|
import "../../moment-BGjjqtLQ.js";
|
|
7
7
|
import "../../arrayExtensions-DFLvtO8l.js";
|
|
8
|
-
import { c as a } from "../../objectUtils-
|
|
8
|
+
import { c as a } from "../../objectUtils-3IeCVocm.js";
|
|
9
9
|
import "react";
|
|
10
10
|
import { EWalletEndpoints as i } from "../../constants/endpoints.js";
|
|
11
11
|
class u {
|
|
@@ -8,14 +8,14 @@ import { mapBaggageType as Q } from "../hooks/useFlightSearch/useFlightSearch.ty
|
|
|
8
8
|
import { WalletService as W } from "../services/wallet/WalletService.js";
|
|
9
9
|
import { ERewardProgramCategories as J } from "../services/wallet/WalletService.types.js";
|
|
10
10
|
const ce = (t) => t == null ? void 0 : t.map((e) => {
|
|
11
|
-
var
|
|
11
|
+
var i, l, c, n, s, a, r, o, p, m, u, d, y, b, F, w, L, D, A, P, T, O, h, I, k, R, _, v, E, M, $, z, G, S;
|
|
12
12
|
return {
|
|
13
13
|
id: e.id,
|
|
14
14
|
points: (e == null ? void 0 : e.points) >= 0 ? e.points : -1,
|
|
15
15
|
partial: e == null ? void 0 : e.partial,
|
|
16
16
|
origin: {
|
|
17
|
-
city: ((
|
|
18
|
-
country: ((n = e.slices[0].segments[0].origin) == null ? void 0 : n.iataCountryCode) || ((
|
|
17
|
+
city: ((i = e.slices[0].segments[0].origin) == null ? void 0 : i.cityName) || ((c = (l = e.slices[0].segments[0].origin) == null ? void 0 : l.city) == null ? void 0 : c.name),
|
|
18
|
+
country: ((n = e.slices[0].segments[0].origin) == null ? void 0 : n.iataCountryCode) || ((a = (s = e.slices[0].segments[0].origin) == null ? void 0 : s.city) == null ? void 0 : a.iataCountryCode),
|
|
19
19
|
airportCode: ((r = e.slices[0].segments[0].origin) == null ? void 0 : r.iataCityCode) || ((p = (o = e.slices[0].segments[0].origin) == null ? void 0 : o.city) == null ? void 0 : p.iataCode),
|
|
20
20
|
coordinates: {
|
|
21
21
|
latitude: (u = (m = e.slices[0].segments[0].origin) == null ? void 0 : m.city) == null ? void 0 : u.latitude,
|
|
@@ -24,7 +24,7 @@ const ce = (t) => t == null ? void 0 : t.map((e) => {
|
|
|
24
24
|
},
|
|
25
25
|
destination: {
|
|
26
26
|
city: ((F = (b = e.slices[0].segments.getLast()) == null ? void 0 : b.destination) == null ? void 0 : F.cityName) || ((D = (L = (w = e.slices[0].segments.getLast()) == null ? void 0 : w.destination) == null ? void 0 : L.city) == null ? void 0 : D.name),
|
|
27
|
-
country: ((
|
|
27
|
+
country: ((P = (A = e.slices[0].segments.getLast()) == null ? void 0 : A.destination) == null ? void 0 : P.iataCountryCode) || ((h = (O = (T = e.slices[0].segments.getLast()) == null ? void 0 : T.destination) == null ? void 0 : O.city) == null ? void 0 : h.iataCountryCode),
|
|
28
28
|
airportCode: ((k = (I = e.slices[0].segments.getLast()) == null ? void 0 : I.destination) == null ? void 0 : k.iataCityCode) || ((v = (_ = (R = e.slices[0].segments.getLast()) == null ? void 0 : R.destination) == null ? void 0 : _.city) == null ? void 0 : v.iataCode),
|
|
29
29
|
coordinates: {
|
|
30
30
|
latitude: ($ = (M = (E = e.slices[0].segments.getLast()) == null ? void 0 : E.destination) == null ? void 0 : M.city) == null ? void 0 : $.latitude,
|
|
@@ -57,35 +57,36 @@ const ce = (t) => t == null ? void 0 : t.map((e) => {
|
|
|
57
57
|
}),
|
|
58
58
|
cashFee: e.cashFee,
|
|
59
59
|
cabinClass: e.slices[0].segments[0].passengers[0].cabinClass || e.slices[0].segments[0].passengers[0].cabin.name || e.slices[0].segments[0].passengers[0].cabinClassMarketingName || e.slices[0].segments[0].passengers[0].cabin.marketingName,
|
|
60
|
-
expiresAt: e.expiresAt
|
|
60
|
+
expiresAt: e.expiresAt,
|
|
61
|
+
transferPartners: []
|
|
61
62
|
};
|
|
62
63
|
}), q = (t) => {
|
|
63
|
-
const e = t.operatingCarrierFlightNumber ? t.operatingCarrier : t.marketingCarrier,
|
|
64
|
-
return e.iataCode + " " + X(
|
|
64
|
+
const e = t.operatingCarrierFlightNumber ? t.operatingCarrier : t.marketingCarrier, i = t.operatingCarrierFlightNumber ?? t.marketingCarrierFlightNumber;
|
|
65
|
+
return e.iataCode + " " + X(i);
|
|
65
66
|
}, me = ({
|
|
66
67
|
originCode: t,
|
|
67
68
|
destinationCode: e,
|
|
68
|
-
dates:
|
|
69
|
+
dates: i,
|
|
69
70
|
cabinClass: l,
|
|
70
71
|
passengerCount: c,
|
|
71
72
|
paymentType: n
|
|
72
73
|
}) => {
|
|
73
74
|
let s = `${j.CASH_POINTS_FLIGHT_SEARCH}?`;
|
|
74
|
-
return s += `origin=${t}`, s += `&destination=${e}`, s += `&departure_dates=[${
|
|
75
|
-
}, V = (t) => t.flightDetails.slices[0].segments.map((
|
|
75
|
+
return s += `origin=${t}`, s += `&destination=${e}`, s += `&departure_dates=[${i.map((a) => `"${a}"`).join(",")}]`, s += `&cabin_class=${l}`, s += `&adults=${c}`, s += `&cash_or_points=[${n}]`, s;
|
|
76
|
+
}, V = (t) => t.flightDetails.slices[0].segments.map((i) => q(i)).join("_") + "_" + g(t.departureTime).format("YYYYMMDD"), le = (t) => {
|
|
76
77
|
const e = {};
|
|
77
78
|
t.forEach((s) => {
|
|
78
|
-
const
|
|
79
|
-
if (e[
|
|
79
|
+
const a = V(s);
|
|
80
|
+
if (e[a]) {
|
|
80
81
|
const r = U(s);
|
|
81
|
-
e[
|
|
82
|
+
e[a].flight.paymentOptions.push(r);
|
|
82
83
|
const { lowestCash: o, currency: p, lowestPoints: m } = x(
|
|
83
|
-
e[
|
|
84
|
+
e[a].flight.paymentOptions
|
|
84
85
|
);
|
|
85
|
-
e[
|
|
86
|
+
e[a].flight.points = m, e[a].flight.cash = o, p && (e[a].flight.currency = p);
|
|
86
87
|
} else {
|
|
87
88
|
const { origin: r, destination: o } = s, p = [U(s)], m = x(p);
|
|
88
|
-
e[
|
|
89
|
+
e[a] = {
|
|
89
90
|
programs: [],
|
|
90
91
|
flight: {
|
|
91
92
|
id: s.awayzGroupId,
|
|
@@ -111,7 +112,7 @@ const ce = (t) => t == null ? void 0 : t.map((e) => {
|
|
|
111
112
|
numberOfStops: s.numberOfStops,
|
|
112
113
|
departureTime: s.departureTime,
|
|
113
114
|
arrivalTime: s.arrivalTime,
|
|
114
|
-
awayzGroupId:
|
|
115
|
+
awayzGroupId: a,
|
|
115
116
|
duration: s.duration,
|
|
116
117
|
airlineProgram: s.airlineProgram,
|
|
117
118
|
durationMinutes: B({
|
|
@@ -131,15 +132,16 @@ const ce = (t) => t == null ? void 0 : t.map((e) => {
|
|
|
131
132
|
currency: s.flightDetails.baseCurrency,
|
|
132
133
|
cashFee: s.cashFee,
|
|
133
134
|
cabinClass: s.flightDetails.slices[0].segments[0].passengers[0].cabinClass || s.flightDetails.slices[0].segments[0].passengers[0].cabin.name || s.flightDetails.slices[0].segments[0].passengers[0].cabinClassMarketingName || s.flightDetails.slices[0].segments[0].passengers[0].cabin.marketingName,
|
|
134
|
-
expiresAt: s.expiresAt
|
|
135
|
+
expiresAt: s.expiresAt,
|
|
136
|
+
transferPartners: s.transferPartners || []
|
|
135
137
|
}
|
|
136
138
|
};
|
|
137
139
|
}
|
|
138
|
-
s.airlineProgram && !e[
|
|
140
|
+
s.airlineProgram && !e[a].programs.includes(s.airlineProgram) && e[a].programs.push(s.airlineProgram);
|
|
139
141
|
});
|
|
140
|
-
const
|
|
142
|
+
const i = [];
|
|
141
143
|
Object.values(e).forEach((s) => {
|
|
142
|
-
const
|
|
144
|
+
const a = s.flight.paymentOptions.filter((r) => r.cash > 0).reduce(
|
|
143
145
|
(r, o) => o.cash < r.cash ? o : r,
|
|
144
146
|
{ cash: 1 / 0, carrier: { name: "", iataCode: "" } }
|
|
145
147
|
);
|
|
@@ -147,23 +149,23 @@ const ce = (t) => t == null ? void 0 : t.map((e) => {
|
|
|
147
149
|
const o = s.flight.paymentOptions.filter(
|
|
148
150
|
(m) => m.program === r && m.points > 0
|
|
149
151
|
), p = o.length > 0 ? Math.min(...o.map((m) => m.points)) : -1;
|
|
150
|
-
|
|
152
|
+
i.push({
|
|
151
153
|
...s.flight,
|
|
152
|
-
airline:
|
|
153
|
-
airlineLogo: C(
|
|
154
|
+
airline: a.carrier.name,
|
|
155
|
+
airlineLogo: C(a.carrier.iataCode),
|
|
154
156
|
airlineProgram: r,
|
|
155
|
-
cash:
|
|
157
|
+
cash: a.cash !== 1 / 0 ? a.cash : -1,
|
|
156
158
|
points: p
|
|
157
159
|
});
|
|
158
|
-
}) :
|
|
160
|
+
}) : i.push({
|
|
159
161
|
...s.flight,
|
|
160
|
-
airline:
|
|
161
|
-
airlineLogo: C(
|
|
162
|
-
cash:
|
|
162
|
+
airline: a.carrier.name,
|
|
163
|
+
airlineLogo: C(a.carrier.iataCode),
|
|
164
|
+
cash: a.cash !== 1 / 0 ? a.cash : -1
|
|
163
165
|
});
|
|
164
166
|
});
|
|
165
|
-
const { cashlessResults: l, otherResults: c } =
|
|
166
|
-
(s,
|
|
167
|
+
const { cashlessResults: l, otherResults: c } = i.reduce(
|
|
168
|
+
(s, a) => (a.cash <= 0 && a.points > 0 ? s.cashlessResults.push(a) : a.cash > 0 && s.otherResults.push(a), s),
|
|
167
169
|
{ cashlessResults: [], otherResults: [] }
|
|
168
170
|
), n = [...c];
|
|
169
171
|
return l.forEach((s) => {
|
|
@@ -190,21 +192,21 @@ const ce = (t) => t == null ? void 0 : t.map((e) => {
|
|
|
190
192
|
staleTime: 864e5
|
|
191
193
|
// 24 hours
|
|
192
194
|
});
|
|
193
|
-
let
|
|
195
|
+
let i = e.find(
|
|
194
196
|
(l) => {
|
|
195
|
-
var c, n, s,
|
|
196
|
-
return ((n = (c = l.mainProgram) == null ? void 0 : c.toLowerCase()) == null ? void 0 : n.includes(t == null ? void 0 : t.toLowerCase())) || ((
|
|
197
|
+
var c, n, s, a;
|
|
198
|
+
return ((n = (c = l.mainProgram) == null ? void 0 : c.toLowerCase()) == null ? void 0 : n.includes(t == null ? void 0 : t.toLowerCase())) || ((a = (s = l.displayProgram) == null ? void 0 : s.toLowerCase()) == null ? void 0 : a.includes(t == null ? void 0 : t.toLowerCase()));
|
|
197
199
|
}
|
|
198
200
|
) ?? N;
|
|
199
|
-
return
|
|
201
|
+
return i || (i = {
|
|
200
202
|
...N,
|
|
201
203
|
mainProgram: t,
|
|
202
204
|
displayProgram: t,
|
|
203
205
|
id: t
|
|
204
|
-
}),
|
|
206
|
+
}), i;
|
|
205
207
|
}, U = (t) => {
|
|
206
|
-
var c, n, s,
|
|
207
|
-
const e = ((s = (n = (c = t.flightDetails.slices.getFirst()) == null ? void 0 : c.segments.getFirst()) == null ? void 0 : n.passengers.getFirst()) == null ? void 0 : s.baggages) ?? [],
|
|
208
|
+
var c, n, s, a, r, o, p, m, u, d;
|
|
209
|
+
const e = ((s = (n = (c = t.flightDetails.slices.getFirst()) == null ? void 0 : c.segments.getFirst()) == null ? void 0 : n.passengers.getFirst()) == null ? void 0 : s.baggages) ?? [], i = ((o = (r = (a = t.flightDetails.slices.getFirst()) == null ? void 0 : a.segments.getFirst()) == null ? void 0 : r.passengers.getFirst()) == null ? void 0 : o.cabinClassMarketingName) ?? ((u = (m = (p = t.flightDetails.slices.getFirst()) == null ? void 0 : p.segments.getFirst()) == null ? void 0 : m.passengers.getFirst()) == null ? void 0 : u.cabinClass), l = e.map(
|
|
208
210
|
(y) => ({
|
|
209
211
|
type: Q(y.type),
|
|
210
212
|
quantity: y.quantity
|
|
@@ -217,7 +219,7 @@ const ce = (t) => t == null ? void 0 : t.map((e) => {
|
|
|
217
219
|
program: t.airlineProgram,
|
|
218
220
|
baseCurrency: t.flightDetails.baseCurrency,
|
|
219
221
|
fareBrandName: (d = t.flightDetails.slices.getFirst()) == null ? void 0 : d.fareBrandName,
|
|
220
|
-
cabinClass:
|
|
222
|
+
cabinClass: i,
|
|
221
223
|
cashFee: t.cashFee,
|
|
222
224
|
conditions: t.flightDetails.conditions,
|
|
223
225
|
baggages: l,
|
|
@@ -228,16 +230,16 @@ const ce = (t) => t == null ? void 0 : t.map((e) => {
|
|
|
228
230
|
};
|
|
229
231
|
}, x = (t) => {
|
|
230
232
|
const e = t.filter((n) => n.cash > 0);
|
|
231
|
-
let
|
|
233
|
+
let i = { cash: 1 / 0, baseCurrency: "" };
|
|
232
234
|
for (const n of e)
|
|
233
|
-
n.cash <
|
|
235
|
+
n.cash < i.cash && (i = n);
|
|
234
236
|
const l = Math.min(
|
|
235
237
|
...t.filter((n) => n.points > 0).map((n) => n.points)
|
|
236
|
-
), c =
|
|
238
|
+
), c = i.cash;
|
|
237
239
|
return {
|
|
238
240
|
lowestCash: c === 1 / 0 ? -1 : c,
|
|
239
241
|
lowestPoints: l === 1 / 0 ? -1 : l,
|
|
240
|
-
currency:
|
|
242
|
+
currency: i.baseCurrency === "" ? null : i.baseCurrency
|
|
241
243
|
};
|
|
242
244
|
};
|
|
243
245
|
export {
|
package/package.json
CHANGED
|
@@ -1,332 +0,0 @@
|
|
|
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
|
-
};
|
package/dist/enums-D9aZqf8G.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
var R = /* @__PURE__ */ ((S) => (S.LOCATIONS = "LOCATIONS", S.CHECK_USER = "CHECK_USER", S.USER_REGIONS = "USER_REGIONS", S.CONVERT_CURRENCY = "CONVERT_CURRENCY", S.CLIENT_COMPONENT_KEY = "CLIENT_COMPONENT_KEY", S.SEARCH_LIMIT = "SEARCH_LIMIT", S.PROGRAMS = "PROGRAMS", S.USER_PROGRAMS = "USER_PROGRAMS", S.LINKED_USER_PROGRAMS = "LINKED_USER_PROGRAMS", S.BANKS = "BANKS", S.CARDS = "CARDS", S.USER_CARDS = "USER_CARDS", S.TRIPS = "TRIPS", S.UNCATEGORISED_BOOKINGS = "UNCATEGORISED_BOOKINGS", S.BOOKING = "BOOKING", S.VALUE_CENTS = "VALUE_CENTS", S.AVAILABILITY_ALERTS = "AVAILABILITY_ALERTS", S.ALERT_NOTIFICATIONS = "ALERT_NOTIFICATIONS", S.POINTS_AS_CASH = "POINTS_AS_CASH", S))(R || {});
|
|
2
|
-
export {
|
|
3
|
-
R as E
|
|
4
|
-
};
|