@odynn/awayz-flights 0.1.24 → 0.1.26
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-DgpK1LYF.js → FlightItinerary-C-fQZjL3.js} +15 -15
- package/dist/components/FlightItinerary/FlightItinerary.js +2 -2
- package/dist/components/FlightResult/FlightResult.js +2 -2
- package/dist/{dateUtils-DeNLG5hw.js → dateUtils-vgrvV5fG.js} +2 -2
- package/dist/hooks/useFlightSearch/useFlightSearch.js +19 -18
- package/dist/lib/utils/flightUtils.d.ts +1 -1
- package/dist/stores/useFlightStore.js +14 -14
- package/dist/utils/flightUtils.js +120 -122
- package/package.json +74 -74
|
@@ -2,7 +2,7 @@ import { jsxs as a, jsx as c, Fragment as B } from "react/jsx-runtime";
|
|
|
2
2
|
import g, { useMemo as k } from "react";
|
|
3
3
|
import { l as G, h as A } from "./arrayExtensions-DWKenJCh.js";
|
|
4
4
|
import { ECabinClass as I } from "./types/enums.js";
|
|
5
|
-
import { a as E, b as
|
|
5
|
+
import { a as E, b as Z, d as V } from "./dateUtils-vgrvV5fG.js";
|
|
6
6
|
import { DUFFEL_ASSET_PATH as K } from "./constants/constants.js";
|
|
7
7
|
import './assets/FlightItinerary.css';const w = (e) => {
|
|
8
8
|
var t;
|
|
@@ -82,7 +82,7 @@ function ee(e, t) {
|
|
|
82
82
|
if (typeof e != "object" || !e) return e;
|
|
83
83
|
var r = e[Symbol.toPrimitive];
|
|
84
84
|
if (r !== void 0) {
|
|
85
|
-
var i = r.call(e, t
|
|
85
|
+
var i = r.call(e, t);
|
|
86
86
|
if (typeof i != "object") return i;
|
|
87
87
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
88
88
|
}
|
|
@@ -122,13 +122,13 @@ function te(e) {
|
|
|
122
122
|
return z !== void 0 ? /* @__PURE__ */ g.createElement(z.Consumer, null, (r) => t(r)) : t(U);
|
|
123
123
|
}
|
|
124
124
|
function $(e) {
|
|
125
|
-
return F({
|
|
125
|
+
return F({ attr: { viewBox: "0 0 448 512" }, child: [{ tag: "path", attr: { d: "M12 192h424c6.6 0 12 5.4 12 12v260c0 26.5-21.5 48-48 48H48c-26.5 0-48-21.5-48-48V204c0-6.6 5.4-12 12-12zm436-44v-36c0-26.5-21.5-48-48-48h-48V12c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v52H160V12c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v52H48C21.5 64 0 85.5 0 112v36c0 6.6 5.4 12 12 12h424c6.6 0 12-5.4 12-12z" }, child: [] }] })(e);
|
|
126
126
|
}
|
|
127
127
|
function me(e) {
|
|
128
|
-
return F({
|
|
128
|
+
return F({ attr: { viewBox: "0 0 448 512" }, child: [{ tag: "path", attr: { d: "M207.029 381.476L12.686 187.132c-9.373-9.373-9.373-24.569 0-33.941l22.667-22.667c9.357-9.357 24.522-9.375 33.901-.04L224 284.505l154.745-154.021c9.379-9.335 24.544-9.317 33.901.04l22.667 22.667c9.373 9.373 9.373 24.569 0 33.941L240.971 381.476c-9.373 9.372-24.569 9.372-33.942 0z" }, child: [] }] })(e);
|
|
129
129
|
}
|
|
130
130
|
function re(e) {
|
|
131
|
-
return F({
|
|
131
|
+
return F({ attr: { viewBox: "0 0 512 512" }, child: [{ tag: "path", attr: { d: "M256,8C119,8,8,119,8,256S119,504,256,504,504,393,504,256,393,8,256,8Zm92.49,313h0l-20,25a16,16,0,0,1-22.49,2.5h0l-67-49.72a40,40,0,0,1-15-31.23V112a16,16,0,0,1,16-16h32a16,16,0,0,1,16,16V256l58,42.5A16,16,0,0,1,348.49,321Z" }, child: [] }] })(e);
|
|
132
132
|
}
|
|
133
133
|
const se = ({
|
|
134
134
|
itinerary: e,
|
|
@@ -139,15 +139,15 @@ const se = ({
|
|
|
139
139
|
}) => {
|
|
140
140
|
var d, l, v, D, y, j;
|
|
141
141
|
const m = () => I.ECONOMY, p = k(() => {
|
|
142
|
-
var
|
|
142
|
+
var f, b, C, O, T, M, N;
|
|
143
143
|
const n = [];
|
|
144
|
-
for (let
|
|
145
|
-
const u = e[
|
|
144
|
+
for (let h = 0; h < e.length; h++) {
|
|
145
|
+
const u = e[h], s = e[h + 1];
|
|
146
146
|
if (!s)
|
|
147
147
|
break;
|
|
148
148
|
const x = {
|
|
149
149
|
arrival: {
|
|
150
|
-
airport: (
|
|
150
|
+
airport: (f = u.destination) == null ? void 0 : f.name,
|
|
151
151
|
city: (b = u.destination) == null ? void 0 : b.cityName,
|
|
152
152
|
country: w((C = u.destination) == null ? void 0 : C.iataCountryCode),
|
|
153
153
|
time: u.arrivingAt,
|
|
@@ -196,8 +196,8 @@ const se = ({
|
|
|
196
196
|
isMultiDayFlight: o
|
|
197
197
|
}
|
|
198
198
|
),
|
|
199
|
-
p.map((n,
|
|
200
|
-
var b, C, O, T, M, N,
|
|
199
|
+
p.map((n, f) => {
|
|
200
|
+
var b, C, O, T, M, N, h, u;
|
|
201
201
|
return /* @__PURE__ */ a(g.Fragment, { children: [
|
|
202
202
|
/* @__PURE__ */ c(
|
|
203
203
|
L,
|
|
@@ -222,16 +222,16 @@ const se = ({
|
|
|
222
222
|
country: (O = n.departure) == null ? void 0 : O.country,
|
|
223
223
|
departureAt: n.departure.time,
|
|
224
224
|
departureTimeZone: n.departure.departureTimeZone,
|
|
225
|
-
arrivalAt: e[
|
|
226
|
-
arrivalTimeZone: e[
|
|
225
|
+
arrivalAt: e[f + 1].arrivingAt,
|
|
226
|
+
arrivalTimeZone: e[f + 1].destination.timeZone,
|
|
227
227
|
airline: (T = n.departure) == null ? void 0 : T.airline,
|
|
228
228
|
airlineCode: (M = n.departure) == null ? void 0 : M.airlineCode,
|
|
229
229
|
aircraft: (N = n.departure) == null ? void 0 : N.aircraft,
|
|
230
|
-
flightNumber: (
|
|
230
|
+
flightNumber: (h = n.departure) == null ? void 0 : h.flightNumber,
|
|
231
231
|
cabin: (u = n.departure) == null ? void 0 : u.cabin
|
|
232
232
|
}
|
|
233
233
|
)
|
|
234
|
-
] }, n.departure.flightNumber ||
|
|
234
|
+
] }, n.departure.flightNumber || f);
|
|
235
235
|
}),
|
|
236
236
|
/* @__PURE__ */ c(
|
|
237
237
|
L,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import "react/jsx-runtime";
|
|
2
2
|
import "react";
|
|
3
3
|
import "../../arrayExtensions-DWKenJCh.js";
|
|
4
|
-
import { a as f } from "../../FlightItinerary-
|
|
4
|
+
import { a as f } from "../../FlightItinerary-C-fQZjL3.js";
|
|
5
5
|
import "../../types/enums.js";
|
|
6
|
-
import "../../dateUtils-
|
|
6
|
+
import "../../dateUtils-vgrvV5fG.js";
|
|
7
7
|
import "../../constants/constants.js";
|
|
8
8
|
export {
|
|
9
9
|
f as default
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as r, jsxs as e } from "react/jsx-runtime";
|
|
2
2
|
import O, { useState as d, useMemo as E } from "react";
|
|
3
|
-
import { g as f, E as N, F as I, a as M } from "../../FlightItinerary-
|
|
3
|
+
import { g as f, E as N, F as I, a as M } from "../../FlightItinerary-C-fQZjL3.js";
|
|
4
4
|
import { DEFAULT_AIRLINE_PROGRAM as R, getFlightNumber as T, getLogoPath as B, getAirlineProgram as L } from "../../utils/flightUtils.js";
|
|
5
5
|
import { h as u } from "../../arrayExtensions-DWKenJCh.js";
|
|
6
|
-
import { g as $ } from "../../dateUtils-
|
|
6
|
+
import { g as $ } from "../../dateUtils-vgrvV5fG.js";
|
|
7
7
|
import { EPaymentType as v } from "../../enums/EPaymentType.js";
|
|
8
8
|
import '../../assets/FlightResult.css';function b(i) {
|
|
9
9
|
if (!i || isNaN(i) || i < 0) return "N/A";
|
|
@@ -89,7 +89,7 @@ var oe = function(o, t) {
|
|
|
89
89
|
};
|
|
90
90
|
const L = "text/event-stream", se = 1e3, M = "last-event-id";
|
|
91
91
|
function ae(o, t) {
|
|
92
|
-
var { signal: r, headers: n, onopen: s, onmessage:
|
|
92
|
+
var { signal: r, headers: n, onopen: s, onmessage: O, onclose: c, onerror: u, openWhenHidden: a, fetch: d } = t, b = oe(t, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
|
|
93
93
|
return new Promise((g, D) => {
|
|
94
94
|
const p = Object.assign({}, n);
|
|
95
95
|
p.accept || (p.accept = L);
|
|
@@ -115,7 +115,7 @@ function ae(o, t) {
|
|
|
115
115
|
h ? p[M] = h : delete p[M];
|
|
116
116
|
}, (h) => {
|
|
117
117
|
I = h;
|
|
118
|
-
},
|
|
118
|
+
}, O))), c == null || c(), S(), g();
|
|
119
119
|
} catch (w) {
|
|
120
120
|
if (!m.signal.aborted)
|
|
121
121
|
try {
|
|
@@ -134,15 +134,15 @@ function ie(o) {
|
|
|
134
134
|
if (!(t != null && t.startsWith(L)))
|
|
135
135
|
throw new Error(`Expected content-type to be ${L}, Actual: ${t}`);
|
|
136
136
|
}
|
|
137
|
-
const
|
|
137
|
+
const W = 1, U = J.ECONOMY, z = new AbortController(), ue = 3 * 60 * 1e3, B = (o) => {
|
|
138
138
|
if (!o.origin || !o.destination)
|
|
139
139
|
throw new Error("Origin and destination are required.");
|
|
140
140
|
if (!o.departureDate)
|
|
141
141
|
throw new Error("Departure date is required.");
|
|
142
142
|
if (o.flightType === Y.ROUND_TRIP && !o.returnDate)
|
|
143
143
|
throw new Error("Return date is required for round-trip flights.");
|
|
144
|
-
},
|
|
145
|
-
const { token: o, config: t } = X(), [r, n] = N(""), [s,
|
|
144
|
+
}, ve = () => {
|
|
145
|
+
const { token: o, config: t } = X(), [r, n] = N(""), [s, O] = N([]), [c, u] = N(!1), a = $(null), {
|
|
146
146
|
inboundResults: d,
|
|
147
147
|
outboundResults: b,
|
|
148
148
|
setInboundResults: g,
|
|
@@ -165,12 +165,12 @@ const U = 1, W = J.ECONOMY, z = new AbortController(), ue = 3 * 60 * 1e3, B = (o
|
|
|
165
165
|
B(e);
|
|
166
166
|
const f = {
|
|
167
167
|
passengers: Array.from(
|
|
168
|
-
{ length: e.passengers ??
|
|
168
|
+
{ length: e.passengers ?? W },
|
|
169
169
|
() => ({ type: "adult" })
|
|
170
170
|
),
|
|
171
171
|
origin: e.origin || "",
|
|
172
172
|
destination: e.destination || "",
|
|
173
|
-
cabin_class: e.cabinClass ||
|
|
173
|
+
cabin_class: e.cabinClass || U
|
|
174
174
|
};
|
|
175
175
|
if (e.flightType === Y.ONE_WAY) {
|
|
176
176
|
const i = await A.cashOnlySearch({
|
|
@@ -247,7 +247,7 @@ const U = 1, W = J.ECONOMY, z = new AbortController(), ue = 3 * 60 * 1e3, B = (o
|
|
|
247
247
|
const { success: l, data: f } = e;
|
|
248
248
|
if (!l) return;
|
|
249
249
|
const i = f.offers;
|
|
250
|
-
|
|
250
|
+
O(x(i));
|
|
251
251
|
},
|
|
252
252
|
onError: (e) => {
|
|
253
253
|
console.error("Error in round-trip fare search:", e);
|
|
@@ -258,8 +258,8 @@ const U = 1, W = J.ECONOMY, z = new AbortController(), ue = 3 * 60 * 1e3, B = (o
|
|
|
258
258
|
originCode: e.origin,
|
|
259
259
|
destinationCode: e.destination,
|
|
260
260
|
departureDate: e.departureDate,
|
|
261
|
-
cabinClass: e.cabinClass ||
|
|
262
|
-
passengerCount: e.passengers ||
|
|
261
|
+
cabinClass: e.cabinClass || U,
|
|
262
|
+
passengerCount: e.passengers || W,
|
|
263
263
|
paymentType: l
|
|
264
264
|
});
|
|
265
265
|
let i = [];
|
|
@@ -271,24 +271,25 @@ const U = 1, W = J.ECONOMY, z = new AbortController(), ue = 3 * 60 * 1e3, B = (o
|
|
|
271
271
|
Authorization: o || "",
|
|
272
272
|
"client-id": (t == null ? void 0 : t.clientId) || ""
|
|
273
273
|
},
|
|
274
|
+
openWhenHidden: !0,
|
|
274
275
|
signal: z.signal,
|
|
275
276
|
onmessage(F) {
|
|
276
277
|
try {
|
|
277
|
-
const
|
|
278
|
-
if (
|
|
278
|
+
const v = x(JSON.parse(F.data));
|
|
279
|
+
if (v.success === !1) {
|
|
279
280
|
C();
|
|
280
281
|
return;
|
|
281
282
|
}
|
|
282
|
-
if (
|
|
283
|
+
if (v.close === !0) {
|
|
283
284
|
C();
|
|
284
285
|
return;
|
|
285
286
|
}
|
|
286
|
-
|
|
287
|
-
data:
|
|
287
|
+
v.flights && (i = y({
|
|
288
|
+
data: v.flights,
|
|
288
289
|
previousResults: i
|
|
289
290
|
}));
|
|
290
|
-
} catch (
|
|
291
|
-
console.error("Error parsing message:",
|
|
291
|
+
} catch (v) {
|
|
292
|
+
console.error("Error parsing message:", v), C();
|
|
292
293
|
}
|
|
293
294
|
},
|
|
294
295
|
onerror(F) {
|
|
@@ -360,5 +361,5 @@ const U = 1, W = J.ECONOMY, z = new AbortController(), ue = 3 * 60 * 1e3, B = (o
|
|
|
360
361
|
};
|
|
361
362
|
};
|
|
362
363
|
export {
|
|
363
|
-
|
|
364
|
+
ve as useFlightSearch
|
|
364
365
|
};
|
|
@@ -30,7 +30,7 @@ export declare const getFlightNumber: (segment: ISegment) => string;
|
|
|
30
30
|
* @param {EFlightPaymentType} params.paymentType - The type of payment (e.g., cash, points).
|
|
31
31
|
* @returns {string} The constructed flight search query URL.
|
|
32
32
|
*/
|
|
33
|
-
export declare const buildFlightSearchQuery: ({ originCode, destinationCode, departureDate, cabinClass, passengerCount, paymentType
|
|
33
|
+
export declare const buildFlightSearchQuery: ({ originCode, destinationCode, departureDate, cabinClass, passengerCount, paymentType }: {
|
|
34
34
|
originCode: string;
|
|
35
35
|
destinationCode: string;
|
|
36
36
|
departureDate: string;
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import
|
|
2
|
-
const
|
|
1
|
+
import a from "react";
|
|
2
|
+
const l = (e) => {
|
|
3
3
|
let t;
|
|
4
|
-
const s = /* @__PURE__ */ new Set(),
|
|
4
|
+
const s = /* @__PURE__ */ new Set(), u = (n, r) => {
|
|
5
5
|
const o = typeof n == "function" ? n(t) : n;
|
|
6
6
|
if (!Object.is(o, t)) {
|
|
7
|
-
const
|
|
8
|
-
t =
|
|
7
|
+
const d = t;
|
|
8
|
+
t = r ?? (typeof o != "object" || o === null) ? o : Object.assign({}, t, o), s.forEach((f) => f(t, d));
|
|
9
9
|
}
|
|
10
|
-
},
|
|
11
|
-
return
|
|
12
|
-
},
|
|
13
|
-
function
|
|
14
|
-
const s =
|
|
10
|
+
}, c = () => t, i = { setState: u, getState: c, getInitialState: () => S, subscribe: (n) => (s.add(n), () => s.delete(n)) }, S = t = e(u, c, i);
|
|
11
|
+
return i;
|
|
12
|
+
}, g = (e) => e ? l(e) : l, I = (e) => e;
|
|
13
|
+
function R(e, t = I) {
|
|
14
|
+
const s = a.useSyncExternalStore(
|
|
15
15
|
e.subscribe,
|
|
16
16
|
() => t(e.getState()),
|
|
17
17
|
() => t(e.getInitialState())
|
|
18
18
|
);
|
|
19
|
-
return
|
|
19
|
+
return a.useDebugValue(s), s;
|
|
20
20
|
}
|
|
21
|
-
const
|
|
22
|
-
const t =
|
|
21
|
+
const b = (e) => {
|
|
22
|
+
const t = g(e), s = (u) => R(t, u);
|
|
23
23
|
return Object.assign(s, t), s;
|
|
24
|
-
}, O = (e) =>
|
|
24
|
+
}, O = (e) => e ? b(e) : b, y = O((e) => ({
|
|
25
25
|
outboundResults: [],
|
|
26
26
|
inboundResults: [],
|
|
27
27
|
setOutboundResults: (t) => e({ outboundResults: t }),
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import { h as
|
|
2
|
-
import { c as
|
|
1
|
+
import { h as f } from "../arrayExtensions-DWKenJCh.js";
|
|
2
|
+
import { c as R } from "../dateUtils-vgrvV5fG.js";
|
|
3
3
|
import "react";
|
|
4
|
-
import { awayzClient as
|
|
5
|
-
import { WalletService as
|
|
6
|
-
import { ERewardProgramCategories as
|
|
7
|
-
const
|
|
8
|
-
var
|
|
4
|
+
import { awayzClient as K } from "@odynn/awayz-auth";
|
|
5
|
+
import { WalletService as j } from "../services/wallet/WalletService.js";
|
|
6
|
+
import { ERewardProgramCategories as q } from "../services/wallet/WalletService.types.js";
|
|
7
|
+
const B = (s) => s == null ? void 0 : s.map((e) => {
|
|
8
|
+
var c, a, i, n, t, o, g, r, d, A, M, I, F, L, w, u, y, l, C, h, b, m, p, D, T, k, z, v, O, G, _, $, Z, P;
|
|
9
9
|
return {
|
|
10
10
|
id: e.id,
|
|
11
11
|
points: (e == null ? void 0 : e.points) >= 0 ? e.points : -1,
|
|
12
|
-
partial: e.partial,
|
|
12
|
+
partial: e == null ? void 0 : e.partial,
|
|
13
13
|
origin: {
|
|
14
|
-
city: e.slices[0].segments[0].origin.cityName || ((
|
|
15
|
-
country: e.slices[0].segments[0].origin.iataCountryCode || ((
|
|
16
|
-
airportCode: e.slices[0].segments[0].origin.iataCityCode || ((
|
|
14
|
+
city: ((c = e.slices[0].segments[0].origin) == null ? void 0 : c.cityName) || ((i = (a = e.slices[0].segments[0].origin) == null ? void 0 : a.city) == null ? void 0 : i.name),
|
|
15
|
+
country: ((n = e.slices[0].segments[0].origin) == null ? void 0 : n.iataCountryCode) || ((o = (t = e.slices[0].segments[0].origin) == null ? void 0 : t.city) == null ? void 0 : o.iataCountryCode),
|
|
16
|
+
airportCode: ((g = e.slices[0].segments[0].origin) == null ? void 0 : g.iataCityCode) || ((d = (r = e.slices[0].segments[0].origin) == null ? void 0 : r.city) == null ? void 0 : d.iataCode),
|
|
17
17
|
coordinates: {
|
|
18
|
-
latitude: (
|
|
19
|
-
longitude: (
|
|
18
|
+
latitude: (M = (A = e.slices[0].segments[0].origin) == null ? void 0 : A.city) == null ? void 0 : M.latitude,
|
|
19
|
+
longitude: (F = (I = e.slices[0].segments[0].origin) == null ? void 0 : I.city) == null ? void 0 : F.longitude
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
destination: {
|
|
23
|
-
city: ((
|
|
24
|
-
country: ((
|
|
25
|
-
airportCode: ((
|
|
23
|
+
city: ((w = (L = e.slices[0].segments.getLast()) == null ? void 0 : L.destination) == null ? void 0 : w.cityName) || ((l = (y = (u = e.slices[0].segments.getLast()) == null ? void 0 : u.destination) == null ? void 0 : y.city) == null ? void 0 : l.name),
|
|
24
|
+
country: ((h = (C = e.slices[0].segments.getLast()) == null ? void 0 : C.destination) == null ? void 0 : h.iataCountryCode) || ((p = (m = (b = e.slices[0].segments.getLast()) == null ? void 0 : b.destination) == null ? void 0 : m.city) == null ? void 0 : p.iataCountryCode),
|
|
25
|
+
airportCode: ((T = (D = e.slices[0].segments.getLast()) == null ? void 0 : D.destination) == null ? void 0 : T.iataCityCode) || ((v = (z = (k = e.slices[0].segments.getLast()) == null ? void 0 : k.destination) == null ? void 0 : z.city) == null ? void 0 : v.iataCode),
|
|
26
26
|
coordinates: {
|
|
27
|
-
latitude: (
|
|
28
|
-
longitude: (
|
|
27
|
+
latitude: (_ = (G = (O = e.slices[0].segments.getLast()) == null ? void 0 : O.destination) == null ? void 0 : G.city) == null ? void 0 : _.latitude,
|
|
28
|
+
longitude: (P = (Z = ($ = e.slices[0].segments.getLast()) == null ? void 0 : $.destination) == null ? void 0 : Z.city) == null ? void 0 : P.longitude
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
airline: e.owner.name,
|
|
32
32
|
cash: parseFloat(e.totalAmount),
|
|
33
|
-
flightNumber:
|
|
33
|
+
flightNumber: U(e.slices[0].segments[0]),
|
|
34
34
|
awayzGroupId: e.slices[0].comparisonKey || e.awayzRouteId || e.awayzGroupId || e.id,
|
|
35
|
-
departureTime:
|
|
36
|
-
arrivalTime:
|
|
35
|
+
departureTime: f(e.slices[0].segments[0].departingAt).toDate(),
|
|
36
|
+
arrivalTime: f(
|
|
37
37
|
e.slices[0].segments[e.slices[0].segments.length - 1].arrivingAt
|
|
38
38
|
).toDate(),
|
|
39
39
|
numberOfStops: e.slices[0].segments.length - 1,
|
|
@@ -41,97 +41,95 @@ const v = (s) => s == null ? void 0 : s.map((e) => {
|
|
|
41
41
|
duration: e.slices[0].duration,
|
|
42
42
|
airlineProgram: e.airlineProgram,
|
|
43
43
|
paymentOptions: [],
|
|
44
|
-
durationMinutes:
|
|
45
|
-
departureTime:
|
|
46
|
-
arrivalTime:
|
|
44
|
+
durationMinutes: R({
|
|
45
|
+
departureTime: f(e.slices[0].segments[0].departingAt),
|
|
46
|
+
arrivalTime: f(e.slices[0].segments.getLast().arrivingAt),
|
|
47
47
|
originTimeZone: e.slices[0].segments[0].origin.timeZone,
|
|
48
48
|
destinationTimeZone: e.slices[0].segments.getLast().destination.timeZone,
|
|
49
49
|
duration: e.slices[0].duration
|
|
50
50
|
})
|
|
51
51
|
};
|
|
52
|
-
}),
|
|
52
|
+
}), J = (s, e) => {
|
|
53
53
|
if (!(e != null && e.length))
|
|
54
|
-
return
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
flightNumber: I(
|
|
62
|
-
d.operatingCarrierFlightNumber
|
|
54
|
+
return B(s);
|
|
55
|
+
const c = [...e], a = [], i = {};
|
|
56
|
+
for (const t of s) {
|
|
57
|
+
const o = t.slices[0].segments, g = o[0], r = {
|
|
58
|
+
iataCode: g.operatingCarrier.iataCode,
|
|
59
|
+
flightNumber: N(
|
|
60
|
+
g.operatingCarrierFlightNumber
|
|
63
61
|
)
|
|
64
|
-
},
|
|
65
|
-
iataCode:
|
|
66
|
-
flightNumber:
|
|
67
|
-
|
|
62
|
+
}, d = {
|
|
63
|
+
iataCode: g.marketingCarrier.iataCode,
|
|
64
|
+
flightNumber: N(
|
|
65
|
+
g.marketingCarrierFlightNumber
|
|
68
66
|
)
|
|
69
|
-
},
|
|
70
|
-
const
|
|
67
|
+
}, A = t.awayzMatchId, M = `${r.iataCode}_${d.iataCode}-${d.flightNumber}`, I = t.awayzMarketerMatchId, F = !!r.flightNumber && r.flightNumber != "", L = !!d.flightNumber && d.flightNumber != "", w = c.filter((u, y) => {
|
|
68
|
+
const l = u.flightDetails, C = u.flightDetails.slices[0].segments[0].operatingCarrierFlightNumber, h = l.id && // TODO: Maybe expand on this - Id check ensures it is a duffel flight
|
|
71
69
|
!!C && C !== "";
|
|
72
|
-
if (!(
|
|
73
|
-
(p,
|
|
70
|
+
if (!(l.slices[0].segments.length === (o == null ? void 0 : o.length) && !l.slices[0].segments.find(
|
|
71
|
+
(p, D) => p.departingAt !== o[D].departingAt || p.arrivingAt !== o[D].arrivingAt || p.duration !== o[D].duration
|
|
74
72
|
)))
|
|
75
73
|
return !1;
|
|
76
|
-
let
|
|
77
|
-
return (
|
|
74
|
+
let m = !1;
|
|
75
|
+
return (L && F && l.awayzMatchId === A || !h && l.awayzMatchId === M || F && !L && l.awayzMarketerMatchId === I) && (m = !0), m && (i[l.id] = y), m;
|
|
78
76
|
});
|
|
79
77
|
if (w.length) {
|
|
80
|
-
|
|
78
|
+
t.slices[0].comparisonKey = w[0].awayzGroupId;
|
|
81
79
|
const u = w.find((y) => {
|
|
82
|
-
var h, b,
|
|
83
|
-
const
|
|
84
|
-
return C ===
|
|
80
|
+
var h, b, m, p;
|
|
81
|
+
const l = (h = y.flightDetails.slices[0].fareBrandName) == null ? void 0 : h.toLowerCase(), C = (b = t.slices[0].fareBrandName) == null ? void 0 : b.toLowerCase();
|
|
82
|
+
return C === l || // Special Case for AC Only match on first word
|
|
85
83
|
// Due to differences in scraped points data and Duffel format
|
|
86
|
-
|
|
84
|
+
d.iataCode === "AC" && ((m = C.split(" ")) == null ? void 0 : m[0]) === ((p = l.split(" ")) == null ? void 0 : p[0]);
|
|
87
85
|
});
|
|
88
86
|
if (u) {
|
|
89
|
-
const y =
|
|
90
|
-
...
|
|
87
|
+
const y = i[u.id], l = {
|
|
88
|
+
...t,
|
|
91
89
|
...u,
|
|
92
|
-
points:
|
|
93
|
-
airlineProgram:
|
|
90
|
+
points: t.points,
|
|
91
|
+
airlineProgram: t.airlineProgram,
|
|
94
92
|
flightDetails: {
|
|
95
|
-
...
|
|
93
|
+
...t,
|
|
96
94
|
...u.flightDetails,
|
|
97
|
-
points:
|
|
98
|
-
airlineProgram:
|
|
95
|
+
points: t.points,
|
|
96
|
+
airlineProgram: t.airlineProgram
|
|
99
97
|
}
|
|
100
98
|
};
|
|
101
|
-
|
|
99
|
+
c[y] = l;
|
|
102
100
|
} else
|
|
103
|
-
a.push(
|
|
101
|
+
a.push(t);
|
|
104
102
|
} else
|
|
105
|
-
a.push(
|
|
103
|
+
a.push(t);
|
|
106
104
|
}
|
|
107
105
|
return [
|
|
108
|
-
...
|
|
109
|
-
...
|
|
106
|
+
...c ?? [],
|
|
107
|
+
...B(a) ?? []
|
|
110
108
|
];
|
|
111
|
-
},
|
|
112
|
-
const e = s.operatingCarrierFlightNumber ? s.operatingCarrier : s.marketingCarrier,
|
|
113
|
-
return e.iataCode + " " +
|
|
114
|
-
},
|
|
109
|
+
}, U = (s) => {
|
|
110
|
+
const e = s.operatingCarrierFlightNumber ? s.operatingCarrier : s.marketingCarrier, c = s.operatingCarrierFlightNumber ?? s.marketingCarrierFlightNumber;
|
|
111
|
+
return e.iataCode + " " + N(c);
|
|
112
|
+
}, X = ({
|
|
115
113
|
originCode: s,
|
|
116
114
|
destinationCode: e,
|
|
117
|
-
departureDate:
|
|
115
|
+
departureDate: c,
|
|
118
116
|
cabinClass: a,
|
|
119
|
-
passengerCount:
|
|
117
|
+
passengerCount: i,
|
|
120
118
|
paymentType: n
|
|
121
119
|
}) => {
|
|
122
|
-
let
|
|
123
|
-
return
|
|
124
|
-
},
|
|
125
|
-
const e = s.reduce((a,
|
|
126
|
-
const n =
|
|
127
|
-
return a[n] || (a[n] = []), a[n].push(
|
|
120
|
+
let t = "/flights/search/one-way/points-cash?";
|
|
121
|
+
return t += `origin=${s}`, t += `&destination=${e}`, t += `&departure_date=${c}`, t += `&cabin_class=${a}`, t += `&adults=${i}`, t += `&cash_or_points=[${n}]`, t;
|
|
122
|
+
}, ee = (s) => {
|
|
123
|
+
const e = s.reduce((a, i) => {
|
|
124
|
+
const n = i.flightDetails.slices[0].segments.map((t) => N(U(t))).join("_");
|
|
125
|
+
return a[n] || (a[n] = []), a[n].push(i), a;
|
|
128
126
|
}, {});
|
|
129
127
|
return Object.values(e).map(
|
|
130
128
|
(a) => {
|
|
131
|
-
const
|
|
129
|
+
const i = a[0], { origin: n, destination: t } = i, o = a.filter((r) => r.cash > 0).reduce((r, d) => Math.min(r, d.cash), 1 / 0), g = a.filter((r) => r.points > 0).reduce((r, d) => Math.min(r, d.points), 1 / 0);
|
|
132
130
|
return {
|
|
133
|
-
id:
|
|
134
|
-
partial:
|
|
131
|
+
id: i.awayzGroupId,
|
|
132
|
+
partial: i.partial,
|
|
135
133
|
origin: {
|
|
136
134
|
city: n.city,
|
|
137
135
|
country: n.country,
|
|
@@ -139,13 +137,13 @@ const v = (s) => s == null ? void 0 : s.map((e) => {
|
|
|
139
137
|
coordinates: n.coordinates
|
|
140
138
|
},
|
|
141
139
|
destination: {
|
|
142
|
-
city:
|
|
143
|
-
country:
|
|
144
|
-
airportCode:
|
|
145
|
-
coordinates:
|
|
140
|
+
city: t.city,
|
|
141
|
+
country: t.country,
|
|
142
|
+
airportCode: t.airportCode,
|
|
143
|
+
coordinates: t.coordinates
|
|
146
144
|
},
|
|
147
|
-
airline:
|
|
148
|
-
flightNumber:
|
|
145
|
+
airline: i.airline,
|
|
146
|
+
flightNumber: i.flightNumber,
|
|
149
147
|
paymentOptions: a.map((r) => ({
|
|
150
148
|
id: r.id,
|
|
151
149
|
cash: r.cash,
|
|
@@ -165,69 +163,69 @@ const v = (s) => s == null ? void 0 : s.map((e) => {
|
|
|
165
163
|
name: r.flightDetails.slices[0].segments[0].marketingCarrier.name
|
|
166
164
|
}
|
|
167
165
|
})),
|
|
168
|
-
numberOfStops:
|
|
169
|
-
departureTime:
|
|
170
|
-
arrivalTime:
|
|
171
|
-
awayzGroupId:
|
|
172
|
-
duration:
|
|
173
|
-
airlineProgram:
|
|
174
|
-
durationMinutes:
|
|
175
|
-
departureTime:
|
|
176
|
-
|
|
166
|
+
numberOfStops: i.numberOfStops,
|
|
167
|
+
departureTime: i.departureTime,
|
|
168
|
+
arrivalTime: i.arrivalTime,
|
|
169
|
+
awayzGroupId: i.awayzGroupId,
|
|
170
|
+
duration: i.duration,
|
|
171
|
+
airlineProgram: i.airlineProgram,
|
|
172
|
+
durationMinutes: R({
|
|
173
|
+
departureTime: f(
|
|
174
|
+
i.flightDetails.slices[0].segments[0].departingAt
|
|
177
175
|
),
|
|
178
|
-
arrivalTime:
|
|
179
|
-
|
|
176
|
+
arrivalTime: f(
|
|
177
|
+
i.flightDetails.slices[0].segments.getLast().arrivingAt
|
|
180
178
|
),
|
|
181
|
-
originTimeZone:
|
|
182
|
-
destinationTimeZone:
|
|
183
|
-
duration:
|
|
179
|
+
originTimeZone: i.flightDetails.slices[0].segments[0].origin.timeZone,
|
|
180
|
+
destinationTimeZone: i.flightDetails.slices[0].segments.getLast().destination.timeZone,
|
|
181
|
+
duration: i.flightDetails.slices[0].duration
|
|
184
182
|
}),
|
|
185
|
-
cash:
|
|
186
|
-
points:
|
|
187
|
-
flightDetails:
|
|
183
|
+
cash: o === 1 / 0 ? -1 : o,
|
|
184
|
+
points: g === 1 / 0 ? -1 : g,
|
|
185
|
+
flightDetails: i.flightDetails
|
|
188
186
|
};
|
|
189
187
|
}
|
|
190
188
|
);
|
|
191
|
-
},
|
|
192
|
-
categoryLogo:
|
|
193
|
-
programLogo:
|
|
189
|
+
}, N = (s) => s.replace(/^0+/, ""), te = (s) => `https://assets.duffel.com/img/airlines/for-light-background/full-color-logo/${s}.svg`, S = "/img/logo/odynn-eye.svg", E = {
|
|
190
|
+
categoryLogo: S,
|
|
191
|
+
programLogo: S,
|
|
194
192
|
awayzActive: [],
|
|
195
193
|
mainProgram: "Unknown",
|
|
196
194
|
displayProgram: "Unknown",
|
|
197
195
|
id: "Unknown",
|
|
198
196
|
totalAccumulatedPoints: 0,
|
|
199
|
-
category:
|
|
197
|
+
category: q.Airline,
|
|
200
198
|
colour: "#fff",
|
|
201
199
|
// Using App Foreground Colour
|
|
202
200
|
url: "https://www.odynn.com"
|
|
203
|
-
},
|
|
204
|
-
const { airlines: e } = await
|
|
201
|
+
}, ie = async (s) => {
|
|
202
|
+
const { airlines: e } = await K.ensureQueryData({
|
|
205
203
|
queryKey: ["walletAwards"],
|
|
206
|
-
queryFn:
|
|
204
|
+
queryFn: j.getAwards,
|
|
207
205
|
staleTime: 864e5
|
|
208
206
|
// 24 hours
|
|
209
207
|
});
|
|
210
|
-
let
|
|
208
|
+
let c = e.find(
|
|
211
209
|
(a) => {
|
|
212
|
-
var t,
|
|
213
|
-
return ((
|
|
210
|
+
var i, n, t, o;
|
|
211
|
+
return ((n = (i = a.mainProgram) == null ? void 0 : i.toLowerCase()) == null ? void 0 : n.includes(s == null ? void 0 : s.toLowerCase())) || ((o = (t = a.displayProgram) == null ? void 0 : t.toLowerCase()) == null ? void 0 : o.includes(s == null ? void 0 : s.toLowerCase()));
|
|
214
212
|
}
|
|
215
|
-
) ??
|
|
216
|
-
return
|
|
217
|
-
...
|
|
213
|
+
) ?? E;
|
|
214
|
+
return c || (c = {
|
|
215
|
+
...E,
|
|
218
216
|
mainProgram: s,
|
|
219
217
|
displayProgram: s,
|
|
220
218
|
id: s
|
|
221
|
-
}),
|
|
219
|
+
}), c;
|
|
222
220
|
};
|
|
223
221
|
export {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
222
|
+
E as DEFAULT_AIRLINE_PROGRAM,
|
|
223
|
+
X as buildFlightSearchQuery,
|
|
224
|
+
ie as getAirlineProgram,
|
|
225
|
+
U as getFlightNumber,
|
|
226
|
+
te as getLogoPath,
|
|
227
|
+
ee as groupFlightResults,
|
|
228
|
+
B as mapFlightDetailsToResults,
|
|
229
|
+
J as parseFlightDetails,
|
|
230
|
+
N as removeLeadingZeros
|
|
233
231
|
};
|
package/package.json
CHANGED
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@odynn/awayz-flights",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"type": "module",
|
|
5
|
-
"files": [
|
|
6
|
-
"dist"
|
|
7
|
-
],
|
|
8
|
-
"main": "dist/main.js",
|
|
9
|
-
"types": "./dist/lib/main.d.ts",
|
|
10
|
-
"scripts": {
|
|
11
|
-
"test": "vite",
|
|
12
|
-
"dev": "npm run storybook",
|
|
13
|
-
"build": "tsc -b ./tsconfig.lib.json && vite build",
|
|
14
|
-
"stoot": "npm publish --access public",
|
|
15
|
-
"push": "npm publish --access public",
|
|
16
|
-
"lint": "eslint .",
|
|
17
|
-
"preview": "vite preview",
|
|
18
|
-
"storybook": "storybook dev -p 6006",
|
|
19
|
-
"build-storybook": "storybook build"
|
|
20
|
-
},
|
|
21
|
-
"peerDependencies": {
|
|
22
|
-
"react": "^18.0.0",
|
|
23
|
-
"react-dom": "^18.0.0"
|
|
24
|
-
},
|
|
25
|
-
"devDependencies": {
|
|
26
|
-
"@chromatic-com/storybook": "^3.2.4",
|
|
27
|
-
"@eslint/js": "^9.17.0",
|
|
28
|
-
"@storybook/addon-essentials": "^8.5.0",
|
|
29
|
-
"@storybook/addon-interactions": "^8.5.0",
|
|
30
|
-
"@storybook/addon-onboarding": "^8.5.0",
|
|
31
|
-
"@storybook/blocks": "^8.5.0",
|
|
32
|
-
"@storybook/react": "^8.5.0",
|
|
33
|
-
"@storybook/react-vite": "^8.5.0",
|
|
34
|
-
"@storybook/test": "^8.5.0",
|
|
35
|
-
"@type-op/shared": "^1.0.0",
|
|
36
|
-
"@types/node": "^22.10.7",
|
|
37
|
-
"@types/react": "^18.3.18",
|
|
38
|
-
"@types/react-dom": "^18.3.5",
|
|
39
|
-
"@vitejs/plugin-react": "^4.3.4",
|
|
40
|
-
"axios": "^1.7.9",
|
|
41
|
-
"eslint": "^9.17.0",
|
|
42
|
-
"eslint-plugin-react-hooks": "^5.0.0",
|
|
43
|
-
"eslint-plugin-react-refresh": "^0.4.16",
|
|
44
|
-
"eslint-plugin-storybook": "^0.11.2",
|
|
45
|
-
"glob": "^11.0.1",
|
|
46
|
-
"globals": "^15.14.0",
|
|
47
|
-
"moment": "^2.30.1",
|
|
48
|
-
"moment-timezone": "^0.5.47",
|
|
49
|
-
"react": "^18.3.1",
|
|
50
|
-
"react-dom": "^18.3.1",
|
|
51
|
-
"react-icons": "^5.4.0",
|
|
52
|
-
"sass": "^1.83.4",
|
|
53
|
-
"storybook": "^8.5.0",
|
|
54
|
-
"typescript": "~5.6.2",
|
|
55
|
-
"typescript-eslint": "^8.18.2",
|
|
56
|
-
"vite": "^6.0.5",
|
|
57
|
-
"vite-plugin-dts": "^4.5.0",
|
|
58
|
-
"vite-plugin-lib-inject-css": "^2.2.1",
|
|
59
|
-
"zustand": "^5.0.3"
|
|
60
|
-
},
|
|
61
|
-
"sideEffects": [
|
|
62
|
-
"**/*.css"
|
|
63
|
-
],
|
|
64
|
-
"eslintConfig": {
|
|
65
|
-
"extends": [
|
|
66
|
-
"plugin:storybook/recommended"
|
|
67
|
-
]
|
|
68
|
-
},
|
|
69
|
-
"dependencies": {
|
|
70
|
-
"@microsoft/fetch-event-source": "^2.0.1",
|
|
71
|
-
"@odynn/awayz-auth": "^0.1.33",
|
|
72
|
-
"@tanstack/react-query": "^5.67.1"
|
|
73
|
-
}
|
|
74
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@odynn/awayz-flights",
|
|
3
|
+
"version": "0.1.26",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"files": [
|
|
6
|
+
"dist"
|
|
7
|
+
],
|
|
8
|
+
"main": "dist/main.js",
|
|
9
|
+
"types": "./dist/lib/main.d.ts",
|
|
10
|
+
"scripts": {
|
|
11
|
+
"test": "vite",
|
|
12
|
+
"dev": "npm run storybook",
|
|
13
|
+
"build": "tsc -b ./tsconfig.lib.json && vite build",
|
|
14
|
+
"stoot": "npm publish --access public",
|
|
15
|
+
"push": "npm publish --access public",
|
|
16
|
+
"lint": "eslint .",
|
|
17
|
+
"preview": "vite preview",
|
|
18
|
+
"storybook": "storybook dev -p 6006",
|
|
19
|
+
"build-storybook": "storybook build"
|
|
20
|
+
},
|
|
21
|
+
"peerDependencies": {
|
|
22
|
+
"react": "^18.0.0",
|
|
23
|
+
"react-dom": "^18.0.0"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@chromatic-com/storybook": "^3.2.4",
|
|
27
|
+
"@eslint/js": "^9.17.0",
|
|
28
|
+
"@storybook/addon-essentials": "^8.5.0",
|
|
29
|
+
"@storybook/addon-interactions": "^8.5.0",
|
|
30
|
+
"@storybook/addon-onboarding": "^8.5.0",
|
|
31
|
+
"@storybook/blocks": "^8.5.0",
|
|
32
|
+
"@storybook/react": "^8.5.0",
|
|
33
|
+
"@storybook/react-vite": "^8.5.0",
|
|
34
|
+
"@storybook/test": "^8.5.0",
|
|
35
|
+
"@type-op/shared": "^1.0.0",
|
|
36
|
+
"@types/node": "^22.10.7",
|
|
37
|
+
"@types/react": "^18.3.18",
|
|
38
|
+
"@types/react-dom": "^18.3.5",
|
|
39
|
+
"@vitejs/plugin-react": "^4.3.4",
|
|
40
|
+
"axios": "^1.7.9",
|
|
41
|
+
"eslint": "^9.17.0",
|
|
42
|
+
"eslint-plugin-react-hooks": "^5.0.0",
|
|
43
|
+
"eslint-plugin-react-refresh": "^0.4.16",
|
|
44
|
+
"eslint-plugin-storybook": "^0.11.2",
|
|
45
|
+
"glob": "^11.0.1",
|
|
46
|
+
"globals": "^15.14.0",
|
|
47
|
+
"moment": "^2.30.1",
|
|
48
|
+
"moment-timezone": "^0.5.47",
|
|
49
|
+
"react": "^18.3.1",
|
|
50
|
+
"react-dom": "^18.3.1",
|
|
51
|
+
"react-icons": "^5.4.0",
|
|
52
|
+
"sass": "^1.83.4",
|
|
53
|
+
"storybook": "^8.5.0",
|
|
54
|
+
"typescript": "~5.6.2",
|
|
55
|
+
"typescript-eslint": "^8.18.2",
|
|
56
|
+
"vite": "^6.0.5",
|
|
57
|
+
"vite-plugin-dts": "^4.5.0",
|
|
58
|
+
"vite-plugin-lib-inject-css": "^2.2.1",
|
|
59
|
+
"zustand": "^5.0.3"
|
|
60
|
+
},
|
|
61
|
+
"sideEffects": [
|
|
62
|
+
"**/*.css"
|
|
63
|
+
],
|
|
64
|
+
"eslintConfig": {
|
|
65
|
+
"extends": [
|
|
66
|
+
"plugin:storybook/recommended"
|
|
67
|
+
]
|
|
68
|
+
},
|
|
69
|
+
"dependencies": {
|
|
70
|
+
"@microsoft/fetch-event-source": "^2.0.1",
|
|
71
|
+
"@odynn/awayz-auth": "^0.1.33",
|
|
72
|
+
"@tanstack/react-query": "^5.67.1"
|
|
73
|
+
}
|
|
74
|
+
}
|