@odynn/awayz-flights 0.5.7 → 0.5.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.
@@ -1,73 +1,73 @@
1
- import { jsx as r, jsxs as s, Fragment as Y } from "react/jsx-runtime";
2
- import { RewardsService as J, CashValue as C, EToolTipPosition as I, EInvalidAmountDisplayOption as W } from "@odynn/awayz-core";
3
- import { useQuery as X } from "@tanstack/react-query";
4
- import { g as Z } from "./index-7zRjF0bU.js";
5
- import { G as w, g as M, a as d, E as N, F as V, b as B } from "./FlightItinerary-Dy-2zMYt.js";
6
- import { E as ii } from "./enums-DxmoBOKL.js";
1
+ import { jsx as r, jsxs as s, Fragment as Q } from "react/jsx-runtime";
2
+ import { RewardsService as Y, CashValue as k, EToolTipPosition as A, EInvalidAmountDisplayOption as J } from "@odynn/awayz-core";
3
+ import { useQuery as W } from "@tanstack/react-query";
4
+ import { g as X } from "./index-7zRjF0bU.js";
5
+ import { G as Z, g as I, a as f, E as d, F as w, b as V } from "./FlightItinerary-Dy-2zMYt.js";
6
+ import { E as B } from "./enums-DxmoBOKL.js";
7
7
  import "./arrayExtensions-DFLvtO8l.js";
8
- import ri, { useState as b, useMemo as L } from "react";
9
- import { h as u } from "./moment-BGjjqtLQ.js";
10
- import { useTranslation as ei } from "react-i18next";
11
- import { EPaymentType as v } from "./enums/EPaymentType.js";
12
- import { isSameDayFlight as si } from "./utils/flightDateUtils.js";
13
- import { DEFAULT_AIRLINE_PROGRAM as oi, getFlightNumber as ti, getFullLogoPath as ni, getLogoPath as ai, getAirlineProgram as ci } from "./utils/flightUtils.js";
14
- import './assets/FlightResult.css';const li = (i, o, a = o + "s") => i === 1 ? o : a;
15
- function mi(i) {
8
+ import ii, { useState as M, useMemo as C } from "react";
9
+ import { h as N } from "./moment-BGjjqtLQ.js";
10
+ import { useTranslation as ri } from "react-i18next";
11
+ import { EPaymentType as u } from "./enums/EPaymentType.js";
12
+ import { isSameDayFlight as ei } from "./utils/flightDateUtils.js";
13
+ import { DEFAULT_AIRLINE_PROGRAM as si, getFlightNumber as ni, getLogoPath as ti, getAirlineProgram as oi } from "./utils/flightUtils.js";
14
+ import './assets/FlightResult.css';const ai = (i, n, a = n + "s") => i === 1 ? n : a;
15
+ function ci(i) {
16
16
  if (!i || isNaN(i) || i < 0) return "N/A";
17
- let o = i == null ? void 0 : i.toString().split(".")[0];
18
- return o == null ? void 0 : o.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
17
+ let n = i == null ? void 0 : i.toString().split(".")[0];
18
+ return n == null ? void 0 : n.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
19
19
  }
20
- function _(i) {
21
- return w({ 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: [] }] })(i);
20
+ function L(i) {
21
+ return Z({ 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: [] }] })(i);
22
22
  }
23
- const Ei = ({
23
+ const Ti = ({
24
24
  details: i,
25
- onClick: o,
25
+ onClick: n,
26
26
  showBestValue: a = !1,
27
- onShowBestValueCalculation: n,
28
- customStyling: $ = !1
27
+ onShowBestValueCalculation: o,
28
+ customStyling: S = !1
29
29
  }) => {
30
- const { t: c } = ei(), [D, S] = b(!1), m = i.origin, p = i.destination, E = i.flightDetails, k = i.paymentOptions || [];
31
- let O = i.airlineLogo;
32
- const R = k.filter((e) => e.points === -1).length === 1, z = k.filter((e) => e.points > -1).length === 1, [U, x] = b(oi), G = async () => {
33
- const e = await ci(i.airlineProgram);
34
- x(e);
35
- }, { flightNumbers: y, airlines: K } = L(() => {
30
+ const { t: c } = ri(), [D, _] = M(!1), m = i.origin, p = i.destination, E = i.flightDetails, O = i.paymentOptions || [], $ = O.filter((e) => e.points === -1).length === 1, R = O.filter((e) => e.points > -1).length === 1, [z, U] = M(si), x = async () => {
31
+ const e = await oi(i.airlineProgram);
32
+ U(e);
33
+ }, { flightNumbers: v, airlines: G } = C(() => {
36
34
  const e = [], t = [];
37
35
  return i.flightDetails.slices.forEach((g) => {
38
- g.segments.forEach((f) => {
39
- const l = ti(f);
40
- e.includes(l) || e.push(l), O = ni(f.marketingCarrier.iataCode);
41
- const T = f.operatingCarrier;
42
- t.some((Q) => Q.airline === T.name) || t.push({
43
- logo: ai(T.iataCode),
36
+ g.segments.forEach((P) => {
37
+ const l = ni(P);
38
+ e.includes(l) || e.push(l);
39
+ const T = P.operatingCarrier;
40
+ t.some((H) => H.airline === T.name) || t.push({
41
+ logo: ti(T.iataCode),
44
42
  airline: T.name
45
43
  });
46
44
  });
47
- }), G(), { flightNumbers: e, airlines: t };
48
- }, [i.flightDetails.slices]), j = () => {
49
- i.cash > 0 ? o(i, v.CASH) : o(i, v.POINTS);
50
- }, q = !si(
45
+ }), x(), { flightNumbers: e, airlines: t };
46
+ }, [i.flightDetails.slices]), K = () => {
47
+ i.cash > 0 ? n(i, u.CASH) : n(i, u.POINTS);
48
+ }, j = !ei(
51
49
  i.departureTime,
52
50
  i.arrivalTime
53
- ), P = i == null ? void 0 : i.airlineProgram, { data: A } = X({
54
- queryKey: [ii.VALUE_CENTS, P],
55
- queryFn: () => J.getPointsPerCent(P ?? ""),
51
+ ), y = i == null ? void 0 : i.airlineProgram, { data: b } = W({
52
+ queryKey: [B.VALUE_CENTS, y],
53
+ queryFn: () => Y.getPointsPerCent(y ?? ""),
56
54
  staleTime: 1 / 0,
57
55
  placeholderData: 0,
58
- enabled: !!P && a
59
- }), H = () => {
56
+ enabled: !!y && a
57
+ }), q = () => {
60
58
  var l;
61
- if (!i || !A || !i.points || !i.cash)
59
+ if (!i || !b || !i.points || !i.cash)
62
60
  return {
63
61
  pointsCashValue: 0,
64
- isBestValue: !1
62
+ bestValueStatus: "none"
63
+ /* NONE */
65
64
  };
66
- const e = A * i.points / 100, t = ((l = i.cashFee) == null ? void 0 : l.amount) || 0;
65
+ const e = b * i.points / 100, t = ((l = i.cashFee) == null ? void 0 : l.amount) || 0;
67
66
  return {
68
- isPointsBestValue: e + t < i.cash
67
+ bestValueStatus: e + t < i.cash ? "points" : "cash"
68
+ /* CASH */
69
69
  };
70
- }, { isPointsBestValue: h } = H(), F = L(() => {
70
+ }, { bestValueStatus: h } = q(), F = C(() => {
71
71
  var e, t;
72
72
  return (t = (e = i.paymentOptions) == null ? void 0 : e.find(
73
73
  (g) => g.program === i.airlineProgram
@@ -76,11 +76,11 @@ const Ei = ({
76
76
  return /* @__PURE__ */ r(
77
77
  "div",
78
78
  {
79
- className: `${$ ? "" : "awayz-"}flight-result`,
80
- onClick: j,
79
+ className: `${S ? "" : "awayz-"}flight-result`,
80
+ onClick: K,
81
81
  children: /* @__PURE__ */ s("div", { className: "content", children: [
82
82
  /* @__PURE__ */ r("div", { className: "flight-info", children: /* @__PURE__ */ s("div", { className: "flight-locations", children: [
83
- /* @__PURE__ */ r("div", { className: "airlines", children: K.map((e, t) => /* @__PURE__ */ r(ri.Fragment, { children: /* @__PURE__ */ s("div", { className: "tip", children: [
83
+ /* @__PURE__ */ r("div", { className: "airlines", children: G.map((e, t) => /* @__PURE__ */ r(ii.Fragment, { children: /* @__PURE__ */ s("div", { className: "tip", children: [
84
84
  /* @__PURE__ */ r("img", { src: e.logo, alt: e.airline }),
85
85
  /* @__PURE__ */ r("span", { className: "right", children: e.airline })
86
86
  ] }, t) }, t)) }),
@@ -88,23 +88,23 @@ const Ei = ({
88
88
  /* @__PURE__ */ s("p", { className: "show-desktop", children: [
89
89
  m.city,
90
90
  ",",
91
- M(m.country)
91
+ I(m.country)
92
92
  ] }),
93
- /* @__PURE__ */ r("p", { className: "show-desktop", children: u(i.departureTime).format(
94
- c(d.DATE_TIME_MEDIUM, N.FlightShortDate)
93
+ /* @__PURE__ */ r("p", { className: "show-desktop", children: N(i.departureTime).format(
94
+ c(f.DATE_TIME_MEDIUM, d.FlightShortDate)
95
95
  ) }),
96
96
  /* @__PURE__ */ r("p", { className: "show-mobile", children: m.airportCode }),
97
- /* @__PURE__ */ r("p", { className: "show-mobile", children: u(i.departureTime).format(
98
- c(d.TIME_ONLY, N.FlightTime)
97
+ /* @__PURE__ */ r("p", { className: "show-mobile", children: N(i.departureTime).format(
98
+ c(f.TIME_ONLY, d.FlightTime)
99
99
  ) })
100
100
  ] }),
101
101
  /* @__PURE__ */ s("div", { className: "flight-duration", children: [
102
102
  /* @__PURE__ */ r("span", { className: "line" }),
103
103
  /* @__PURE__ */ s("p", { children: [
104
- Z(E.slices[0].duration),
104
+ X(E.slices[0].duration),
105
105
  " ",
106
106
  " - ",
107
- i.numberOfStops > 0 ? `${i.numberOfStops} ${li(
107
+ i.numberOfStops > 0 ? `${i.numberOfStops} ${ai(
108
108
  i.numberOfStops,
109
109
  "Stop"
110
110
  )}` : "Direct"
@@ -115,17 +115,17 @@ const Ei = ({
115
115
  /* @__PURE__ */ s("p", { className: "show-desktop", children: [
116
116
  p.city,
117
117
  ", ",
118
- M(p.country)
118
+ I(p.country)
119
119
  ] }),
120
120
  /* @__PURE__ */ s("p", { className: "show-desktop", children: [
121
- u(i.arrivalTime).format(
122
- c(d.DATE_TIME_MEDIUM, N.FlightShortDate)
121
+ N(i.arrivalTime).format(
122
+ c(f.DATE_TIME_MEDIUM, d.FlightShortDate)
123
123
  ),
124
124
  " "
125
125
  ] }),
126
126
  /* @__PURE__ */ r("p", { className: "show-mobile", children: p.airportCode }),
127
- /* @__PURE__ */ r("p", { className: "show-mobile", children: u(i.arrivalTime).format(
128
- c(d.TIME_ONLY, N.FlightTime)
127
+ /* @__PURE__ */ r("p", { className: "show-mobile", children: N(i.arrivalTime).format(
128
+ c(f.TIME_ONLY, d.FlightTime)
129
129
  ) })
130
130
  ] })
131
131
  ] }) }),
@@ -135,17 +135,17 @@ const Ei = ({
135
135
  {
136
136
  className: "flight-detail",
137
137
  onClick: (e) => {
138
- e.stopPropagation(), S(!D);
138
+ e.stopPropagation(), _(!D);
139
139
  },
140
140
  children: [
141
141
  /* @__PURE__ */ r("p", { children: "Aircraft" }),
142
142
  /* @__PURE__ */ s("p", { className: "chevron-text", children: [
143
- /* @__PURE__ */ r(V, {}),
143
+ /* @__PURE__ */ r(w, {}),
144
144
  /* @__PURE__ */ s("span", { children: [
145
- y[0],
146
- y.length > 1 && /* @__PURE__ */ s("sup", { children: [
145
+ v[0],
146
+ v.length > 1 && /* @__PURE__ */ s("sup", { children: [
147
147
  "+",
148
- y.length - 1
148
+ v.length - 1
149
149
  ] })
150
150
  ] })
151
151
  ] })
@@ -156,34 +156,40 @@ const Ei = ({
156
156
  i.cash > 0 && /* @__PURE__ */ s(
157
157
  "div",
158
158
  {
159
- className: `amount-value ${!h && a ? "show-best-value-flag" : ""}`,
159
+ className: `amount-value ${h === "cash" && a ? "show-best-value-flag" : ""}`,
160
160
  onClick: (e) => {
161
- e.stopPropagation(), o(i, v.CASH);
161
+ e.stopPropagation(), n(i, u.CASH);
162
162
  },
163
163
  children: [
164
- /* @__PURE__ */ r("img", { src: O, alt: "marketing carrier logo" }),
164
+ /* @__PURE__ */ r(
165
+ "img",
166
+ {
167
+ src: i.marketingLogo ?? i.airlineLogo,
168
+ alt: "marketing carrier logo"
169
+ }
170
+ ),
165
171
  /* @__PURE__ */ s("div", { children: [
166
- /* @__PURE__ */ r("label", { children: R ? "Book For" : "From" }),
172
+ /* @__PURE__ */ r("label", { children: $ ? "Book For" : "From" }),
167
173
  /* @__PURE__ */ r(
168
- C,
174
+ k,
169
175
  {
170
176
  amount: i.cash,
171
177
  currency: i.currency,
172
- position: I.LEFT
178
+ position: A.LEFT
173
179
  }
174
180
  )
175
181
  ] }),
176
- !h && a && /* @__PURE__ */ s(
182
+ h === "cash" && a && /* @__PURE__ */ s(
177
183
  "div",
178
184
  {
179
185
  className: "best-value-flag tip",
180
186
  onClick: (e) => {
181
- e.stopPropagation(), n == null || n(i);
187
+ e.stopPropagation(), o == null || o(i);
182
188
  },
183
189
  children: [
184
- n && /* @__PURE__ */ r(_, {}),
190
+ o && /* @__PURE__ */ r(L, {}),
185
191
  /* @__PURE__ */ r("p", { children: "Best Value" }),
186
- n && /* @__PURE__ */ r("span", { children: "Click to learn more" })
192
+ o && /* @__PURE__ */ r("span", { children: "Click to learn more" })
187
193
  ]
188
194
  }
189
195
  )
@@ -193,40 +199,40 @@ const Ei = ({
193
199
  i.points > 0 && /* @__PURE__ */ s(
194
200
  "div",
195
201
  {
196
- className: `amount-value ${h && a ? "show-best-value-flag" : ""}`,
202
+ className: `amount-value ${h === "points" && a ? "show-best-value-flag" : ""}`,
197
203
  onClick: (e) => {
198
- e.stopPropagation(), o(i, v.POINTS);
204
+ e.stopPropagation(), n(i, u.POINTS);
199
205
  },
200
206
  children: [
201
- h && a && /* @__PURE__ */ s(
207
+ h === "points" && a && /* @__PURE__ */ s(
202
208
  "div",
203
209
  {
204
210
  className: "best-value-flag tip",
205
211
  onClick: (e) => {
206
- e.stopPropagation(), n == null || n(i);
212
+ e.stopPropagation(), o == null || o(i);
207
213
  },
208
214
  children: [
209
- n && /* @__PURE__ */ r(_, {}),
215
+ o && /* @__PURE__ */ r(L, {}),
210
216
  /* @__PURE__ */ r("p", { children: "Best Value" }),
211
- n && /* @__PURE__ */ r("span", { children: "Click to learn more" })
217
+ o && /* @__PURE__ */ r("span", { children: "Click to learn more" })
212
218
  ]
213
219
  }
214
220
  ),
215
- /* @__PURE__ */ r("img", { src: U.programLogo }),
221
+ /* @__PURE__ */ r("img", { src: z.programLogo }),
216
222
  /* @__PURE__ */ s("div", { children: [
217
- /* @__PURE__ */ r("label", { children: z ? "Book For" : "From" }),
223
+ /* @__PURE__ */ r("label", { children: R ? "Book For" : "From" }),
218
224
  /* @__PURE__ */ s("p", { children: [
219
- `${mi(i.points)} ${c("miles")}`,
220
- !!F && /* @__PURE__ */ s(Y, { children: [
225
+ `${ci(i.points)} ${c("miles")}`,
226
+ !!F && /* @__PURE__ */ s(Q, { children: [
221
227
  " + ",
222
228
  /* @__PURE__ */ r(
223
- C,
229
+ k,
224
230
  {
225
231
  amount: F.amount,
226
232
  currency: F.currency,
227
233
  customDisplay: "No fee",
228
- zeroDisplayOption: W.CUSTOM,
229
- position: I.LEFT
234
+ zeroDisplayOption: J.CUSTOM,
235
+ position: A.LEFT
230
236
  }
231
237
  )
232
238
  ] })
@@ -238,12 +244,12 @@ const Ei = ({
238
244
  ] })
239
245
  ] }),
240
246
  /* @__PURE__ */ r("div", { className: `flight-details ${D ? "is-open" : ""}`, children: /* @__PURE__ */ r("div", { className: "inner", children: /* @__PURE__ */ r(
241
- B,
247
+ V,
242
248
  {
243
249
  itinerary: E.slices[0].segments,
244
250
  origin: m,
245
251
  destination: p,
246
- isMultiDayFlight: q
252
+ isMultiDayFlight: j
247
253
  }
248
254
  ) }) })
249
255
  ] })
@@ -251,6 +257,6 @@ const Ei = ({
251
257
  );
252
258
  };
253
259
  export {
254
- Ei as F,
255
- mi as c
260
+ Ti as F,
261
+ ci as c
256
262
  };
@@ -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-7HBkr7Al.js";
4
+ import { F as x } from "../../FlightResult-CXQqIDcc.js";
5
5
  import "../../index-7zRjF0bU.js";
6
6
  import "../../FlightItinerary-Dy-2zMYt.js";
7
7
  import "../../enums-DxmoBOKL.js";
@@ -1,4 +1,4 @@
1
- import { F as l } from "../FlightResult-7HBkr7Al.js";
1
+ import { F as l } from "../FlightResult-CXQqIDcc.js";
2
2
  export {
3
3
  l as FlightResult
4
4
  };
@@ -128,6 +128,7 @@ export interface IFlightPaymentOption {
128
128
  iataCode: string;
129
129
  name: string;
130
130
  };
131
+ cabinClass?: string;
131
132
  }
132
133
  export interface IFlightResult {
133
134
  id: string;
@@ -149,6 +150,7 @@ export interface IFlightResult {
149
150
  awayzGroupId: string;
150
151
  duration: string;
151
152
  airlineProgram: string;
153
+ marketingLogo?: string;
152
154
  durationMinutes: number;
153
155
  flightDetails: IFlightOffer;
154
156
  paymentOptions: IFlightPaymentOption[];
@@ -1,5 +1,5 @@
1
- import { IFlightOffer, IFlightResult } from '../hooks/useFlightSearch/useFlightSearch.types';
2
1
  import { ISegment } from '@type-op/shared';
2
+ import { IFlightOffer, IFlightResult } from '../hooks/useFlightSearch/useFlightSearch.types';
3
3
  import { IAirlineProgram } from '../services/wallet/WalletService.types';
4
4
  import { ECabinClass } from '../types/ECabinClass';
5
5
  /**
package/dist/main.js CHANGED
@@ -1,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-7HBkr7Al.js";
4
+ import { F as f, c as l } from "./FlightResult-CXQqIDcc.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,37 +1,40 @@
1
- import { mapBaggageType as j } from "../hooks/useFlightSearch/useFlightSearch.types.js";
2
- import { h as p } from "../moment-BGjjqtLQ.js";
1
+ import { awayzClient as j } from "@odynn/awayz-core";
3
2
  import { d as B, D as Q } from "../index-7zRjF0bU.js";
4
3
  import "../arrayExtensions-DFLvtO8l.js";
5
4
  import "react";
6
- import { awayzClient as V } from "@odynn/awayz-core";
5
+ import { h as p } from "../moment-BGjjqtLQ.js";
6
+ import { mapBaggageType as V } from "../hooks/useFlightSearch/useFlightSearch.types.js";
7
7
  import { WalletService as Y } from "../services/wallet/WalletService.js";
8
8
  import { ERewardProgramCategories as x } from "../services/wallet/WalletService.types.js";
9
9
  const ne = (t) => t == null ? void 0 : t.map((e) => {
10
- var i, n, m, c, s, a, r, o, g, l, d, C, w, b, D, F, L, A, T, P, k, h, O, v, R, E, I, _, z, M, S, Z, $, G;
10
+ var n, r, g, m, s, a, i, o, l, c, d, y, C, b, F, D, L, k, A, T, P, O, h, v, R, E, I, _, M, z, N, S, Z, $;
11
11
  return {
12
12
  id: e.id,
13
13
  points: (e == null ? void 0 : e.points) >= 0 ? e.points : -1,
14
14
  partial: e == null ? void 0 : e.partial,
15
15
  origin: {
16
- city: ((i = e.slices[0].segments[0].origin) == null ? void 0 : i.cityName) || ((m = (n = e.slices[0].segments[0].origin) == null ? void 0 : n.city) == null ? void 0 : m.name),
17
- country: ((c = e.slices[0].segments[0].origin) == null ? void 0 : c.iataCountryCode) || ((a = (s = e.slices[0].segments[0].origin) == null ? void 0 : s.city) == null ? void 0 : a.iataCountryCode),
18
- airportCode: ((r = e.slices[0].segments[0].origin) == null ? void 0 : r.iataCityCode) || ((g = (o = e.slices[0].segments[0].origin) == null ? void 0 : o.city) == null ? void 0 : g.iataCode),
16
+ city: ((n = e.slices[0].segments[0].origin) == null ? void 0 : n.cityName) || ((g = (r = e.slices[0].segments[0].origin) == null ? void 0 : r.city) == null ? void 0 : g.name),
17
+ country: ((m = e.slices[0].segments[0].origin) == null ? void 0 : m.iataCountryCode) || ((a = (s = e.slices[0].segments[0].origin) == null ? void 0 : s.city) == null ? void 0 : a.iataCountryCode),
18
+ airportCode: ((i = e.slices[0].segments[0].origin) == null ? void 0 : i.iataCityCode) || ((l = (o = e.slices[0].segments[0].origin) == null ? void 0 : o.city) == null ? void 0 : l.iataCode),
19
19
  coordinates: {
20
- latitude: (d = (l = e.slices[0].segments[0].origin) == null ? void 0 : l.city) == null ? void 0 : d.latitude,
21
- longitude: (w = (C = e.slices[0].segments[0].origin) == null ? void 0 : C.city) == null ? void 0 : w.longitude
20
+ latitude: (d = (c = e.slices[0].segments[0].origin) == null ? void 0 : c.city) == null ? void 0 : d.latitude,
21
+ longitude: (C = (y = e.slices[0].segments[0].origin) == null ? void 0 : y.city) == null ? void 0 : C.longitude
22
22
  }
23
23
  },
24
24
  destination: {
25
- city: ((D = (b = e.slices[0].segments.getLast()) == null ? void 0 : b.destination) == null ? void 0 : D.cityName) || ((A = (L = (F = e.slices[0].segments.getLast()) == null ? void 0 : F.destination) == null ? void 0 : L.city) == null ? void 0 : A.name),
26
- country: ((P = (T = e.slices[0].segments.getLast()) == null ? void 0 : T.destination) == null ? void 0 : P.iataCountryCode) || ((O = (h = (k = e.slices[0].segments.getLast()) == null ? void 0 : k.destination) == null ? void 0 : h.city) == null ? void 0 : O.iataCountryCode),
25
+ city: ((F = (b = e.slices[0].segments.getLast()) == null ? void 0 : b.destination) == null ? void 0 : F.cityName) || ((k = (L = (D = e.slices[0].segments.getLast()) == null ? void 0 : D.destination) == null ? void 0 : L.city) == null ? void 0 : k.name),
26
+ country: ((T = (A = e.slices[0].segments.getLast()) == null ? void 0 : A.destination) == null ? void 0 : T.iataCountryCode) || ((h = (O = (P = e.slices[0].segments.getLast()) == null ? void 0 : P.destination) == null ? void 0 : O.city) == null ? void 0 : h.iataCountryCode),
27
27
  airportCode: ((R = (v = e.slices[0].segments.getLast()) == null ? void 0 : v.destination) == null ? void 0 : R.iataCityCode) || ((_ = (I = (E = e.slices[0].segments.getLast()) == null ? void 0 : E.destination) == null ? void 0 : I.city) == null ? void 0 : _.iataCode),
28
28
  coordinates: {
29
- latitude: (S = (M = (z = e.slices[0].segments.getLast()) == null ? void 0 : z.destination) == null ? void 0 : M.city) == null ? void 0 : S.latitude,
30
- longitude: (G = ($ = (Z = e.slices[0].segments.getLast()) == null ? void 0 : Z.destination) == null ? void 0 : $.city) == null ? void 0 : G.longitude
29
+ latitude: (N = (z = (M = e.slices[0].segments.getLast()) == null ? void 0 : M.destination) == null ? void 0 : z.city) == null ? void 0 : N.latitude,
30
+ longitude: ($ = (Z = (S = e.slices[0].segments.getLast()) == null ? void 0 : S.destination) == null ? void 0 : Z.city) == null ? void 0 : $.longitude
31
31
  }
32
32
  },
33
33
  airline: e.owner.name,
34
- airlineLogo: y(
34
+ airlineLogo: u(
35
+ e.slices[0].segments[0].operatingCarrier.iataCode
36
+ ),
37
+ marketingLogo: u(
35
38
  e.slices[0].segments[0].marketingCarrier.iataCode
36
39
  ),
37
40
  cash: e.totalAmount ? parseFloat(e.totalAmount) : 0,
@@ -58,41 +61,41 @@ const ne = (t) => t == null ? void 0 : t.map((e) => {
58
61
  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
59
62
  };
60
63
  }), K = (t) => {
61
- const e = t.operatingCarrierFlightNumber ? t.operatingCarrier : t.marketingCarrier, i = t.operatingCarrierFlightNumber ?? t.marketingCarrierFlightNumber;
62
- return e.iataCode + " " + W(i);
64
+ const e = t.operatingCarrierFlightNumber ? t.operatingCarrier : t.marketingCarrier, n = t.operatingCarrierFlightNumber ?? t.marketingCarrierFlightNumber;
65
+ return e.iataCode + " " + W(n);
63
66
  }, re = ({
64
67
  originCode: t,
65
68
  destinationCode: e,
66
- departureDate: i,
67
- cabinClass: n,
68
- passengerCount: m,
69
- paymentType: c
69
+ departureDate: n,
70
+ cabinClass: r,
71
+ passengerCount: g,
72
+ paymentType: m
70
73
  }) => {
71
74
  let s = "/flights/search/one-way/points-cash?";
72
- return s += `origin=${t}`, s += `&destination=${e}`, s += `&departure_date=${i}`, s += `&cabin_class=${n}`, s += `&adults=${m}`, s += `&cash_or_points=[${c}]`, s;
73
- }, H = (t) => t.flightDetails.slices[0].segments.map((i) => K(i)).join("_"), oe = (t) => {
75
+ return s += `origin=${t}`, s += `&destination=${e}`, s += `&departure_date=${n}`, s += `&cabin_class=${r}`, s += `&adults=${g}`, s += `&cash_or_points=[${m}]`, s;
76
+ }, H = (t) => t.flightDetails.slices[0].segments.map((n) => K(n)).join("_"), oe = (t) => {
74
77
  const e = {};
75
78
  t.forEach((s) => {
76
79
  const a = H(s);
77
80
  if (e[a]) {
78
- const r = U(s);
79
- e[a].flight.paymentOptions.push(r);
80
- const o = u(
81
+ const i = U(s);
82
+ e[a].flight.paymentOptions.push(i);
83
+ const o = w(
81
84
  e[a].flight.paymentOptions
82
85
  );
83
86
  e[a].flight.cash = o.lowestCash, e[a].flight.points = o.lowestPoints;
84
87
  } else {
85
- const { origin: r, destination: o } = s, g = [U(s)], l = u(g);
88
+ const { origin: i, destination: o } = s, l = [U(s)], c = w(l);
86
89
  e[a] = {
87
90
  programs: [],
88
91
  flight: {
89
92
  id: s.awayzGroupId,
90
93
  partial: s.partial,
91
94
  origin: {
92
- city: r.city,
93
- country: r.country,
94
- airportCode: r.airportCode,
95
- coordinates: r.coordinates
95
+ city: i.city,
96
+ country: i.country,
97
+ airportCode: i.airportCode,
98
+ coordinates: i.coordinates
96
99
  },
97
100
  destination: {
98
101
  city: o.city,
@@ -101,11 +104,14 @@ const ne = (t) => t == null ? void 0 : t.map((e) => {
101
104
  coordinates: o.coordinates
102
105
  },
103
106
  airline: s.airline,
104
- airlineLogo: y(
107
+ airlineLogo: u(
108
+ s.flightDetails.slices[0].segments[0].operatingCarrier.iataCode
109
+ ),
110
+ marketingLogo: u(
105
111
  s.flightDetails.slices[0].segments[0].marketingCarrier.iataCode
106
112
  ),
107
113
  flightNumber: s.flightNumber,
108
- paymentOptions: g,
114
+ paymentOptions: l,
109
115
  numberOfStops: s.numberOfStops,
110
116
  departureTime: s.departureTime,
111
117
  arrivalTime: s.arrivalTime,
@@ -123,8 +129,8 @@ const ne = (t) => t == null ? void 0 : t.map((e) => {
123
129
  destinationTimeZone: s.flightDetails.slices[0].segments.getLast().destination.timeZone,
124
130
  duration: s.flightDetails.slices[0].duration
125
131
  }),
126
- cash: l.lowestCash,
127
- points: l.lowestPoints,
132
+ cash: c.lowestCash,
133
+ points: c.lowestPoints,
128
134
  flightDetails: s.flightDetails,
129
135
  currency: s.flightDetails.baseCurrency,
130
136
  cashFee: s.cashFee,
@@ -134,65 +140,65 @@ const ne = (t) => t == null ? void 0 : t.map((e) => {
134
140
  }
135
141
  s.airlineProgram && !e[a].programs.includes(s.airlineProgram) && e[a].programs.push(s.airlineProgram);
136
142
  });
137
- const i = [];
143
+ const n = [];
138
144
  Object.values(e).forEach((s) => {
139
145
  const a = [
140
146
  ...new Set(
141
- s.flight.paymentOptions.map((r) => r.carrier.name)
147
+ s.flight.paymentOptions.map((i) => i.carrier.name)
142
148
  )
143
149
  ];
144
- s.programs.length > 0 ? s.programs.forEach((r) => {
150
+ s.programs.length > 0 ? s.programs.forEach((i) => {
145
151
  a.forEach((o) => {
146
- var l;
147
- const g = u(
152
+ var c;
153
+ const l = w(
148
154
  s.flight.paymentOptions.filter(
149
- (d) => d.program === r || d.cash > 0 && d.carrier.name === o
155
+ (d) => d.program === i || d.cash > 0 && d.carrier.name === o
150
156
  )
151
157
  );
152
- i.push({
158
+ n.push({
153
159
  ...s.flight,
154
160
  airline: o,
155
- airlineLogo: y(
156
- (l = s.flight.paymentOptions.find(
161
+ airlineLogo: u(
162
+ (c = s.flight.paymentOptions.find(
157
163
  (d) => d.carrier.name === o
158
- )) == null ? void 0 : l.carrier.iataCode
164
+ )) == null ? void 0 : c.carrier.iataCode
159
165
  ),
160
- airlineProgram: r,
161
- cash: g.lowestCash,
162
- points: g.lowestPoints
166
+ airlineProgram: i,
167
+ cash: l.lowestCash,
168
+ points: l.lowestPoints
163
169
  });
164
170
  });
165
- }) : a.forEach((r) => {
166
- var g;
167
- const { lowestCash: o } = u(
171
+ }) : a.forEach((i) => {
172
+ var l;
173
+ const { lowestCash: o } = w(
168
174
  s.flight.paymentOptions.filter(
169
- (l) => l.carrier.name === r
175
+ (c) => c.carrier.name === i
170
176
  )
171
177
  );
172
- i.push({
178
+ n.push({
173
179
  ...s.flight,
174
- airline: r,
175
- airlineLogo: y(
176
- (g = s.flight.paymentOptions.find(
177
- (l) => l.carrier.name === r
178
- )) == null ? void 0 : g.carrier.iataCode
180
+ airline: i,
181
+ airlineLogo: u(
182
+ (l = s.flight.paymentOptions.find(
183
+ (c) => c.carrier.name === i
184
+ )) == null ? void 0 : l.carrier.iataCode
179
185
  ),
180
186
  cash: o
181
187
  });
182
188
  });
183
189
  });
184
- const { cashlessResults: n, otherResults: m } = i.reduce(
190
+ const { cashlessResults: r, otherResults: g } = n.reduce(
185
191
  (s, a) => (a.cash <= 0 && a.points > 0 ? s.cashlessResults.push(a) : a.cash > 0 && s.otherResults.push(a), s),
186
192
  { cashlessResults: [], otherResults: [] }
187
- ), c = m;
188
- return n.forEach((s) => {
189
- c.find(
190
- (r) => r.awayzGroupId === s.awayzGroupId
191
- ) || c.push(s);
192
- }), c;
193
- }, W = (t) => t ? t.replace(/^0+/, "") : "", ce = (t) => `https://assets.duffel.com/img/airlines/for-light-background/full-color-logo/${t}.svg`, y = (t) => `${Q}${t}.svg`, N = "/img/logo/odynn-eye.svg", q = {
194
- categoryLogo: N,
195
- programLogo: N,
193
+ ), m = g;
194
+ return r.forEach((s) => {
195
+ m.find(
196
+ (i) => i.awayzGroupId === s.awayzGroupId
197
+ ) || m.push(s);
198
+ }), m;
199
+ }, W = (t) => t ? t.replace(/^0+/, "") : "", ce = (t) => `https://assets.duffel.com/img/airlines/for-light-background/full-color-logo/${t}.svg`, u = (t) => `${Q}${t}.svg`, G = "/img/logo/odynn-eye.svg", q = {
200
+ categoryLogo: G,
201
+ programLogo: G,
196
202
  awayzActive: [],
197
203
  mainProgram: "Unknown",
198
204
  displayProgram: "Unknown",
@@ -203,30 +209,30 @@ const ne = (t) => t == null ? void 0 : t.map((e) => {
203
209
  // Using App Foreground Colour
204
210
  url: "https://www.odynn.com"
205
211
  }, me = async (t) => {
206
- const { airlines: e } = await V.ensureQueryData({
212
+ const { airlines: e } = await j.ensureQueryData({
207
213
  queryKey: ["walletAwards"],
208
214
  queryFn: Y.getAwards,
209
215
  staleTime: 864e5
210
216
  // 24 hours
211
217
  });
212
- let i = e.find(
213
- (n) => {
214
- var m, c, s, a;
215
- return ((c = (m = n.mainProgram) == null ? void 0 : m.toLowerCase()) == null ? void 0 : c.includes(t == null ? void 0 : t.toLowerCase())) || ((a = (s = n.displayProgram) == null ? void 0 : s.toLowerCase()) == null ? void 0 : a.includes(t == null ? void 0 : t.toLowerCase()));
218
+ let n = e.find(
219
+ (r) => {
220
+ var g, m, s, a;
221
+ return ((m = (g = r.mainProgram) == null ? void 0 : g.toLowerCase()) == null ? void 0 : m.includes(t == null ? void 0 : t.toLowerCase())) || ((a = (s = r.displayProgram) == null ? void 0 : s.toLowerCase()) == null ? void 0 : a.includes(t == null ? void 0 : t.toLowerCase()));
216
222
  }
217
223
  ) ?? q;
218
- return i || (i = {
224
+ return n || (n = {
219
225
  ...q,
220
226
  mainProgram: t,
221
227
  displayProgram: t,
222
228
  id: t
223
- }), i;
229
+ }), n;
224
230
  }, U = (t) => {
225
- var n, m, c, s;
226
- const i = (((c = (m = (n = t.flightDetails.slices.getFirst()) == null ? void 0 : n.segments.getFirst()) == null ? void 0 : m.passengers.getFirst()) == null ? void 0 : c.baggages) ?? []).map(
227
- (a) => ({
228
- type: j(a.type),
229
- quantity: a.quantity
231
+ var g, m, s, a, i, o, l, c, d, y;
232
+ const e = ((s = (m = (g = t.flightDetails.slices.getFirst()) == null ? void 0 : g.segments.getFirst()) == null ? void 0 : m.passengers.getFirst()) == null ? void 0 : s.baggages) ?? [], n = ((o = (i = (a = t.flightDetails.slices.getFirst()) == null ? void 0 : a.segments.getFirst()) == null ? void 0 : i.passengers.getFirst()) == null ? void 0 : o.cabinClass) ?? ((d = (c = (l = t.flightDetails.slices.getFirst()) == null ? void 0 : l.segments.getFirst()) == null ? void 0 : c.passengers.getFirst()) == null ? void 0 : d.cabinClassMarketingName), r = e.map(
233
+ (C) => ({
234
+ type: V(C.type),
235
+ quantity: C.quantity
230
236
  })
231
237
  );
232
238
  return {
@@ -235,24 +241,25 @@ const ne = (t) => t == null ? void 0 : t.map((e) => {
235
241
  points: t.points,
236
242
  program: t.airlineProgram,
237
243
  baseCurrency: t.flightDetails.baseCurrency,
238
- fareBrandName: (s = t.flightDetails.slices.getFirst()) == null ? void 0 : s.fareBrandName,
244
+ fareBrandName: (y = t.flightDetails.slices.getFirst()) == null ? void 0 : y.fareBrandName,
245
+ cabinClass: n,
239
246
  cashFee: t.cashFee,
240
247
  conditions: t.flightDetails.conditions,
241
- baggages: i,
248
+ baggages: r,
242
249
  carrier: {
243
250
  iataCode: t.flightDetails.slices.getFirst().segments.getFirst().marketingCarrier.iataCode,
244
251
  name: t.flightDetails.slices.getFirst().segments.getFirst().marketingCarrier.name
245
252
  }
246
253
  };
247
- }, u = (t) => {
254
+ }, w = (t) => {
248
255
  const e = Math.min(
249
- ...t.filter((n) => n.cash > 0).map((n) => n.cash)
250
- ), i = Math.min(
251
- ...t.filter((n) => n.points > 0).map((n) => n.points)
256
+ ...t.filter((r) => r.cash > 0).map((r) => r.cash)
257
+ ), n = Math.min(
258
+ ...t.filter((r) => r.points > 0).map((r) => r.points)
252
259
  );
253
260
  return {
254
261
  lowestCash: e === 1 / 0 ? -1 : e,
255
- lowestPoints: i === 1 / 0 ? -1 : i
262
+ lowestPoints: n === 1 / 0 ? -1 : n
256
263
  };
257
264
  };
258
265
  export {
@@ -260,7 +267,7 @@ export {
260
267
  re as buildFlightSearchQuery,
261
268
  me as getAirlineProgram,
262
269
  K as getFlightNumber,
263
- y as getFullLogoPath,
270
+ u as getFullLogoPath,
264
271
  ce as getLogoPath,
265
272
  oe as groupFlightResults,
266
273
  ne as mapDataToFlightDetails,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odynn/awayz-flights",
3
- "version": "0.5.7",
3
+ "version": "0.5.9",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"