@odynn/awayz-flights 0.5.9 → 0.5.11

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.
@@ -10,69 +10,68 @@ import { h as N } from "./moment-BGjjqtLQ.js";
10
10
  import { useTranslation as ri } from "react-i18next";
11
11
  import { EPaymentType as u } from "./enums/EPaymentType.js";
12
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;
13
+ import { DEFAULT_AIRLINE_PROGRAM as si, getFlightNumber as ti, getLogoPath as ni, getAirlineProgram as oi } from "./utils/flightUtils.js";
14
+ import './assets/FlightResult.css';const ai = (i, t, a = t + "s") => i === 1 ? t : a;
15
15
  function ci(i) {
16
16
  if (!i || isNaN(i) || i < 0) return "N/A";
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, ",");
17
+ let t = i == null ? void 0 : i.toString().split(".")[0];
18
+ return t == null ? void 0 : t.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
19
19
  }
20
20
  function L(i) {
21
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
23
  const Ti = ({
24
24
  details: i,
25
- onClick: n,
25
+ onClick: t,
26
26
  showBestValue: a = !1,
27
27
  onShowBestValueCalculation: o,
28
28
  customStyling: S = !1
29
29
  }) => {
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 () => {
30
+ const { t: l } = ri(), [T, _] = M(!1), m = i.origin, p = i.destination, D = i.flightDetails, E = i.paymentOptions || [], $ = E.filter((e) => e.points === -1).length === 1, R = E.filter((e) => e.points > -1).length === 1, [z, U] = M(si), x = async () => {
31
31
  const e = await oi(i.airlineProgram);
32
32
  U(e);
33
33
  }, { flightNumbers: v, airlines: G } = C(() => {
34
- const e = [], t = [];
34
+ const e = [], n = [];
35
35
  return i.flightDetails.slices.forEach((g) => {
36
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),
42
- airline: T.name
37
+ const b = ti(P);
38
+ e.includes(b) || e.push(b);
39
+ const F = P.operatingCarrier;
40
+ n.some((H) => H.airline === F.name) || n.push({
41
+ logo: ni(F.iataCode),
42
+ airline: F.name
43
43
  });
44
44
  });
45
- }), x(), { flightNumbers: e, airlines: t };
45
+ }), x(), { flightNumbers: e, airlines: n };
46
46
  }, [i.flightDetails.slices]), K = () => {
47
- i.cash > 0 ? n(i, u.CASH) : n(i, u.POINTS);
47
+ i.cash > 0 ? t(i, u.CASH) : t(i, u.POINTS);
48
48
  }, j = !ei(
49
49
  i.departureTime,
50
50
  i.arrivalTime
51
- ), y = i == null ? void 0 : i.airlineProgram, { data: b } = W({
51
+ ), y = i == null ? void 0 : i.airlineProgram, { data: O } = W({
52
52
  queryKey: [B.VALUE_CENTS, y],
53
53
  queryFn: () => Y.getPointsPerCent(y ?? ""),
54
54
  staleTime: 1 / 0,
55
55
  placeholderData: 0,
56
56
  enabled: !!y && a
57
- }), q = () => {
58
- var l;
59
- if (!i || !b || !i.points || !i.cash)
57
+ }), c = C(() => {
58
+ var e, n;
59
+ return (n = (e = i.paymentOptions) == null ? void 0 : e.find(
60
+ (g) => g.program === i.airlineProgram
61
+ )) == null ? void 0 : n.cashFee;
62
+ }, [i.paymentOptions, i.airlineProgram]), q = () => {
63
+ if (!i || !O || !i.points || !i.cash)
60
64
  return {
61
65
  pointsCashValue: 0,
62
66
  bestValueStatus: "none"
63
67
  /* NONE */
64
68
  };
65
- const e = b * i.points / 100, t = ((l = i.cashFee) == null ? void 0 : l.amount) || 0;
69
+ const e = O * i.points / 100, n = (c == null ? void 0 : c.amount) || 0;
66
70
  return {
67
- bestValueStatus: e + t < i.cash ? "points" : "cash"
71
+ bestValueStatus: e + n < i.cash ? "points" : "cash"
68
72
  /* CASH */
69
73
  };
70
- }, { bestValueStatus: h } = q(), F = C(() => {
71
- var e, t;
72
- return (t = (e = i.paymentOptions) == null ? void 0 : e.find(
73
- (g) => g.program === i.airlineProgram
74
- )) == null ? void 0 : t.cashFee;
75
- }, [i.paymentOptions, i.airlineProgram]);
74
+ }, { bestValueStatus: h } = q();
76
75
  return /* @__PURE__ */ r(
77
76
  "div",
78
77
  {
@@ -80,10 +79,10 @@ const Ti = ({
80
79
  onClick: K,
81
80
  children: /* @__PURE__ */ s("div", { className: "content", children: [
82
81
  /* @__PURE__ */ r("div", { className: "flight-info", children: /* @__PURE__ */ s("div", { className: "flight-locations", children: [
83
- /* @__PURE__ */ r("div", { className: "airlines", children: G.map((e, t) => /* @__PURE__ */ r(ii.Fragment, { children: /* @__PURE__ */ s("div", { className: "tip", children: [
82
+ /* @__PURE__ */ r("div", { className: "airlines", children: G.map((e, n) => /* @__PURE__ */ r(ii.Fragment, { children: /* @__PURE__ */ s("div", { className: "tip", children: [
84
83
  /* @__PURE__ */ r("img", { src: e.logo, alt: e.airline }),
85
84
  /* @__PURE__ */ r("span", { className: "right", children: e.airline })
86
- ] }, t) }, t)) }),
85
+ ] }, n) }, n)) }),
87
86
  /* @__PURE__ */ s("div", { className: "flight-location", children: [
88
87
  /* @__PURE__ */ s("p", { className: "show-desktop", children: [
89
88
  m.city,
@@ -91,17 +90,17 @@ const Ti = ({
91
90
  I(m.country)
92
91
  ] }),
93
92
  /* @__PURE__ */ r("p", { className: "show-desktop", children: N(i.departureTime).format(
94
- c(f.DATE_TIME_MEDIUM, d.FlightShortDate)
93
+ l(f.DATE_TIME_MEDIUM, d.FlightShortDate)
95
94
  ) }),
96
95
  /* @__PURE__ */ r("p", { className: "show-mobile", children: m.airportCode }),
97
96
  /* @__PURE__ */ r("p", { className: "show-mobile", children: N(i.departureTime).format(
98
- c(f.TIME_ONLY, d.FlightTime)
97
+ l(f.TIME_ONLY, d.FlightTime)
99
98
  ) })
100
99
  ] }),
101
100
  /* @__PURE__ */ s("div", { className: "flight-duration", children: [
102
101
  /* @__PURE__ */ r("span", { className: "line" }),
103
102
  /* @__PURE__ */ s("p", { children: [
104
- X(E.slices[0].duration),
103
+ X(D.slices[0].duration),
105
104
  " ",
106
105
  " - ",
107
106
  i.numberOfStops > 0 ? `${i.numberOfStops} ${ai(
@@ -119,13 +118,13 @@ const Ti = ({
119
118
  ] }),
120
119
  /* @__PURE__ */ s("p", { className: "show-desktop", children: [
121
120
  N(i.arrivalTime).format(
122
- c(f.DATE_TIME_MEDIUM, d.FlightShortDate)
121
+ l(f.DATE_TIME_MEDIUM, d.FlightShortDate)
123
122
  ),
124
123
  " "
125
124
  ] }),
126
125
  /* @__PURE__ */ r("p", { className: "show-mobile", children: p.airportCode }),
127
126
  /* @__PURE__ */ r("p", { className: "show-mobile", children: N(i.arrivalTime).format(
128
- c(f.TIME_ONLY, d.FlightTime)
127
+ l(f.TIME_ONLY, d.FlightTime)
129
128
  ) })
130
129
  ] })
131
130
  ] }) }),
@@ -135,7 +134,7 @@ const Ti = ({
135
134
  {
136
135
  className: "flight-detail",
137
136
  onClick: (e) => {
138
- e.stopPropagation(), _(!D);
137
+ e.stopPropagation(), _(!T);
139
138
  },
140
139
  children: [
141
140
  /* @__PURE__ */ r("p", { children: "Aircraft" }),
@@ -158,7 +157,7 @@ const Ti = ({
158
157
  {
159
158
  className: `amount-value ${h === "cash" && a ? "show-best-value-flag" : ""}`,
160
159
  onClick: (e) => {
161
- e.stopPropagation(), n(i, u.CASH);
160
+ e.stopPropagation(), t(i, u.CASH);
162
161
  },
163
162
  children: [
164
163
  /* @__PURE__ */ r(
@@ -201,7 +200,7 @@ const Ti = ({
201
200
  {
202
201
  className: `amount-value ${h === "points" && a ? "show-best-value-flag" : ""}`,
203
202
  onClick: (e) => {
204
- e.stopPropagation(), n(i, u.POINTS);
203
+ e.stopPropagation(), t(i, u.POINTS);
205
204
  },
206
205
  children: [
207
206
  h === "points" && a && /* @__PURE__ */ s(
@@ -222,14 +221,14 @@ const Ti = ({
222
221
  /* @__PURE__ */ s("div", { children: [
223
222
  /* @__PURE__ */ r("label", { children: R ? "Book For" : "From" }),
224
223
  /* @__PURE__ */ s("p", { children: [
225
- `${ci(i.points)} ${c("miles")}`,
226
- !!F && /* @__PURE__ */ s(Q, { children: [
224
+ `${ci(i.points)} ${l("miles")}`,
225
+ !!c && /* @__PURE__ */ s(Q, { children: [
227
226
  " + ",
228
227
  /* @__PURE__ */ r(
229
228
  k,
230
229
  {
231
- amount: F.amount,
232
- currency: F.currency,
230
+ amount: c.amount,
231
+ currency: c.currency,
233
232
  customDisplay: "No fee",
234
233
  zeroDisplayOption: J.CUSTOM,
235
234
  position: A.LEFT
@@ -243,10 +242,10 @@ const Ti = ({
243
242
  )
244
243
  ] })
245
244
  ] }),
246
- /* @__PURE__ */ r("div", { className: `flight-details ${D ? "is-open" : ""}`, children: /* @__PURE__ */ r("div", { className: "inner", children: /* @__PURE__ */ r(
245
+ /* @__PURE__ */ r("div", { className: `flight-details ${T ? "is-open" : ""}`, children: /* @__PURE__ */ r("div", { className: "inner", children: /* @__PURE__ */ r(
247
246
  V,
248
247
  {
249
- itinerary: E.slices[0].segments,
248
+ itinerary: D.slices[0].segments,
250
249
  origin: m,
251
250
  destination: p,
252
251
  isMultiDayFlight: j
@@ -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-CXQqIDcc.js";
4
+ import { F as x } from "../../FlightResult-BOOft6zl.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-CXQqIDcc.js";
1
+ import { F as l } from "../FlightResult-BOOft6zl.js";
2
2
  export {
3
3
  l as FlightResult
4
4
  };
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-CXQqIDcc.js";
4
+ import { F as f, c as l } from "./FlightResult-BOOft6zl.js";
5
5
  import { EPaymentType as x } from "./enums/EPaymentType.js";
6
6
  import { DEFAULT_AIRLINE_PROGRAM as C, getAirlineProgram as E, getFlightNumber as F, getLogoPath as c } from "./utils/flightUtils.js";
7
7
  import { isSameDayFlight as y } from "./utils/flightDateUtils.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odynn/awayz-flights",
3
- "version": "0.5.9",
3
+ "version": "0.5.11",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"