@odynn/awayz-flights 0.9.6 → 0.9.8

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.
Files changed (44) hide show
  1. package/dist/BookingOption-V-FzaupW.js +196 -0
  2. package/dist/FlightItinerary-C4KPpVcF.js +94 -0
  3. package/dist/_commonjsHelpers-MdHo5S7N.js +26 -0
  4. package/dist/{arrayExtensions-DFLvtO8l.js → arrayExtensions-Ce8YopTP.js} +92 -113
  5. package/dist/assets/FlightItinerary.css +1 -1
  6. package/dist/assets/FlightItineraryDropdown.css +1 -1
  7. package/dist/assets/_styles.css +1 -1
  8. package/dist/assets/_styles2.css +1 -1
  9. package/dist/assets/_styles3.css +1 -0
  10. package/dist/assets/_styles4.css +1 -0
  11. package/dist/components/BookingOption/BookingOption.js +5 -6
  12. package/dist/components/Dialog/Dialog.js +20542 -0
  13. package/dist/components/FlightItinerary/FlightItinerary.js +5 -6
  14. package/dist/components/FlightItineraryDropdown/FlightItineraryDropdown.js +23 -29
  15. package/dist/components/FlightResult/FlightResult.js +318 -284
  16. package/dist/components/HorizontalScroller/HorizontalScroller.js +4 -4
  17. package/dist/components/MiniFlightItinerary/MiniFlightItinerary.js +90 -7
  18. package/dist/components/index.js +5 -5
  19. package/dist/constants/endpoints.js +1 -1
  20. package/dist/{dateUtils-CWDSSY2R.js → dateUtils-Cb9VQiIL.js} +1 -1
  21. package/dist/enums-tLvxh02p.js +4 -0
  22. package/dist/hooks/index.js +3 -3
  23. package/dist/hooks/useAirportSearch/useAirportSearch.js +1 -1
  24. package/dist/hooks/useFlightSearch/useFlightSearch.js +422 -12
  25. package/dist/{index-nOT-DH7g.js → index-9LVJi5JO.js} +12 -8
  26. package/dist/index-Kopwbl-x.js +19 -0
  27. package/dist/lib/components/Dialog/Dialog.d.ts +9 -0
  28. package/dist/lib/components/FlightItinerary/FlightItinerary.d.ts +1 -6
  29. package/dist/lib/components/FlightItineraryDropdown/FlightItineraryDropdown.d.ts +2 -4
  30. package/dist/lib/components/FlightResult/FlightResult.d.ts +1 -1
  31. package/dist/lib/constants/endpoints.d.ts +2 -1
  32. package/dist/lib/hooks/useFlightSearch/useFlightSearch.types.d.ts +3 -2
  33. package/dist/lib/services/flights/FlightsService.d.ts +1 -0
  34. package/dist/main.js +36 -35
  35. package/dist/services/flights/FlightsService.js +38 -29
  36. package/dist/services/wallet/WalletService.js +1 -1
  37. package/dist/utils/flightUtils.js +27 -28
  38. package/package.json +2 -1
  39. package/dist/BookingOption-Bf4d2RKS.js +0 -192
  40. package/dist/FlightItinerary-C2Jp2a9c.js +0 -262
  41. package/dist/MiniFlightItinerary-BEdrqoGh.js +0 -105
  42. package/dist/index-Gj4bRuCQ.js +0 -15
  43. package/dist/index-nI16-czT.js +0 -4
  44. package/dist/useFlightSearch-C0DEmnCL.js +0 -412
@@ -1,11 +1,6 @@
1
1
  import { ISegment } from '@type-op/shared';
2
- import { IAirportLocation } from '../../hooks/useFlightSearch/useFlightSearch.types';
3
2
  interface FlightItineraryProps {
4
- origin: IAirportLocation;
5
- destination: IAirportLocation;
6
3
  itinerary: ISegment[];
7
- onDisableRenderItinerary?: () => void;
8
- isMultiDayFlight?: boolean;
9
4
  }
10
- export declare const FlightItinerary: ({ itinerary, origin, destination, onDisableRenderItinerary, isMultiDayFlight }: FlightItineraryProps) => import("react/jsx-runtime").JSX.Element;
5
+ export declare const FlightItinerary: ({ itinerary }: FlightItineraryProps) => import("react/jsx-runtime").JSX.Element;
11
6
  export {};
@@ -1,9 +1,7 @@
1
- import { IAirportLocation, IFlightDetails, IFlightResult } from '../../hooks';
1
+ import { IFlightDetails, IFlightResult } from '../../hooks';
2
2
  interface IFlightItineraryDropdownProps {
3
3
  flightDetails: IFlightDetails | IFlightResult;
4
- origin: IAirportLocation;
5
- destination: IAirportLocation;
6
4
  onOpenChange?: (isOpen: boolean) => void;
7
5
  }
8
- export declare const FlightItineraryDropdown: ({ flightDetails, origin, destination, onOpenChange }: IFlightItineraryDropdownProps) => import("react/jsx-runtime").JSX.Element;
6
+ export declare const FlightItineraryDropdown: ({ flightDetails, onOpenChange }: IFlightItineraryDropdownProps) => import("react/jsx-runtime").JSX.Element;
9
7
  export {};
@@ -34,7 +34,7 @@ export interface IFlightResultProps {
34
34
  * Optional custom component to display points value
35
35
  */
36
36
  customPointsComponent?: React.ReactNode;
37
- onBookWithCash?: (flightDetails: IFlightPaymentOption) => void;
37
+ onBookWithCash?: (flightDetails: IFlightPaymentOption, flightResult?: IFlightResult) => void;
38
38
  onBookWithPoints?: (flightDetails: IFlightPaymentOption) => void;
39
39
  }
40
40
  export declare const FlightResult: ({ details, onClick, showBestValue, onShowBestValueCalculation, customStyling, customCashComponent, customPointsComponent, onBookWithCash, onBookWithPoints }: IFlightResultProps) => import("react/jsx-runtime").JSX.Element;
@@ -4,7 +4,8 @@ export declare enum EFlightEndpoint {
4
4
  CASH_POINTS_FLIGHT_SEARCH = "/flights/search/multi/one-way/points-cash/",
5
5
  CASH_OUTBOUND_SEARCH = "/flights/search/multi/outbound",
6
6
  CASH_INBOUND_SEARCH = "/flights/search/multi/inbound",
7
- ROUND_TRIP_FARES = "/flights/search/multi/fares"
7
+ ROUND_TRIP_FARES = "/flights/search/multi/fares",
8
+ SUPPORTED_AIRLINE_PROGRAMS = "/flights/search/supported-airlines"
8
9
  }
9
10
  export declare enum EWalletEndpoints {
10
11
  GET_AWARDS = "user/rewards",
@@ -1,4 +1,4 @@
1
- import { IChangeCondition, ICoordinates, IPassenger, ISlice, ITransferPartner } from '@type-op/shared';
1
+ import { IChangeCondition, ICoordinates, IPassenger, ISlice } from '@type-op/shared';
2
2
  import { EFlightPaymentType, EFlightType } from '../../types';
3
3
  import { ECabinClass } from '../../types/ECabinClass';
4
4
  export interface ISearchFlightArgs {
@@ -152,7 +152,7 @@ export interface IFlightResult {
152
152
  currency: string;
153
153
  cabinClass: string;
154
154
  expiresAt: string;
155
- transferPartners: ITransferPartner[];
155
+ transferPartners: string[];
156
156
  }
157
157
  export interface IAirportLocation {
158
158
  city: string;
@@ -197,6 +197,7 @@ export interface IFlightOffer {
197
197
  currency: string;
198
198
  };
199
199
  googleUrl: string;
200
+ partners: string[];
200
201
  }
201
202
  export interface IPaymentRequirements {
202
203
  requiresInstantPayment: boolean;
@@ -16,6 +16,7 @@ declare class _FlightService {
16
16
  }>;
17
17
  roundTripInboundSearch: (args: IRoundTripInboundSearchArgs) => Promise<any>;
18
18
  getRoundTripFares: (args: IRoundTripFareSearchArgs) => Promise<any>;
19
+ getSupportedAirlinePrograms: () => Promise<string[]>;
19
20
  }
20
21
  export declare const FlightService: _FlightService;
21
22
  export {};
package/dist/main.js CHANGED
@@ -1,43 +1,44 @@
1
- import { u as a } from "./useFlightSearch-C0DEmnCL.js";
2
- import { useAirportSearch as m } from "./hooks/useAirportSearch/useAirportSearch.js";
3
- import { EBaggage as s } from "./hooks/useFlightSearch/useFlightSearch.types.js";
4
- import { E as f, F as l, g as n } from "./FlightItinerary-C2Jp2a9c.js";
5
- import { FlightItineraryDropdown as h } from "./components/FlightItineraryDropdown/FlightItineraryDropdown.js";
6
- import { FlightResult as y } from "./components/FlightResult/FlightResult.js";
7
- import { M as C } from "./MiniFlightItinerary-BEdrqoGh.js";
8
- import { EPaymentType as c } from "./enums/EPaymentType.js";
9
- import { DEFAULT_AIRLINE_PROGRAM as T, getAirlineProgram as D, getFlightNumber as A, getLogoPath as I } from "./utils/flightUtils.js";
10
- import { isSameDayFlight as P } from "./utils/flightDateUtils.js";
11
- import { EFlightPaymentType as d, EFlightType as N } from "./types/enums.js";
12
- import { ECabinClass as M, getCabinClassLabel as O, getCabinClassList as B } from "./types/ECabinClass.js";
13
- import { c as w, g as z, b as G, a as U } from "./dateUtils-CWDSSY2R.js";
14
- import { c as k } from "./BookingOption-Bf4d2RKS.js";
15
- import "./arrayExtensions-DFLvtO8l.js";
1
+ import { useFlightSearch as a } from "./hooks/useFlightSearch/useFlightSearch.js";
2
+ import { useAirportSearch as Y } from "./hooks/useAirportSearch/useAirportSearch.js";
3
+ import { EBaggage as p } from "./hooks/useFlightSearch/useFlightSearch.types.js";
4
+ import { F as l, g as n } from "./FlightItinerary-C4KPpVcF.js";
5
+ import { FlightItineraryDropdown as f } from "./components/FlightItineraryDropdown/FlightItineraryDropdown.js";
6
+ import { FlightResult as S } from "./components/FlightResult/FlightResult.js";
7
+ import { MiniFlightItinerary as F } from "./components/MiniFlightItinerary/MiniFlightItinerary.js";
8
+ import { EPaymentType as y } from "./enums/EPaymentType.js";
9
+ import { DEFAULT_AIRLINE_PROGRAM as A, getAirlineProgram as C, getFlightNumber as c, getLogoPath as b } from "./utils/flightUtils.js";
10
+ import { isSameDayFlight as L } from "./utils/flightDateUtils.js";
11
+ import { EFlightPaymentType as d, EFlightType as H } from "./types/enums.js";
12
+ import { ECabinClass as R, getCabinClassLabel as U, getCabinClassList as O } from "./types/ECabinClass.js";
13
+ import { c as z, g as B, b as G, a as _ } from "./dateUtils-Cb9VQiIL.js";
14
+ import { c as W } from "./BookingOption-V-FzaupW.js";
15
+ import "./arrayExtensions-Ce8YopTP.js";
16
16
  import "react";
17
+ var r = /* @__PURE__ */ ((e) => (e.USStringDateFormat = "MMM DD, YYYY", e.USStringDateTimeFormat = "MMM DD, YYYY, h:mm A (z)", e.FlightShortDate = "MMM DD - h:mm A", e.FlightTime = "h:mm A", e.DateFormat = "MM/DD", e.StringDateFormat = "MMM DD", e.FullDateFormat = "MM/DD/YYYY", e.ServerDate = "YYYY-MM-DD", e.GoogleDateFormat = "YYYYMMDDTHHmmssZ", e.AppleDateFormat = "YYYYMMDDTHHmmss", e.USStringDateWithTimeFormat = "MMM DD, YYYY, h:mm A", e))(r || {});
17
18
  export {
18
- T as DEFAULT_AIRLINE_PROGRAM,
19
- s as EBaggage,
20
- M as ECabinClass,
21
- f as EDateFormats,
19
+ A as DEFAULT_AIRLINE_PROGRAM,
20
+ p as EBaggage,
21
+ R as ECabinClass,
22
+ r as EDateFormats,
22
23
  d as EFlightPaymentType,
23
- N as EFlightType,
24
- c as EPaymentType,
24
+ H as EFlightType,
25
+ y as EPaymentType,
25
26
  l as FlightItinerary,
26
- h as FlightItineraryDropdown,
27
- y as FlightResult,
28
- C as MiniFlightItinerary,
29
- w as calculateTimeDifference,
30
- k as commaSeparatedNumber,
31
- D as getAirlineProgram,
32
- O as getCabinClassLabel,
33
- B as getCabinClassList,
27
+ f as FlightItineraryDropdown,
28
+ S as FlightResult,
29
+ F as MiniFlightItinerary,
30
+ z as calculateTimeDifference,
31
+ W as commaSeparatedNumber,
32
+ C as getAirlineProgram,
33
+ U as getCabinClassLabel,
34
+ O as getCabinClassList,
34
35
  n as getCountryNameByCode,
35
- z as getDuration,
36
- A as getFlightNumber,
37
- I as getLogoPath,
36
+ B as getDuration,
37
+ c as getFlightNumber,
38
+ b as getLogoPath,
38
39
  G as getTimeString,
39
- U as getTimezoneOffsetOrCode,
40
- P as isSameDayFlight,
41
- m as useAirportSearch,
40
+ _ as getTimezoneOffsetOrCode,
41
+ L as isSameDayFlight,
42
+ Y as useAirportSearch,
42
43
  a as useFlightSearch
43
44
  };
@@ -1,21 +1,21 @@
1
1
  var g = Object.defineProperty;
2
- var p = (c, s, a) => s in c ? g(c, s, { enumerable: !0, configurable: !0, writable: !0, value: a }) : c[s] = a;
3
- var o = (c, s, a) => p(c, typeof s != "symbol" ? s + "" : s, a);
4
- import { clientInstance as d } from "@odynn/awayz-core";
2
+ var p = (o, s, a) => s in o ? g(o, s, { enumerable: !0, configurable: !0, writable: !0, value: a }) : o[s] = a;
3
+ var c = (o, s, a) => p(o, typeof s != "symbol" ? s + "" : s, a);
4
+ import { clientInstance as u } from "@odynn/awayz-core";
5
5
  import "../../moment-BGjjqtLQ.js";
6
- import "../../arrayExtensions-DFLvtO8l.js";
6
+ import "../../arrayExtensions-Ce8YopTP.js";
7
7
  import { c as f } from "../../objectUtils-3IeCVocm.js";
8
8
  import "react";
9
- import { EFlightEndpoint as i } from "../../constants/endpoints.js";
9
+ import { EFlightEndpoint as d } from "../../constants/endpoints.js";
10
10
  class y {
11
11
  constructor() {
12
- o(this, "getAirports", async (s) => {
12
+ c(this, "getAirports", async (s) => {
13
13
  try {
14
- const { data: a } = await d.get(
15
- `${i.GET_AIRPORTS}?search_term=${s}`
14
+ const { data: a } = await u.get(
15
+ `${d.GET_AIRPORTS}?search_term=${s}`
16
16
  );
17
17
  return a.data.map((e) => {
18
- var u;
18
+ var i;
19
19
  return {
20
20
  city: {
21
21
  name: e.city_name,
@@ -27,7 +27,7 @@ class y {
27
27
  },
28
28
  country: {
29
29
  code: e.iata_country_code,
30
- name: (u = e.country) == null ? void 0 : u.name
30
+ name: (i = e.country) == null ? void 0 : i.name
31
31
  },
32
32
  name: e.name,
33
33
  iataCode: e.iata_code,
@@ -40,11 +40,11 @@ class y {
40
40
  return [];
41
41
  }
42
42
  });
43
- o(this, "cashOnlySearch", async (s) => {
44
- var a, n, e, u, m, _;
43
+ c(this, "cashOnlySearch", async (s) => {
44
+ var a, n, e, i, m, r;
45
45
  try {
46
- const { data: t } = await d.post(
47
- i.CASH_FLIGHT_SEARCH,
46
+ const { data: t } = await u.post(
47
+ d.CASH_FLIGHT_SEARCH,
48
48
  s
49
49
  );
50
50
  if (!t.success)
@@ -52,28 +52,28 @@ class y {
52
52
  success: !1,
53
53
  message: t.message
54
54
  };
55
- const r = ((n = (a = t.data) == null ? void 0 : a.flights) == null ? void 0 : n.flatMap(
55
+ const _ = ((n = (a = t.data) == null ? void 0 : a.flights) == null ? void 0 : n.flatMap(
56
56
  (l) => l.offers
57
57
  )) ?? [];
58
58
  return {
59
59
  success: !0,
60
- data: f(r)
60
+ data: f(_)
61
61
  };
62
62
  } catch (t) {
63
63
  return console.error(JSON.stringify(t)), t.message === "canceled" ? {
64
64
  success: !1,
65
- message: ((u = (e = t == null ? void 0 : t.response) == null ? void 0 : e.data) == null ? void 0 : u.message) || (t == null ? void 0 : t.message)
65
+ message: ((i = (e = t == null ? void 0 : t.response) == null ? void 0 : e.data) == null ? void 0 : i.message) || (t == null ? void 0 : t.message)
66
66
  } : {
67
67
  success: !1,
68
- message: ((_ = (m = t == null ? void 0 : t.response) == null ? void 0 : m.data) == null ? void 0 : _.message) || (t == null ? void 0 : t.message)
68
+ message: ((r = (m = t == null ? void 0 : t.response) == null ? void 0 : m.data) == null ? void 0 : r.message) || (t == null ? void 0 : t.message)
69
69
  };
70
70
  }
71
71
  });
72
- o(this, "roundTripOutboundSearch", async (s) => {
72
+ c(this, "roundTripOutboundSearch", async (s) => {
73
73
  var a, n;
74
74
  try {
75
- const { data: e } = await d.post(
76
- i.CASH_OUTBOUND_SEARCH,
75
+ const { data: e } = await u.post(
76
+ d.CASH_OUTBOUND_SEARCH,
77
77
  { ...s, to: s.return_date, from: s.departure_date }
78
78
  );
79
79
  if (!e.success) throw e;
@@ -88,11 +88,11 @@ class y {
88
88
  };
89
89
  }
90
90
  });
91
- o(this, "roundTripInboundSearch", async (s) => {
91
+ c(this, "roundTripInboundSearch", async (s) => {
92
92
  var a, n;
93
93
  try {
94
- const { data: e } = await d.get(
95
- i.CASH_INBOUND_SEARCH,
94
+ const { data: e } = await u.get(
95
+ d.CASH_INBOUND_SEARCH,
96
96
  {
97
97
  params: {
98
98
  outbound_offer_id: s.outboundOfferId,
@@ -110,11 +110,11 @@ class y {
110
110
  };
111
111
  }
112
112
  });
113
- o(this, "getRoundTripFares", async (s) => {
113
+ c(this, "getRoundTripFares", async (s) => {
114
114
  var a, n;
115
115
  try {
116
- const { data: e } = await d.get(
117
- i.ROUND_TRIP_FARES,
116
+ const { data: e } = await u.get(
117
+ d.ROUND_TRIP_FARES,
118
118
  {
119
119
  params: {
120
120
  outbound_offer_id: s.outboundOfferId,
@@ -133,9 +133,18 @@ class y {
133
133
  };
134
134
  }
135
135
  });
136
+ c(this, "getSupportedAirlinePrograms", async () => {
137
+ const { data: s } = await u.get(
138
+ d.SUPPORTED_AIRLINE_PROGRAMS
139
+ );
140
+ if (!s.success) throw s;
141
+ return s.data.reward_programs.map(
142
+ (a) => a.long_name
143
+ );
144
+ });
136
145
  }
137
146
  }
138
- const A = new y();
147
+ const C = new y();
139
148
  export {
140
- A as FlightService
149
+ C as FlightService
141
150
  };
@@ -4,7 +4,7 @@ var s = (e, r, t) => p(e, typeof r != "symbol" ? r + "" : r, t);
4
4
  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
- import "../../arrayExtensions-DFLvtO8l.js";
7
+ import "../../arrayExtensions-Ce8YopTP.js";
8
8
  import { c as a } from "../../objectUtils-3IeCVocm.js";
9
9
  import "react";
10
10
  import { EWalletEndpoints as i } from "../../constants/endpoints.js";
@@ -1,15 +1,14 @@
1
1
  import { defaultAwayzConfig as q, awayzClient as H } from "@odynn/awayz-core";
2
- import { d as B } from "../dateUtils-CWDSSY2R.js";
3
- import "../arrayExtensions-DFLvtO8l.js";
4
- import { D as K } from "../index-nI16-czT.js";
2
+ import { d as B } from "../dateUtils-Cb9VQiIL.js";
3
+ import "../arrayExtensions-Ce8YopTP.js";
5
4
  import "react";
6
5
  import { h as u } from "../moment-BGjjqtLQ.js";
7
- import { EFlightEndpoint as Y } from "../constants/endpoints.js";
8
- import { mapBaggageType as Q } from "../hooks/useFlightSearch/useFlightSearch.types.js";
9
- import { WalletService as W } from "../services/wallet/WalletService.js";
10
- import { ERewardProgramCategories as J } from "../services/wallet/WalletService.types.js";
11
- const me = (t) => t == null ? void 0 : t.map((e) => {
12
- var i, p, o, c, s, a, n, r, l, m, g, d, y, F, b, w, L, D, A, h, P, T, O, I, k, R, _, v, E, M, $, z, G, S;
6
+ import { EFlightEndpoint as K } from "../constants/endpoints.js";
7
+ import { mapBaggageType as Y } from "../hooks/useFlightSearch/useFlightSearch.types.js";
8
+ import { WalletService as Q } from "../services/wallet/WalletService.js";
9
+ import { ERewardProgramCategories as W } from "../services/wallet/WalletService.types.js";
10
+ const J = "https://assets.duffel.com/img/airlines/for-light-background/full-color-lockup/", ce = (t) => t == null ? void 0 : t.map((e) => {
11
+ var i, p, o, c, s, a, n, r, l, m, g, d, y, F, b, w, L, A, D, h, P, T, O, k, I, R, _, v, E, M, $, z, G, S;
13
12
  return {
14
13
  id: e.id,
15
14
  points: (e == null ? void 0 : e.points) >= 0 ? e.points : -1,
@@ -17,16 +16,16 @@ const me = (t) => t == null ? void 0 : t.map((e) => {
17
16
  origin: {
18
17
  city: ((i = e.slices[0].segments[0].origin) == null ? void 0 : i.cityName) || ((o = (p = e.slices[0].segments[0].origin) == null ? void 0 : p.city) == null ? void 0 : o.name),
19
18
  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),
20
- airportCode: ((n = e.slices[0].segments[0].origin) == null ? void 0 : n.iataCityCode) || ((l = (r = e.slices[0].segments[0].origin) == null ? void 0 : r.city) == null ? void 0 : l.iataCode),
19
+ airportCode: ((n = e.slices[0].segments[0].origin) == null ? void 0 : n.iataCode) || ((l = (r = e.slices[0].segments[0].origin) == null ? void 0 : r.city) == null ? void 0 : l.iataCode),
21
20
  coordinates: {
22
21
  latitude: (g = (m = e.slices[0].segments[0].origin) == null ? void 0 : m.city) == null ? void 0 : g.latitude,
23
22
  longitude: (y = (d = e.slices[0].segments[0].origin) == null ? void 0 : d.city) == null ? void 0 : y.longitude
24
23
  }
25
24
  },
26
25
  destination: {
27
- city: ((b = (F = e.slices[0].segments.getLast()) == null ? void 0 : F.destination) == null ? void 0 : b.cityName) || ((D = (L = (w = e.slices[0].segments.getLast()) == null ? void 0 : w.destination) == null ? void 0 : L.city) == null ? void 0 : D.name),
28
- country: ((h = (A = e.slices[0].segments.getLast()) == null ? void 0 : A.destination) == null ? void 0 : h.iataCountryCode) || ((O = (T = (P = e.slices[0].segments.getLast()) == null ? void 0 : P.destination) == null ? void 0 : T.city) == null ? void 0 : O.iataCountryCode),
29
- 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),
26
+ city: ((b = (F = e.slices[0].segments.getLast()) == null ? void 0 : F.destination) == null ? void 0 : b.cityName) || ((A = (L = (w = e.slices[0].segments.getLast()) == null ? void 0 : w.destination) == null ? void 0 : L.city) == null ? void 0 : A.name),
27
+ country: ((h = (D = e.slices[0].segments.getLast()) == null ? void 0 : D.destination) == null ? void 0 : h.iataCountryCode) || ((O = (T = (P = e.slices[0].segments.getLast()) == null ? void 0 : P.destination) == null ? void 0 : T.city) == null ? void 0 : O.iataCountryCode),
28
+ airportCode: ((I = (k = e.slices[0].segments.getLast()) == null ? void 0 : k.destination) == null ? void 0 : I.iataCode) || ((v = (_ = (R = e.slices[0].segments.getLast()) == null ? void 0 : R.destination) == null ? void 0 : _.city) == null ? void 0 : v.iataCode),
30
29
  coordinates: {
31
30
  latitude: ($ = (M = (E = e.slices[0].segments.getLast()) == null ? void 0 : E.destination) == null ? void 0 : M.city) == null ? void 0 : $.latitude,
32
31
  longitude: (S = (G = (z = e.slices[0].segments.getLast()) == null ? void 0 : z.destination) == null ? void 0 : G.city) == null ? void 0 : S.longitude
@@ -59,12 +58,12 @@ const me = (t) => t == null ? void 0 : t.map((e) => {
59
58
  cashFee: e.cashFee,
60
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,
61
60
  expiresAt: e.expiresAt,
62
- transferPartners: []
61
+ transferPartners: e.partners
63
62
  };
64
63
  }), j = (t) => {
65
64
  const e = t.operatingCarrierFlightNumber ? t.operatingCarrier : t.marketingCarrier, i = t.operatingCarrierFlightNumber ?? t.marketingCarrierFlightNumber;
66
65
  return e.iataCode + " " + X(i);
67
- }, le = ({
66
+ }, me = ({
68
67
  originCode: t,
69
68
  destinationCode: e,
70
69
  dates: i,
@@ -72,9 +71,9 @@ const me = (t) => t == null ? void 0 : t.map((e) => {
72
71
  passengerCount: o,
73
72
  paymentType: c
74
73
  }) => {
75
- let s = `${Y.CASH_POINTS_FLIGHT_SEARCH}?`;
74
+ let s = `${K.CASH_POINTS_FLIGHT_SEARCH}?`;
76
75
  return s += `origin=${t}`, s += `&destination=${e}`, s += `&departure_dates=[${i.map((a) => `"${a}"`).join(",")}]`, s += `&cabin_class=${p}`, s += `&adults=${o}`, s += `&cash_or_points=[${c}]`, s;
77
- }, V = (t) => t.flightDetails.slices[0].segments.map((i) => j(i)).join("_") + "_" + u(t.departureTime).format("YYYYMMDD"), pe = (t) => t ? t.replace(/[_-]/g, " ").split(" ").map((e) => e.charAt(0).toUpperCase() + e.slice(1).toLowerCase()).join(" ") : "", ge = (t) => {
76
+ }, V = (t) => t.flightDetails.slices[0].segments.map((i) => j(i)).join("_") + "_" + u(t.departureTime).format("YYYYMMDD"), le = (t) => t ? t.replace(/[_-]/g, " ").split(" ").map((e) => e.charAt(0).toUpperCase() + e.slice(1).toLowerCase()).join(" ") : "", pe = (t) => {
78
77
  const e = {};
79
78
  t.forEach((s) => {
80
79
  const a = V(s);
@@ -172,7 +171,7 @@ const me = (t) => t == null ? void 0 : t.map((e) => {
172
171
  (n) => n.awayzGroupId === s.awayzGroupId
173
172
  ) || o.length === 0) && c.push(s);
174
173
  }), c;
175
- }, X = (t) => t ? t.replace(/^0+/, "") : "", ue = (t) => `https://assets.duffel.com/img/airlines/for-light-background/full-color-logo/${t}.svg`, C = (t) => `${K}${t}.svg`, Z = q.logoFallbackImageUrl, N = {
174
+ }, X = (t) => t ? t.replace(/^0+/, "") : "", ge = (t) => `https://assets.duffel.com/img/airlines/for-light-background/full-color-logo/${t}.svg`, C = (t) => `${J}${t}.svg`, Z = q.logoFallbackImageUrl, N = {
176
175
  categoryLogo: Z,
177
176
  programLogo: Z,
178
177
  awayzActive: [],
@@ -180,14 +179,14 @@ const me = (t) => t == null ? void 0 : t.map((e) => {
180
179
  displayProgram: "Unknown",
181
180
  id: "Unknown",
182
181
  totalAccumulatedPoints: 0,
183
- category: J.Airline,
182
+ category: W.Airline,
184
183
  colour: "#fff",
185
184
  // Using App Foreground Colour
186
185
  url: "https://www.odynn.com"
187
- }, de = async (t) => {
186
+ }, ue = async (t) => {
188
187
  const { airlines: e } = await H.ensureQueryData({
189
188
  queryKey: ["walletAwards"],
190
- queryFn: W.getAwards,
189
+ queryFn: Q.getAwards,
191
190
  staleTime: 864e5
192
191
  // 24 hours
193
192
  });
@@ -207,7 +206,7 @@ const me = (t) => t == null ? void 0 : t.map((e) => {
207
206
  var o, c, s, a, n, r, l, m, g, d;
208
207
  const e = ((s = (c = (o = t.flightDetails.slices.getFirst()) == null ? void 0 : o.segments.getFirst()) == null ? void 0 : c.passengers.getFirst()) == null ? void 0 : s.baggages) ?? [], i = ((r = (n = (a = t.flightDetails.slices.getFirst()) == null ? void 0 : a.segments.getFirst()) == null ? void 0 : n.passengers.getFirst()) == null ? void 0 : r.cabinClassMarketingName) ?? ((g = (m = (l = t.flightDetails.slices.getFirst()) == null ? void 0 : l.segments.getFirst()) == null ? void 0 : m.passengers.getFirst()) == null ? void 0 : g.cabinClass), p = e.map(
209
208
  (y) => ({
210
- type: Q(y.type),
209
+ type: Y(y.type),
211
210
  quantity: y.quantity
212
211
  })
213
212
  );
@@ -253,13 +252,13 @@ const me = (t) => t == null ? void 0 : t.map((e) => {
253
252
  };
254
253
  export {
255
254
  N as DEFAULT_AIRLINE_PROGRAM,
256
- le as buildFlightSearchQuery,
257
- pe as formatCabinClass,
258
- de as getAirlineProgram,
255
+ me as buildFlightSearchQuery,
256
+ le as formatCabinClass,
257
+ ue as getAirlineProgram,
259
258
  j as getFlightNumber,
260
259
  C as getFullLogoPath,
261
- ue as getLogoPath,
262
- ge as groupFlightResults,
263
- me as mapDataToFlightDetails,
260
+ ge as getLogoPath,
261
+ pe as groupFlightResults,
262
+ ce as mapDataToFlightDetails,
264
263
  X as removeLeadingZeros
265
264
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odynn/awayz-flights",
3
- "version": "0.9.6",
3
+ "version": "0.9.8",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
@@ -69,6 +69,7 @@
69
69
  "dependencies": {
70
70
  "@microsoft/fetch-event-source": "^2.0.1",
71
71
  "@odynn/awayz-core": ">= 0.6.0",
72
+ "@radix-ui/react-dialog": "^1.1.15",
72
73
  "@tanstack/react-query": "^5.67.1",
73
74
  "country-code-lookup": "^0.1.3"
74
75
  }
@@ -1,192 +0,0 @@
1
- import { jsxs as r, jsx as o, Fragment as d } from "react/jsx-runtime";
2
- import { useFeatureFlags as H, useWallet as Y, EBookingPaymentMethod as $, convertCashToClientPoints as M, CashValue as C, EToolTipPosition as y, EInvalidAmountDisplayOption as u, EAmountsDisplayFeature as j, ClientPointsValue as q } from "@odynn/awayz-core";
3
- import { useQuery as z } from "@tanstack/react-query";
4
- import "./moment-BGjjqtLQ.js";
5
- import "./arrayExtensions-DFLvtO8l.js";
6
- import W, { useState as g, useEffect as x } from "react";
7
- import { F as v } from "./index-Gj4bRuCQ.js";
8
- import { h as Z, i as O, j as K, k as Q } from "./index-nOT-DH7g.js";
9
- import { EPaymentType as P } from "./enums/EPaymentType.js";
10
- import { EBaggage as L } from "./hooks/useFlightSearch/useFlightSearch.types.js";
11
- import { getAirlineProgram as b, formatCabinClass as G } from "./utils/flightUtils.js";
12
- import './assets/_styles2.css';/* empty css */
13
- const k = (e, l, t = l + "s") => e === 1 ? l : t, J = (e) => e ? e.toLowerCase().replace(/-/g, " ").split(" ").map((l) => l.charAt(0).toUpperCase() + l.slice(1)).join(" ") : "";
14
- function X(e, l = !0) {
15
- if ((!e || isNaN(e) || e < 0) && l) return "N/A";
16
- let t = e == null ? void 0 : e.toString().split(".")[0];
17
- return t == null ? void 0 : t.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
18
- }
19
- const V = "USD", Co = ({
20
- type: e,
21
- title: l,
22
- cashValue: t,
23
- milesValue: I,
24
- cashFee: p,
25
- setSelected: F,
26
- conditions: s,
27
- slices: c,
28
- baggages: f,
29
- program: N
30
- }) => {
31
- var _, R, T;
32
- const { featureFlags: h } = H(), [m, U] = g(!1), [A, w] = g(), { pointsAsCash: S } = Y(), i = s == null ? void 0 : s.refundBeforeDeparture, a = s == null ? void 0 : s.changeBeforeDeparture, E = (i != null && i.allowed ? 1 : 0) + (a != null && a.allowed ? 1 : 0) + (((R = (_ = c == null ? void 0 : c[0]) == null ? void 0 : _.segments) == null ? void 0 : R.length) || 0), { data: D } = z({
33
- queryKey: ["airlineProgram", N],
34
- queryFn: () => b(N),
35
- enabled: !!N
36
- });
37
- return x(() => {
38
- h.bookingPaymentMethodFeature === $.FULL_VCC_PARTIAL_DISABLED && M({
39
- cashAmount: (t == null ? void 0 : t.amount) ?? 0,
40
- currency: (t == null ? void 0 : t.currency) ?? "",
41
- pointsAsCash: S
42
- }).then((n) => {
43
- S.availablePoints < n && w("Insufficient points balance.");
44
- });
45
- }, [t, h]), /* @__PURE__ */ r(
46
- "div",
47
- {
48
- className: "flight-booking-option",
49
- onClick: (n) => n.stopPropagation(),
50
- children: [
51
- /* @__PURE__ */ r("div", { className: "rate-details", children: [
52
- e === P.POINTS && /* @__PURE__ */ o("img", { src: D == null ? void 0 : D.programLogo }),
53
- /* @__PURE__ */ o("p", { className: "fare-brand-name", children: J(l) })
54
- ] }),
55
- e === P.CASH && /* @__PURE__ */ r("div", { className: "fare-comparison-content", children: [
56
- f == null ? void 0 : f.map((n, B) => /* @__PURE__ */ r(W.Fragment, { children: [
57
- n.type === L.CHECKED && /* @__PURE__ */ r("div", { className: "fare-option checked", children: [
58
- /* @__PURE__ */ o("p", { children: "Checked bags:" }),
59
- /* @__PURE__ */ o("p", { children: n.quantity })
60
- ] }),
61
- n.type === L.CARRY_ON && /* @__PURE__ */ r("div", { className: "fare-option", children: [
62
- /* @__PURE__ */ o("p", { children: "Carry-on bags:" }),
63
- /* @__PURE__ */ o("p", { children: n.quantity })
64
- ] }),
65
- n.type === null && /* @__PURE__ */ r("div", { className: "fare-option", children: [
66
- /* @__PURE__ */ o(Z, {}),
67
- /* @__PURE__ */ o("p", { children: "N/A" })
68
- ] })
69
- ] }, B)),
70
- /* @__PURE__ */ r("div", { className: "fare-option refundable", children: [
71
- "Refundable:",
72
- " ",
73
- i != null && i.allowed ? /* @__PURE__ */ o(O, { className: "yes" }) : /* @__PURE__ */ o(v, { className: "no" })
74
- ] }),
75
- /* @__PURE__ */ r("div", { className: "fare-option changeable", children: [
76
- "Changeable:",
77
- " ",
78
- a != null && a.allowed ? /* @__PURE__ */ o(O, { className: "yes" }) : /* @__PURE__ */ o(v, { className: "no" })
79
- ] }),
80
- /* @__PURE__ */ r(
81
- "div",
82
- {
83
- className: "fare-option show-more-toggle",
84
- onClick: (n) => {
85
- n.stopPropagation(), U(!m);
86
- },
87
- children: [
88
- /* @__PURE__ */ o("p", { children: m ? `Hide ${k(E, "option")}` : `+${E} ${k(E, "option")}` }),
89
- /* @__PURE__ */ o("p", { children: m ? /* @__PURE__ */ o(K, {}) : /* @__PURE__ */ o(Q, {}) })
90
- ]
91
- }
92
- ),
93
- m && /* @__PURE__ */ r(d, { children: [
94
- (i == null ? void 0 : i.allowed) && /* @__PURE__ */ r("div", { className: "fare-option", children: [
95
- "Refundable Penalty:",
96
- " ",
97
- /* @__PURE__ */ o(
98
- C,
99
- {
100
- amount: i.penaltyAmount || 0,
101
- currency: i.penaltyCurrency || "",
102
- zeroDisplayOption: u.DISPLAY_AS_ZERO_WITH_CURRENCY,
103
- position: y.LEFT
104
- }
105
- )
106
- ] }),
107
- (a == null ? void 0 : a.allowed) && /* @__PURE__ */ r("div", { className: "fare-option", children: [
108
- "Changeable Penalty:",
109
- " ",
110
- /* @__PURE__ */ o(
111
- C,
112
- {
113
- amount: a.penaltyAmount || 0,
114
- currency: a.penaltyCurrency || "",
115
- zeroDisplayOption: u.DISPLAY_AS_ZERO_WITH_CURRENCY,
116
- position: y.LEFT
117
- }
118
- )
119
- ] }),
120
- (T = c == null ? void 0 : c[0].segments) == null ? void 0 : T.map((n) => /* @__PURE__ */ r(
121
- "div",
122
- {
123
- className: "fare-option checked",
124
- children: [
125
- /* @__PURE__ */ r("p", { children: [
126
- n.origin.iataCode,
127
- " - ",
128
- n.destination.iataCode,
129
- ":"
130
- ] }),
131
- /* @__PURE__ */ r("div", { children: [
132
- /* @__PURE__ */ o("img", { src: n.operatingCarrier.logo }),
133
- /* @__PURE__ */ o("p", { children: G(n.passengers[0].cabinClass) })
134
- ] })
135
- ]
136
- },
137
- `${n.origin.iataCode}-${n.destination.iataCode}`
138
- ))
139
- ] })
140
- ] }),
141
- /* @__PURE__ */ o(
142
- "button",
143
- {
144
- onClick: (n) => {
145
- n.stopPropagation(), F();
146
- },
147
- disabled: !!A,
148
- children: e === P.CASH && t ? /* @__PURE__ */ o(d, { children: A ? /* @__PURE__ */ o("p", { children: A }) : /* @__PURE__ */ r(d, { children: [
149
- /* @__PURE__ */ o(
150
- C,
151
- {
152
- amount: t.amount,
153
- currency: t.currency,
154
- position: y.LEFT,
155
- zeroDisplayOption: u.DISPLAY_AS_ZERO_WITH_CURRENCY,
156
- decimalPlaces: 2
157
- }
158
- ),
159
- h.amountsDisplayFeature === j.CASH_AND_CLIENT_POINTS && /* @__PURE__ */ r(d, { children: [
160
- " / ",
161
- /* @__PURE__ */ o(
162
- q,
163
- {
164
- currency: t.currency,
165
- cashAmount: t.amount
166
- }
167
- )
168
- ] })
169
- ] }) }) : /* @__PURE__ */ r(d, { children: [
170
- `${X(I)} miles + `,
171
- /* @__PURE__ */ o(
172
- C,
173
- {
174
- amount: (p == null ? void 0 : p.amount) || 0,
175
- currency: (p == null ? void 0 : p.currency) || V,
176
- position: y.LEFT,
177
- customDisplay: "No fee",
178
- zeroDisplayOption: u.CUSTOM
179
- }
180
- )
181
- ] })
182
- }
183
- )
184
- ]
185
- }
186
- );
187
- };
188
- export {
189
- Co as B,
190
- X as c,
191
- k as p
192
- };